blob: ac9ddb53094ca69f0794d2eb642969d08338a590 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
pub struct Ticket {
title: String,
description: String,
status: String,
}
impl Ticket {
pub fn title(&self) -> String {
self.title.clone()
}
pub fn description(&self) -> String {
self.description.clone()
}
pub fn status(&self) -> String {
self.status.clone()
}
pub fn set_title(&mut self, title: &str) {
self.title = String::from(title);
}
pub fn set_description(&mut self, description: &str) {
self.description = String::from(description);
}
pub fn set_status(&mut self, status: &str) {
self.status = String::from(status);
}
}
fn main() {
println!("Hello, world!");
}
#[cfg(test)]
mod tests {
use crate::*;
#[test]
fn t0() {
let mut t = Ticket{
title:String::from("title"),
description:String::from("desc"),
status:String::from("status"),
};
t.set_title("boo");
assert_eq!(t.title, "boo");
}
}
|