You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reference is annoying because it pollutes the type (and everything using it) with a lifetime and by binding the Datetime to its Timezone, making it difficult to move the Datetime around. Other solutions exist to circumvent this issue, although none of them seems to really stand out.
Type
Pros
Cons
reference
Sharable between Datetimes
Makes Datetime difficult to move around; lifetime pollution
owned
Straightforward
Timezone is moved on Datetime creation; would need to clone when creating several Datetimes with the same Timezone
Rc
Easily shared between multiple Datetimes
Ref count overhead
Arc
Easily shared between multiple Datetimes; cross thread boundaries
Ref count overhead
Another solution would be to actually let the user choose the adequate solution through the use of the Borrow trait. Although I haven't dig deep on this solution, I believe it would be awkward to use because of the way the current API is written i.e. Timezone creates Datetime. If the calls were reversed i.e. a Datetime is created from a Timezone and some parameters (e.g. unix timestamp, date, ...) then Borrow would become usable.
The text was updated successfully, but these errors were encountered:
A
Datetime
basically bundles aTimespec
and aTimezone
together:The reference is annoying because it pollutes the type (and everything using it) with a lifetime and by binding the
Datetime
to itsTimezone
, making it difficult to move theDatetime
around. Other solutions exist to circumvent this issue, although none of them seems to really stand out.Datetimes
Datetime
difficult to move around; lifetime pollutionTimezone
is moved onDatetime
creation; would need to clone when creating severalDatetime
s with the sameTimezone
Rc
Datetime
sArc
Datetime
s; cross thread boundariesAnother solution would be to actually let the user choose the adequate solution through the use of the
Borrow
trait. Although I haven't dig deep on this solution, I believe it would be awkward to use because of the way the current API is written i.e.Timezone
createsDatetime
. If the calls were reversed i.e. aDatetime
is created from aTimezone
and some parameters (e.g. unix timestamp, date, ...) thenBorrow
would become usable.The text was updated successfully, but these errors were encountered: