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

Remove unnecessary lifetime from CRC digest in deserializer #155

Closed

Conversation

MathiasKoch
Copy link

This PR is the deserialize complement to #129

This is required to allow wrappers such as

fn deserialize(buf: &[u8]) -> Result<Data<'_>, Error> {
    let crc = Crc::<u32>::new(&CRC_32_ISCSI);
    let digest = crc.digest();
    postcard::from_bytes_crc32(buf, digest).map_err(|_| Error::Deserialize)
}

without getting

   |
54 |         let digest = crc.digest();
   |                      --- `crc` is borrowed here
55 |         postcard::from_bytes_crc32(buf, digest).map_err(|_| Error::Deserialize)
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function

Copy link

netlify bot commented May 15, 2024

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit d761d65
🔍 Latest deploy log https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/6644fcef2a6dd2000801a98f

@MathiasKoch
Copy link
Author

Nevermind this.. Moved a bit too fast with the PR.. Don't think this will work in practice?

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