mirror of
https://github.com/danbulant/nushell
synced 2026-05-19 20:38:40 +00:00
* Move lite_parse tests into a submodule * Have lite_parse return partial parses when error encountered. Although a parse fails, we can generally still return what was successfully parsed. This is useful, for example, when figuring out completions at some cursor position, because we can map the cursor to something more structured (e.g., cursor is at a flag name).
19 lines
543 B
Rust
19 lines
543 B
Rust
use std::fmt::Debug;
|
|
|
|
/// A combination of an informative parse error, and what has been successfully parsed so far
|
|
#[derive(Debug)]
|
|
pub struct ParseError<T: Debug> {
|
|
/// An informative cause for this parse error
|
|
pub(crate) cause: nu_errors::ParseError,
|
|
|
|
/// What has been successfully parsed, if anything
|
|
pub(crate) partial: Option<T>,
|
|
}
|
|
|
|
pub type ParseResult<T> = Result<T, ParseError<T>>;
|
|
|
|
impl<T: Debug> From<ParseError<T>> for nu_errors::ShellError {
|
|
fn from(e: ParseError<T>) -> Self {
|
|
e.cause.into()
|
|
}
|
|
}
|