Fix issues in current nightly by removing try_match
This commit is contained in:
parent
d05d45e7ab
commit
4e69eb6390
2 changed files with 26 additions and 21 deletions
|
@ -1,5 +1,4 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
use crate::value::AttrValue;
|
use crate::value::AttrValue;
|
||||||
use crate::with_text_pos_context;
|
use crate::with_text_pos_context;
|
||||||
|
@ -85,16 +84,16 @@ impl WidgetUse {
|
||||||
//)
|
//)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//pub fn text_with_var_refs(elements: Vec<AttrValue>) -> Self {
|
pub fn text_with_var_refs(elements: Vec<AttrValue>) -> Self {
|
||||||
//dbg!(WidgetUse {
|
dbg!(WidgetUse {
|
||||||
//name: "layout".to_owned(),
|
name: "layout".to_owned(),
|
||||||
//attrs: hashmap! {
|
attrs: hashmap! {
|
||||||
//"halign".to_owned() => AttrValue::Concrete(PrimitiveValue::String("center".to_owned())),
|
"halign".to_owned() => AttrValue::Concrete(PrimitiveValue::String("center".to_owned())),
|
||||||
//"space-evenly".to_owned() => AttrValue::Concrete(PrimitiveValue::String("false".to_owned())),
|
"space-evenly".to_owned() => AttrValue::Concrete(PrimitiveValue::String("false".to_owned())),
|
||||||
//},
|
},
|
||||||
//children: elements.into_iter().map(WidgetUse::simple_text).collect(),
|
children: elements.into_iter().map(WidgetUse::simple_text).collect(),
|
||||||
//})
|
})
|
||||||
//}
|
}
|
||||||
|
|
||||||
pub fn get_attr(&self, key: &str) -> Result<&AttrValue> {
|
pub fn get_attr(&self, key: &str) -> Result<&AttrValue> {
|
||||||
self.attrs
|
self.attrs
|
||||||
|
|
26
src/value.rs
26
src/value.rs
|
@ -110,22 +110,28 @@ pub enum AttrValue {
|
||||||
|
|
||||||
impl AttrValue {
|
impl AttrValue {
|
||||||
pub fn as_string(&self) -> Result<String> {
|
pub fn as_string(&self) -> Result<String> {
|
||||||
try_match!(AttrValue::Concrete(x) = self)
|
match self {
|
||||||
.map_err(|e| anyhow!("{:?} is not a string", e))?
|
AttrValue::Concrete(x) => Ok(x.as_string()?),
|
||||||
.as_string()
|
_ => Err(anyhow!("{:?} is not a string", self)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn as_f64(&self) -> Result<f64> {
|
pub fn as_f64(&self) -> Result<f64> {
|
||||||
try_match!(AttrValue::Concrete(x) = self)
|
match self {
|
||||||
.map_err(|e| anyhow!("{:?} is not an f64", e))?
|
AttrValue::Concrete(x) => Ok(x.as_f64()?),
|
||||||
.as_f64()
|
_ => Err(anyhow!("{:?} is not an f64", self)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn as_bool(&self) -> Result<bool> {
|
pub fn as_bool(&self) -> Result<bool> {
|
||||||
try_match!(AttrValue::Concrete(x) = self)
|
match self {
|
||||||
.map_err(|e| anyhow!("{:?} is not a bool", e))?
|
AttrValue::Concrete(x) => Ok(x.as_bool()?),
|
||||||
.as_bool()
|
_ => Err(anyhow!("{:?} is not a bool", self)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn as_var_ref(&self) -> Result<&String> {
|
pub fn as_var_ref(&self) -> Result<&String> {
|
||||||
try_match!(AttrValue::VarRef(x) = self).map_err(|e| anyhow!("{:?} is not a VarRef", e))
|
match self {
|
||||||
|
AttrValue::VarRef(x) => Ok(x),
|
||||||
|
_ => Err(anyhow!("{:?} is not a VarRef", self)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// parses the value, trying to turn it into VarRef,
|
/// parses the value, trying to turn it into VarRef,
|
||||||
|
|
Loading…
Add table
Reference in a new issue