cubecl_core/frontend/element/
bool.rs1use cubecl_ir::{ExpandElement, Scope};
2
3use crate::frontend::{CubePrimitive, CubeType};
4use crate::ir::Elem;
5
6use super::{
7 ExpandElementIntoMut, ExpandElementTyped, IntoMut, IntoRuntime, into_mut_expand_element,
8};
9
10pub trait BoolOps {
12 #[allow(clippy::new_ret_no_self)]
13 fn new(value: bool) -> bool {
14 value
15 }
16 fn __expand_new(
17 _scope: &mut Scope,
18 value: ExpandElementTyped<bool>,
19 ) -> ExpandElementTyped<bool> {
20 ExpandElement::Plain(Elem::Bool.from_constant(*value.expand)).into()
21 }
22}
23
24impl BoolOps for bool {}
25
26impl CubeType for bool {
27 type ExpandType = ExpandElementTyped<Self>;
28}
29
30impl CubePrimitive for bool {
31 fn as_elem_native() -> Option<Elem> {
32 Some(Elem::Bool)
33 }
34}
35
36impl IntoRuntime for bool {
37 fn __expand_runtime_method(self, scope: &mut Scope) -> ExpandElementTyped<Self> {
38 let expand: ExpandElementTyped<Self> = self.into();
39 IntoMut::into_mut(expand, scope)
40 }
41}
42
43impl ExpandElementIntoMut for bool {
44 fn elem_into_mut(scope: &mut Scope, elem: ExpandElement) -> ExpandElement {
45 into_mut_expand_element(scope, elem)
46 }
47}