pub struct SetWriter<'caller, 'buf, K: Kind> { /* private fields */ }Expand description
A Display object for writing a set of warnings.
The warnings set is formatted as a tree with element paths on the first level and a list of warning ids on the second.
$path.to.json.[0].field:
- list_of_warning_ids
- next_warning_id
$next.path.to.[1].json.field
- list_of_warning_idsImplementations§
Source§impl<'caller, 'buf, K: Kind> SetWriter<'caller, 'buf, K>
impl<'caller, 'buf, K: Kind> SetWriter<'caller, 'buf, K>
Sourcepub fn new(root_elem: &'caller Element<'buf>, warnings: &'caller Set<K>) -> Self
pub fn new(root_elem: &'caller Element<'buf>, warnings: &'caller Set<K>) -> Self
Create a new SetWriter with a default warning id indent of " - ".
Examples found in repository?
examples/lint_tariff.rs (line 43)
32fn print_lint_warnings(
33 tariff: &tariff::Versioned<'_>,
34 warnings: &warning::Set<lint::tariff::WarningKind>,
35) {
36 if warnings.is_empty() {
37 return;
38 }
39
40 eprintln!(
41 "WARN: {} warnings from the linting:\n {}",
42 warnings.len(),
43 warning::SetWriter::new(tariff.as_element(), warnings)
44 );
45}More examples
examples/price_cdr_with_unknown_version.rs (line 88)
75fn print_timezone_warnings(
76 cdr: &cdr::Versioned<'_>,
77 warnings: &warning::Set<timezone::WarningKind>,
78) {
79 if warnings.is_empty() {
80 return;
81 }
82
83 eprintln!("WARN: {} warnings from the timezone search", warnings.len());
84
85 eprintln!(
86 "WARN: {} warnings from the timezone search:\n {}",
87 warnings.len(),
88 warning::SetWriter::new(cdr.as_element(), warnings)
89 );
90}Sourcepub fn with_indent(
root_elem: &'caller Element<'buf>,
warnings: &'caller Set<K>,
indent: &'caller str,
) -> Self
pub fn with_indent( root_elem: &'caller Element<'buf>, warnings: &'caller Set<K>, indent: &'caller str, ) -> Self
Create a new SetWriter with a custom warning id indent.
Trait Implementations§
Auto Trait Implementations§
impl<'caller, 'buf, K> Freeze for SetWriter<'caller, 'buf, K>
impl<'caller, 'buf, K> RefUnwindSafe for SetWriter<'caller, 'buf, K>where
K: RefUnwindSafe,
impl<'caller, 'buf, K> !Send for SetWriter<'caller, 'buf, K>
impl<'caller, 'buf, K> !Sync for SetWriter<'caller, 'buf, K>
impl<'caller, 'buf, K> Unpin for SetWriter<'caller, 'buf, K>
impl<'caller, 'buf, K> UnwindSafe for SetWriter<'caller, 'buf, K>where
K: RefUnwindSafe,
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