mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-10 12:49:18 +00:00
structs ing..
This commit is contained in:
parent
235b8ff018
commit
d6953d34f4
@ -32,7 +32,7 @@ mod tests {
|
||||
#[test]
|
||||
fn tuple_structs() {
|
||||
// TODO: Instantiate a tuple struct!
|
||||
let green =(String::from("en"),String::from("#00FF00"));
|
||||
let green =(String::from("green"),String::from("#00FF00"));
|
||||
|
||||
assert_eq!(green.0, "green");
|
||||
assert_eq!(green.1, "#00FF00");
|
||||
@ -41,7 +41,9 @@ mod tests {
|
||||
#[test]
|
||||
fn unit_structs() {
|
||||
// TODO: Instantiate a unit struct!
|
||||
let unit_structs =String::from("UnitStructsss");
|
||||
let unit_structs ={
|
||||
let str=String::from("test");
|
||||
};
|
||||
let message = format!("{:?}s are fun!", unit_structs);
|
||||
|
||||
assert_eq!(message, "UnitStructs are fun!");
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
// structs2.rs
|
||||
// Address all the TODOs to make the tests pass!
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Order {
|
||||
@ -37,6 +36,7 @@ mod tests {
|
||||
// TODO: Create your own order using the update syntax and template above!
|
||||
let mut your_order=Order{
|
||||
name:String::from("Hacker in Rust"),
|
||||
count: 1,
|
||||
..order_template
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user