pub struct TreeId(/* private fields */);Expand description
The identifier of one tree of a document’s tree arena, or of one synthesized value built inside a run.
The two kinds of identifier are numbered separately: a document tree and a
synthesized value with the same number are different identifiers.
TreeId::tree and TreeId::value create an identifier of each kind;
TreeId::is_document_tree and TreeId::is_value tell which kind an
identifier is, and TreeId::index returns its number. See the module
documentation for what each kind identifies.
Every document tree orders before every synthesized value; identifiers of
one kind order by their number. The Display form is tree#3 for a
document tree and value#3 for a synthesized value.
§Examples
use flm_core::model::addr::TreeId;
let tree = TreeId::tree(3);
let value = TreeId::value(3);
assert_ne!(tree, value);
assert_eq!(tree.index(), value.index());
assert!(tree.is_document_tree());
assert!(value.is_value());
assert!(tree < value);Implementations§
Source§impl TreeId
impl TreeId
Sourcepub const fn tree(index: u32) -> TreeId
pub const fn tree(index: u32) -> TreeId
The identifier of the document tree at index index of a document’s
tree arena.
A document assigns these identifiers itself as trees are added
(DocContent::place,
DocContent::add_tree); a
caller creates one to refer to a tree it knows the index of. See
TreeId::value for the identifier of a synthesized value.
§Panics
Panics if index is 2³¹ or greater: the highest bit is the tag that
tells the two kinds of identifier apart.
DocContent::add_tree
checks the same bound before it creates an identifier.
Sourcepub const fn value(index: u32) -> TreeId
pub const fn value(index: u32) -> TreeId
The identifier of the synthesized value numbered index within one
stage invocation.
Each stage invocation numbers its synthesized values from zero, so an identifier created here is meaningful only inside the invocation that built the synthesized value.
§Panics
Panics if index is 2³¹ or greater: the highest bit is the tag that
tells the two kinds of identifier apart.
Sourcepub const fn index(self) -> u32
pub const fn index(self) -> u32
The identifier’s number: the arena index of a document tree, or the number a stage invocation gave a synthesized value.
A document tree and a synthesized value may have the same number;
TreeId::is_value tells them apart.
Sourcepub const fn is_value(self) -> bool
pub const fn is_value(self) -> bool
Returns true when this identifies a synthesized value, false when it
identifies a document tree.
Sourcepub const fn is_document_tree(self) -> bool
pub const fn is_document_tree(self) -> bool
Returns true when this identifies a document tree, false when it
identifies a synthesized value.
Trait Implementations§
impl Copy for TreeId
impl Eq for TreeId
Source§impl Ord for TreeId
impl Ord for TreeId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for TreeId
impl PartialOrd for TreeId
impl StructuralPartialEq for TreeId
Auto Trait Implementations§
impl Forget for TreeId
impl Freeze for TreeId
impl Move for TreeId
impl RefUnwindSafe for TreeId
impl Send for TreeId
impl Sync for TreeId
impl Unpin for TreeId
impl UnsafeUnpin for TreeId
impl UnwindSafe for TreeId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more