You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
// structs2.rs
// 解决所有的 TODO ,通过测试!
// I AM NOT DONE
#[ derive(Debug) ]
struct Order {
name : String ,
year : u32 ,
made_by_phone : bool ,
made_by_mobile : bool ,
made_by_email : bool ,
item_number : u32 ,
count : u32 ,
}
fn create_order_template ( ) -> Order {
Order {
name : String ::from ( "Bob" ) ,
year : 2019 ,
made_by_phone : false ,
made_by_mobile : false ,
made_by_email : true ,
item_number : 123 ,
count : 0 ,
}
}
#[ cfg(test) ]
mod tests {
use super ::* ;
#[ test ]
fn your_order ( ) {
let order_template = create_order_template ( ) ;
// TODO: 利用上面的模板( template 是模板的意思)然后改变其中的一些值来创建属于你的订单!
// let your_order =
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 ) ;
assert_eq! ( your_order . made_by_mobile , order_template . made_by_mobile ) ;
assert_eq! ( your_order . made_by_email , order_template . made_by_email ) ;
assert_eq! ( your_order . item_number , order_template . item_number ) ;
assert_eq! ( your_order . count , 1 ) ;
}
}