DEV Community

loading...

Discussion on: Rocket Tutorial 03: Proper routing

Collapse
sentinel1909 profile image
Jeff Mitchell

I modified the impl User block by adding .map(char::from) just before .collect(), everything compiled and I was able to carry on with the testing described in the rest of Tutorial 3. Here's the code:

impl User {
pub fn new(name: String, email: String, password: String) -> Self {
let salt: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(20)
.map(char::from)
.collect();
let hashed_password = hash_password(&password, &salt);

I'll be honest, I Googled for this...I'm now researching to understand why this worked :)

Thread Thread
davidedelpapa profile image
Davide Del Papa Author

Up till version 0.7.3, rng.sample(Alphanumeric)) would produce chars. After 0.8.0 you need the char conversion you added to the code.