Skip to content

Commit 66ca72e

Browse files
committed
Minor docs (update WithBaseField, hide UserClass)
1 parent 786f5dc commit 66ca72e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

godot-core/src/obj/bounds.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,16 @@ pub(super) mod private {
6464
///
6565
/// See [`bounds`](crate::obj::bounds) module for how to use this for bounds checking.
6666
///
67+
/// # No manual `impl`
68+
///
6769
/// <div class="warning">
6870
/// <strong>Never</strong> implement this trait manually.
6971
/// </div>
7072
///
7173
/// Most of the time, this trait is covered by [`#[derive(GodotClass)]`](../register/derive.GodotClass.html).
7274
/// If you implement `GodotClass` manually, use the [`implement_godot_bounds!`][crate::implement_godot_bounds] macro.
7375
///
74-
/// There are two reasons to avoid a hand-written `impl Bounds`:
76+
/// There are two reasons to avoid a handwritten `impl Bounds`:
7577
/// - The trait is `unsafe` and it is very easy to get internal bounds wrong. This will lead to immediate UB.
7678
/// - Apart from the documented members, the trait may have undocumented items that may be broken at any time and stand under no SemVer
7779
/// guarantees.

godot-core/src/obj/traits.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ pub unsafe trait Inherits<Base: GodotClass>: GodotClass {}
137137
unsafe impl<T: GodotClass> Inherits<T> for T {}
138138

139139
/// Implemented for all user-defined classes, providing extensions on the raw object to interact with `Gd`.
140+
#[doc(hidden)]
140141
pub trait UserClass: Bounds<Declarer = bounds::DeclUser> {
141142
#[doc(hidden)]
142143
fn __config() -> crate::private::ClassConfig;
@@ -207,15 +208,14 @@ pub trait IndexEnum: EngineEnum {
207208
}
208209
}
209210

210-
/// Trait that's implemented for user-defined classes that provide a `Base<T>` field.
211+
/// Trait that is automatically implemented for user classes containing a `Base<T>` field.
211212
///
212-
/// Gives direct access to the containing `Gd<Self>` from `Self`.
213+
/// Gives direct access to the containing `Gd<Self>` from `self`.
213214
///
214-
/// # Using WithBaseField as a bound
215+
/// # Usage as a bound
215216
///
216-
/// In order to call `self.base()` or `self.base_mut()` within a trait or on a type you define, the type of `Self::Base` must be specified via `WithBaseField<Base = T>`
217-
///
218-
/// E.g.
217+
/// In order to call `base()` or `base_mut()` within a function or on a type you define, you need a `WithBaseField<Base = T>` bound,
218+
/// where `T` is the base class of your type.
219219
///
220220
/// ```no_run
221221
/// # use godot::prelude::*;
@@ -225,6 +225,7 @@ pub trait IndexEnum: EngineEnum {
225225
/// T: WithBaseField<Base = Node3D>,
226226
/// {
227227
/// let base = value.base();
228+
/// let pos = base.get_position();
228229
/// }
229230
/// ```
230231
///

0 commit comments

Comments
 (0)