cli for num account index bins (#19085)

This commit is contained in:
Jeff Washington (jwash)
2021-08-11 11:45:25 -05:00
committed by GitHub
parent 3bdadb3930
commit e91988c977
8 changed files with 44 additions and 6 deletions

View File

@ -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,