Skip to content

Commit

Permalink
Improve ViewMut::as_view doc
Browse files Browse the repository at this point in the history
  • Loading branch information
leudz committed Jan 15, 2025
1 parent 8a9dd9c commit 6fa6c1c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/views/view_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<A>) {
/// // -- SNIP --
///
/// sys_b(vm_compA.as_view());
/// }
///
/// fn sys_b(v_compA: View<A>) {}
///
/// world.run(sys_a);
/// world.run(sys_b);
/// ```
pub fn as_view(&self) -> View<'_, T, Track> {
View {
sparse_set: self.sparse_set,
Expand Down

0 comments on commit 6fa6c1c

Please sign in to comment.