#Is Option<Vec> better than an empty Vec?

2 messages · Page 1 of 1 (latest)

hallow cliff
#

Writing a library that deserializes docker build --progress rawjson's output and I'm stuck between using an Option<Vec> and having serde default to an empty vec:

#[derive(Debug, Deserialize)]
pub struct DockerBuilderCommandOutput {
    #[serde(default)]
    pub vertexes: Vec<VertexData>,
    #[serde(default)]
    pub statuses: Vec<StatusData>,
}

Is it better if i just used Option<Vec< ... >>?

latent frost
#

i'd say this is more a semantics question. is there a useful difference between a None and a Some(vec![]) in your case?