sorry about monster commit

This commit is contained in:
galister
2025-09-20 15:28:23 +09:00
parent c6a32f4109
commit cfb733de09
32 changed files with 1208 additions and 289 deletions

View File

@@ -766,6 +766,45 @@ impl CustomAttribsInfo<'_> {
None
}
pub fn to_owned(&self) -> CustomAttribsInfoOwned {
CustomAttribsInfoOwned {
parent_id: self.parent_id,
widget_id: self.widget_id,
pairs: self
.pairs
.iter()
.map(|p| CustomAttribPairOwned {
attrib: p.attrib.to_string(),
value: p.value.to_string(),
})
.collect(),
}
}
}
pub struct CustomAttribPairOwned {
pub attrib: String, // without _ at the beginning
pub value: String,
}
pub struct CustomAttribsInfoOwned {
pub parent_id: WidgetID,
pub widget_id: WidgetID,
pub pairs: Vec<CustomAttribPairOwned>,
}
impl CustomAttribsInfoOwned {
pub fn get_value(&self, attrib_name: &str) -> Option<&str> {
// O(n) search, these pairs won't be problematically big anyways
for pair in self.pairs.iter() {
if pair.attrib == attrib_name {
return Some(pair.value.as_str());
}
}
None
}
}
pub type OnCustomAttribsFunc = Box<dyn Fn(CustomAttribsInfo)>;