From b32d864f0bc2d812ab16dd587c2c89ae9f3db2dd Mon Sep 17 00:00:00 2001 From: KOKI Date: Fri, 16 Sep 2022 21:20:34 +0900 Subject: [PATCH] Simplify NodeGraphExample::new() --- egui_node_graph_example/src/app.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/egui_node_graph_example/src/app.rs b/egui_node_graph_example/src/app.rs index ee0f0bc..7a04a80 100644 --- a/egui_node_graph_example/src/app.rs +++ b/egui_node_graph_example/src/app.rs @@ -365,12 +365,10 @@ impl NodeGraphExample { /// If the persistence feature is enabled, Called once before the first frame. /// Load previous app state (if any). pub fn new(cc: &eframe::CreationContext<'_>) -> Self { - let state = if let Some(storage) = cc.storage { - eframe::get_value(storage, PERSISTENCE_KEY) - .unwrap_or_else(|| GraphEditorState::new(0.0)) - } else { - GraphEditorState::new(0.0) - }; + let state = cc + .storage + .and_then(|storage| eframe::get_value(storage, PERSISTENCE_KEY)) + .unwrap_or_else(|| GraphEditorState::new(0.0)); Self { state, user_state: MyGraphState::default(),