Return previous values from replace and remove
@@ -31,7 +31,6 @@ impl From<*mut c_void> for ImTexture {
/// Create your image using the builder pattern then [`Image::build`] it.
#[must_use]
pub struct Image<'ui> {
- /// we use Result to allow postponing any construction errors to the build call
texture_id: ImTexture,
size: ImVec2,
uv0: ImVec2,
@@ -131,13 +130,12 @@ impl<T> Textures<T> {
ImTexture(id)
}
- pub fn replace(&mut self, id: ImTexture, texture: T) {
- assert!(self.textures.contains_key(&id.0));
- self.textures.insert(id.0, texture);
+ pub fn replace(&mut self, id: ImTexture, texture: T) -> Option<T> {
+ self.textures.insert(id.0, texture)
}
- pub fn remove(&mut self, id: ImTexture) {
- self.textures.remove(&id.0);
+ pub fn remove(&mut self, id: ImTexture) -> Option<T> {
+ self.textures.remove(&id.0)
}
pub fn get(&self, id: ImTexture) -> Option<&T> {
