cli for num account index bins (#19085)
This commit is contained in:
committed by
GitHub
parent
3bdadb3930
commit
e91988c977
@ -237,6 +237,22 @@ where
|
||||
is_parsable_generic::<Slot, _>(slot)
|
||||
}
|
||||
|
||||
pub fn is_bin<T>(bins: T) -> Result<(), String>
|
||||
where
|
||||
T: AsRef<str> + Display,
|
||||
{
|
||||
bins.as_ref()
|
||||
.parse::<usize>()
|
||||
.map_err(|e| format!("Unable to parse bins, provided: {}, err: {}", bins, e))
|
||||
.and_then(|v| {
|
||||
if !v.is_power_of_two() {
|
||||
Err(format!("Bins must be a power of 2: {}", v))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn is_port<T>(port: T) -> Result<(), String>
|
||||
where
|
||||
T: AsRef<str> + Display,
|
||||
|
Reference in New Issue
Block a user