&'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]),

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).


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.