File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
rust-cookbook/src/encoding/string Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -8,12 +8,12 @@ and decodes it with [`decode`].
88``` rust,edition2018
99use anyhow::Result;
1010use std::str;
11- use base64::{encode, decode };
11+ use base64::prelude::{Engine as _, BASE64_STANDARD };
1212
1313fn main() -> Result<()> {
1414 let hello = b"hello rustaceans";
15- let encoded = encode(hello);
16- let decoded = decode(&encoded)?;
15+ let encoded = BASE64_STANDARD. encode(hello);
16+ let decoded = BASE64_STANDARD. decode(&encoded)?;
1717
1818 println!("origin: {}", str::from_utf8(hello)?);
1919 println!("base64 encoded: {}", encoded);
@@ -23,5 +23,5 @@ fn main() -> Result<()> {
2323}
2424```
2525
26- [ `decode` ] : https://docs.rs/base64/* /base64/fn.decode .html
27- [ `encode` ] : https://docs.rs/base64/* /base64/fn.encode .html
26+ [ `decode` ] : https://docs.rs/base64/latest /base64/engine/trait.Engine .html#method.decode
27+ [ `encode` ] : https://docs.rs/base64/latest /base64/engine/trait.Engine .html#method.encode
You can’t perform that action at this time.
0 commit comments