Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool-module
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool-module
Commits
9e725c10
Commit
9e725c10
authored
1 year ago
by
Egor Ivkov
Browse files
Options
Downloads
Patches
Plain Diff
doc: add warning about Instant's inner representation
parent
8f67021c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!419
doc: add warning about Instant's inner representation
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tarantool/src/time.rs
+29
-4
29 additions, 4 deletions
tarantool/src/time.rs
with
29 additions
and
4 deletions
tarantool/src/time.rs
+
29
−
4
View file @
9e725c10
...
...
@@ -17,10 +17,11 @@ use std::time::Duration;
/// experience time dilation (slow down or speed up), but it will never go
/// backwards.
///
/// Instants are opaque types that can only be compared to one another. There is
/// no method to get "the number of seconds" from an instant. Instead, it only
/// allows measuring the duration between two instants (or comparing two
/// instants).
/// Instants should generally be condsidered as opaque types that can only be compared to one another.
/// Though there is a method to get "the number of seconds" from an instant it is implementation dependent
/// and should be used with knowledge of how this particular `Instant` was constructed.
/// Instead, prefer using other operations, such as measuring the duration between two instants, comparing two
/// instants, adding and subtracting `Duration`.
///
/// This struct is almost identical to [`std::time::Instant`] but provides
/// some additional saturating methods. And it can also be constructed with
...
...
@@ -152,16 +153,40 @@ impl Instant {
self
.0
.saturating_sub
(
earlier
.0
)
}
/// Get the inner representation of an `Instant`.
///
/// # Warning
/// The inner representation of an instant is implementation dependent
/// and should be used with knowledge of how this particular `Instant` was constructed.
///
/// If possible prefer working with `Instant` and `Duration` directly without
/// getting its inner representation.
#[inline(always)]
pub
fn
as_secs
(
&
self
)
->
u64
{
self
.0
.as_secs
()
}
/// Get the inner representation of an `Instant`.
///
/// # Warning
/// The inner representation of an instant is implementation dependent
/// and should be used with knowledge of how this particular `Instant` was constructed.
///
/// If possible prefer working with `Instant` and `Duration` directly without
/// getting its inner representation.
#[inline(always)]
pub
fn
as_secs_f64
(
&
self
)
->
f64
{
self
.0
.as_secs_f64
()
}
/// Get the inner representation of an `Instant`.
///
/// # Warning
/// The inner representation of an instant is implementation dependent
/// and should be used with knowledge of how this particular `Instant` was constructed.
///
/// If possible prefer working with `Instant` and `Duration` directly without
/// getting its inner representation.
#[inline(always)]
pub
fn
as_secs_f32
(
&
self
)
->
f32
{
self
.0
.as_secs_f32
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment