News for hackers. Stuff that matters.
Re:Python: Uncovering the Overlooked Core Functionalities by kragen on Tuesday July 25, 2023 @09:21AM (#36861815)
ruby is closer to what i meant because you can't add methods to rust's iterator, can you? but people add stuff to enumerable all the time
Re:Python: Uncovering the Overlooked Core Functionalities by josephg on Tuesday July 25, 2023 @01:14PM (#36865740)
You can!

    trait MyIterHelpers: Iterator {
        fn dance(&self) {
            println!("wheee");
        }
    }
    
    // And tell rust that all Iterators are also MyIterHelpers.
    impl<I: Iterator> MyIterHelpers for I {}
The one caveat is that using it in a different context will need a use crate::MyIterHelpers; line, so the namespace isn't polluted.
Re:Python: Uncovering the Overlooked Core Functionalities by kragen on Tuesday July 25, 2023 @07:03PM (#36870951)
neat, i didn't know that was possible