Function marked_yaml::from_yaml_with_options
source ยท pub fn from_yaml_with_options<T>(
source: usize,
yaml: &str,
options: LoaderOptions,
) -> Result<T, FromYamlError>where
T: DeserializeOwned,
Available on crate feature
serde
only.Expand description
Deserialize some YAML into the requisite type
This permits deserialisation of a YAML string into
any structure which serde
can deserialize. In
addition, if any part of the type tree is Spanned
then the spans are provided from the requisite marked
node.
const YAML: &str = "hello: world\n";
#[derive(Deserialize)]
struct Greeting {
hello: Spanned<String>,
}
let greets: Greeting = marked_yaml::from_yaml_with_options(0, YAML, LoaderOptions::default()).unwrap();
let start = greets.hello.span().start().unwrap();
assert_eq!(start.line(), 1);
assert_eq!(start.column(), 8);