Use Option as resource fields, remove the update switch: update_values

Use idiomatic Option::None to represent optional fields.
This enables updates where not all fields need to be specified.

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang
2020-11-05 11:18:39 +08:00
parent 0c18b0855e
commit 567cdb43b3
11 changed files with 99 additions and 143 deletions
+2 -4
View File
@@ -48,10 +48,8 @@ impl ControllerInternal for NetPrioController {
// get the resources that apply to this controller
let res: &NetworkResources = &res.network;
if res.update_values {
for i in &res.priorities {
let _ = self.set_if_prio(&i.name, i.priority);
}
for i in &res.priorities {
let _ = self.set_if_prio(&i.name, i.priority);
}
Ok(())