changes from Northstar on Sat 20 Apr 11:59:19 BST 2024
This commit is contained in:
parent
df0605736a
commit
4bb74fa0e0
|
@ -5,13 +5,13 @@
|
|||
// Execute `rustlings hint structs1` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
struct ColorClassicStruct {
|
||||
// TODO: Something goes here
|
||||
red: i32,
|
||||
green: i32,
|
||||
blue: i32,
|
||||
}
|
||||
|
||||
struct ColorTupleStruct(/* TODO: Something goes here */);
|
||||
struct ColorTupleStruct(i32, i32, i32);
|
||||
|
||||
#[derive(Debug)]
|
||||
struct UnitLikeStruct;
|
||||
|
@ -23,7 +23,11 @@ mod tests {
|
|||
#[test]
|
||||
fn classic_c_structs() {
|
||||
// TODO: Instantiate a classic c struct!
|
||||
// let green =
|
||||
let green = ColorClassicStruct {
|
||||
red: 0,
|
||||
green: 255,
|
||||
blue: 0,
|
||||
};
|
||||
|
||||
assert_eq!(green.red, 0);
|
||||
assert_eq!(green.green, 255);
|
||||
|
@ -33,7 +37,7 @@ mod tests {
|
|||
#[test]
|
||||
fn tuple_structs() {
|
||||
// TODO: Instantiate a tuple struct!
|
||||
// let green =
|
||||
let green = (0, 255, 0);
|
||||
|
||||
assert_eq!(green.0, 0);
|
||||
assert_eq!(green.1, 255);
|
||||
|
@ -43,7 +47,7 @@ mod tests {
|
|||
#[test]
|
||||
fn unit_structs() {
|
||||
// TODO: Instantiate a unit-like struct!
|
||||
// let unit_like_struct =
|
||||
let unit_like_struct = UnitLikeStruct;
|
||||
let message = format!("{:?}s are fun!", unit_like_struct);
|
||||
|
||||
assert_eq!(message, "UnitLikeStructs are fun!");
|
||||
|
|
|
@ -38,7 +38,7 @@ mod tests {
|
|||
fn your_order() {
|
||||
let order_template = create_order_template();
|
||||
// TODO: Create your own order using the update syntax and template above!
|
||||
// let your_order =
|
||||
let your_order = create_order_template();
|
||||
assert_eq!(your_order.name, "Hacker in Rust");
|
||||
assert_eq!(your_order.year, order_template.year);
|
||||
assert_eq!(your_order.made_by_phone, order_template.made_by_phone);
|
||||
|
|
Loading…
Reference in a new issue