From 6fa6c1c2c7ad8b2a58fad3a7054ba6fb1e34d88a Mon Sep 17 00:00:00 2001 From: leudz Date: Wed, 15 Jan 2025 16:06:46 +0100 Subject: [PATCH] Improve ViewMut::as_view doc --- src/views/view_mut.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/views/view_mut.rs b/src/views/view_mut.rs index d06fbd47..67642ea7 100644 --- a/src/views/view_mut.rs +++ b/src/views/view_mut.rs @@ -34,6 +34,22 @@ where Track: Tracking, { /// Returns a `View` reborrowing from `ViewMut`. + /// + /// There are often alternatives to calling this method, like reborrow.\ + /// One case where this method shines is for calling a system in another system.\ + /// `sys_b` cannot use a reference or it wouldn't work as a system anymore. + /// ```rust + /// fn sys_a(vm_compA: ViewMut) { + /// // -- SNIP -- + /// + /// sys_b(vm_compA.as_view()); + /// } + /// + /// fn sys_b(v_compA: View) {} + /// + /// world.run(sys_a); + /// world.run(sys_b); + /// ``` pub fn as_view(&self) -> View<'_, T, Track> { View { sparse_set: self.sparse_set,