diff --git a/egui_node_graph/src/editor_ui.rs b/egui_node_graph/src/editor_ui.rs index f630b2a..56ff218 100644 --- a/egui_node_graph/src/editor_ui.rs +++ b/egui_node_graph/src/editor_ui.rs @@ -473,9 +473,9 @@ where } else { // NOTE: We want to pass the `user_data` to // `value_widget`, but we can't since that would require - // borrowing the graph twice. Here, we take the - // assumption that the value is cheaply replace, and use - // `std::mem::take` to temporarily replace it with a + // borrowing the graph twice. Here, we make the + // assumption that the value is cheaply replaced, and + // use `std::mem::take` to temporarily replace it with a // dummy value. This requires `ValueType` to implement // Default, but results in a totally safe alternative. let mut value = std::mem::take(&mut self.graph[param_id].value); diff --git a/egui_node_graph/src/traits.rs b/egui_node_graph/src/traits.rs index fe7a46c..638b590 100644 --- a/egui_node_graph/src/traits.rs +++ b/egui_node_graph/src/traits.rs @@ -3,6 +3,12 @@ use super::*; /// This trait must be implemented by the `ValueType` generic parameter of the /// [`Graph`]. The trait allows drawing custom inline widgets for the different /// types of the node graph. +/// +/// The [`Default`] trait bound is required to circumvent borrow checker issues +/// using `std::mem::take` Otherwise, it would be impossible to pass the +/// `node_data` parameter during `value_widget`. The default value is never +/// used, so the implementation is not important, but it should be reasonably +/// cheap to construct. pub trait WidgetValueTrait : Default { type Response; type UserState;