Reformat the code a bit more.
This commit is contained in:
+6
-1
@@ -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"
|
||||||
|
|||||||
+6
-49
@@ -57,10 +57,7 @@ impl std::string::ToString for Password {
|
|||||||
Some(s) => format!(" ^{}", s.borrow().name),
|
Some(s) => format!(" ^{}", s.borrow().name),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
};
|
};
|
||||||
format!(
|
format!("{}{} {}{} {} {}{}{}", prefix, self.name, length, self.mode, self.seq, self.date, comment, parent)
|
||||||
"{}{} {}{} {} {}{}{}",
|
|
||||||
prefix, self.name, length, self.mode, self.seq, self.date, comment, parent
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,59 +99,19 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn exec_recursion_test() {
|
fn exec_recursion_test() {
|
||||||
let p1 = Rc::new(RefCell::new(Password::new(
|
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)));
|
||||||
None,
|
|
||||||
"p1".to_string(),
|
|
||||||
None,
|
|
||||||
Mode::Regular,
|
|
||||||
99,
|
|
||||||
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
|
|
||||||
None,
|
|
||||||
)));
|
|
||||||
|
|
||||||
p1.borrow_mut().parent = Some(p1.clone());
|
p1.borrow_mut().parent = Some(p1.clone());
|
||||||
fix_password_recursion(p1.clone());
|
fix_password_recursion(p1.clone());
|
||||||
assert_eq!(p1.borrow().parent, None);
|
assert_eq!(p1.borrow().parent, None);
|
||||||
|
|
||||||
let p2 = Rc::new(RefCell::new(Password::new(
|
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)));
|
||||||
None,
|
|
||||||
"p2".to_string(),
|
|
||||||
None,
|
|
||||||
Mode::Regular,
|
|
||||||
99,
|
|
||||||
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
|
|
||||||
None,
|
|
||||||
)));
|
|
||||||
p2.borrow_mut().parent = Some(p1.clone());
|
p2.borrow_mut().parent = Some(p1.clone());
|
||||||
let p3 = Rc::new(RefCell::new(Password::new(
|
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)));
|
||||||
None,
|
|
||||||
"p3".to_string(),
|
|
||||||
None,
|
|
||||||
Mode::Regular,
|
|
||||||
99,
|
|
||||||
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
|
|
||||||
None,
|
|
||||||
)));
|
|
||||||
p3.borrow_mut().parent = Some(p2.clone());
|
p3.borrow_mut().parent = Some(p2.clone());
|
||||||
let p4 = Rc::new(RefCell::new(Password::new(
|
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)));
|
||||||
None,
|
|
||||||
"p4".to_string(),
|
|
||||||
None,
|
|
||||||
Mode::Regular,
|
|
||||||
99,
|
|
||||||
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
|
|
||||||
None,
|
|
||||||
)));
|
|
||||||
p4.borrow_mut().parent = Some(p3.clone());
|
p4.borrow_mut().parent = Some(p3.clone());
|
||||||
let p5 = Rc::new(RefCell::new(Password::new(
|
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)));
|
||||||
None,
|
|
||||||
"p5".to_string(),
|
|
||||||
None,
|
|
||||||
Mode::Regular,
|
|
||||||
99,
|
|
||||||
NaiveDate::from_ymd_opt(2022, 12, 3).unwrap(),
|
|
||||||
None,
|
|
||||||
)));
|
|
||||||
p5.borrow_mut().parent = Some(p4.clone());
|
p5.borrow_mut().parent = Some(p4.clone());
|
||||||
|
|
||||||
p1.borrow_mut().parent = Some(p3.clone());
|
p1.borrow_mut().parent = Some(p3.clone());
|
||||||
|
|||||||
+3
-13
@@ -178,14 +178,8 @@ mod tests {
|
|||||||
db.insert(pwd1.borrow().name.clone(), pwd1.clone());
|
db.insert(pwd1.borrow().name.clone(), pwd1.clone());
|
||||||
db
|
db
|
||||||
});
|
});
|
||||||
assert_eq!(
|
assert_eq!(LKEval::new(Command::Ls, lk.clone()).eval(), LKPrint::new(vec!["t1 R 99 2022-12-30 comment".to_string()], false, lk.clone()));
|
||||||
LKEval::new(Command::Ls, lk.clone()).eval(),
|
assert_eq!(LKEval::new(Command::Quit, lk.clone()).eval(), LKPrint::new(vec!["Bye!".to_string()], true, lk.clone()));
|
||||||
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 {
|
let pwd2 = Rc::new(RefCell::new(Password {
|
||||||
name: Rc::new("t2".to_string()),
|
name: Rc::new("t2".to_string()),
|
||||||
prefix: None,
|
prefix: None,
|
||||||
@@ -204,11 +198,7 @@ mod tests {
|
|||||||
});
|
});
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
LKEval::new(Command::Ls, lk.clone()).eval(),
|
LKEval::new(Command::Ls, lk.clone()).eval(),
|
||||||
LKPrint::new(
|
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())
|
||||||
vec!["t1 R 99 2022-12-30 comment".to_string(), "t2 R 99 2022-12-31 bli blup".to_string()],
|
|
||||||
false,
|
|
||||||
lk.clone()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user