Skip to content

Commit 5ea5447

Browse files
committed
Smaller fixes for clippy and doctest
1 parent bcad368 commit 5ea5447

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

godot-core/src/builtin/dictionary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,15 +328,15 @@ impl Share for Dictionary {
328328
///
329329
/// Example
330330
/// ```no_run
331-
/// use godot::builtin::dict;
331+
/// use godot::builtin::{dict, Variant};
332332
///
333333
/// let key = "my_key";
334334
/// let d = dict! {
335335
/// "key1": 10,
336336
/// "another": Variant::nil(),
337337
/// key: true,
338338
/// (1 + 2): "final",
339-
/// }
339+
/// };
340340
/// ```
341341
#[macro_export]
342342
macro_rules! dict {

godot-ffi/src/godot_ffi.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ use crate as sys;
88
use std::fmt::Debug;
99

1010
/// Adds methods to convert from and to Godot FFI pointers.
11-
#[doc(hidden)]
11+
/// See [crate::ffi_methods] for ergonomic implementation.
1212
pub trait GodotFfi {
1313
/// Construct from Godot opaque pointer.
14+
///
15+
/// # Safety
16+
/// `ptr` must be a valid _type ptr_: it must follow Godot's convention to encode `Self`,
17+
/// which is different depending on the type.
1418
unsafe fn from_sys(ptr: sys::GDExtensionTypePtr) -> Self;
1519

16-
/// Construct uninitialized opaque data, then initialize it with `init` function.
20+
/// Construct uninitialized opaque data, then initialize it with `init_fn` function.
21+
///
22+
/// # Safety
23+
/// `init_fn` must be a function that correctly handles a (possibly-uninitialized) _type ptr_.
1724
unsafe fn from_sys_init(init_fn: impl FnOnce(sys::GDExtensionTypePtr)) -> Self;
1825

1926
/// Return Godot opaque pointer, for an immutable operation.
@@ -38,6 +45,11 @@ pub trait GodotFfi {
3845
self.sys()
3946
}
4047

48+
/// Write the contents of `self` into the pointer `dst`.
49+
///
50+
/// # Safety
51+
/// `dst` must be a valid _type ptr_: it must follow Godot's convention to encode `Self`,
52+
/// which is different depending on the type.
4153
unsafe fn write_sys(&self, dst: sys::GDExtensionTypePtr);
4254
}
4355

@@ -66,6 +78,7 @@ pub trait GodotFuncMarshal: Sized {
6678
// See doc comment of `ffi_methods!` for information
6779

6880
#[macro_export]
81+
#[doc(hidden)]
6982
macro_rules! ffi_methods_one {
7083
// type $Ptr = *mut Opaque
7184
(OpaquePtr $Ptr:ty; $( #[$attr:meta] )? $vis:vis $from_sys:ident = from_sys) => {
@@ -159,6 +172,7 @@ macro_rules! ffi_methods_one {
159172
}
160173

161174
#[macro_export]
175+
#[doc(hidden)]
162176
macro_rules! ffi_methods_rest {
163177
( // impl T: each method has a custom name and is annotated with 'pub'
164178
$Impl:ident $Ptr:ty; $( fn $user_fn:ident = $sys_fn:ident; )*

godot/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ pub use godot_core::private;
9999
/// Often-imported symbols.
100100
pub mod prelude {
101101
pub use super::bind::{godot_api, GodotClass, GodotExt};
102+
pub use super::builtin::dict; // Re-export macros.
102103
pub use super::builtin::*;
103104
pub use super::engine::{
104105
load, try_load, utilities, AudioStreamPlayer, Camera2D, Camera3D, Input, Node, Node2D,

0 commit comments

Comments
 (0)