Giter Club home page Giter Club logo

Comments (10)

jonhoo avatar jonhoo commented on August 30, 2024 1

I'm inclined to agree. Let's remove the impls for now 👍 We could perhaps add a helper method like Key::and?

from fantoccini.

tomaspecl avatar tomaspecl commented on August 30, 2024

I found something relevant here:
https://std-dev-guide.rust-lang.org/code-considerations/breaking-changes/new-trait-impls.html#deref-coercion-breaks-when-a-new-impl-is-introduced

It is caused by your

impl Add<Key> for String {
    type Output = String;

    fn add(mut self, rhs: Key) -> Self::Output {
        self.push(rhs.into());
        self
    }
}

impl AddAssign<Key> for String {
    fn add_assign(&mut self, rhs: Key) {
        self.push(rhs.into());
    }
}

from fantoccini.

jonhoo avatar jonhoo commented on August 30, 2024

That's very suspicious, and I think it should be reported upstream. Those docs are specifically for the standard library, not for crate authors, and this is certainly a footgun if it applies to all crates!

cc @stevepryde as this was introduced in #151. We could totally remove these impls as they haven't been made part of a stable release yet, though that would also hurt the ergonomics of Key a fair amount.

from fantoccini.

jonhoo avatar jonhoo commented on August 30, 2024

I added a note in rust-lang/rust#51916

from fantoccini.

stevepryde avatar stevepryde commented on August 30, 2024

Yeah that's unfortunate. I think it's better to take a small drop in ergonomics than potentially break other code just by importing fantoccini.

from fantoccini.

tomaspecl avatar tomaspecl commented on August 30, 2024

Hello I have an idea how to make it work and still be quite ergonomic:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=cd64fbcedcdc4e446a64d7f1c8616d43

from fantoccini.

tomaspecl avatar tomaspecl commented on August 30, 2024

@jonhoo should I do a pull request or will you (or @stevepryde ) do it?

from fantoccini.

jonhoo avatar jonhoo commented on August 30, 2024

It's pretty weird to have to add those & in there, but maybe that's the best we can do for now. We should call it out in the docs for Key explicitly at least.

Feel free to open a PR, that'll probably be faster!

from fantoccini.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.