What's everyone working on this week (31/2020)?

New week, new Rust! What are you folks up to?

I am working on a platform-agnostic driver for Melexis MLX90614/MLX90615 infrared (non-contact) thermometer.

2 Likes

Just I released the new version 0.7.2 of Yew Styles which includes title text type in Text component, the prop disabled in FormSubmit and more fixes.

I'm currently trying to make my own crypto currency / library for cryptocurrencies

I has been a while since the last release, but here are some performance improvements:

https://www.rs-pbrt.org/blog/v0-8-2-release-notes/

and one change for parse_blend_file.rs to re-use the same Blender mesh for several objects:

That issue was mentioned before but is now part of the release (and I needed a pretty picture) ...

For more details read the release notes (link above).

1 Like

That looks eerily like my old school classrooms.

Of course the world was monochrome back in those days before they invented color. :slight_smile:

2 Likes

I managed to finally publish my first crate, impl-enum. It's a macro I created mainly for my own use, but I could see others getting something out of it as well. It's inspired by enum_dispatch but is a little more flexible at the cost of requiring more work from the user.

In short

#[impl_enum::with_methods {
    fn write_all(&mut self, buf: &[u8]) -> Result<(), std::io::Error> {}
    pub fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {}
}]
enum Writer {
    Cursor(Cursor<Vec<u8>>),
    File(File),
}

=>

impl Writer {
    fn write_all(&mut self, buf: &[u8]) -> Result<(), std::io::Error> {
        match self {
            Self::Cursor(cursor) => cursor.write_all(buf),
            Self::File(file) => file.write_all(buf),
        }
    }

    pub fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
        match self {
            Self::Cursor(cursor) => cursor.write(buf),
            Self::File(file) => file.write(buf),
        }
    }
}

I had a set of 6 types (and more in the future) implementing the same trait with several methods, where one is dynamically chosen at runtime. Using trait objects worked but meant I couldn't use associated types or constants in the trait which would've made the implementation a lot cleaner, and enum_dispatch didn't work because the types and trait were all defined in different crates. I eventually switched to an enum with a hand-written impl like above, which was very tedious and repetitive to write and maintain. So I made this! I intend to expand it a bit in the future , but for now it does what I need it to do.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.