From ba2847929ffde717a8accbd94ff5bf914aacf7ed Mon Sep 17 00:00:00 2001 From: Alice Cecile Date: Tue, 20 Aug 2024 07:08:46 -0400 Subject: [PATCH] Revert "Add conversions between Visibility and bool (#14784)" (#14830) This reverts commit e37bf18e2b5291cd0620fb92264acfdf225e5a1b, added in #14784. # Objective The PR was fine, but the work was very poorly motivated and the resulting API is not actually very nice. The actual user need is likely better addressed by #14825. ## Solution Revert the offending PR. --- crates/bevy_render/src/view/visibility/mod.rs | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/crates/bevy_render/src/view/visibility/mod.rs b/crates/bevy_render/src/view/visibility/mod.rs index 61dfce124259e..341404d189fdb 100644 --- a/crates/bevy_render/src/view/visibility/mod.rs +++ b/crates/bevy_render/src/view/visibility/mod.rs @@ -21,8 +21,6 @@ use crate::{ primitives::{Aabb, Frustum, Sphere}, }; -use thiserror::Error; - use super::NoCpuCulling; /// User indication of whether an entity is visible. Propagates down the entity hierarchy. @@ -49,43 +47,6 @@ pub enum Visibility { Visible, } -/// Enum of errors that could occur during conversion to [`bool`] -#[non_exhaustive] -#[derive(Error, Debug)] -pub enum VisibilityToBoolConversionError { - #[error("The variant `{0:?}` cannot be converted to a bool")] - VariantNotSupported(Visibility), -} -/// Implements conversion from bool to Visibility -/// `true` corresponds to [`Visibility::Visible`], while false corresponds to [`Visibility::Hidden`]. -impl From for Visibility { - fn from(visible: bool) -> Visibility { - if visible { - Visibility::Visible - } else { - Visibility::Hidden - } - } -} - -/// Implements conversion from [`Visibility`] to [`bool`] -/// - returns `Ok(true)` if `Visibility::Visible` -/// - returns `Ok(false)` if `Visibility::Hidden` -/// - returns `Err()` if `Visibility::Inherited` -impl TryFrom for bool { - type Error = VisibilityToBoolConversionError; - - fn try_from(visible: Visibility) -> Result { - match visible { - Visibility::Hidden => Ok(false), - Visibility::Visible => Ok(true), - Visibility::Inherited => Err(VisibilityToBoolConversionError::VariantNotSupported( - Visibility::Inherited, - )), - } - } -} - // Allows `&Visibility == Visibility` impl PartialEq for &Visibility { #[inline]