For non-professionals like me, it looks like o.and_then(|o| o.f()) works similiarly to o?.f() in JavaScript.
The callback does have to return an Option though... So if o.f() returns (), you can write it as Some(o.f()) depending on how you're using the expression:
struct C;
impl C {
fn f(&self) {
println!("o.f()");
}
}
fn main() {
let o = Some(C);
o.and_then(|o| Some(o.f()));
}
I'm wondering if there's anything more concise too.
I'm not sure what you're proposing there. If you have a known Some(C), couldn't you write C.f() to do what you want?
I was answering the original question, for where you have an Option and want to call a method and get an Option. For that, if you don't want map you could (in the future) use try and ?.