pub struct BuildTool(Name);
Expand description
A build tool name
The same character restrictions as with Name
apply.
Further name restrictions may be enforced on an existing instances using
matches_restriction()
.
§Examples
use std::str::FromStr;
use alpm_types::{BuildTool, Error, Name};
// create BuildTool from &str
assert!(BuildTool::from_str("test-123@.foo_+").is_ok());
assert!(BuildTool::from_str(".test").is_err());
// format as String
assert_eq!("foo", format!("{}", BuildTool::from_str("foo").unwrap()));
// validate that BuildTool follows naming restrictions
let buildtool = BuildTool::from_str("foo").unwrap();
let restrictions = vec![
Name::from_str("foo").unwrap(),
Name::from_str("bar").unwrap(),
];
assert!(buildtool.matches_restriction(&restrictions));
Tuple Fields§
§0: Name
Implementations§
source§impl BuildTool
impl BuildTool
sourcepub fn new_with_restriction(
name: &str,
restrictions: &[Name],
) -> Result<Self, Error>
pub fn new_with_restriction( name: &str, restrictions: &[Name], ) -> Result<Self, Error>
Create a new BuildTool in a Result, which matches one Name in a list of restrictions
§Examples
use alpm_types::{BuildTool, Error, Name};
assert!(
BuildTool::new_with_restriction("foo", &[Name::new("foo".to_string()).unwrap()]).is_ok()
);
assert!(
BuildTool::new_with_restriction("foo", &[Name::new("bar".to_string()).unwrap()]).is_err()
);
sourcepub fn matches_restriction(&self, restrictions: &[Name]) -> bool
pub fn matches_restriction(&self, restrictions: &[Name]) -> bool
Validate that the BuildTool has a name matching one Name in a list of restrictions
Trait Implementations§
source§impl Ord for BuildTool
impl Ord for BuildTool
source§impl PartialOrd for BuildTool
impl PartialOrd for BuildTool
impl Eq for BuildTool
impl StructuralPartialEq for BuildTool
Auto Trait Implementations§
impl Freeze for BuildTool
impl RefUnwindSafe for BuildTool
impl Send for BuildTool
impl Sync for BuildTool
impl Unpin for BuildTool
impl UnwindSafe for BuildTool
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)