&'static [T] | Rc<[T]>

Is there a commonly agreed upon word for this struct:

Edit: Thanks @SebastianJL for pointing out struct -> enum

pub enum Foo<T> {
  Static(&'static [T]),
  Rc(Rc<[T]>)
}

basically it is an immutable slice &[T] that is either static or Rc backed

I think the closest is Cow in std::borrow - Rust , but it is about T, not [T], and the non-static case is not Rc-backed.

Cow has a T: ?Sized bound, so you can have Cow<[T]>.

Yeah, I personally consider it a misfeature that Cow can't be Rc backed.

Not that I know of. I did personally call it RcCow or something like that though.

1 Like

Do you mean enum instead of struct? AFAIK this is not valid rust.

1 Like

You can shoehorn this into Cow with a custom DST (with the usual pains of custom DSTs).

3 Likes