Skip to content

Why are Span methods like hours() or minutes() setters instead of getters? #37

Answered by BurntSushi
epidemian asked this question in Q&A
Discussion options

You must be logged in to vote

I answered what I believe is a related question in a more focused way in #41. The answer to that somewhat subsumes this question because it effectively rejects your suggestion of using operator overloading on addition to make constructing spans easier.

With that said, it is technically separable from the problem of using the get_ prefix in getters.

I use the pattern of the get_ prefix for getters in regex-automata as well: https://docs.rs/regex-automata/latest/regex_automata/meta/struct.Config.html

The main reason for this is that I perceive the getters in this case to be less frequently used---by a substantial amount---than the builder/setters. The Rust API guidelines are just that; guid…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants