diff options
| author | sigoden <sigoden@gmail.com> | 2023-03-09 07:58:44 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-09 07:58:44 +0800 |
| commit | 1ec451da896f930829d8908da81e416d891f9aa5 (patch) | |
| tree | a5a99ba939cd67dd735bdd87912bd8cb23926a67 /src/config.rs | |
| parent | ebd3cb2401739305c6f36c1f7a4cd543a1fdf419 (diff) | |
| download | aichat-1ec451da896f930829d8908da81e416d891f9aa5.tar.gz | |
refactor: replace Arc<Refcell<Config>> with Arc<Mutex<Config>> (#46)
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs index 1542f9e..fe93da6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,4 @@ use std::{ - cell::RefCell, env, fs::{create_dir_all, read_to_string, File, OpenOptions}, io::Write, @@ -8,6 +7,8 @@ use std::{ sync::Arc, }; +use parking_lot::Mutex; + use anyhow::{anyhow, Context, Result}; use inquire::{Confirm, Text}; use serde::{Deserialize, Serialize}; @@ -56,7 +57,7 @@ pub struct Config { pub role: Option<Role>, } -pub type SharedConfig = Arc<RefCell<Config>>; +pub type SharedConfig = Arc<Mutex<Config>>; impl Config { pub fn init(is_interactive: bool) -> Result<Config> { |
