mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 03:36:42 +01:00
This commit is contained in:
parent
ab0dc3fae0
commit
ab1afa219f
2 changed files with 24 additions and 47 deletions
|
|
@ -62,7 +62,7 @@ impl<E: Clone + Ord, C> EventMap<E, C> {
|
|||
/// Create event map from path to text file.
|
||||
pub fn load_from_path <'s> (
|
||||
&'s mut self, path: impl AsRef<Path>
|
||||
) -> Usually<&mut Self> where Self: DslInto<C> + DslInto<E> {
|
||||
) -> Usually<&'s mut Self> where Self: DslInto<C> + DslInto<E> {
|
||||
if exists(path.as_ref())? {
|
||||
let source = read_to_string(&path)?;
|
||||
let path: Arc<PathBuf> = Arc::new(path.as_ref().into());
|
||||
|
|
@ -81,7 +81,7 @@ impl<E: Clone + Ord, C> EventMap<E, C> {
|
|||
/// Load one event binding into the event map.
|
||||
pub fn load_from_source_one <'s> (
|
||||
&'s mut self, dsl: impl Dsl, path: &Option<&Arc<PathBuf>>
|
||||
) -> Usually<&mut Self> where Self: DslInto<C> + DslInto<E> {
|
||||
) -> Usually<&'s mut Self> where Self: DslInto<C> + DslInto<E> {
|
||||
if let Some(exp) = dsl.head()?.exp()?
|
||||
&& let Some(sym) = exp.head()?.sym()?
|
||||
&& let Some(tail) = exp.tail()?
|
||||
|
|
@ -117,10 +117,10 @@ impl<E: Clone + Ord, C> EventMap<E, C> {
|
|||
}
|
||||
impl<C> Binding<C> {
|
||||
pub fn from_dsl (dsl: impl Dsl) -> Usually<Self> {
|
||||
let mut command: Option<C> = None;
|
||||
let mut condition: Option<Condition> = None;
|
||||
let mut description: Option<Arc<str>> = None;
|
||||
let mut source: Option<Arc<PathBuf>> = None;
|
||||
let command: Option<C> = None;
|
||||
let condition: Option<Condition> = None;
|
||||
let description: Option<Arc<str>> = None;
|
||||
let source: Option<Arc<PathBuf>> = None;
|
||||
if let Some(command) = command {
|
||||
Ok(Self { command, condition, description, source })
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue