mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
proc: auto implement Context on command target
Context and TryFromDsl overlap
This commit is contained in:
parent
3bb38f2d27
commit
20ccff13de
5 changed files with 17 additions and 13 deletions
|
|
@ -18,24 +18,20 @@ pub type ParseResult<T> = Result<T, ParseError>;
|
|||
|
||||
pub trait TryFromDsl<'state, T>: Sized {
|
||||
fn try_from_expr <'source: 'state> (
|
||||
_state: &'state T, _iter: TokenIter<'source>
|
||||
_state: &'state T, _iter: &mut TokenIter<'source>
|
||||
) -> Option<Self> {
|
||||
None
|
||||
}
|
||||
fn try_from_atom <'source: 'state> (
|
||||
state: &'state T, value: Value<'source>
|
||||
) -> Option<Self> {
|
||||
if let Exp(0, iter) = value {
|
||||
return Self::try_from_expr(state, iter.clone())
|
||||
if let Exp(0, mut iter) = value {
|
||||
return Self::try_from_expr(state, &mut iter)
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TryIntoDsl<T>: Sized {
|
||||
fn try_into_atom (&self) -> Option<Value>;
|
||||
}
|
||||
|
||||
/// Map EDN tokens to parameters of a given type for a given context
|
||||
pub trait Context<'state, U>: Sized {
|
||||
fn get <'source> (&'state self, _iter: &mut TokenIter<'source>) -> Option<U> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue