Dusty Pomerleau on Nostr: I have these #RustLang newtypes where I want the inner field private because of ...
I have these #RustLang newtypes where I want the inner field private because of checks in the `new()` constructor, but then later I wish I could pattern match to get the inner value, and the private field prevents that. Is there a pattern in Rust that allows some sort of "read-only public” visibility?
Published at
2024-07-24 03:45:34Event JSON
{
"id": "546695a3ed06131fd66570034b6c2b276b6d4db90165636131c8e18b2711f187",
"pubkey": "5bdfe5c3188a24f76efd37648930d8ada3e458961d03b2e0d62596d4f76e4778",
"created_at": 1721792734,
"kind": 1,
"tags": [
[
"t",
"rustlang"
],
[
"proxy",
"https://fosstodon.org/users/dpom/statuses/112839408636355671",
"activitypub"
]
],
"content": "I have these #RustLang newtypes where I want the inner field private because of checks in the `new()` constructor, but then later I wish I could pattern match to get the inner value, and the private field prevents that. Is there a pattern in Rust that allows some sort of \"read-only public” visibility?",
"sig": "92ca06bf5ddda27ad5ea17f258e1bc5f6bed32706ce81d19e799522f265c53bf35f600d5c3fb7a05396b5c3286e8718df31c9d24b79391ef95a6a2df7033670a"
}