Reformat the code a bit more.

This commit is contained in:
Oleksandr Kozachuk 2022-12-04 00:13:25 +01:00
parent 157bab1d56
commit de7fd70110
3 changed files with 15 additions and 63 deletions

View File

@ -1 +1,6 @@
max_width = 160
max_width = 180
fn_call_width = 150
attr_fn_like_width = 140
array_width = 160
chain_width = 160
edition = "2021"

View File

@ -57,10 +57,7 @@ impl std::string::ToString for Password {
Some(s) => format!(" ^{}", s.borrow().name),
None => "".to_string(),
};
format!(
"{}{} {}{} {} {}{}{}",
prefix, self.name, length, self.mode, self.seq, self.date, comment, parent
)
format!("{}{} {}{} {} {}{}{}", prefix, self.name, length, self.mode, self.seq, self.date, comment, parent)
}
}
@ -102,59 +99,19 @@ mod tests {
#[test]
fn exec_recursion_test() {
let p1 = Rc::new(RefCell::new(Password::new(
None,
"p1".to_string(),
None,
Mode::Regular,
99,
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
None,
)));
let p1 = Rc::new(RefCell::new(Password::new(None, "p1".to_string(), None, Mode::Regular, 99, NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(), None)));
p1.borrow_mut().parent = Some(p1.clone());
fix_password_recursion(p1.clone());
assert_eq!(p1.borrow().parent, None);
let p2 = Rc::new(RefCell::new(Password::new(
None,
"p2".to_string(),
None,
Mode::Regular,
99,
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
None,
)));
let p2 = Rc::new(RefCell::new(Password::new(None, "p2".to_string(), None, Mode::Regular, 99, NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(), None)));
p2.borrow_mut().parent = Some(p1.clone());
let p3 = Rc::new(RefCell::new(Password::new(
None,
"p3".to_string(),
None,
Mode::Regular,
99,
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
None,
)));
let p3 = Rc::new(RefCell::new(Password::new(None, "p3".to_string(), None, Mode::Regular, 99, NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(), None)));
p3.borrow_mut().parent = Some(p2.clone());
let p4 = Rc::new(RefCell::new(Password::new(
None,
"p4".to_string(),
None,
Mode::Regular,
99,
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
None,
)));
let p4 = Rc::new(RefCell::new(Password::new(None, "p4".to_string(), None, Mode::Regular, 99, NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(), None)));
p4.borrow_mut().parent = Some(p3.clone());
let p5 = Rc::new(RefCell::new(Password::new(
None,
"p5".to_string(),
None,
Mode::Regular,
99,
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
None,
)));
let p5 = Rc::new(RefCell::new(Password::new(None, "p5".to_string(), None, Mode::Regular, 99, NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(), None)));
p5.borrow_mut().parent = Some(p4.clone());
p1.borrow_mut().parent = Some(p3.clone());

View File

@ -178,14 +178,8 @@ mod tests {
db.insert(pwd1.borrow().name.clone(), pwd1.clone());
db
});
assert_eq!(
LKEval::new(Command::Ls, lk.clone()).eval(),
LKPrint::new(vec!["t1 R 99 2022-12-30 comment".to_string()], false, lk.clone())
);
assert_eq!(
LKEval::new(Command::Quit, lk.clone()).eval(),
LKPrint::new(vec!["Bye!".to_string()], true, lk.clone())
);
assert_eq!(LKEval::new(Command::Ls, lk.clone()).eval(), LKPrint::new(vec!["t1 R 99 2022-12-30 comment".to_string()], false, lk.clone()));
assert_eq!(LKEval::new(Command::Quit, lk.clone()).eval(), LKPrint::new(vec!["Bye!".to_string()], true, lk.clone()));
let pwd2 = Rc::new(RefCell::new(Password {
name: Rc::new("t2".to_string()),
prefix: None,
@ -204,11 +198,7 @@ mod tests {
});
assert_eq!(
LKEval::new(Command::Ls, lk.clone()).eval(),
LKPrint::new(
vec!["t1 R 99 2022-12-30 comment".to_string(), "t2 R 99 2022-12-31 bli blup".to_string()],
false,
lk.clone()
)
LKPrint::new(vec!["t1 R 99 2022-12-30 comment".to_string(), "t2 R 99 2022-12-31 bli blup".to_string()], false, lk.clone())
);
}
}