What are some good conventions (any language) for methods/functions with subtly different behavior, especially as it relates to public invariants, etc?
Some examples of what I mean in thread...
Conversation
Replying to
Not sure if you'd think it is ‘good’, but Rust has:
- to_*: copy to some other storage/type
- into_*: convert to some type by-move
- as_*: cast to some type without copying
- try_*: fallible conversion returning a Result rather than panicking
- *_mut: mutable variant of a method
Replying to
"{to,into,as}_", while "good" conventions, they are not quite what I'm asking about. try_ and _mut are more relevant though. Interestingly, these both seem to suggest a missing language feature to me for automatic lifting/lowering from panics/results or immutable/mutable.
1
Does Rust have a convention for private-variants of public methods?
Show replies

