Closed matklad closed 5 years ago
I've though about it, and came to the conclusion that we shouldn't do that
set
returning ()
is less surprising and can be more convenient in, for example, match
arms, where you need ()
. If someone needs &T
, we can add insert
method.
regarding naming, while get / set / init
name are not really orthogonal, they do a good job explaining semantically what's going on: in config.get_or_init
it's clear-er that init is called at most once. With config.get_or_set_with
it's not so.
set
should returnResult<&T, T>
maybe align naming with option?
get
insert
get_or_insert
get_or_insert_with
try_get_or_insert_with
alternative
get
set
get_or_set
get_or_set_with
try_get_or_set_with