Repository: dalek-cryptography/curve25519-dalek (language: rust)

Issue:
docs.rs homepage examples use `rand_core` crate option, but do not mention its existence
I'm attempting to follow the [documentation](https://docs.rs/ed25519-dalek/latest/ed25519_dalek/#example) and have the following file:
```rs
use ed25519_dalek::SigningKey;
use rand::rngs::OsRng;

fn main() {
  let mut csprng = OsRng;
  let signing_key: SigningKey = SigningKey::generate(&mut csprng);
}
```
which I'm attempting to build against ed25519_dalek 2.1.1 and rand 0.8.5 but I'm getting the following error:
```
error[E0599]: no function or associated item named `generate` found for struct `SigningKey` in the current scope
 --> src/bin/foo.rs:6:45
  |
6 |   let signing_key: SigningKey = SigningKey::generate(&mut csprng);
  |                                             ^^^^^^^^ function or associated item not found in `SigningKey`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `cherami` (bin "foo") due to previous error
```


Discussion / hints:
I agree that example is deficient and doesn't fully explain everything you need to do for the `generate` method to be available.

For more information, see the documentation here, note "available on crate feature `rand_core` only":

https://docs.rs/ed25519-dalek/latest/ed25519_dalek/struct.SigningKey.html#method.generate

<img width="1019" alt="Screenshot 2024-02-22 at 6 34 39 PM" src="https://github.com/dalek-cryptography/curve25519-dalek/assets/797/6086e460-ee3d-41f9-9db2-3c5b88c13c63">

Solution: you need to enable the `rand_core` crate feature in Cargo.toml:

```toml
[dependencies]
ed25519-dalek = { version = "2", features = ["rand_core"] }
```
Thanks @tarcieri ! That indeed solves the compilation error. I was not aware of the `rand_core` option after reading https://docs.rs/ed25519-dalek/latest/ed25519_dalek/.

I will update the issue title to reflect a docs issue, instead of a compilation one.

Fix patch:
diff --git a/ed25519-dalek/src/lib.rs b/ed25519-dalek/src/lib.rs
index a7cfac488..21d8737ba 100644
--- a/ed25519-dalek/src/lib.rs
+++ b/ed25519-dalek/src/lib.rs
@@ -21,6 +21,7 @@
 #![cfg_attr(feature = "rand_core", doc = "```")]
 #![cfg_attr(not(feature = "rand_core"), doc = "```ignore")]
 //! # fn main() {
+//! // $ cargo add ed25519_dalek --features rand_core
 //! use rand::rngs::OsRng;
 //! use ed25519_dalek::SigningKey;
 //! use ed25519_dalek::Signature;


Test patch: