diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-10 22:19:36 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-10 22:19:36 +0200 |
| commit | 92c01da36016e94ff20163806ddcbcf7e33d4031 (patch) | |
| tree | 1a900b3c11edcc93e9153fada3ce92310db5768b /src/geom/mod.rs | |
| parent | 42500d5ed85539c5ab04dd3544beaf802da29be9 (diff) | |
Switch back to custom geometry types, unified with layout primitives 🏞
Diffstat (limited to 'src/geom/mod.rs')
| -rw-r--r-- | src/geom/mod.rs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/geom/mod.rs b/src/geom/mod.rs new file mode 100644 index 00000000..c9c3040c --- /dev/null +++ b/src/geom/mod.rs @@ -0,0 +1,53 @@ +//! Geometrical primitivies. + +#[macro_use] +mod macros; +mod align; +mod dir; +mod gen; +mod length; +mod linear; +mod point; +mod relative; +mod sides; +mod size; +mod spec; + +pub use align::*; +pub use dir::*; +pub use gen::*; +pub use length::*; +pub use linear::*; +pub use point::*; +pub use relative::*; +pub use sides::*; +pub use size::*; +pub use spec::*; + +use std::fmt::{self, Debug, Display, Formatter}; +use std::iter::Sum; +use std::ops::*; + +/// Generic access to a structure's components. +pub trait Get<Index> { + /// The structure's component type. + type Component; + + /// Return the component for the specified index. + fn get(self, index: Index) -> Self::Component; + + /// Borrow the component for the specified index mutably. + fn get_mut(&mut self, index: Index) -> &mut Self::Component; +} + +/// Switch between the specific and generic representations of a type. +/// +/// The generic representation deals with main and cross axes while the specific +/// representation deals with horizontal and vertical axes. +pub trait Switch { + /// The type of the other version. + type Other; + + /// The other version of this type based on the current directions. + fn switch(self, dirs: Gen<Dir>) -> Self::Other; +} |
