pub struct Versioned<'buf> { /* private fields */ }Expand description
A json::Element that has been parsed by the either the parse_with_version or parse functions
and has been identified as being a certain Version.
Implementations§
Source§impl<'buf> Versioned<'buf>
impl<'buf> Versioned<'buf>
Sourcepub fn into_element(self) -> Element<'buf>
pub fn into_element(self) -> Element<'buf>
Return the inner json::Element and discard the version info.
Sourcepub fn as_element(&self) -> &Element<'buf>
pub fn as_element(&self) -> &Element<'buf>
Return the inner json::Element and discard the version info.
Examples found in repository?
examples/lint_tariff.rs (line 42)
32fn print_lint_warnings(
33 tariff: &tariff::Versioned<'_>,
34 warnings: &warning::Report<lint::tariff::WarningKind>,
35) {
36 if warnings.is_empty() {
37 return;
38 }
39
40 eprintln!("WARN: {} warnings from the linting", warnings.len());
41
42 for warning::ElementReport { element, warnings } in warnings.iter(tariff.as_element()) {
43 eprintln!(
44 "Warnings reported for `json::Element` at path: `{}`",
45 element.path()
46 );
47
48 for warning in warnings {
49 eprintln!(" * {warning}");
50 }
51
52 eprintln!();
53 }
54}Sourcepub fn as_json_str(&self) -> &'buf str
pub fn as_json_str(&self) -> &'buf str
Return the inner JSON str and discard the version info.
Trait Implementations§
Auto Trait Implementations§
impl<'buf> Freeze for Versioned<'buf>
impl<'buf> RefUnwindSafe for Versioned<'buf>
impl<'buf> !Send for Versioned<'buf>
impl<'buf> !Sync for Versioned<'buf>
impl<'buf> Unpin for Versioned<'buf>
impl<'buf> UnwindSafe for Versioned<'buf>
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