diff options
Diffstat (limited to 'ex4_6/src')
| -rw-r--r-- | ex4_6/src/main.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/ex4_6/src/main.rs b/ex4_6/src/main.rs new file mode 100644 index 0000000..f9aef19 --- /dev/null +++ b/ex4_6/src/main.rs @@ -0,0 +1,41 @@ +pub struct Ticket { + title: String, + description: String, + status: String, +} + +impl Ticket { + fn title(&self) -> &str { + self.title.as_str() + } + + fn description(&self) -> &str { + self.description.as_str() + } + + fn status(&self) -> &str { + self.status.as_str() + } +} + +fn main() { + println!(""); +} + +#[cfg(test)] +mod tests { + use crate::*; + use std::any::{Any, TypeId}; + + #[test] + fn t0() { + let t = Ticket{ + title: String::from("t"), + description: String::from("d"), + status: String::from("s"), + }; + assert_eq!(TypeId::of::<str>(), t.title().type_id()); + assert_eq!(TypeId::of::<str>(), t.description().type_id()); + assert_eq!(TypeId::of::<str>(), t.status().type_id()); + } +} |
