Switch from Rc<RefCell> to Arc<Mutex<T>> or Arc<ReentrantMutex<RefCell<T>>>.

This commit is contained in:
Oleksandr Kozachuk
2023-01-06 13:12:58 +01:00
parent a2978c1230
commit 538a32a471
13 changed files with 384 additions and 214 deletions
+10 -4
View File
@@ -11,12 +11,14 @@ pub mod date {
#[derive(PartialEq, Debug, Clone, Copy)]
pub struct Date {
date: NaiveDate
date: NaiveDate,
}
impl Date {
pub fn new(year: i32, month: u32, day: u32) -> Self {
Self { date: NaiveDate::from_ymd_opt(year, month, day).unwrap() }
Self {
date: NaiveDate::from_ymd_opt(year, month, day).unwrap(),
}
}
pub fn try_new(year: i32, month: u32, day: u32) -> Result<Self, &'static str> {
@@ -27,7 +29,9 @@ pub mod date {
}
pub fn now() -> Self {
Self { date: Local::now().naive_local().date() }
Self {
date: Local::now().naive_local().date(),
}
}
pub fn cmp(&self, other: &Self) -> core::cmp::Ordering {
@@ -95,7 +99,9 @@ pub mod editor {
impl Editor {
pub fn new() -> Self {
Self { editor: rustyline::Editor::<()>::new().unwrap() }
Self {
editor: rustyline::Editor::<()>::new().unwrap(),
}
}
pub fn clear_history(&mut self) {