pub struct Diagnostics { /* private fields */ }
Expand description
Structure to collect compilation diagnostics.
If the project is compiled with the emit
feature, you can make use of
Diagnostics::emit.
§Examples
use rune::{Sources, Diagnostics};
use rune::termcolor::{StandardStream, ColorChoice};
let mut sources = Sources::new();
let mut diagnostics = Diagnostics::new();
// use sources and diagnostics to compile a project.
if !diagnostics.is_empty() {
let mut writer = StandardStream::stderr(ColorChoice::Always);
diagnostics.emit(&mut writer, &sources)?;
}
Implementations§
Source§impl Diagnostics
impl Diagnostics
Source§impl Diagnostics
impl Diagnostics
Sourcepub fn without_warnings() -> Self
pub fn without_warnings() -> Self
Construct a new, empty collection of compilation warnings that is disabled, i.e. any warnings added to it will be ignored.
§Examples
use rune::{Diagnostics, SourceId};
use rune::ast::Span;
let mut diagnostics = Diagnostics::without_warnings();
assert!(diagnostics.is_empty());
// emit warnings
assert!(diagnostics.is_empty());
let warning = diagnostics.into_diagnostics().into_iter().next();
assert!(matches!(warning, None));
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new, empty collection of compilation warnings.
§Examples
use rune::{Diagnostics, SourceId};
use rune::ast::Span;
use rune::diagnostics::Diagnostic;
let mut diagnostics = Diagnostics::new();
assert!(diagnostics.is_empty());
Sourcepub fn has_warning(&self) -> bool
pub fn has_warning(&self) -> bool
Check if diagnostics has any warnings reported.
Sourcepub fn diagnostics(&self) -> &[Diagnostic]
pub fn diagnostics(&self) -> &[Diagnostic]
Access underlying diagnostics.
Sourcepub fn into_diagnostics(self) -> Vec<Diagnostic>
pub fn into_diagnostics(self) -> Vec<Diagnostic>
Convert into underlying diagnostics.
Trait Implementations§
Source§impl Debug for Diagnostics
impl Debug for Diagnostics
Auto Trait Implementations§
impl Freeze for Diagnostics
impl !RefUnwindSafe for Diagnostics
impl Send for Diagnostics
impl Sync for Diagnostics
impl Unpin for Diagnostics
impl !UnwindSafe for Diagnostics
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