use yaml_rust::parser::{Event, EventReceiver, Parser}; use yaml_rust::scanner::TScalarStyle;
// These names match the names used in the C++ test suite. #[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))] #[derive(Clone, PartialEq, PartialOrd, Debug)] enum TestEvent {
OnDocumentStart,
OnDocumentEnd,
OnSequenceStart,
OnSequenceEnd,
OnMapStart,
OnMapEnd,
OnScalar,
OnAlias,
OnNull,
}
struct YamlChecker { pub evs: Vec<TestEvent>,
}
impl EventReceiver for YamlChecker { fn on_event(&mutself, ev: Event) { let tev = match ev {
Event::DocumentStart => TestEvent::OnDocumentStart,
Event::DocumentEnd => TestEvent::OnDocumentEnd,
Event::SequenceStart(..) => TestEvent::OnSequenceStart,
Event::SequenceEnd => TestEvent::OnSequenceEnd,
Event::MappingStart(..) => TestEvent::OnMapStart,
Event::MappingEnd => TestEvent::OnMapEnd,
Event::Scalar(ref v, style, _, _) => { if v == "~" && style == TScalarStyle::Plain {
TestEvent::OnNull
} else {
TestEvent::OnScalar
}
}
Event::Alias(_) => TestEvent::OnAlias,
_ => return, // ignore other events
}; self.evs.push(tev);
}
}
// At this point, we are tempted to naively render like this: // // ```yaml // --- // {key: // - 1 // - 2 // - 3}: // - 4 // - 5 // - 6 // ``` // // However, this doesn't work, because the key sequence [1, 2, 3] is // rendered in block mode, which is not legal (as far as I can tell) // inside the flow mode of the key. We need to either fully render // everything that's in a key in flow mode (which may make for some // long lines), or use the explicit map identifier '?': // // ```yaml // --- // ? // key: // - 1 // - 2 // - 3 // : // - 4 // - 5 // - 6 // ```
YamlLoader::load_from_str(&out_str).unwrap();
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.