How to choose an owned vs. borrowed struct member

First, remember that "references in structs [are] the evil-hardmode of Rust that will ruin your day.".

But if you'd like some more nuanced guidelines, you might find this thread interesting:

As a specific place you might move slightly less to owned stuff, it's plausible that the methods are commonly string literals. So you could consider something like

pub struct Endpoint {
    pub uri: String,
    pub methods: Vec<Cow<'static, str>>, // e.g. "GET", "POST"
}

As that way you wouldn't need to allocate for common things.

8 Likes