pub struct LowerResult {
pub document: Document,
pub diagnostics: Vec<Diagnostic>,
pub metadata: DocumentMetadata,
pub reads_external_resources: bool,
}Expand description
Result of lowering a [SyntaxTree] into a [Document].
§Examples
use std::path::Path;
use mos_core::CollectingSink;
use mos_eval::{Evaluator, LowerResult};
let mut sink = CollectingSink::new();
let parse_result = mos_parse::parse("= Hello\n", Path::new("main.mos"), &mut sink);
assert!(
parse_result.is_ok(),
"parse structurally aborted: {parse_result:?}"
);
if let Ok(tree) = parse_result {
let result: LowerResult = Evaluator::new().evaluate(&tree);
assert!(!result.has_errors());
}Fields§
§document: Document§diagnostics: Vec<Diagnostic>§metadata: DocumentMetadata§reads_external_resources: boolWhether lowering this document read external files: #image /
#figure image loads and #bibliography source reads. Such a
lowering is not a pure function of the source text: the same
(src, file) can lower differently as referenced files appear,
change, or fail to load. Callers that cache a LowerResult across
time (e.g. the language server’s per-document memo) must not reuse
one with this set, since an external change would make it stale
without any source edit to invalidate it.
Implementations§
Source§impl LowerResult
impl LowerResult
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Return whether any lowering diagnostic is an error.
§Examples
use std::path::Path;
let result = mos_eval::lower("= Hello\n", Path::new("main.mos"));
assert!(!result.has_errors());Trait Implementations§
Auto Trait Implementations§
impl Freeze for LowerResult
impl RefUnwindSafe for LowerResult
impl Send for LowerResult
impl Sync for LowerResult
impl Unpin for LowerResult
impl UnsafeUnpin for LowerResult
impl UnwindSafe for LowerResult
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