Closed
Description
struct Type {
option: Option<Vec<u8>>
}
impl Type {
fn method(&self) -> Option<Vec<u8>> {
self.option..as_ref().map(|x| x)
}
}
fn main() {
let _ = Type { option: None }.method();
}
error[E0425]: cannot find function `as_ref` in this scope
--> src/main.rs:7:22
|
7 | self.option..as_ref().map(|x| x)
| ^^^^^^ not found in this scope
error[E0308]: mismatched types
--> src/main.rs:7:9
|
6 | fn method(&self) -> Option<Vec<u8>> {
| --------------- expected `std::option::Option<std::vec::Vec<u8>>` because of return type
7 | self.option..as_ref().map(|x| x)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found struct `std::ops::Range`
|
= note: expected type `std::option::Option<_>`
found type `std::ops::Range<std::option::Option<_>>`
has a typo where two dots where written where one for method access was meant. It is not made clear enough in the output due to complaining about finding Range
but not pointing at the two dots that caused the range to be there.