diff options
| author | Mike Buland <mike@xagasoft.com> | 2026-07-07 15:10:21 -0700 |
|---|---|---|
| committer | Mike Buland <mike@xagasoft.com> | 2026-07-07 15:10:21 -0700 |
| commit | e1a688efb16f96a6dca3678c67ff38b7cabfa8c6 (patch) | |
| tree | 374fef101bd0bc9cd7623ae1167d784bf832c64c | |
| parent | 1553b785cbc75bfc47066096b81d0066017a91ad (diff) | |
| download | crimtag-main.tar.gz crimtag-main.tar.bz2 crimtag-main.tar.xz crimtag-main.zip | |
| -rw-r--r-- | crimtag/Cargo.toml | 1 | ||||
| -rw-r--r-- | crimtag/src/context.rs | 6 | ||||
| -rw-r--r-- | crimtag/src/lib.rs | 2 | ||||
| -rw-r--r-- | derive/src/lib.rs | 4 |
4 files changed, 11 insertions, 2 deletions
diff --git a/crimtag/Cargo.toml b/crimtag/Cargo.toml index ee022ca..e48d065 100644 --- a/crimtag/Cargo.toml +++ b/crimtag/Cargo.toml | |||
| @@ -4,3 +4,4 @@ version = "0.1.0" | |||
| 4 | edition = "2024" | 4 | edition = "2024" |
| 5 | 5 | ||
| 6 | [dependencies] | 6 | [dependencies] |
| 7 | derive = {path="../derive"} | ||
diff --git a/crimtag/src/context.rs b/crimtag/src/context.rs index 15448ee..a922fd8 100644 --- a/crimtag/src/context.rs +++ b/crimtag/src/context.rs | |||
| @@ -148,6 +148,12 @@ basic_mapped_value_from!(f32, Float32); | |||
| 148 | basic_mapped_value_from!(f64, Float64); | 148 | basic_mapped_value_from!(f64, Float64); |
| 149 | basic_mapped_value_from!(bool, Bool); | 149 | basic_mapped_value_from!(bool, Bool); |
| 150 | 150 | ||
| 151 | impl<'a> MappedStructure<'a> for HashMap<String,String> { | ||
| 152 | fn get_value(&'a self, id: &str) -> Option<MappedValue<'a>> { | ||
| 153 | self.get(id).map(|x|MappedValue::String(x)) | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 151 | impl<'a> From<&'a String> for MappedValue<'a> { | 157 | impl<'a> From<&'a String> for MappedValue<'a> { |
| 152 | fn from(val: &'a String ) -> MappedValue<'a> { | 158 | fn from(val: &'a String ) -> MappedValue<'a> { |
| 153 | MappedValue::String(val) | 159 | MappedValue::String(val) |
diff --git a/crimtag/src/lib.rs b/crimtag/src/lib.rs index e8f9e9f..0fe0e4e 100644 --- a/crimtag/src/lib.rs +++ b/crimtag/src/lib.rs | |||
| @@ -9,6 +9,8 @@ mod position; | |||
| 9 | mod error; | 9 | mod error; |
| 10 | pub mod context; | 10 | pub mod context; |
| 11 | 11 | ||
| 12 | pub use derive::CrimtagMappable; | ||
| 13 | |||
| 12 | pub use error::{CrimError,CrimResult}; | 14 | pub use error::{CrimError,CrimResult}; |
| 13 | pub use position::*; | 15 | pub use position::*; |
| 14 | pub use context::{Context,Value,MappedStructure,StatefulContext,MappedValue,MappedList,MappedHash}; | 16 | pub use context::{Context,Value,MappedStructure,StatefulContext,MappedValue,MappedList,MappedHash}; |
diff --git a/derive/src/lib.rs b/derive/src/lib.rs index bb299d0..379ebe7 100644 --- a/derive/src/lib.rs +++ b/derive/src/lib.rs | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | extern crate proc_macro; | 1 | extern crate proc_macro; |
| 2 | use proc_macro::{TokenStream,TokenTree,Ident,Delimiter}; | 2 | use proc_macro::{TokenStream,TokenTree,/*Ident,*/Delimiter}; |
| 3 | 3 | ||
| 4 | use lookahead::LookAhead; | 4 | use lookahead::LookAhead; |
| 5 | 5 | ||
| @@ -24,7 +24,7 @@ pub fn derive_crimtag_mappable(s: TokenStream) -> TokenStream { | |||
| 24 | 24 | ||
| 25 | let mut newfunc = format!( | 25 | let mut newfunc = format!( |
| 26 | r#"impl<'a> crimtag::MappedStructure<'a> for {} {{ | 26 | r#"impl<'a> crimtag::MappedStructure<'a> for {} {{ |
| 27 | fn get_value(&'a self, id: &str) -> Option<MappedValue<'a>> {{ | 27 | fn get_value(&'a self, id: &str) -> Option<crimtag::MappedValue<'a>> {{ |
| 28 | match id {{ | 28 | match id {{ |
| 29 | "#, name); | 29 | "#, name); |
| 30 | 30 | ||
