Replace try_set with set_if_ok
This commit is contained in:
parent
874c823dbe
commit
894931a6e7
2 changed files with 11 additions and 10 deletions
|
|
@ -181,13 +181,11 @@ pub struct Regulator {
|
|||
}
|
||||
|
||||
impl Regulator {
|
||||
pub fn try_set(&self, set_pt_spec: String) -> bool {
|
||||
match SpecifiedValue::try_from(set_pt_spec) {
|
||||
Ok(set_pt) => {
|
||||
self.set_point.set(set_pt);
|
||||
true
|
||||
}
|
||||
Err(_) => false
|
||||
/* TO DO */
|
||||
// if it's called for, add a `set` method that takes a bare SpecifiedValue
|
||||
pub fn set_if_ok<E>(&self, set_pt_result: Result<SpecifiedValue, E>) {
|
||||
if let Ok(set_pt) = set_pt_result {
|
||||
self.set_point.set(set_pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue