mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-25 08:35:51 +00:00
Add Shape::get_handle_or_insert
This commit is contained in:
parent
13c1d366a7
commit
c780a717ab
@ -92,6 +92,21 @@ impl Shape {
|
|||||||
.find(|obj| &obj.get() == object)
|
.find(|obj| &obj.get() == object)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get handle of an identical object, if it exists, or add the object
|
||||||
|
///
|
||||||
|
/// In any case, returns a handle that refers to an object that is identical
|
||||||
|
/// to the provided object.
|
||||||
|
pub fn get_handle_or_insert<T>(&mut self, object: T) -> ValidationResult<T>
|
||||||
|
where
|
||||||
|
T: Object,
|
||||||
|
{
|
||||||
|
if let Some(handle) = self.get_handle(&object) {
|
||||||
|
return Ok(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.insert(object)
|
||||||
|
}
|
||||||
|
|
||||||
/// Access the shape's geometry
|
/// Access the shape's geometry
|
||||||
pub fn geometry(&mut self) -> Geometry {
|
pub fn geometry(&mut self) -> Geometry {
|
||||||
Geometry {
|
Geometry {
|
||||||
|
Loading…
Reference in New Issue
Block a user