pub struct Element { /* private fields */ }Expand description
A representation of a JSON element that satisfies the needs of most consumers of a Warning.
This representation avoids the complexity of needing to provide a 'buf lifetime to the json::Element.
This would complicate all warnings types with that lifetime.
A consumer of warnings wants to group them by [json::ElemId] using Warning::group_by_elem and then
display or report the warnings by path.
The linter report also wants to highlight the source JSON that a warning refers too.
Implementations§
Source§impl Element
impl Element
pub fn span(&self) -> Span
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Examples found in repository?
More examples
examples/price_cdr_with_unknown_version.rs (line 91)
88fn print_timezone_error(error: &warning::Error<timezone::Warning>) {
89 eprintln!(
90 "ERR: Unable to find timezone due to error at path `{}`: {}",
91 error.element().path(),
92 error.warning()
93 );
94}
95
96fn print_timezone_warnings(warnings: &warning::Set<timezone::Warning>) {
97 if warnings.is_empty() {
98 return;
99 }
100
101 eprintln!(
102 "WARN: {} warnings from the timezone search",
103 warnings.len_warnings()
104 );
105
106 eprintln!(
107 "WARN: {} warnings from the timezone search:\n {}",
108 warnings.len_warnings(),
109 warning::SetWriter::new(warnings)
110 );
111}
112
113fn print_pricing_error(error: &warning::Error<price::Warning>) {
114 eprintln!(
115 "ERR: Unable to price CDR due to error at path `{}`: {}",
116 error.element().path(),
117 error.warning()
118 );
119}pub fn into_parts(self) -> (Span, Path)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl UnwindSafe for Element
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