The Rust Language Idioms like "warning: variable does not need to be mutable" and "warning: value assigned to '<variable_name>' is never read" lead to constructs like:
let vsttrpt: Vec<char> = String::from_utf8(text.to_vec()).unwrap().chars().collect();
as in this Prototype:
Unfortunately the Use of the socalled "Language Sugar":
the ?
operator and the unwrap()
rest to the Robustness of the Rust Application.
In an imperfect real world use case you actually might find in text
invalid UTF8 text. (perhaps one stray ill formated Byte)
Like trying to work with some internet content like in
$ wget -S -O - "http://www.lanzarote.com/de/ausfluge" 2>&1 |target/release/text-sanitizer -d
which than leads to unexpected Rust Engine Panics:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 0, error_len: Some(1) }', src/libcore/result.rs:997:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::sys_common::backtrace::print
at src/libstd/sys_common/backtrace.rs:70
at src/libstd/sys_common/backtrace.rs:58
2: std::panicking::default_hook::{{closure}}
at src/libstd/panicking.rs:200
3: std::panicking::default_hook
at src/libstd/panicking.rs:215
4: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:478
5: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:385
6: rust_begin_unwind
at src/libstd/panicking.rs:312
7: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
8: core::result::unwrap_failed
9: sanitizer_lib::sanitizer::sanitize_u8
10: text_sanitizer::main
11: std::rt::lang_start::{{closure}}
12: std::panicking::try::do_call
at src/libstd/rt.rs:49
at src/libstd/panicking.rs:297
13: __rust_maybe_catch_panic
at src/libpanic_unwind/lib.rs:87
14: std::rt::lang_start_internal
at src/libstd/panicking.rs:276
at src/libstd/panic.rs:388
at src/libstd/rt.rs:48
15: main
16: __libc_start_main
17: <unknown>
Imagine a Rust Web Spider that would crash on every wrong encoded Web Page.
(Ironically this tool was meant to sanitize text to make parsing it easier.)
So on this side the overuse of Result
objects in the Rust Libraries make the work with the Language complicated, slow and tiresome.