pub enum DnfBool {
True,
False,
}Expand description
DNF boolean value.
DNF accepts multiple textual representations for booleans in .repo files:
| Input | Result |
|---|---|
1 | True |
yes | True |
true | True |
on | True |
0 | False |
no | False |
false | False |
off | False |
§Examples
use dnf_repofile::DnfBool;
// Parsing
let enabled = DnfBool::parse("1").unwrap();
assert_eq!(enabled, DnfBool::True);
// Convenience constructors
assert_eq!(DnfBool::yes(), DnfBool::True);
assert_eq!(DnfBool::no(), DnfBool::False);
// Conversion from bool
let d: DnfBool = true.into();
assert_eq!(d, DnfBool::True);
// Conversion to bool
let b: bool = DnfBool::True.into();
assert!(b);
// Display as "1" or "0"
assert_eq!(DnfBool::True.to_string(), "1");
assert_eq!(DnfBool::False.to_string(), "0");Variants§
True
Boolean true (parsed from 1, yes, true, on).
False
Boolean false (parsed from 0, no, false, off).
Implementations§
Source§impl DnfBool
impl DnfBool
Sourcepub fn parse(s: &str) -> Result<Self, ParseBoolError>
pub fn parse(s: &str) -> Result<Self, ParseBoolError>
Parse a DNF boolean string into a DnfBool.
Accepted values (case-insensitive):
"1","yes","true","on"→DnfBool::True"0","no","false","off"→DnfBool::False
§Errors
Returns crate::error::ParseBoolError if the input does not
match any known boolean value.
§Examples
use dnf_repofile::DnfBool;
assert!(DnfBool::parse("1").is_ok());
assert!(DnfBool::parse("yes").is_ok());
assert!(DnfBool::parse("TRUE").is_ok());
assert!(DnfBool::parse("maybe").is_err());Sourcepub fn yes() -> Self
pub fn yes() -> Self
Convenience constructor for DnfBool::True (enabled).
Equivalent to DnfBool::True.
Sourcepub fn no() -> Self
pub fn no() -> Self
Convenience constructor for DnfBool::False (disabled).
Equivalent to DnfBool::False.
Trait Implementations§
impl Copy for DnfBool
impl Eq for DnfBool
impl StructuralPartialEq for DnfBool
Auto Trait Implementations§
impl Freeze for DnfBool
impl RefUnwindSafe for DnfBool
impl Send for DnfBool
impl Sync for DnfBool
impl Unpin for DnfBool
impl UnsafeUnpin for DnfBool
impl UnwindSafe for DnfBool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.