You wouldn't probably use this for each and every method, but what it gives
you is Go-style duck typing.

Sure you can define a trait, but what if the struct you to pass to your
function does not implement it? I guess you would have to implement a
wrapper around it manually then.

--
Ziad


On Sun, Mar 23, 2014 at 4:37 AM, Matthieu Monrocq <
[email protected]> wrote:

> I would note that Rust macros are actually working with structural typing:
> the expanded macro cannot be compiled unless the expressions/statements it
> results in can be compiled.
>
> Regarding Scala here, it seems a weird idea to ask that each and every
> method should copy+paste the interface. We all know the woes of duplication.
>
> Instead, you can define a Trait (even if for a single function) and it'll
> just work; and when you add a second function you will be able to re-use
> the same trait.
>
>
> On Sun, Mar 23, 2014 at 11:37 AM, Liigo Zhuang <[email protected]>wrote:
>
>> IMO, this is bad.
>> 2014年3月23日 下午6:34于 "Ziad Hatahet" <[email protected]>写道:
>>
>>>  Hi all,
>>>
>>> Are there any plans to implement structural typing in Rust? Something
>>> like this Scala code: http://en.wikipedia.org/wiki/Duck_typing#In_Scala
>>>
>>>
>>> _______________________________________________
>>> Rust-dev mailing list
>>> [email protected]
>>> https://mail.mozilla.org/listinfo/rust-dev
>>>
>>>
>> _______________________________________________
>> Rust-dev mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to