pub struct Alias(/* private fields */);Expand description
A YAML alias reference (e.g., *anchor_name)
Note: This type uses interior mutability through the rowan library.
Mutation methods work even when called through &self. See the crate-level
documentation for details on the mutability model.
Implementations§
Source§impl Alias
impl Alias
Sourcepub fn name(&self) -> String
pub fn name(&self) -> String
Get the anchor name this alias refers to (without the * prefix)
§Examples
use yaml_edit::Document;
use std::str::FromStr;
let yaml = r#"
anchor: &my_anchor
key: value
reference: *my_anchor
"#;
let doc = Document::from_str(yaml).unwrap();
let mapping = doc.as_mapping().unwrap();
let reference = mapping.get("reference").unwrap();
if let yaml_edit::YamlNode::Alias(alias) = reference {
assert_eq!(alias.name(), "my_anchor");
}Trait Implementations§
Source§impl AsYaml for Alias
impl AsYaml for Alias
Source§fn as_node(&self) -> Option<&SyntaxNode<Lang>>
fn as_node(&self) -> Option<&SyntaxNode<Lang>>
Returns a reference to the underlying
SyntaxNode if one exists. Read moreSource§fn build_content(
&self,
builder: &mut GreenNodeBuilder<'_>,
_indent: usize,
_flow_context: bool,
) -> bool
fn build_content( &self, builder: &mut GreenNodeBuilder<'_>, _indent: usize, _flow_context: bool, ) -> bool
Serialize this value into a
GreenNodeBuilder. Read moreimpl Eq for Alias
impl StructuralPartialEq for Alias
Auto Trait Implementations§
impl Freeze for Alias
impl !RefUnwindSafe for Alias
impl !Send for Alias
impl !Sync for Alias
impl Unpin for Alias
impl UnsafeUnpin for Alias
impl !UnwindSafe for Alias
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
Mutably borrows from an owned value. Read more