Skip to content

Commit

Permalink
feat(rust)!: Import NamedFrom in df! macro
Browse files Browse the repository at this point in the history
`Series::new` is not implemented on `Series`. This method is provided by
`NamedFrom` most of the time. This change makes `df!` explicitly use the
NamedFrom::new implementation, potentially causing a breaking change if
someone had defined another trait that provides a `new` method to
construct a `Series`.
  • Loading branch information
mickvangelderen committed Mar 6, 2024
1 parent 6a181f2 commit 772a90c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions crates/polars-core/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,9 @@ macro_rules! apply_method_physical_numeric {
#[macro_export]
macro_rules! df {
($($col_name:expr => $slice:expr), + $(,)?) => {
{
$crate::prelude::DataFrame::new(vec![$($crate::prelude::Series::new($col_name, $slice),)+])
}
$crate::prelude::DataFrame::new(vec![
$(<$crate::prelude::Series as $crate::prelude::NamedFrom::<_, _>>::new($col_name, $slice),)+
])
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/polars-io/src/cloud/adaptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Drop for CloudWriter {
#[cfg(test)]
mod tests {
use polars_core::df;
use polars_core::prelude::{DataFrame, NamedFrom};
use polars_core::prelude::DataFrame;

use super::*;

Expand Down
1 change: 0 additions & 1 deletion crates/polars-sql/tests/ops_distinct_on.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use polars_core::df;
use polars_core::prelude::*;
use polars_lazy::prelude::*;
use polars_sql::*;

Expand Down

0 comments on commit 772a90c

Please sign in to comment.