Skip to content

Commit

Permalink
Fix IsFreeze trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Voultapher committed Aug 18, 2023
1 parent e79ed09 commit 2d524b1
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,16 @@ unsafe impl<T: ?Sized> Freeze for *mut T {}
unsafe impl<T: ?Sized> Freeze for &T {}
unsafe impl<T: ?Sized> Freeze for &mut T {}

#[const_trait]
trait IsFreeze {
fn value() -> bool;
const IS_FREEZE: bool;
}

impl<T> const IsFreeze for T {
default fn value() -> bool {
false
}
default const IS_FREEZE: bool = false;
}

impl<T: Freeze> const IsFreeze for T {
fn value() -> bool {
true
}
const IS_FREEZE: bool = true;
}

#[must_use]
Expand All @@ -201,7 +196,7 @@ const fn has_direct_interior_mutability<T>() -> bool {
// can have interior mutability it may alter itself during comparison in a way that must be
// observed after the sort operation concludes. Otherwise a type like Mutex<Option<Box<str>>>
// could lead to double free.
!<T as IsFreeze>::value()
!T::IS_FREEZE
}

trait IsTrue<const B: bool> {}
Expand Down

0 comments on commit 2d524b1

Please sign in to comment.