forked from extern/nushell
nu-cmd-lang
cleanup (#12609)
# Description This PR does miscellaneous cleanup in some of the commands from `nu-cmd-lang`. # User-Facing Changes None. # After Submitting Cleanup the other commands in `nu-cmd-lang`.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
ast::{Argument, Block, Expr, ExternalArgument, ImportPattern, RecordItem},
|
||||
ast::{Argument, Block, Expr, ExternalArgument, ImportPattern, MatchPattern, RecordItem},
|
||||
engine::StateWorkingSet,
|
||||
BlockId, DeclId, Signature, Span, Type, VarId, IN_VARIABLE_ID,
|
||||
};
|
||||
@ -79,6 +79,13 @@ impl Expression {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_match_block(&self) -> Option<&[(MatchPattern, Expression)]> {
|
||||
match &self.expr {
|
||||
Expr::MatchBlock(matches) => Some(matches),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_signature(&self) -> Option<Box<Signature>> {
|
||||
match &self.expr {
|
||||
Expr::Signature(sig) => Some(sig.clone()),
|
||||
|
Reference in New Issue
Block a user