Recompiling some older code against the newer nightlies, I'm getting warnings on using the as_slice() syntax in favour of the var[] syntax.
However when I replace as_slice() with [] as shown in the RFC, I get a compiler error saying:
expected `&str`,
found `str`
(expected &-ptr,
found str) [E0308]
src/main.rs:38 print_usage(program[], opts);
compared to my original
print_usage(program.as_slice(), opts);
Is the as_slice() syntax going away entirely, or is it just more idiomatic to write it as vec[]? What's the deal with the error I'm getting when I follow what the compiler is asking me to do?
You were near to success:
print_usage(&program[], opts);
So yes, now we should use square brackets syntax as &[start .. end] or &mut [start .. end] instead of as_slice/slice/slice_from/slice_to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With