New to rust, working on a gtk app, am I on the right track?

⚓ Rust    📅 2025-06-03    👤 surdeus    👁️ 3      

surdeus

Warning

This post was published 61 days ago. The information described in this article may have changed.

Hi Everyone!

While I've been reading a lot of peoples rust code and building bindings between it and other languages like typescript and C#, I'm new to developing rust apps on my own.

The strategy I've been using to help split up code has been to use nested modules, specifically. Say you have a module like "chain_child_items" you then seperate it into it's composite parts (e.g. traits, functions, structs, enums) then put all of your implementations into the root of the module.

This ends up creating the kind of nested structure familiar to me as a typescript developer, where it's primarily functional rather than object oriented, but still maintains a clear hierarchy.

Is this a good approach?

If it is, is there a better strategy for my impls than... this?

mod traits;
mod functions;

pub (crate) use traits::*;
pub (crate) use functions::*;


impl ChainAddTitledItems for gtk::Stack {
    fn add_titled_items<const N: usize>(self, child_widgets: [(&str, &impl IsA<Widget>); N]) -> Self {
        stack::add_titled_items(self, child_widgets)
    }
    fn add_titled_item(self, name: &str, child: &impl IsA<Widget>) -> Self {
        stack::add_titled_item(self, name, child)
    }
}

Edit-
Just including a link to the project in case it helps
https://git.sr.ht/~alicealysia/NiGuiRi/tree/master/item/src/build_children.rs

1 post - 1 participant

Read full topic

🏷️ rust_feed