Struct truck_topology::Vertex [−][src]
Vertex, the minimum topological unit.
The constructor Vertex::new()
creates a different vertex each time.
These vertices are uniquely identified by their id
.
let v0 = Vertex::new(()); // one vertex let v1 = Vertex::new(()); // another vertex assert_ne!(v0, v1); // two vertices are different
Implementations
impl<P> Vertex<P>
[src]
pub fn new(point: P) -> Vertex<P>
[src]
constructor
Examples
use truck_topology::*; let v0 = Vertex::new(()); // a vertex whose geometry is the empty tuple. let v1 = Vertex::new(()); // another vertex let v2 = v0.clone(); // a cloned vertex assert_ne!(v0, v1); assert_eq!(v0, v2);
pub fn news(points: &[P]) -> Vec<Vertex<P>>ⓘ where
P: Copy,
[src]
P: Copy,
Creates len
distinct vertices and return them by vector.
Examples
use truck_topology::Vertex; let v = Vertex::news(&[(), (), ()]); assert_eq!(v.len(), 3); assert_ne!(v[0], v[2]);
pub fn try_lock_point(&self) -> TryLockResult<MutexGuard<'_, P>>
[src]
Tries to lock the mutex of the contained point. The thread will not blocked.
Examples
use truck_topology::*; let v0 = Vertex::new(0); let v1 = v0.clone(); // Two vertices have the same content. assert_eq!(*v0.try_lock_point().unwrap(), 0); assert_eq!(*v1.try_lock_point().unwrap(), 0); { let mut point = v0.try_lock_point().unwrap(); *point = 1; } // The contents of two vertices are synchronized. assert_eq!(*v0.try_lock_point().unwrap(), 1); assert_eq!(*v1.try_lock_point().unwrap(), 1); // The thread is not blocked even if the point is already locked. let lock = v0.try_lock_point(); assert!(v1.try_lock_point().is_err());
pub fn lock_point(&self) -> LockResult<MutexGuard<'_, P>>
[src]
Acquires the mutex of the contained point, blocking the current thread until it is able to do so.
Examples
use truck_topology::*; let v0 = Vertex::new(0); let v1 = v0.clone(); // Two vertices have the same content. assert_eq!(*v0.lock_point().unwrap(), 0); assert_eq!(*v1.lock_point().unwrap(), 0); { let mut point = v0.lock_point().unwrap(); *point = 1; } // The contents of two vertices are synchronized. assert_eq!(*v0.lock_point().unwrap(), 1); assert_eq!(*v1.lock_point().unwrap(), 1); // Check the behavior of `lock`. std::thread::spawn(move || { *v0.lock_point().unwrap() = 2; }).join().expect("thread::spawn failed"); assert_eq!(*v1.lock_point().unwrap(), 2);
pub fn id(&self) -> VertexID<P>
[src]
Returns the id of the vertex.
Trait Implementations
impl<P> Clone for Vertex<P>
[src]
impl<P: Debug> Debug for Vertex<P>
[src]
impl<P> Eq for Vertex<P>
[src]
impl<P> Hash for Vertex<P>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<P> PartialEq<Vertex<P>> for Vertex<P>
[src]
Auto Trait Implementations
impl<P> RefUnwindSafe for Vertex<P>
[src]
impl<P> Send for Vertex<P> where
P: Send,
[src]
P: Send,
impl<P> Sync for Vertex<P> where
P: Send,
[src]
P: Send,
impl<P> Unpin for Vertex<P>
[src]
impl<P> UnwindSafe for Vertex<P>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,