Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yutannihilation
Copy link
Contributor

Currently, this doesn't work because the trait requires it to be &str, not &String. Just using .as_str() fixes the problem, but it's nice if insert() accept it as it is.

let value: String = some_function();
flat_vector.insert(index, &value);

I thought impl<T: AsRef<str>> Inserter<T> for FlatVector { works, but it's not allowed by the compiler. So, I added impls for &String and &Vec<u8> individually.

error[E0119]: conflicting implementations of trait `vector::Inserter<CString>` for type `vector::FlatVector`
   --> crates\duckdb\src\core\vector.rs:138:1
    |
130 | impl Inserter<CString> for FlatVector {
    | ------------------------------------- first implementation here
...
138 | impl<T: AsRef<str>> Inserter<T> for FlatVector {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `vector::FlatVector`
    |
    = note: upstream crates may add a new impl of trait `std::convert::AsRef<str>` for type `std::ffi::CString` in future versions

mlafeldt added a commit that referenced this pull request Jun 27, 2025
@mlafeldt mlafeldt merged commit ed06007 into duckdb:main Jun 27, 2025
4 checks passed
@mlafeldt
Copy link
Member

@yutannihilation Thanks! I also added some tests in #525.

@yutannihilation
Copy link
Contributor Author

Oh, great. Thank you!!

@yutannihilation yutannihilation deleted the inserter-types branch June 27, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants