Skip to content

Commit

Permalink
try refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
biabbas committed Oct 22, 2024
1 parent 8861edd commit d7a7769
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,17 +256,17 @@ impl ThreadPriorityValue {
}

impl std::convert::TryFrom<u8> for ThreadPriorityValue {
type Error = &'static str;
type Error = String;

fn try_from(value: u8) -> Result<Self, Self::Error> {
if (Self::MIN..=Self::MAX).contains(&value) {
Ok(Self(value))
} else {
if cfg!(target_os = "vxworks") {
Err("The value is not in the range of [0;255]")
} else {
Err("The value is not in the range of [0;99]")
}
Err(format!(
"The value is not in the range of [{}; {}]",
Self::MIN,
Self::MAX
))
}
}
}
Expand Down

0 comments on commit d7a7769

Please sign in to comment.