Working with collections of bytes
Chester Wyke November 06, 2023 Updated: April 15, 2025 #rust
rust (Series)
Conditional Compilation
Install
Crate Serde
References
Cargo
Toolchain (Nightly)
String Formatting
Time
Crate Tokio
Publish Crate
rustfmt
Single file script
Snippets
CI
Pattern Type State
WASM
Create New Crate
Documentation
JSON
Pattern Builder
Testing
Working with collections of bytes
Thoughts about rust
Are we yet
OnceLock
Crate Actix Web
Stack Overflow
Crate Clap
Crate Poll Promise
Crate Insta
Tips
Create new egui project
Crate CSV
Crate egui
Iterators
Crate Tracing Subscriber
Regex
vscode
Enum Conversion
Macros
lettre
Google APIs
Conditional Compilation
Install
Crate Serde
References
Cargo
Toolchain (Nightly)
String Formatting
Time
Crate Tokio
Publish Crate
rustfmt
Single file script
Snippets
CI
Pattern Type State
WASM
Create New Crate
Documentation
JSON
Pattern Builder
Testing
Working with collections of bytes
Thoughts about rust
Are we yet
OnceLock
Crate Actix Web
Stack Overflow
Crate Clap
Crate Poll Promise
Crate Insta
Tips
Create new egui project
Crate CSV
Crate egui
Iterators
Crate Tracing Subscriber
Regex
vscode
Enum Conversion
Macros
lettre
Google APIs
Converting to String
Some types use byte arrays instead of strings and you may want to convert them to strings based on your use case.
For example std::process::OutputOutput uses by Vec<u8>
to store both stdout
and stderr
.
Use the following to convert them to strings.
Note that if you only want to print them to stdout it isn’t required to convert them as also shown in the example from std
use Command;
use ;
let output = new
.arg
.output
.expect;
println!;
.write_all.unwrap;
stdout.write_all.unwrap;
stderr
assert!;
let data = &output.stdout;
match from_utf8