Skip to content

chore: Let Inserter accept &String and &Vec<u8> #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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

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.

1 participant