Join Nostr
2025-12-16 21:33:51 UTC
in reply to

Rusty Russell on Nostr: I love this pattern: excellent advice. I asked ChatGPT how to do this in Rust, and it ...

I love this pattern: excellent advice. I asked ChatGPT how to do this in Rust, and it suggested a template using a phantom type was idiomatic Rust:

pub struct ReadOnly;
pub struct Writable;

pub struct Store<Mode> {
file: File,
_mode: PhantomData<Mode>,
}

Then implement write() only in the writable specialization.

I've deferred this change for now, but congratulations: you are responsible for my first refactoring (once the implementation is complete!) 🧡