Skip to content
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

digest: implement Update for Vec<u8> #1630

Closed
wants to merge 1 commit into from

Commits on Jul 27, 2024

  1. digest: implement Update for Vec<u8>

    In use-cases like https://github.com/RustCrypto/SSH/blob/a6f33709d6a48d82c818a9bdec87fe3a96b027ca/ssh-encoding/src/writer.rs#L19
    it is not currently possible to write things like;
    ``` rust
    impl<D> Writer for D
    where
        D: digest::Update,
    {
        fn write(&mut self, bytes: &[u8]) -> Result<()> {
            self.update(bytes);
            Ok(())
        }
    }
    ```
    
    This isn't currently possible because of the following error:
    ```
    error[E0119]: conflicting implementations of trait `Writer` for type `Vec<u8>`
       |
    21 |   impl Writer for Vec<u8> {
       |   ----------------------- first implementation here
    ...
    44 | / impl<D> Writer for D
    45 | | where
    46 | |     D: Update,
       | |______________^ conflicting implementation for `Vec<u8>`
       |
       = note: upstream crates may add a new impl of trait `digest::Update` for type `alloc::vec::Vec<u8>` in future versions
    ```
    
    Although this is technically incorrect, as Vec isn't a digest,
    an `Update` implementation still seems relevant.
    baloo committed Jul 27, 2024
    Configuration menu
    Copy the full SHA
    83cb4b7 View commit details
    Browse the repository at this point in the history