mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
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:
parent
7881a1cb78
commit
547f5889d2
1 changed files with 11 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue