pub trait HasTetrahedra<'a>: Sized{
type Point: IsPoint;
type Normal: IsUnitVector;
type Tetrahedron: IsTetrahedron<'a, Self::Point, Self::Normal>;
type TetrahedronTable: IsGeometryTable<Key = TetrahedronId, Item = Self::Tetrahedron> + ?Sized + 'a;
// Required methods
fn tetrahedron_table(&self) -> &Self::TetrahedronTable;
fn tetrahedron_table_mut(&mut self) -> &mut Self::TetrahedronTable;
fn set_tetrahedron_table(&mut self, table: &'a mut Self::TetrahedronTable);
// Provided methods
fn tetrahedron_table_size(&self) -> usize { ... }
fn get_tetrahedron(&self, id: &TetrahedronId) -> Option<Self::Tetrahedron> { ... }
fn contains_tetrahedron(&self, id: &TetrahedronId) -> bool { ... }
fn insert_tetrahedron(
&mut self,
id: TetrahedronId,
value: Self::Tetrahedron,
) -> Result<(), ErrorsJSL> { ... }
fn remove_tetrahedron(
&mut self,
id: &TetrahedronId,
) -> Option<Self::Tetrahedron> { ... }
}Expand description
Provides access to a borrowed tetrahedron table.
ⓘ
use lib_jsl::geometry::common::{HasTetrahedra, IsGeometryTable, PointId, TetrahedronId};
use lib_jsl::geometry::two_d::{CoordinateVector2D, UnitVector2D};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct FakeTable;
impl IsGeometryTable for FakeTable {
type Key = TetrahedronId;
type Item = CoordinateVector2D;
fn get(&self, _: &Self::Key) -> Option<Self::Item> { None }
fn insert(&mut self, _: Self::Key, _: Self::Item) -> Result<(), ErrorsJSL> { Ok(()) }
fn remove(&mut self, _: &Self::Key) -> Option<Self::Item> { None }
fn contains_key(&self, _: &Self::Key) -> bool { false }
fn size(&self) -> usize { 0 }
fn union(&self, _: &Self) -> Self where Self: Sized { FakeTable }
fn intersection(&self, _: &Self) -> Self where Self: Sized { FakeTable }
fn iter(&self) -> Box<dyn Iterator<Item = (Self::Key, Self::Item)> + '_> { Box::new(std::iter::empty()) }
fn to_file(&self, _: &str) -> Result<(), ErrorsJSL> { Ok(()) }
fn from_file(_: &str) -> Result<Self, ErrorsJSL> where Self: Sized { Ok(FakeTable) }
}
struct BadCells<'a> {
table: &'a mut FakeTable,
}
impl<'a> HasTetrahedra<'a> for BadCells<'a> {
type Point = CoordinateVector2D;
type Normal = UnitVector2D;
type Tetrahedron = CoordinateVector2D;
type TetrahedronTable = FakeTable;
fn tetrahedron_table(&self) -> &Self::TetrahedronTable { self.table }
fn tetrahedron_table_mut(&mut self) -> &mut Self::TetrahedronTable { self.table }
fn set_tetrahedron_table(&mut self, table: &'a mut Self::TetrahedronTable) { self.table = table; }
}Required Associated Types§
Sourcetype Normal: IsUnitVector
type Normal: IsUnitVector
Unit normal type used by the stored tetrahedra.
Sourcetype Tetrahedron: IsTetrahedron<'a, Self::Point, Self::Normal>
type Tetrahedron: IsTetrahedron<'a, Self::Point, Self::Normal>
Tetrahedron primitive stored in the tetrahedron table.
Sourcetype TetrahedronTable: IsGeometryTable<Key = TetrahedronId, Item = Self::Tetrahedron> + ?Sized + 'a
type TetrahedronTable: IsGeometryTable<Key = TetrahedronId, Item = Self::Tetrahedron> + ?Sized + 'a
Borrowed tetrahedron-table type.
Required Methods§
Sourcefn tetrahedron_table(&self) -> &Self::TetrahedronTable
fn tetrahedron_table(&self) -> &Self::TetrahedronTable
Returns an immutable reference to the tetrahedron table.
Sourcefn tetrahedron_table_mut(&mut self) -> &mut Self::TetrahedronTable
fn tetrahedron_table_mut(&mut self) -> &mut Self::TetrahedronTable
Returns a mutable reference to the tetrahedron table.
Sourcefn set_tetrahedron_table(&mut self, table: &'a mut Self::TetrahedronTable)
fn set_tetrahedron_table(&mut self, table: &'a mut Self::TetrahedronTable)
Rebinds the implementor to a different borrowed tetrahedron table.
Provided Methods§
Sourcefn tetrahedron_table_size(&self) -> usize
fn tetrahedron_table_size(&self) -> usize
Returns the number of entries in the tetrahedron table.
Sourcefn get_tetrahedron(&self, id: &TetrahedronId) -> Option<Self::Tetrahedron>
fn get_tetrahedron(&self, id: &TetrahedronId) -> Option<Self::Tetrahedron>
Returns the tetrahedron stored at id.
Sourcefn contains_tetrahedron(&self, id: &TetrahedronId) -> bool
fn contains_tetrahedron(&self, id: &TetrahedronId) -> bool
Returns true if the tetrahedron table contains id.
Sourcefn insert_tetrahedron(
&mut self,
id: TetrahedronId,
value: Self::Tetrahedron,
) -> Result<(), ErrorsJSL>
fn insert_tetrahedron( &mut self, id: TetrahedronId, value: Self::Tetrahedron, ) -> Result<(), ErrorsJSL>
Inserts or replaces the tetrahedron stored at id.
Sourcefn remove_tetrahedron(
&mut self,
id: &TetrahedronId,
) -> Option<Self::Tetrahedron>
fn remove_tetrahedron( &mut self, id: &TetrahedronId, ) -> Option<Self::Tetrahedron>
Removes and returns the tetrahedron stored at id, if present.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".