vortex_scalar/scalarvalue/
bool.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use vortex_error::{vortex_err, VortexError, VortexResult};

use crate::ScalarValue;

impl TryFrom<&ScalarValue> for bool {
    type Error = VortexError;

    fn try_from(value: &ScalarValue) -> VortexResult<Self> {
        <Option<bool>>::try_from(value)?
            .ok_or_else(|| vortex_err!("Can't extract present value from null scalar"))
    }
}

impl TryFrom<&ScalarValue> for Option<bool> {
    type Error = VortexError;

    fn try_from(value: &ScalarValue) -> VortexResult<Self> {
        value.as_bool()
    }
}