Struct dendron::HierarchyEditProhibition
source · pub struct HierarchyEditProhibition<T>(_);
Expand description
A token to keep the tree hierarchy prohibited to be edited.
A prohibition can be created by Tree::prohibit_hierarchy_edit
or
FrozenNode::extract_hierarchy_edit_prohibition
.
Implementations§
source§impl<T> HierarchyEditProhibition<T>
impl<T> HierarchyEditProhibition<T>
sourcepub fn try_clone(&self) -> Result<Self, HierarchyEditProhibitionError>
pub fn try_clone(&self) -> Result<Self, HierarchyEditProhibitionError>
Clones the tree hierarchy edit prohibition.
Failures
Fails if the number of active edit prohibitions for the tree exceeds
isize::MAX
.
sourcepub fn is_valid_for_node(&self, node: &Node<T>) -> bool
pub fn is_valid_for_node(&self, node: &Node<T>) -> bool
Returns true if the prohibition is valid for the tree the given node belongs to.
Examples
use dendron::Node;
let node1 = Node::new_tree("foo");
let node2 = Node::new_tree("bar");
let prohibition1 = node1.tree()
.prohibit_hierarchy_edit()
.expect("hierarchy edit should not yet be granted");
assert!(prohibition1.is_valid_for_node(&node1));
assert!(!prohibition1.is_valid_for_node(&node2));