pub struct Field {
pub name: SmartString<LazyCompact>,
pub dtype: DataType,
}
Expand description
Characterizes the name and the DataType
of a column.
Fields§
§name: SmartString<LazyCompact>
§dtype: DataType
Implementations§
source§impl Field
impl Field
sourcepub fn new(name: &str, dtype: DataType) -> Field
pub fn new(name: &str, dtype: DataType) -> Field
Creates a new Field
.
§Example
let f1 = Field::new("Fruit name", DataType::String);
let f2 = Field::new("Lawful", DataType::Boolean);
let f2 = Field::new("Departure", DataType::Time);
pub fn from_owned(name: SmartString<LazyCompact>, dtype: DataType) -> Field
sourcepub fn name(&self) -> &SmartString<LazyCompact>
pub fn name(&self) -> &SmartString<LazyCompact>
Returns a reference to the Field
name.
§Example
let f = Field::new("Year", DataType::Int32);
assert_eq!(f.name(), "Year");
sourcepub fn data_type(&self) -> &DataType
pub fn data_type(&self) -> &DataType
Returns a reference to the Field
datatype.
§Example
let f = Field::new("Birthday", DataType::Date);
assert_eq!(f.data_type(), &DataType::Date);
sourcepub fn coerce(&mut self, dtype: DataType)
pub fn coerce(&mut self, dtype: DataType)
Sets the Field
datatype.
§Example
let mut f = Field::new("Temperature", DataType::Int32);
f.coerce(DataType::Float32);
assert_eq!(f, Field::new("Temperature", DataType::Float32));
Trait Implementations§
source§impl PartialEq for Field
impl PartialEq for Field
impl Eq for Field
impl StructuralPartialEq for Field
Auto Trait Implementations§
impl Freeze for Field
impl !RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl !UnwindSafe for Field
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more