I ran into an error:
extern crate rustc_serialize; // 0.3.24
use rustc_serialize::base64::{self, FromBase64, ToBase64};
fn main() {
let a: [u8; 30] = [
The problem here is that you are not storing the result of from_base64
anywhere and then take a reference to it by calling as_slice
. Chaining calls like that causes the result of from_base64
to go out of scope at the end of the line and the reference taken is no longer valid.
extern crate rustc_serialize; // 0.3.24
use rustc_serialize::base64::FromBase64;
fn main() {
let a: [u8; 30] = [0; 30];
let b = a.from_base64().unwrap();
println!("{:?}", b.as_slice());
}