-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2178 from hannobraun/bare
Add `IsObject` trait
- Loading branch information
Showing
5 changed files
with
111 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
use crate::storage::Handle; | ||
|
||
use super::{ | ||
Curve, Cycle, Face, HalfEdge, Region, Shell, Sketch, Solid, Surface, Vertex, | ||
}; | ||
|
||
/// A trait implemented for all object types | ||
/// | ||
/// This trait is implemented for both `T` and `Handle<T>`, where `T` is the | ||
/// type of any bare object. The `BareObject` associated type provides access to | ||
/// the bare object type. | ||
/// | ||
/// This is a piece of infrastructure that is useful for other traits, which | ||
/// would otherwise have to duplicate its functionality. Users are unlikely to | ||
/// be affected by this trait. | ||
pub trait IsObject { | ||
/// The type of the bare object | ||
type BareObject; | ||
} | ||
|
||
impl IsObject for Curve { | ||
type BareObject = Curve; | ||
} | ||
|
||
impl IsObject for Cycle { | ||
type BareObject = Cycle; | ||
} | ||
|
||
impl IsObject for Face { | ||
type BareObject = Face; | ||
} | ||
|
||
impl IsObject for HalfEdge { | ||
type BareObject = HalfEdge; | ||
} | ||
|
||
impl IsObject for Region { | ||
type BareObject = Region; | ||
} | ||
|
||
impl IsObject for Shell { | ||
type BareObject = Shell; | ||
} | ||
|
||
impl IsObject for Sketch { | ||
type BareObject = Sketch; | ||
} | ||
|
||
impl IsObject for Solid { | ||
type BareObject = Solid; | ||
} | ||
|
||
impl IsObject for Surface { | ||
type BareObject = Surface; | ||
} | ||
|
||
impl IsObject for Vertex { | ||
type BareObject = Vertex; | ||
} | ||
|
||
impl IsObject for Handle<Curve> { | ||
type BareObject = Curve; | ||
} | ||
|
||
impl IsObject for Handle<Cycle> { | ||
type BareObject = Cycle; | ||
} | ||
|
||
impl IsObject for Handle<Face> { | ||
type BareObject = Face; | ||
} | ||
|
||
impl IsObject for Handle<HalfEdge> { | ||
type BareObject = HalfEdge; | ||
} | ||
|
||
impl IsObject for Handle<Region> { | ||
type BareObject = Region; | ||
} | ||
|
||
impl IsObject for Handle<Shell> { | ||
type BareObject = Shell; | ||
} | ||
|
||
impl IsObject for Handle<Sketch> { | ||
type BareObject = Sketch; | ||
} | ||
|
||
impl IsObject for Handle<Solid> { | ||
type BareObject = Solid; | ||
} | ||
|
||
impl IsObject for Handle<Surface> { | ||
type BareObject = Surface; | ||
} | ||
|
||
impl IsObject for Handle<Vertex> { | ||
type BareObject = Vertex; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.