Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
finchxx committed Jan 24, 2025
1 parent 20052d9 commit 716b199
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
14 changes: 9 additions & 5 deletions exercises/structs/structs1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
// Execute `rustlings hint structs1` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

use std::arch::aarch64::{int32x2_t, int64x1_t};

struct ColorClassicStruct {
// TODO: Something goes here
red: int32x2_t,
green: int32x2_t,
blue: int32x2_t,
}

struct ColorTupleStruct(/* TODO: Something goes here */);
struct ColorTupleStruct(int32x2_t, int32x2_t, int32x2_t);

#[derive(Debug)]
struct UnitLikeStruct;
Expand All @@ -23,7 +27,7 @@ mod tests {
#[test]
fn classic_c_structs() {
// TODO: Instantiate a classic c struct!
// let green =
let green = ColorClassicStruct(0, 255, 0);

assert_eq!(green.red, 0);
assert_eq!(green.green, 255);
Expand All @@ -33,7 +37,7 @@ mod tests {
#[test]
fn tuple_structs() {
// TODO: Instantiate a tuple struct!
// let green =
let green = ColorTupleStruct(0,255,0);

assert_eq!(green.0, 0);
assert_eq!(green.1, 255);
Expand All @@ -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!");
Expand Down
8 changes: 5 additions & 3 deletions exercises/structs/structs2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// Execute `rustlings hint structs2` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE

#[derive(Debug)]
struct Order {
name: String,
Expand Down Expand Up @@ -38,7 +36,11 @@ 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 = Order{
name: String::from("Hacker in Rust"),
count: 1,
..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);
Expand Down

0 comments on commit 716b199

Please sign in to comment.