On Wed, May 28, 2014 at 5:38 PM, Oleg Eterevsky <[email protected]> wrote:

> 3. It seems like almost any string operation requires as_slice().
> Can't various string methods be also implemented for String?
>

When writing functions for others to use, you don't want to require them to
have a String, since that requires a heap allocation. It's free to go from
String to a slice, but not vice-versa. That said, there's been whispers of
making String implement Deref, as well passing as arguments to autoderef,
so you could pass a String and rustc would convert to a slice for you.


> 5. Simple indexing doesn't work for vectors:
>   let a = vec![1, 2, 3];
>   println!("{}", a[0]);
> It's a bit surprising...
>

Known issue: https://github.com/mozilla/rust/issues/11875


>
> 6. impl ToStr for custom struct fails:
>   error: conflicting implementations for trait `std::to_str::ToStr`
>   note: conflicting implementation in crate `std`
> Is it a bug? Is Show implicitly assumed for all struct's?
>

This is because ToStr is implemented for all Show implementations. You
can't implement ToStr, because if you then implemented Show, you'd have
conflicting implementations. #[deriving(Show)] on your structs is probably
all you want.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to