How to get Sha1::new()?

Sample code: sha1 - Rust

I am trying sha1 = "0.10.0"

  1. rustc can not find sha1::Sha1::new()
  2. IntelliJ can't find sha1::Sha1::new() either
  3. I can't seem to find additional feature flags to add

How do I fix this ?

Does Sha1::default() work? (Just a guess from clicking through.)

1 Like

The Sha1::new() function is defined within the Digest trait.

2 Likes

Ah, this is my fault. I failed to use sha1::Digest, as the sample code does.

Note that sha-1 got renamed to sha1, so you should prefer the latter. sha-1 will be fully deprecated on the next breaking release.

1 Like

@newpavlov : Thanks. I was not aware of this issue. To be pedantic, are the two following statements correct ?

  1. sha1 = "0.10.0" is actually the correct dependency right ?

  2. my mistake here is that I linked to the documentation of crate sha-1 instead of sha1 ?

Both versions are currently "correct", but sha-1 will be eventually deprecated in favor of sha1.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.