DEV Community

loading...

Discussion on: Rocket Tutorial 03: Proper routing

Collapse
davidedelpapa profile image
Davide Del Papa Author

Hi. Sorry, where's the screenshot?
Anyway, I have to check the code on the latest rocket release.. It might be a version compatibility issue. So check also the rocket version and the dependencies versions (the .lock file might help)

Collapse
sentinel1909 profile image
Jeff Mitchell

I don't think the screenshot quite worked. I checked my post afterwards and couldn't see it either. I did find a solution such that the code compiles and output is as expected. I'm not at my home computer now, but will post later.

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.