Skip to content

Commit

Permalink
Added create_with_id method.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdecimus committed Jul 5, 2023
1 parent ab6a9e5 commit a55af18
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ impl<O: SetObject> SetRequest<O> {
.unwrap()
}

pub fn create_with_id(&mut self, create_id: impl Into<String>) -> &mut O {
let create_id = create_id.into();
self.create
.get_or_insert_with(AHashMap::new)
.insert(create_id.clone(), O::new(0.into()));
self.create.as_mut().unwrap().get_mut(&create_id).unwrap()
}

pub fn create_item(&mut self, item: O) -> String {
let create_id = self.create.as_ref().map_or(0, |c| c.len());
let create_id_str = format!("c{}", create_id);
Expand Down

0 comments on commit a55af18

Please sign in to comment.