1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use *;
use Display;
use EnumIter;
/// This code defines an enumeration called `DataType` with five possible variants:
/// `Quantity`, `Coordinate`, `String`, `DateTime`, and `Entity`. The
/// `#[derive(Clone, Debug, PartialEq)]` attribute macros are used to automatically
/// generate implementations of the `Clone`, `Debug`, and `PartialEq` traits for the
/// `DataType` enum. This allows instances of the enum to be cloned, printed for
/// debugging purposes, and compared for equality using the `==` operator.
/// This code defines an implementation of the `AsRef` trait for the `DataType`
/// enum, which allows instances of the enum to be converted into a reference to a
/// string slice (`&str`). The `as_ref` method is called on an instance of the
/// `DataType` enum and returns a reference to a string slice that corresponds to
/// the variant of the enum. For example, if `DataType::Quantity` is passed to
/// `as_ref`, it will return the string slice `"quantity"`. This implementation is
/// useful for cases where a `&str` reference is needed instead of an enum variant,
/// such as when constructing error messages or logging information.
/// This implementation allows instances of the `DataType` enum to be converted into
/// `Expr` instances. It does so by calling the `lit` function with the result of
/// converting the `DataType` variant into a `u64` using the `From` implementation
/// defined for `&DataType`. The resulting `Expr` represents a literal value that
/// can be used in Polars expressions.
/// This implementation allows for conversion from a reference to a `DataType` enum
/// variant to a `u8` integer. It matches the variant of the `DataType` enum and
/// returns a corresponding `u8` value. This is used in the `From<DataType> for
/// Expr` implementation to convert a `DataType` variant into a literal `Expr` value
/// that can be used in Polars expressions. It is also used in the `Display`
/// implementation to convert a `DataType` variant into a string representation of
/// its corresponding `u8` value.
/// This code defines a display implementation for the `DataType` enum, which allows
/// instances of the enum to be formatted as strings using the `format!` macro or
/// other formatting methods. The `fmt` method takes a reference to a `Formatter`
/// object and returns a `Result` indicating whether the formatting was successful.
/// Inside the method, the `into` method is called on `self` to convert the
/// `DataType` variant into a `u32` integer, which is then written to the formatter
/// using the `write!` macro. This allows the `DataType` enum to be displayed as its
/// corresponding `u32` value when formatted as a string.