Skip to content

Commit 267ddc3

Browse files
authored
chore: Remove Default on DataType (#26511)
1 parent 50fc35b commit 267ddc3

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

crates/polars-core/src/datatypes/dtype.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,6 @@ pub enum DataType {
143143
Unknown(UnknownKind),
144144
}
145145

146-
impl Default for DataType {
147-
fn default() -> Self {
148-
DataType::Unknown(UnknownKind::Any)
149-
}
150-
}
151-
152146
pub trait AsRefDataType {
153147
fn as_ref_dtype(&self) -> &DataType;
154148
}

crates/polars-core/src/schema/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl SchemaExt for Schema {
107107

108108
pub trait SchemaNamesAndDtypes {
109109
const IS_ARROW: bool;
110-
type DataType: Debug + Clone + Default + PartialEq;
110+
type DataType: Debug + Clone + PartialEq;
111111

112112
fn iter_names_and_dtypes(
113113
&self,

crates/polars-schema/src/schema.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ use polars_error::{PolarsError, PolarsResult, polars_bail, polars_ensure, polars
66
use polars_utils::aliases::{InitHashMaps, PlIndexMap};
77
use polars_utils::pl_str::PlSmallStr;
88

9-
#[derive(Debug, Clone, Default)]
9+
#[derive(Debug, Clone)]
1010
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1111
#[cfg_attr(feature = "dsl-schema", derive(schemars::JsonSchema))]
1212
pub struct Schema<Field, Metadata> {
1313
fields: PlIndexMap<PlSmallStr, Field>,
1414
metadata: Metadata,
1515
}
1616

17+
impl<Field, Metadata: Default> Default for Schema<Field, Metadata> {
18+
fn default() -> Self {
19+
Self {
20+
fields: PlIndexMap::default(),
21+
metadata: Metadata::default(),
22+
}
23+
}
24+
}
25+
1726
impl<Field: Eq, Metadata: Eq> Eq for Schema<Field, Metadata> {}
1827

1928
impl<Field, Metadata: Default> Schema<Field, Metadata> {
@@ -401,7 +410,7 @@ impl<Field, Metadata> Schema<Field, Metadata> {
401410

402411
impl<Field, Metadata> Schema<Field, Metadata>
403412
where
404-
Field: Clone + Default,
413+
Field: Clone,
405414
Metadata: Clone,
406415
{
407416
/// Create a new schema from this one, inserting a field with `name` and `dtype` at the given `index`.

0 commit comments

Comments
 (0)