Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/dsl/function_expr/bitwise.rs
6940 views
1
use std::fmt;
2
3
use strum_macros::IntoStaticStr;
4
5
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
7
#[derive(Clone, Copy, PartialEq, Debug, Eq, Hash, IntoStaticStr)]
8
#[strum(serialize_all = "snake_case")]
9
pub enum BitwiseFunction {
10
CountOnes,
11
CountZeros,
12
13
LeadingOnes,
14
LeadingZeros,
15
16
TrailingOnes,
17
TrailingZeros,
18
19
// Bitwise Aggregations
20
And,
21
Or,
22
Xor,
23
}
24
25
impl fmt::Display for BitwiseFunction {
26
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> std::fmt::Result {
27
use BitwiseFunction as B;
28
29
let s = match self {
30
B::CountOnes => "count_ones",
31
B::CountZeros => "count_zeros",
32
B::LeadingOnes => "leading_ones",
33
B::LeadingZeros => "leading_zeros",
34
B::TrailingOnes => "trailing_ones",
35
B::TrailingZeros => "trailing_zeros",
36
37
B::And => "and",
38
B::Or => "or",
39
B::Xor => "xor",
40
};
41
42
f.write_str(s)
43
}
44
}
45
46