mirror of https://github.com/sunface/rust-course
				
				
				
			
			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.
		
		
		
		
		
			
		
			
				
					46 lines
				
				940 B
			
		
		
			
		
	
	
					46 lines
				
				940 B
			| 
											4 years ago
										 | // structs1.rs
 | ||
| 
											4 years ago
										 | // 解决所有的 TODO ,通过测试!
 | ||
| 
											4 years ago
										 | 
 | ||
|  | // I AM NOT DONE
 | ||
|  | 
 | ||
|  | struct ColorClassicStruct {
 | ||
| 
											4 years ago
										 |     // TODO: 一些东西需要在这里
 | ||
| 
											4 years ago
										 | }
 | ||
|  | 
 | ||
| 
											4 years ago
										 | struct ColorTupleStruct(/* TODO: 一些东西需要在这里 */);
 | ||
| 
											4 years ago
										 | 
 | ||
|  | #[derive(Debug)]
 | ||
|  | struct UnitStruct;
 | ||
|  | 
 | ||
|  | #[cfg(test)]
 | ||
|  | mod tests {
 | ||
|  |     use super::*;
 | ||
|  | 
 | ||
|  |     #[test]
 | ||
|  |     fn classic_c_structs() {
 | ||
| 
											4 years ago
										 |         // TODO: 实例化一个经典的 C 结构体!
 | ||
| 
											4 years ago
										 |         // let green =
 | ||
|  | 
 | ||
|  |         assert_eq!(green.name, "green");
 | ||
|  |         assert_eq!(green.hex, "#00FF00");
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     #[test]
 | ||
|  |     fn tuple_structs() {
 | ||
| 
											4 years ago
										 |         // TODO: 实例化一个元组结构!
 | ||
| 
											4 years ago
										 |         // let green =
 | ||
|  | 
 | ||
|  |         assert_eq!(green.0, "green");
 | ||
|  |         assert_eq!(green.1, "#00FF00");
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     #[test]
 | ||
|  |     fn unit_structs() {
 | ||
| 
											4 years ago
										 |         // TODO: 实例化一个单元结构!
 | ||
| 
											4 years ago
										 |         // let unit_struct =
 | ||
|  |         let message = format!("{:?}s are fun!", unit_struct);
 | ||
|  | 
 | ||
|  |         assert_eq!(message, "UnitStructs are fun!");
 | ||
|  |     }
 | ||
|  | }
 |