Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - bevy_reflect: ReflectFromPtr to create &dyn Reflect from a *const () #4475

Closed
Closed
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix '# Safety' comment to be recognized by clippy
  • Loading branch information
jakobhellermann committed Apr 18, 2022
commit 3038e3ffa1e08adc9cc5e0dc84f7f5a7b5e4c985
6 changes: 4 additions & 2 deletions crates/bevy_reflect/src/type_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,17 @@ pub struct ReflectFromPtr {
}

impl ReflectFromPtr {
/// # Safety:
/// # Safety
///
/// - `val` must be a pointer to a value of the type that the [`ReflectFromPtr`] was constructed for
/// - the lifetime `'a` of the return type can be arbitrarily chosen by the caller, who must ensure that during
/// that lifetime, `val` is valid
pub unsafe fn to_reflect_ptr<'a>(&self, val: *const ()) -> &'a dyn Reflect {
jakobhellermann marked this conversation as resolved.
Show resolved Hide resolved
(self.to_reflect)(val, PhantomData)
}

/// # Safety:
/// # Safety
///
/// - `val` must be a pointer to a value of the type that the [`ReflectFromPtr`] was constructed for
/// - the lifetime `'a` of the return type can be arbitrarily chosen by the caller, who must ensure that during
/// that lifetime, `val` is valid and not aliased
Expand Down