Login
You're viewing the techdon.dev public feed.

Replies

  • Mar 23, 2026, 9:06 PM

    @epage

    In no particular order:

    epage.github.io/dev/rust-style
    I generally agree with it. But it is possible for a private type to be more relevant to user understanding than another public type and thus warrants being put above it.

    epage.github.io/dev/rust-style
    Sometimes a trait impl is more important than seeing the functions. Probably not true for normal trait impls like Clone or Display. Definitely put those last yeah

    💬 2🔄 0⭐ 0
  • 💬 0🔄 0⭐ 0
  • Mar 23, 2026, 9:15 PM

    @diondokter This is for a very particular case: you have a public type that is purely a newtype for a data-only inner type. In particular for enums, this is a technique to make your variants private. This is similar to what you said about sometimes you need the contexts of a private items to understand public items. `BarInner` exists purely for `Bar` and is that kind of context. Think of `struct Bar` and `enum BarInner` as one unit.

    💬 1🔄 0⭐ 0
  • Mar 23, 2026, 9:21 PM

    @epage yeah fair!

    But like I said, I'm not opposed to these guidelines. Just small disagreements and it seems like you're more relaxed about them than the writeup suggested (to me).

    For someone new to Rust they're good tips

    💬 0🔄 0⭐ 0
  • Mar 23, 2026, 9:12 PM

    @diondokter

    > epage.github.io/dev/rust-style
    > I generally agree with it. But it is possible for a private type to be more relevant to user understanding than another public type and thus warrants being put above it.

    Note that M-CALLER-CALLEE goes before it and calls out: "The weaker the abstraction of the callee, the more immediately after the caller it should be."

    I assume that covers your situation?

    > epage.github.io/dev/rust-style
    > Sometimes a trait impl is more important than seeing the functions. Probably not true for normal trait impls like Clone or Display. Definitely put those last yeah

    That guideline provides some important context for it: "Typically, associated functions form the core API for a type and trait implementations augment that API."

    Sounds like you are dealing with exception cases. That said, I can only think of a couple of places where I intentionally do not follow this guideline.

    💬 0🔄 0⭐ 0