# Impl From\<&Cow\<\[T\]\>\> for &\[T\]

**URL:** https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946
**Category:** libs
**Created:** [January 22, 2026, 9:26am UTC](https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946 "2026-01-22T09:26:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ia0](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ia0/32/1396_2.png) [@ia0](https://internals.rust-lang.org/u/ia0)
#### Post date: [January 22, 2026, 9:26am UTC](https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946/1 "2026-01-22T09:26:40Z")

</div>

Is there a fundamental reason that `impl From<&Cow<[T]>> for &[T]` does not exist?

This would be marginally useful for some generic code. Right now, I'm making the generic code generic over the conversion function `FnOnce(T) -> R` (which could arguably be seen as better, but if I could get away with `T: Into<R>`, it would have been simpler).

---

<div class="post-metadata">

### Author: ![ais523](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@ais523](https://internals.rust-lang.org/u/ais523)
#### Post date: [January 22, 2026, 9:41am UTC](https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946/2 "2026-01-22T09:41:08Z")

</div>

This particular implementation exists as [`Deref`](https://doc.rust-lang.org/stable/std/ops/trait.Deref.html), [`AsRef`](https://doc.rust-lang.org/stable/std/convert/trait.AsRef.html) and [`Borrow`](https://doc.rust-lang.org/stable/std/borrow/trait.Borrow.html) implementations on `Cow`. Maybe one of those traits would give you the generic behaviour you need?

I don't think there's a fundamental obstacle to implementing `From` on references when you can implement `Deref` on the references' targets (but it would have to be done one type at a time, rather than as a blanket implementation, both for coherence reasons and to handle weird situations like a type that `Deref`s into itself) – the implementation itself would be valid on its own, so the only potential problem would be conflicting trait definitions.

---

<div class="post-metadata">

### Author: ![ia0](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ia0/32/1396_2.png) [@ia0](https://internals.rust-lang.org/u/ia0)
#### Post date: [January 22, 2026, 10:01am UTC](https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946/3 "2026-01-22T10:01:26Z")

</div>

> [@ais523](#):
>
> Maybe one of those traits would give you the generic behaviour you need?

I need both reflexivity without being under a reference and this `&Cow<[u8]>` to `&[u8]`. So it seems none of those options would work.

---

<div class="post-metadata">

### Author: ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)
#### Post date: [January 22, 2026, 1:55pm UTC](https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946/4 "2026-01-22T13:55:44Z")

</div>

`impl AsRef<[u8]>` and `where &T: AsRef<[u8]>, T: ?Sized` work, but only if you don't need a specific lifetime.

I think you could make a PR to the standard library. Often such implementations are missing simply because nobody asked for them yet. If it overlaps with some other `From`, at least the build error will tell you why.

---

<div class="post-metadata">

### Author: ![kornel](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/kornel/32/2711_2.png) [@kornel](https://internals.rust-lang.org/u/kornel)
#### Post date: [January 22, 2026, 2:06pm UTC](https://internals.rust-lang.org/t/impl-from-cow-t-for-t/23946/5 "2026-01-22T14:06:29Z")

</div>

`impl AsRef<[u8]>` and `where &T: AsRef<[u8]>, T: ?Sized` work, but only if you don't need a specific lifetime.

I think you could make a PR to the standard library. Often such implementations are missing simply because nobody asked for them yet. If it overlaps with some other `From`, at least the build error will tell you why.

* * *

It's annoying that libstd has so many borrowing traits, but none of them take a lifetime. AFAIK there's no way to ask for a generic `T` that can lend something for a specific `&'a` lifetime.
