File tree 1 file changed +15
-8
lines changed
crates/bevy_render/src/view/visibility 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ use bevy_reflect::Reflect;
11
11
use bevy_transform:: components:: GlobalTransform ;
12
12
use bevy_transform:: TransformSystem ;
13
13
use std:: cell:: Cell ;
14
+ use std:: ops:: Not ;
14
15
use thread_local:: ThreadLocal ;
15
16
16
17
use crate :: {
@@ -39,23 +40,29 @@ impl Default for Visibility {
39
40
}
40
41
}
41
42
43
+ impl Not for & Visibility {
44
+ type Output = Visibility ;
45
+
46
+ #[ inline]
47
+ fn not ( self ) -> Visibility {
48
+ match self {
49
+ Visibility :: Shown => Visibility :: Hidden ,
50
+ Visibility :: Hidden => Visibility :: Shown ,
51
+ }
52
+ }
53
+ }
54
+
42
55
impl Visibility {
43
56
/// Whether this entity is visible.
44
57
#[ inline]
45
58
pub const fn is_visible ( & self ) -> bool {
46
- match self {
47
- Self :: Shown => true ,
48
- Self :: Hidden => false ,
49
- }
59
+ matches ! ( self , Self :: Shown )
50
60
}
51
61
52
62
/// Toggle the visibility.
53
63
#[ inline]
54
64
pub fn toggle ( & mut self ) {
55
- * self = match self {
56
- Self :: Shown => Self :: Hidden ,
57
- Self :: Hidden => Self :: Shown ,
58
- }
65
+ * self = !& * self
59
66
}
60
67
}
61
68
You can’t perform that action at this time.
0 commit comments