remove .to_owned() calls on &str in exceptions

This commit is contained in:
Vukašin Stepanović
2023-02-15 11:03:27 +00:00
parent 722ce78fd0
commit 528ddea41c
47 changed files with 107 additions and 167 deletions

View File

@@ -101,16 +101,14 @@ impl Version {
dimension: u32,
) -> Result<&'static Version, Exceptions> {
if dimension % 4 != 1 {
return Err(Exceptions::format("dimension incorrect".to_owned()));
return Err(Exceptions::format("dimension incorrect"));
}
Self::getVersionForNumber((dimension - 17) / 4)
}
pub fn getVersionForNumber(versionNumber: u32) -> Result<&'static Version, Exceptions> {
if !(1..=40).contains(&versionNumber) {
return Err(Exceptions::illegalArgument(
"version out of spec".to_owned(),
));
return Err(Exceptions::illegalArgument("version out of spec"));
}
Ok(&VERSIONS[versionNumber as usize - 1])
}