Destructuring "newtype"?

I'm trying to get the underlying array for Salt from sodiumoxide - any thoughts on this?

let salt_data: [u8; SALTBYTES] = pwhash::gen_salt() is breaking for me.

help?

let Salt(salt_data) = pwhash::gen_salt();
2 Likes

This is a 1-tuple struct, so there are two way to get at the inner value:

let Salt(salt_data) = gen_salt(); // destructuring
let salt_data = gen_salt().0; // tuple indexing
2 Likes