this post was submitted on 13 Aug 2023
10 points (91.7% liked)
Rust
5981 readers
143 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Note: the ᐸᐳ characters used below are Canadian Aboriginal syllabics because Lemmy devs haven’t fixed broken input sanitization yet.
Well, getters are not an official concept in Rust. You can do whatever works best in your case.
Just worth pointing out that a method with a return value of
OptionᐸVecᐸStringᐳᐳ
wouldn't be really a getter, as you must be constructing values, or moving ownership, or cloning. None of these actions conceptually belong to a getter.Also, you should be clear on the what the
Option
abstraction means. Does it mean the vector is empty? Does it mean the vector does not exist or some sort of null (FFI ore serialization contexts)? And make sure the code does what you expect it to do.