[rust-dev] Request for feedback

Benjamin Striegel ben.striegel at gmail.com
Fri Dec 7 13:28:19 PST 2012

Rather than using a function as a constructor, like:

    pure fn PairingHeap<E: Copy Eq Ord>(initial_value: E) -> PairingHeap<E>
{ ... }
    let heap = PairingHeap(1);

I believe it's more idiomatic to instead use a static method, as in:

    impl<E: Copy Eq Ord> PairingHeap<E> : Eq {
        static fn new(initial_value: E) -> PairingHeap<E> { ... }
    let heap = PairingHeap::new(1);

Though this probably only works in 0.5.

IIRC there are also plans to make Ord inherit from Eq, so all the places
where you have `<E: Copy Ord Eq>` can eventually be reduced to just `<E:
Copy Ord>`.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20121207/6749daeb/attachment.html>

More information about the Rust-dev mailing list