Skip to content

Commit bc2702e

Browse files
committed
update original
1 parent 1fa01c2 commit bc2702e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

rust-cookbook/src/encoding/string/base64.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ and decodes it with [`decode`].
88
```rust,edition2018
99
use anyhow::Result;
1010
use std::str;
11-
use base64::{encode, decode};
11+
use base64::prelude::{Engine as _, BASE64_STANDARD};
1212
1313
fn 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

0 commit comments

Comments
 (0)