Skip to main content

from_str_borrowing_with_config

Function from_str_borrowing_with_config 

Source
pub fn from_str_borrowing_with_config<'de, T>(
    s: &'de str,
    config: &ParserConfig,
) -> Result<T>
where T: Deserialize<'de>,
Expand description

from_str_borrowing with a custom ParserConfig — typically to tighten security limits for untrusted input.

§Errors

Returns an error if s is not valid YAML under the supplied config or cannot be deserialised into T.

§Examples

use noyalib::{from_str_borrowing_with_config, ParserConfig};
let cfg = ParserConfig::strict();
let s: &str = from_str_borrowing_with_config("hello\n", &cfg).unwrap();
assert_eq!(s, "hello");