fn add_task_to_user(task_id: &str, user_id: &str) -> Result<()> {
    let uid = user_id.to_owned();
    let id_set = USER_TASK_STORE.get(&uid)?;
    match id_set {
        Some(mut set) => {
            set.insert(task_id.to_owned());
            USER_TASK_STORE.set(&uid, &set)?;
        }
        None => {
            let mut set = HashSet::<String>::new();
            set.insert(task_id.to_owned());
            USER_TASK_STORE.set(&uid, &set)?;
        }
    }
    Ok(())
}
// Before calling this function, use lock to avoid data race;
Before calling this function, use lock to avoid data race.
Before calling this function use lock to avoid data race .
fn add_task_to_user(task_id: &str, user_id: &str) -> Result<()> {
    let uid = user_id.to_owned();
    let id_set = USER_TASK_STORE.get(&uid)?;
    match id_set {
        Some(mut set) => {
            set.insert(task_id.to_owned());
            USER_TASK_STORE.set(&uid, &set)?;
        }
        None => {
            let mut set = HashSet::<String>::new();
            set.insert(task_id.to_owned());
            USER_TASK_STORE.set(&uid, &set)?;
        }
    }
    Ok(())
}
fn add_task_to_user ( task_id : & str , user_id : & str ) -> Result < ( ) > { let uid = user_id . to_owned ( ) ; let id_set = USER_TASK_STORE . get ( & uid ) ? ; match id_set { Some ( mut set ) => { set . insert ( task_id . to_owned ( ) ) ; USER_TASK_STORE . set ( & uid , & set ) ? ; } None => { let mut set = HashSet :: < String > :: new ( ) ; set . insert ( task_id . to_owned ( ) ) ; USER_TASK_STORE . set ( & uid , & set ) ? ; } } Ok ( ( ) ) }
Before calling this function, use lock to avoid data race;
Before calling this function use lock to avoid data race ;
task_id
&str
user_id
&str
task_id
&str
user_id
&str