Add expect_none method function to AttrValue

This method function will return a error if the option not a flag option
This commit is contained in:
TheAwiteb 2023-09-07 08:02:17 +03:00
parent 7881a1cb78
commit 547f5889d2
No known key found for this signature in database
GPG key ID: ABF818BD15DC2D34

View file

@ -87,6 +87,17 @@ impl AttrValue {
})
}
/// Unwraps this value if it's a nothing.
pub fn expect_none(self, option_name: &str) -> Result<()> {
match self {
AttrValue::None(_) => Ok(()),
_ => Err(compile_error_at(
&format!("The {option_name} option should not have a value, remove it"),
self.span(),
)),
}
}
// /// Unwraps this value if it's a path.
// pub fn expect_path(self) -> Result<Path> {
// self.expect("a path", |this| match this {