beef icon indicating copy to clipboard operation
beef copied to clipboard

Error with implicit Deref String in &str

Open uselessgoddess opened this issue 3 years ago • 0 comments

If i use the following code with std::Cow - will be ok

let string = "hello".to_string();
let cow: Cow<str> = Cow::from(&string);

but beef::Cow tells me:

error[E0277]: the trait bound `String: beef::traits::internal::Beef` is not satisfied
  --> src\main.rs:6:35
   |
6  |     let cow: Cow<str> = Cow::from(&string);
   |                         --------- ^^^^^^^ the trait `beef::traits::internal::Beef` is not implemented for `String`
   |                         |
   |                         required by a bound introduced by this call
   |
   = help: the trait `beef::traits::internal::Beef` is implemented for `str`
note: required by a bound in `beef::generic::Cow`
  --> F:\Rust\beef\src\generic.rs:26:23
   |
26 | pub struct Cow<'a, T: Beef + ?Sized + 'a, U: Capacity> {
   |                       ^^^^ required by this bound in `beef::generic::Cow`

Maybe you need an explicit impl From<&str> for Cow in addition to From<&T>? Or is it not important?

uselessgoddess avatar Jul 27 '22 18:07 uselessgoddess