Skip to content

Commit 033a131

Browse files
authored
Merge pull request #1103 from TitanNano/jovan/base_mut_docs
Describe semantics of base_mut() in docs
2 parents 1dac7f3 + 5886fb4 commit 033a131

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

godot-core/src/obj/script.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,9 @@ impl<'a, T: ScriptInstance> SiMut<'a, T> {
457457
/// Returns a mutable reference suitable for calling engine methods on this object.
458458
///
459459
/// This method will allow you to call back into the same object from Godot (re-entrancy).
460+
/// You have to keep the `ScriptBaseRef` guard bound for the entire duration the engine might re-enter a function of your
461+
/// `ScriptInstance`. The guard temporarily absorbs the `&mut self` reference, which allows for an additional mutable reference to be
462+
/// acquired.
460463
///
461464
/// Holding a mutable guard prevents other code paths from obtaining _any_ reference to `self`, as such it is recommended to drop the
462465
/// guard as soon as you no longer need it.

godot-core/src/obj/traits.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,9 @@ pub trait WithBaseField: GodotClass + Bounds<Declarer = bounds::DeclUser> {
342342
/// Returns a mutable reference suitable for calling engine methods on this object.
343343
///
344344
/// This method will allow you to call back into the same object from Godot, unlike what would happen
345-
/// if you used [`to_gd()`](WithBaseField::to_gd).
345+
/// if you used [`to_gd()`](WithBaseField::to_gd). You have to keep the `BaseRef` guard bound for the entire duration the engine might
346+
/// re-enter a function of your class. The guard temporarily absorbs the `&mut self` reference, which allows for an additional mutable
347+
/// reference to be acquired.
346348
///
347349
/// Holding a mutable guard prevents other code paths from obtaining _any_ reference to `self`, as such it is recommended to drop the
348350
/// guard as soon as you no longer need it.

0 commit comments

Comments
 (0)