pub struct UpdateId(_);Expand description
An update identifier
Used to identify the origin of an Event::Update.
Implementations§
source§impl UpdateId
impl UpdateId
sourcepub fn new() -> UpdateId
pub fn new() -> UpdateId
Issue a new UpdateId
A total of 232 - 1 update handles are available. Attempting to issue 232 handles will result in a panic.
Examples found in repository?
src/model/shared_rc.rs (line 26)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
fn default() -> Self {
SharedRc(Rc::new((UpdateId::new(), Default::default())))
}
}
/// A borrowed reference
pub struct SharedRcRef<'a, T>(Ref<'a, T>);
impl<'a, T> std::borrow::Borrow<T> for SharedRcRef<'a, T> {
fn borrow(&self) -> &T {
&self.0
}
}
impl<'a, T> Deref for SharedRcRef<'a, T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
/// A mutably borrowed reference
pub struct SharedRcRefMut<'a, T>(RefMut<'a, T>);
impl<'a, T> std::borrow::Borrow<T> for SharedRcRefMut<'a, T> {
fn borrow(&self) -> &T {
&self.0
}
}
impl<'a, T> std::borrow::BorrowMut<T> for SharedRcRefMut<'a, T> {
fn borrow_mut(&mut self) -> &mut T {
&mut self.0
}
}
impl<'a, T> Deref for SharedRcRefMut<'a, T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<'a, T> DerefMut for SharedRcRefMut<'a, T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.0
}
}
impl<T: Debug> SharedRc<T> {
/// Construct with given data
pub fn new(data: T) -> Self {
let id = UpdateId::new();
let data = RefCell::new((data, 1));
SharedRc(Rc::new((id, data)))
}More examples
src/model/shared_arc.rs (line 25)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
fn default() -> Self {
SharedArc(Arc::new((UpdateId::new(), Default::default())))
}
}
/// A borrowed reference
pub struct SharedArcRef<'a, T>(MutexGuard<'a, (T, u64)>);
impl<'a, T> std::borrow::Borrow<T> for SharedArcRef<'a, T> {
fn borrow(&self) -> &T {
&self.0.deref().0
}
}
impl<'a, T> Deref for SharedArcRef<'a, T> {
type Target = T;
fn deref(&self) -> &T {
&self.0.deref().0
}
}
/// A mutably borrowed reference
//
// Note: this is identical to SharedArcRef other than the trait impls. We cannot
// allow SharedData::borrow to return a type supporting mutable access!
pub struct SharedArcRefMut<'a, T>(MutexGuard<'a, (T, u64)>);
impl<'a, T> std::borrow::Borrow<T> for SharedArcRefMut<'a, T> {
fn borrow(&self) -> &T {
&self.0.deref().0
}
}
impl<'a, T> std::borrow::BorrowMut<T> for SharedArcRefMut<'a, T> {
fn borrow_mut(&mut self) -> &mut T {
&mut self.0.deref_mut().0
}
}
impl<'a, T> Deref for SharedArcRefMut<'a, T> {
type Target = T;
fn deref(&self) -> &T {
&self.0.deref().0
}
}
impl<'a, T> DerefMut for SharedArcRefMut<'a, T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.0.deref_mut().0
}
}
impl<T: Debug> SharedArc<T> {
/// Construct with given data
pub fn new(data: T) -> Self {
let id = UpdateId::new();
let data = Mutex::new((data, 1));
SharedArc(Arc::new((id, data)))
}Trait Implementations§
source§impl Ord for UpdateId
impl Ord for UpdateId
source§impl PartialEq<UpdateId> for UpdateId
impl PartialEq<UpdateId> for UpdateId
source§impl PartialOrd<UpdateId> for UpdateId
impl PartialOrd<UpdateId> for UpdateId
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for UpdateId
impl Eq for UpdateId
impl StructuralEq for UpdateId
impl StructuralPartialEq for UpdateId
Auto Trait Implementations§
impl RefUnwindSafe for UpdateId
impl Send for UpdateId
impl Sync for UpdateId
impl Unpin for UpdateId
impl UnwindSafe for UpdateId
Blanket Implementations§
source§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
source§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
source§fn cast_approx(self) -> T
fn cast_approx(self) -> T
source§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
source§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
source§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
source§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.