On Sun, Apr 28, 2013 at 8:14 PM, Patrick Walton <[email protected]> wrote:

>
>
> > Is
> > there some way to make it just work, no matter what kind of strings
> > you're comparing?  Perhaps "foo" == (*x) would work, for example?
>
>  That doesn't work, because it makes the dynamically sized `str` a type,
> which is incoherent. (It would lead to dynamically sized stack frames, or
> structs or enums with infinite size, and so on.)
>
>
Couldn't this be relaxed? In other words allow dynamically sized `str` as a
type (and perhaps similarly for other dynamically sized types), but
prohibit those things specifically which would be problematic, i.e. using
it in ways that would require knowing its size? I think this would
essentially mean no variables, members, or parameters of that type, but you
*could* use it as a type argument -- including to the various pointer type
constructors. You might also have a rule whereby dereferencing a variable
when the result would be a dynamically-sized type is allowed *if* the
result is immediately borrowed. Then instead of `impl Eq for {@str, ~str,
&str}`, you would have just `impl Eq for str`, and if you want to compare
an ~str you dereference it.  Which seems logical to me, after all
ostensibly you want to compare the contents and not the pointer.

-- 
Your ship was destroyed in a monadic eruption.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to