serde_yml::value::tagged

Function check_for_tag

Source
pub fn check_for_tag<T>(value: &T) -> MaybeTag<String>
where T: ?Sized + Display,
Expand description

Returns a MaybeTag enum indicating whether the input value is a YAML tag or not.

A YAML tag is denoted by a leading exclamation mark (!). If the input value is empty, it is considered not to be a tag. If the input value starts with an exclamation mark, it is considered to be a tag but not a bang tag (i.e., !foo is a tag, but !bar is not). If the input value does not start with an exclamation mark, it is considered not to be a tag.

ยงExamples

use serde_yml::value::tagged::check_for_tag;
use serde_yml::value::tagged::MaybeTag;

let result = check_for_tag(&"foo".to_owned());
assert!(
    matches!(result, MaybeTag::NotTag(_)),
    "Expected MaybeTag::NotTag but got {:?}", result
);