mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-23 19:38:27 +00:00
Return previous values from replace and remove
This commit is contained in:
parent
d202872280
commit
bdbdfe58e3
10
src/image.rs
10
src/image.rs
@ -31,7 +31,6 @@ impl From<*mut c_void> for ImTexture {
|
|||||||
/// Create your image using the builder pattern then [`Image::build`] it.
|
/// Create your image using the builder pattern then [`Image::build`] it.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct Image<'ui> {
|
pub struct Image<'ui> {
|
||||||
/// we use Result to allow postponing any construction errors to the build call
|
|
||||||
texture_id: ImTexture,
|
texture_id: ImTexture,
|
||||||
size: ImVec2,
|
size: ImVec2,
|
||||||
uv0: ImVec2,
|
uv0: ImVec2,
|
||||||
@ -131,13 +130,12 @@ impl<T> Textures<T> {
|
|||||||
ImTexture(id)
|
ImTexture(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn replace(&mut self, id: ImTexture, texture: T) {
|
pub fn replace(&mut self, id: ImTexture, texture: T) -> Option<T> {
|
||||||
assert!(self.textures.contains_key(&id.0));
|
self.textures.insert(id.0, texture)
|
||||||
self.textures.insert(id.0, texture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove(&mut self, id: ImTexture) {
|
pub fn remove(&mut self, id: ImTexture) -> Option<T> {
|
||||||
self.textures.remove(&id.0);
|
self.textures.remove(&id.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self, id: ImTexture) -> Option<&T> {
|
pub fn get(&self, id: ImTexture) -> Option<&T> {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user