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] - relax Sized bounds around change detection types #5917

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/bevy_ecs/src/change_detection.rs
Expand Up @@ -46,7 +46,7 @@ pub trait DetectChanges {
/// The type contained within this smart pointer
///
/// For example, for `Res<T>` this would be `T`.
type Inner;
type Inner: ?Sized;

/// Returns `true` if this value was added after the system last ran.
fn is_added(&self) -> bool;
Expand Down Expand Up @@ -90,7 +90,7 @@ pub trait DetectChanges {

macro_rules! change_detection_impl {
($name:ident < $( $generics:tt ),+ >, $target:ty, $($traits:ident)?) => {
impl<$($generics),* $(: $traits)?> DetectChanges for $name<$($generics),*> {
impl<$($generics),* : ?Sized $(+ $traits)?> DetectChanges for $name<$($generics),*> {
type Inner = $target;

#[inline]
Expand Down Expand Up @@ -130,7 +130,7 @@ macro_rules! change_detection_impl {
}
}

impl<$($generics),* $(: $traits)?> Deref for $name<$($generics),*> {
impl<$($generics),*: ?Sized $(+ $traits)?> Deref for $name<$($generics),*> {
type Target = $target;

#[inline]
Expand All @@ -139,7 +139,7 @@ macro_rules! change_detection_impl {
}
}

impl<$($generics),* $(: $traits)?> DerefMut for $name<$($generics),*> {
impl<$($generics),* : ?Sized $(+ $traits)?> DerefMut for $name<$($generics),*> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
self.set_changed();
Expand All @@ -165,7 +165,7 @@ macro_rules! change_detection_impl {

macro_rules! impl_into_inner {
($name:ident < $( $generics:tt ),+ >, $target:ty, $($traits:ident)?) => {
impl<$($generics),* $(: $traits)?> $name<$($generics),*> {
impl<$($generics),* : ?Sized $(+ $traits)?> $name<$($generics),*> {
/// Consume `self` and return a mutable reference to the
/// contained value while marking `self` as "changed".
#[inline]
Expand All @@ -179,12 +179,12 @@ macro_rules! impl_into_inner {

macro_rules! impl_debug {
($name:ident < $( $generics:tt ),+ >, $($traits:ident)?) => {
impl<$($generics),* $(: $traits)?> std::fmt::Debug for $name<$($generics),*>
impl<$($generics),* : ?Sized $(+ $traits)?> std::fmt::Debug for $name<$($generics),*>
where T: std::fmt::Debug
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_tuple(stringify!($name))
.field(self.value)
.field(&self.value)
.finish()
}
}
Expand All @@ -209,7 +209,7 @@ pub(crate) struct Ticks<'a> {
/// Panics when used as a [`SystemParam`](crate::system::SystemParam) if the resource does not exist.
///
/// Use `Option<ResMut<T>>` instead if the resource might not always exist.
pub struct ResMut<'a, T: Resource> {
pub struct ResMut<'a, T: ?Sized + Resource> {
pub(crate) value: &'a mut T,
pub(crate) ticks: Ticks<'a>,
}
Expand Down Expand Up @@ -241,7 +241,7 @@ impl<'a, T: Resource> From<ResMut<'a, T>> for Mut<'a, T> {
/// Panics when used as a `SystemParameter` if the resource does not exist.
///
/// Use `Option<NonSendMut<T>>` instead if the resource might not always exist.
pub struct NonSendMut<'a, T: 'static> {
pub struct NonSendMut<'a, T: ?Sized + 'static> {
pub(crate) value: &'a mut T,
pub(crate) ticks: Ticks<'a>,
}
Expand Down