From 8197cd693f026f0ef5179b162d39e5dab665f5a3 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 13:15:09 +0530 Subject: [PATCH 1/7] ver --- Cargo.toml | 2 +- examples/basics_casepath.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c36a9a..a012c84 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust-key-paths" -version = "2.9.1" +version = "2.9.2" edition = "2024" authors = ["Codefonsi "] license = "MPL-2.0" diff --git a/examples/basics_casepath.rs b/examples/basics_casepath.rs index 9e15cfc..474d9fb 100644 --- a/examples/basics_casepath.rs +++ b/examples/basics_casepath.rs @@ -8,8 +8,8 @@ use std::sync::Arc; // cargo run --example basics_casepath --features parking_lot #[derive(Debug, Kp)] struct SomeComplexStruct { + id: String, scsf: Option>, - identity: String, scfs2: Arc>, scfs3: Arc>, // scfs4: Arc>, @@ -89,9 +89,8 @@ impl SomeComplexStruct { }; Self { + id: String::from("SomeComplexStruct"), scsf: Some(Box::new(inner.clone())), - identity: String::from("SomeComplexStruct"), - // Arc> scfs2: Arc::new(std::sync::Mutex::new(inner.clone())), scfs3: Arc::new(std::sync::RwLock::new(inner.clone())), From 92dd17e8d829eb4be686e1e30e7d73850f2478d1 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 14:28:55 +0530 Subject: [PATCH 2/7] wip --- examples/rule_eng.rs | 60 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 examples/rule_eng.rs diff --git a/examples/rule_eng.rs b/examples/rule_eng.rs new file mode 100644 index 0000000..daa8677 --- /dev/null +++ b/examples/rule_eng.rs @@ -0,0 +1,60 @@ +use key_paths_derive::Kp; +use rust_key_paths::{AccessorTrait, KpTrait, KpType}; + +struct RuleBuilder<'a, R, V> { + root: Option, + value: Option, + kp: KpType<'a, R, V>, + rules: Vec) -> Option<&'a str>>, + errors: Vec<&'a str> +} + +impl<'a, R, V> RuleBuilder<'a, R, V> { + pub fn new(kp: KpType<'a, R, V>) -> Self { + todo!() + } +} + +pub trait ISOabc123 { + fn a<'a>() -> &'a str; +} + +impl<'a, R, V> RuleBuilder<'a, R, V> { + fn rule(mut self, f: fn(Option<&V>) -> Option<&'a str>) -> Self { + self.rules.push(f); + self + } + + fn apply(&'a self) { + for i in &self.rules { + let x = (i)(self.kp.get_optional(self.root.as_ref())); + } + } +} + + + +fn rule<'a, R, V>(kp: KpType<'a, R, V>) -> RuleBuilder<'a, R, V> { + RuleBuilder::new(kp) +} + + +fn iso123rule<'a>(r:Option<&str>) -> Option<&'a str> { + if r.is_none() && r.unwrap().trim().len() > 0 { + None + } else { + Some("iso123rule vailated") + } +} + +#[derive(Kp)] +struct Test { + a: String +} +fn main() { + let mut builder = RuleBuilder::new(Test::a()); + let rule = builder + .rule(iso123rule) + .rule(iso123rule) + .apply(); +} \ No newline at end of file From ce77d46d276e783a0e1fde52c82afa3b93082bfe Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 14:32:08 +0530 Subject: [PATCH 3/7] wip --- examples/rule_eng.rs | 69 +++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/examples/rule_eng.rs b/examples/rule_eng.rs index daa8677..c89217f 100644 --- a/examples/rule_eng.rs +++ b/examples/rule_eng.rs @@ -1,60 +1,63 @@ use key_paths_derive::Kp; use rust_key_paths::{AccessorTrait, KpTrait, KpType}; -struct RuleBuilder<'a, R, V> { - root: Option, - value: Option, +pub struct RuleBuilder<'a, R, V> { + root: Option, kp: KpType<'a, R, V>, - rules: Vec) -> Option<&'a str>>, - errors: Vec<&'a str> + rules: Vec) -> Option<&'static str>>, } impl<'a, R, V> RuleBuilder<'a, R, V> { pub fn new(kp: KpType<'a, R, V>) -> Self { - todo!() + Self { + root: None, + kp, + rules: vec![], + } } -} -pub trait ISOabc123 { - fn a<'a>() -> &'a str; -} + pub fn with_root(mut self, root: R) -> Self { + self.root = Some(root); + self + } -impl<'a, R, V> RuleBuilder<'a, R, V> { - fn rule(mut self, f: fn(Option<&V>) -> Option<&'a str>) -> Self { + pub fn rule(mut self, f: fn(Option<&V>) -> Option<&'static str>) -> Self { self.rules.push(f); self } - fn apply(&'a self) { - for i in &self.rules { - let x = (i)(self.kp.get_optional(self.root.as_ref())); - } + pub fn apply(&self) -> Vec<&'static str> { + let val = self.kp.get_optional(self.root.as_ref()); + self.rules + .iter() + .filter_map(|f| f(val)) + .collect() } } - - -fn rule<'a, R, V>(kp: KpType<'a, R, V>) -> RuleBuilder<'a, R, V> { - RuleBuilder::new(kp) -} - - -fn iso123rule<'a>(r:Option<&str>) -> Option<&'a str> { - if r.is_none() && r.unwrap().trim().len() > 0 { - None +fn iso123rule(r: Option<&str>) -> Option<&'static str> { + if r.map_or(true, |s| s.trim().is_empty()) { + Some("iso123rule: field is required and must not be blank") } else { - Some("iso123rule vailated") + None } } #[derive(Kp)] struct Test { - a: String + a: String, } + fn main() { - let mut builder = RuleBuilder::new(Test::a()); - let rule = builder - .rule(iso123rule) - .rule(iso123rule) - .apply(); + let t = Test { a: " ".to_string() }; + + let errors = RuleBuilder::new(Test::a()) + .with_root(t) + .rule(iso123rule) + .rule(iso123rule) + .apply(); + + for e in &errors { + println!("{}", e); + } } \ No newline at end of file From 81f4200a64cd67e749a8064624e0aecdc4e68ed4 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 14:36:50 +0530 Subject: [PATCH 4/7] rule engine added --- examples/basics.rs | 14 +++++--------- examples/box_keypath.rs | 8 ++++---- examples/rule_eng.rs | 36 ++++++++++++++++++------------------ src/async_lock.rs | 10 ++++++++-- src/lib.rs | 33 ++++++++++++--------------------- 5 files changed, 47 insertions(+), 54 deletions(-) diff --git a/examples/basics.rs b/examples/basics.rs index 1276088..7e4cc94 100644 --- a/examples/basics.rs +++ b/examples/basics.rs @@ -34,11 +34,11 @@ struct Rectangle { impl Rectangle { // fn kp() -> KpType<'static, Rectangle, String> { // KpType::new( - // |root| { + // |root| { // let x = root.name.borrow(); // let y = &*x as *const String; // Some(unsafe { &*y })} - // ,|root| { + // ,|root| { // let mut x = root.name.borrow_mut(); // let y = &mut *x as *mut String; // Some(unsafe {&mut *y}) @@ -46,14 +46,12 @@ impl Rectangle { // ) // } - // fn kp() -> KpType<'static, Rectangle, std::cell::Ref<'static, String>> { // KpType::new( // |root| { Some(&'static root.name.borrow()) } // ,|_| { None } // ) // } - } // Standalone fn pointers for keypath (reference: lib.rs identity_typed / Kp with fn types) @@ -111,13 +109,11 @@ fn main() { println!("Updated rectangle: {:?}", rect); } - fn that_takes(f: fn(&Rectangle) -> Option<&Size>) -> for<'a> fn(&'a Rectangle) -> String { - |_root| { "working".to_string() } + |_root| "working".to_string() } - -// fn +// fn // impl Fn // Fn, FnMut, FnOnce -// Box \ No newline at end of file +// Box diff --git a/examples/box_keypath.rs b/examples/box_keypath.rs index 94f603b..97cf216 100644 --- a/examples/box_keypath.rs +++ b/examples/box_keypath.rs @@ -81,18 +81,18 @@ fn main() { .then(DarkStruct::dsf()) .get(&instance); assert_eq!(dsf, Some(&"dark_value".to_string())); - + /* Kp - struct 8 genric KpType - typealias 2 genric - KpTrait - to enforce use to use kp - KpTraitType - 2 gen + KpTrait - to enforce use to use kp + KpTraitType - 2 gen Accessor - acccessor fns into a triat - get, get_mut OptionalAccessor - get_optionl, get_mut_optional HofExt - map, filter, flatmap ..... Chain - then CoercionTrait - to_box, to_arc ChainExt - then_async, then_pin_fut, then_sync - */ + */ println!("{:?}", instance); } diff --git a/examples/rule_eng.rs b/examples/rule_eng.rs index c89217f..f84f212 100644 --- a/examples/rule_eng.rs +++ b/examples/rule_eng.rs @@ -2,7 +2,7 @@ use key_paths_derive::Kp; use rust_key_paths::{AccessorTrait, KpTrait, KpType}; pub struct RuleBuilder<'a, R, V> { - root: Option, + root: Option<&'a R>, kp: KpType<'a, R, V>, rules: Vec) -> Option<&'static str>>, } @@ -16,7 +16,7 @@ impl<'a, R, V> RuleBuilder<'a, R, V> { } } - pub fn with_root(mut self, root: R) -> Self { + pub fn with_root(mut self, root: &'a R) -> Self { self.root = Some(root); self } @@ -27,37 +27,37 @@ impl<'a, R, V> RuleBuilder<'a, R, V> { } pub fn apply(&self) -> Vec<&'static str> { - let val = self.kp.get_optional(self.root.as_ref()); - self.rules - .iter() - .filter_map(|f| f(val)) - .collect() + let val = self.kp.get_optional(self.root); + self.rules.iter().filter_map(|f| f(val)).collect() } } -fn iso123rule(r: Option<&str>) -> Option<&'static str> { - if r.map_or(true, |s| s.trim().is_empty()) { - Some("iso123rule: field is required and must not be blank") - } else { - None +mod iso_pain { + pub fn iso123rule(r: Option<&String>) -> Option<&'static str> { + if r.map_or(true, |s| s.trim().is_empty()) { + Some("iso123rule: field is required and must not be blank") + } else { + None + } } } - #[derive(Kp)] struct Test { a: String, } fn main() { - let t = Test { a: " ".to_string() }; + let t = Test { + a: " ".to_string(), + }; let errors = RuleBuilder::new(Test::a()) - .with_root(t) - .rule(iso123rule) - .rule(iso123rule) + .with_root(&t) + .rule(iso_pain::iso123rule) + .rule(iso_pain::iso123rule) .apply(); for e in &errors { println!("{}", e); } -} \ No newline at end of file +} diff --git a/src/async_lock.rs b/src/async_lock.rs index ecc117d..ad4de19 100644 --- a/src/async_lock.rs +++ b/src/async_lock.rs @@ -1866,7 +1866,10 @@ impl<'a, T: 'static + Send + Sync> AsyncLockLike>) -> Option<&'a mut T> { + async fn lock_write( + &self, + lock: &mut std::sync::Arc>, + ) -> Option<&'a mut T> { let mut guard = lock.lock().await; let ptr = &mut *guard as *mut T; unsafe { Some(&mut *ptr) } @@ -1948,7 +1951,10 @@ impl<'a, T: 'static + Send + Sync> AsyncLockLike>) -> Option<&'a mut T> { + async fn lock_write( + &self, + lock: &mut std::sync::Arc>, + ) -> Option<&'a mut T> { // SHALLOW CLONE: Only Arc refcount is incremented let mut guard = lock.write().await; let ptr = &mut *guard as *mut T; diff --git a/src/lib.rs b/src/lib.rs index aa1a8a7..f77ae03 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ // type Getter where Root: std::borrow::Borrow, Value: std::borrow::Borrow = fn(Root) -> Option; // type Setter = fn(&'r mut R) -> Option<&'r mut V>; -use std::sync::{Arc}; +use std::sync::Arc; // Export the lock module pub mod lock; @@ -1226,8 +1226,7 @@ where } } -pub trait AccessorTrait -{ +pub trait AccessorTrait { /// Like [get](Kp::get), but takes an optional root: returns `None` if `root` is `None`, otherwise the result of the getter. fn get_optional(&self, root: Option) -> Option; // { @@ -1252,7 +1251,7 @@ pub trait AccessorTrait #[inline] fn get_mut_or_else(&self, root: MutRoot, f: F) -> MutValue where - F: FnOnce() -> MutValue,; + F: FnOnce() -> MutValue; // { // self.get_mut(root).unwrap_or_else(f) // } @@ -1283,7 +1282,7 @@ where R: 'b, V: 'b, Root: for<'a> From<&'a R>, - MutRoot: for<'a> From<&'a mut R>,; + MutRoot: for<'a> From<&'a mut R>; fn for_box<'a>( &self, @@ -1301,14 +1300,13 @@ where R: 'a, V: 'a, Root: for<'b> From<&'b R>, - MutRoot: for<'b> From<&'b mut R>,; + MutRoot: for<'b> From<&'b mut R>; /// set fn is converting fn pointer to Fn closure fn into_set(self) -> impl Fn(MutRoot) -> Option; /// get fn is converting fn pointer to Fn closure fn into_get(self) -> impl Fn(Root) -> Option; - } pub trait HofTrait: @@ -1757,7 +1755,6 @@ where G: Fn(Root) -> Option, S: Fn(MutRoot) -> Option, { - fn then( self, next: Kp, @@ -1783,15 +1780,14 @@ where move |root: MutRoot| (self.set)(root).and_then(|value| (next.set)(value)), ) } - + fn get(&self, root: Root) -> Option { (self.get)(root) } - + fn get_mut(&self, root: MutRoot) -> Option { (self.set)(root) } - } impl @@ -1805,7 +1801,7 @@ where G: Fn(Root) -> Option, S: Fn(MutRoot) -> Option, { - fn for_arc<'b>( + fn for_arc<'b>( &self, ) -> Kp< std::sync::Arc, @@ -1866,13 +1862,12 @@ where ) } - /// set fn is converting fn pointer to Fn closure #[inline] fn into_set(self) -> impl Fn(MutRoot) -> Option { self.set } - + /// get fn is converting fn pointer to Fn closure #[inline] fn into_get(self) -> impl Fn(Root) -> Option { @@ -1906,15 +1901,13 @@ where { /// Like [get](Kp::get), but takes an optional root: returns `None` if `root` is `None`, otherwise the result of the getter. #[inline] - fn get_optional(&self, root: Option) -> Option - { + fn get_optional(&self, root: Option) -> Option { root.and_then(|r| (self.get)(r)) } /// Like [get_mut](Kp::get_mut), but takes an optional root: returns `None` if `root` is `None`, otherwise the result of the setter. #[inline] - fn get_mut_optional(&self, root: Option) -> Option - { + fn get_mut_optional(&self, root: Option) -> Option { root.and_then(|r| (self.set)(r)) } @@ -1922,7 +1915,7 @@ where #[inline] fn get_or_else(&self, root: Root, f: F) -> Value where - F: FnOnce() -> Value + F: FnOnce() -> Value, { (self.get)(root).unwrap_or_else(f) } @@ -1986,7 +1979,6 @@ where { } - impl Kp where Root: std::borrow::Borrow, @@ -2040,7 +2032,6 @@ where move |root: MutRoot| (self.set)(root).and_then(|value| (next.set)(value)), ) } - } /// Zip two keypaths together to create a tuple /// Works only with KpType (reference-based keypaths) From 0a2ce8f99e7acca12044beb90ae72c0e5ca49844 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 14:59:49 +0530 Subject: [PATCH 5/7] error to enum --- examples/rule_eng.rs | 49 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/examples/rule_eng.rs b/examples/rule_eng.rs index f84f212..bc76e99 100644 --- a/examples/rule_eng.rs +++ b/examples/rule_eng.rs @@ -1,10 +1,20 @@ +use std::borrow::Cow; + use key_paths_derive::Kp; use rust_key_paths::{AccessorTrait, KpTrait, KpType}; +#[derive(Debug)] +pub enum ErrorCode { + ISOError, + Some1Error(Cow<'static, String>), + Some2Error(Cow<'static, String>), + Some3Error(Cow<'static, String>), + Success +} pub struct RuleBuilder<'a, R, V> { root: Option<&'a R>, kp: KpType<'a, R, V>, - rules: Vec) -> Option<&'static str>>, + rules: Vec) -> &'a ErrorCode>, } impl<'a, R, V> RuleBuilder<'a, R, V> { @@ -21,34 +31,57 @@ impl<'a, R, V> RuleBuilder<'a, R, V> { self } - pub fn rule(mut self, f: fn(Option<&V>) -> Option<&'static str>) -> Self { + pub fn rule(mut self, f: fn(Option<&'a V>) -> &'a ErrorCode) -> Self { self.rules.push(f); self } - pub fn apply(&self) -> Vec<&'static str> { + pub fn apply(&self) -> Vec<&'a ErrorCode> { let val = self.kp.get_optional(self.root); - self.rules.iter().filter_map(|f| f(val)).collect() + self.rules.iter().map(|f| f(val)).collect() } } + mod iso_pain { - pub fn iso123rule(r: Option<&String>) -> Option<&'static str> { + // For raw rule — still receives Option<&String> + pub fn iso123rule<'a>(r: Option<&'a String>) -> &'a crate::ErrorCode { if r.map_or(true, |s| s.trim().is_empty()) { - Some("iso123rule: field is required and must not be blank") + &crate::ErrorCode::ISOError + } else { + &crate::ErrorCode::Success + } + } + + // For mandatory/optional — receives &String directly, None already handled + pub fn not_blank<'a>(s: &'a String) -> &'a crate::ErrorCode { + if s.trim().is_empty() { + &crate::ErrorCode::ISOError } else { - None + &crate::ErrorCode::Success + } + } + + pub fn max_len_35<'a>(s: &'a String) -> &'a crate::ErrorCode { + if s.len() > 35 { + &crate::ErrorCode::ISOError + } else { + &crate::ErrorCode::Success } } } + #[derive(Kp)] struct Test { a: String, + b: String, + } fn main() { let t = Test { a: " ".to_string(), + b: "asdf ".to_string(), }; let errors = RuleBuilder::new(Test::a()) @@ -58,6 +91,6 @@ fn main() { .apply(); for e in &errors { - println!("{}", e); + println!("{:?}", e); } } From b488f5e89993b8f0487fa6c92bed3f96df0c28bd Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 16:32:25 +0530 Subject: [PATCH 6/7] par wip --- examples/rule_eng.rs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/examples/rule_eng.rs b/examples/rule_eng.rs index bc76e99..827a5cc 100644 --- a/examples/rule_eng.rs +++ b/examples/rule_eng.rs @@ -6,6 +6,7 @@ use rust_key_paths::{AccessorTrait, KpTrait, KpType}; #[derive(Debug)] pub enum ErrorCode { ISOError, + ISOError2, Some1Error(Cow<'static, String>), Some2Error(Cow<'static, String>), Some3Error(Cow<'static, String>), @@ -56,7 +57,7 @@ mod iso_pain { // For mandatory/optional — receives &String directly, None already handled pub fn not_blank<'a>(s: &'a String) -> &'a crate::ErrorCode { if s.trim().is_empty() { - &crate::ErrorCode::ISOError + &crate::ErrorCode::ISOError2 } else { &crate::ErrorCode::Success } @@ -84,13 +85,30 @@ fn main() { b: "asdf ".to_string(), }; - let errors = RuleBuilder::new(Test::a()) + let rules = [RuleBuilder::new(Test::a()) .with_root(&t) .rule(iso_pain::iso123rule) .rule(iso_pain::iso123rule) - .apply(); + .rule(iso_pain::iso123rule) + .rule(iso_pain::iso123rule), - for e in &errors { - println!("{:?}", e); - } + + RuleBuilder::new(Test::b()) + .with_root(&t) + .rule(iso_pain::iso123rule) + .rule(iso_pain::iso123rule) + .rule(iso_pain::iso123rule) + .rule(iso_pain::iso123rule) + ]; + + + // let errors = rules + // .iter() + // .fold(Vec::new(), |mut acc, v| {acc.append(&mut v.apply()); acc} ); + + let errors: Vec<&ErrorCode> = rules.iter().flat_map(|v| v.apply()).collect(); + + for e in errors { + println!("{:?}", e); + } } From 657c394e56b95f5322389ceeaa0becacba7fd7f2 Mon Sep 17 00:00:00 2001 From: Akash soni <33283321+akashsoni01@users.noreply.github.com> Date: Sat, 21 Mar 2026 16:34:11 +0530 Subject: [PATCH 7/7] rule deleted --- examples/rule_eng.rs | 114 ------------------------------------------- 1 file changed, 114 deletions(-) delete mode 100644 examples/rule_eng.rs diff --git a/examples/rule_eng.rs b/examples/rule_eng.rs deleted file mode 100644 index 827a5cc..0000000 --- a/examples/rule_eng.rs +++ /dev/null @@ -1,114 +0,0 @@ -use std::borrow::Cow; - -use key_paths_derive::Kp; -use rust_key_paths::{AccessorTrait, KpTrait, KpType}; - -#[derive(Debug)] -pub enum ErrorCode { - ISOError, - ISOError2, - Some1Error(Cow<'static, String>), - Some2Error(Cow<'static, String>), - Some3Error(Cow<'static, String>), - Success -} -pub struct RuleBuilder<'a, R, V> { - root: Option<&'a R>, - kp: KpType<'a, R, V>, - rules: Vec) -> &'a ErrorCode>, -} - -impl<'a, R, V> RuleBuilder<'a, R, V> { - pub fn new(kp: KpType<'a, R, V>) -> Self { - Self { - root: None, - kp, - rules: vec![], - } - } - - pub fn with_root(mut self, root: &'a R) -> Self { - self.root = Some(root); - self - } - - pub fn rule(mut self, f: fn(Option<&'a V>) -> &'a ErrorCode) -> Self { - self.rules.push(f); - self - } - - pub fn apply(&self) -> Vec<&'a ErrorCode> { - let val = self.kp.get_optional(self.root); - self.rules.iter().map(|f| f(val)).collect() - } -} - - -mod iso_pain { - // For raw rule — still receives Option<&String> - pub fn iso123rule<'a>(r: Option<&'a String>) -> &'a crate::ErrorCode { - if r.map_or(true, |s| s.trim().is_empty()) { - &crate::ErrorCode::ISOError - } else { - &crate::ErrorCode::Success - } - } - - // For mandatory/optional — receives &String directly, None already handled - pub fn not_blank<'a>(s: &'a String) -> &'a crate::ErrorCode { - if s.trim().is_empty() { - &crate::ErrorCode::ISOError2 - } else { - &crate::ErrorCode::Success - } - } - - pub fn max_len_35<'a>(s: &'a String) -> &'a crate::ErrorCode { - if s.len() > 35 { - &crate::ErrorCode::ISOError - } else { - &crate::ErrorCode::Success - } - } -} - -#[derive(Kp)] -struct Test { - a: String, - b: String, - -} - -fn main() { - let t = Test { - a: " ".to_string(), - b: "asdf ".to_string(), - }; - - let rules = [RuleBuilder::new(Test::a()) - .with_root(&t) - .rule(iso_pain::iso123rule) - .rule(iso_pain::iso123rule) - .rule(iso_pain::iso123rule) - .rule(iso_pain::iso123rule), - - - RuleBuilder::new(Test::b()) - .with_root(&t) - .rule(iso_pain::iso123rule) - .rule(iso_pain::iso123rule) - .rule(iso_pain::iso123rule) - .rule(iso_pain::iso123rule) - ]; - - - // let errors = rules - // .iter() - // .fold(Vec::new(), |mut acc, v| {acc.append(&mut v.apply()); acc} ); - - let errors: Vec<&ErrorCode> = rules.iter().flat_map(|v| v.apply()).collect(); - - for e in errors { - println!("{:?}", e); - } -}