polars_utils/
bool.rs

1use std::ops::Deref;
2
3// a boolean flag that can only be set to `true` safely
4#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
7pub struct UnsafeBool(bool);
8impl Default for UnsafeBool {
9    fn default() -> Self {
10        UnsafeBool(true)
11    }
12}
13
14impl UnsafeBool {
15    #[allow(clippy::missing_safety_doc)]
16    pub unsafe fn new_false() -> Self {
17        UnsafeBool(false)
18    }
19}
20
21impl Deref for UnsafeBool {
22    type Target = bool;
23
24    fn deref(&self) -> &Self::Target {
25        &self.0
26    }
27}
28
29impl AsRef<bool> for UnsafeBool {
30    fn as_ref(&self) -> &bool {
31        &self.0
32    }
33}