Should I return &Option<Foo> or Option<&Foo> from a getter?

Viewed 482

I have a struct:

struct Foo {}
struct Boo {
    foo: Option<Foo>,
}

I want to create getter for it, so user cannot modify it but can read it:

impl Boo {
    pub fn get_foo(&self) -> ? { unimplemented!(); }
}

Should I return &Option<Foo> or Option<&Foo>? Are there any advantages between these two variants?

I use both variants in my program, and it became an inconvenience to mix them, so I want to choose one of them for the entire program.

2 Answers
Related