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