pub trait TestTrait<T> {}
impl TestTrait<&Series> for DataFrame {}
impl <T> TestTrait<T> for DataFrame
where
T: NumericNative,
{}
error:
error[E0119]: conflicting implementations of trait `core::traits::TestTrait<&polars::prelude::Series>` for type `polars::prelude::DataFrame`
--> src/core/traits.rs:117:1
|
115 | impl TestTrait<&Series> for DataFrame {}
| ------------------------------------- first implementation here
116 |
117 | impl <T> TestTrait<T> for DataFrame
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `polars::prelude::DataFrame`
while there is a similar implement in polars' Series, why My code can't work.
here is polars Series source code:
The currently active rustc version is rustc 1.66.1 (90743e729 2023-01-10)
The error message you posted here is incomplete and missing the important line explaining to you why your implementations are conflicting while polar's aren't. Namely, you don't control whether polars will add an implementation of NumericNative to &Series in the future. If they do, this would unexpectedly break your implementation, which Rust prevents from happening.
Here is the complete error message:
error[E0119]: conflicting implementations of trait `TestTrait<&polars::prelude::Series>` for type `polars::prelude::DataFrame`
--> src/main.rs:7:1
|
5 | impl TestTrait<&Series> for DataFrame {}
| ------------------------------------- first implementation here
6 |
7 | impl<T> TestTrait<T> for DataFrame where T: NumericNative {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `polars::prelude::DataFrame`
|
= note: upstream crates may add a new impl of trait `polars::prelude::NumericNative` for type `&polars::prelude::Series` in future versions
For more information about this error, try `rustc --explain E0119`.