When building #rustlang libraries, and you have result payloads (structs), is it more idiomatic to expose public struct fields or to create getter methods?
Conversation
Are you saying public fields could break pattern matching or the getter method would?
1
I think they are saying that making fields private with getters would mean you wouldn't be able to pattern match.
Not sure why? you can do a match on the result value of the getter, can’t you?
1
You couldn't do:
Struct { field1, field2: Some(x) } => ...
1
2
Show replies

