Skip to content

Commit c0a68b1

Browse files
authored
predictable collection api (#182)
1 parent 9a3a833 commit c0a68b1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

star_frame/src/unsize/impls/set.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ where
127127
self.list.get(index)
128128
}
129129

130-
/// Adds a value to the set. Returns whether the value was already present. If the value is already present, the set is unchanged.
130+
/// Adds a value to the set.
131+
///
132+
/// Returns whether the value was newly inserted. If the value is already present, the set is unchanged and `false` is returned.
131133
///
132134
/// # Examples
133135
///

star_frame/src/unsize/impls/unsized_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ where
168168
}
169169
}
170170

171-
/// Inserts or modifies an item into the map, returning true if the item already existed, and false otherwise.
171+
/// Inserts or modifies an item into the map, returning true if the item was newly inserted, and false otherwise.
172172
#[exclusive]
173173
pub fn insert<I>(&mut self, key: K, value: I) -> Result<bool>
174174
where
@@ -179,12 +179,12 @@ where
179179
// TODO: optimize this by just modifying bytes to fit and then writing to them
180180
self.list().remove(existing_index)?;
181181
self.list().insert_with_offset(existing_index, value, key)?;
182-
Ok(true)
182+
Ok(false)
183183
}
184184
Err(insertion_index) => {
185185
self.list()
186186
.insert_with_offset(insertion_index, value, key)?;
187-
Ok(false)
187+
Ok(true)
188188
}
189189
}
190190
}

0 commit comments

Comments
 (0)