Before

…lines 1–68 unchanged (68 lines)
69}
70
71impl std::ops::Add<Duration> for Instant {
72 type Output = Instant;
73
74 fn add(self, rhs: Duration) -> Self::Output {
75 self.checked_add_duration(&rhs).unwrap()
76 }
77}
78
79impl std::ops::Sub<Duration> for Instant {
80 type Output = Instant;
81
82 fn sub(self, rhs: Duration) -> Self::Output {
83 self.checked_sub_duration(&rhs).unwrap()
84 }
85}
86
87pub trait Clock {
88 fn now(&self) -> Instant;
89}
…lines 90–102 unchanged (13 lines)

After

…lines 1–69 unchanged (69 lines)
70
71impl std::ops::Add<Duration> for Instant {
72 type Output = Instant;
73
74 fn add(self, rhs: Duration) -> Self::Output {
75 self.checked_add_duration(&rhs)
76 .expect("duration addition overflow")
77 }
78}
79
80impl std::ops::Sub<Duration> for Instant {
81 type Output = Instant;
82
83 fn sub(self, rhs: Duration) -> Self::Output {
84 self.checked_sub_duration(&rhs)
85 .expect("duration subtraction underflow")
86 }
87}
88
89pub trait Clock {
90 fn now(&self) -> Instant;
91}
…lines 92–104 unchanged (13 lines)

Before

source_file
use_declaration
use "use"
scoped_use_list
scoped_identifier
identifier "std"
:: "::"
identifier "time"
:: "::"
use_list
{ "{"
identifier "Duration"
, ","
identifier "SystemTime"
, ","
identifier "UNIX_EPOCH"
} "}"
; ";"
attribute_item (+22 nodes collapsed)
struct_item (+22 nodes collapsed)
const_item
const "const"
identifier "NSEC_PER_SEC"
: ":"
primitive_type "u64"
= "="
integer_literal "1_000_000_000"
; ";"
const_item
const "const"
identifier "NANOS_PER_MICRO"
: ":"
primitive_type "u32"
= "="
integer_literal "1_000"
; ";"
const_item
const "const"
identifier "MICROS_PER_SEC"
: ":"
primitive_type "u32"
= "="
binary_expression
type_cast_expression
identifier "NSEC_PER_SEC"
as "as"
primitive_type "u32"
/ "/"
identifier "NANOS_PER_MICRO"
; ";"
impl_item (+420 nodes collapsed)
impl_item (+84 nodes collapsed)
impl_item
impl "impl"
generic_type
scoped_type_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "ops"
:: "::"
type_identifier "Add"
type_arguments
< "<"
type_identifier "Duration"
> ">"
for "for"
type_identifier "Instant"
declaration_list
{ "{"
type_item
type "type"
type_identifier "Output"
= "="
type_identifier "Instant"
; ";"
function_item
fn "fn"
identifier "add"
parameters
( "("
self_parameter
self "self"
, ","
parameter
identifier "rhs"
: ":"
type_identifier "Duration"
) ")"
-> "->"
scoped_type_identifier
identifier "Self"
:: "::"
type_identifier "Output"
block
{ "{"
call_expression
field_expression
call_expression
field_expression
self "self"
. "."
field_identifier "checked_add_duration"
arguments
( "("
reference_expression
& "&"
identifier "rhs"
) ")"
. "."
field_identifier "unwrap"
arguments
( "("
) ")"
} "}"
} "}"
impl_item
impl "impl"
generic_type
scoped_type_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "ops"
:: "::"
type_identifier "Sub"
type_arguments
< "<"
type_identifier "Duration"
> ">"
for "for"
type_identifier "Instant"
declaration_list
{ "{"
type_item
type "type"
type_identifier "Output"
= "="
type_identifier "Instant"
; ";"
function_item
fn "fn"
identifier "sub"
parameters
( "("
self_parameter
self "self"
, ","
parameter
identifier "rhs"
: ":"
type_identifier "Duration"
) ")"
-> "->"
scoped_type_identifier
identifier "Self"
:: "::"
type_identifier "Output"
block
{ "{"
call_expression
field_expression
call_expression
field_expression
self "self"
. "."
field_identifier "checked_sub_duration"
arguments
( "("
reference_expression
& "&"
identifier "rhs"
) ")"
. "."
field_identifier "unwrap"
arguments
( "("
) ")"
} "}"
} "}"
trait_item
visibility_modifier
pub "pub"
trait "trait"
type_identifier "Clock"
declaration_list
{ "{"
function_signature_item
fn "fn"
identifier "now"
parameters
( "("
self_parameter
& "&"
self "self"
) ")"
-> "->"
type_identifier "Instant"
; ";"
} "}"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "DefaultClock"
; ";"
impl_item (+67 nodes collapsed)

After

source_file
use_declaration
use "use"
scoped_use_list
scoped_identifier
identifier "std"
:: "::"
identifier "time"
:: "::"
use_list
{ "{"
identifier "Duration"
, ","
identifier "SystemTime"
, ","
identifier "UNIX_EPOCH"
} "}"
; ";"
attribute_item (+22 nodes collapsed)
struct_item (+22 nodes collapsed)
const_item
const "const"
identifier "NSEC_PER_SEC"
: ":"
primitive_type "u64"
= "="
integer_literal "1_000_000_000"
; ";"
const_item
const "const"
identifier "NANOS_PER_MICRO"
: ":"
primitive_type "u32"
= "="
integer_literal "1_000"
; ";"
const_item
const "const"
identifier "MICROS_PER_SEC"
: ":"
primitive_type "u32"
= "="
binary_expression
type_cast_expression
identifier "NSEC_PER_SEC"
as "as"
primitive_type "u32"
/ "/"
identifier "NANOS_PER_MICRO"
; ";"
impl_item (+420 nodes collapsed)
impl_item (+84 nodes collapsed)
impl_item
impl "impl"
generic_type
scoped_type_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "ops"
:: "::"
type_identifier "Add"
type_arguments
< "<"
type_identifier "Duration"
> ">"
for "for"
type_identifier "Instant"
declaration_list
{ "{"
type_item
type "type"
type_identifier "Output"
= "="
type_identifier "Instant"
; ";"
function_item
fn "fn"
identifier "add"
parameters
( "("
self_parameter
self "self"
, ","
parameter
identifier "rhs"
: ":"
type_identifier "Duration"
) ")"
-> "->"
scoped_type_identifier
identifier "Self"
:: "::"
type_identifier "Output"
block
{ "{"
call_expression
field_expression
call_expression
field_expression
self "self"
. "."
field_identifier "checked_add_duration"
arguments
( "("
reference_expression
& "&"
identifier "rhs"
) ")"
. "."
field_identifier "expect"
arguments
( "("
string_literal
" "\""
string_content "duration addition overflow"
" "\""
) ")"
} "}"
} "}"
impl_item
impl "impl"
generic_type
scoped_type_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "ops"
:: "::"
type_identifier "Sub"
type_arguments
< "<"
type_identifier "Duration"
> ">"
for "for"
type_identifier "Instant"
declaration_list
{ "{"
type_item
type "type"
type_identifier "Output"
= "="
type_identifier "Instant"
; ";"
function_item
fn "fn"
identifier "sub"
parameters
( "("
self_parameter
self "self"
, ","
parameter
identifier "rhs"
: ":"
type_identifier "Duration"
) ")"
-> "->"
scoped_type_identifier
identifier "Self"
:: "::"
type_identifier "Output"
block
{ "{"
call_expression
field_expression
call_expression
field_expression
self "self"
. "."
field_identifier "checked_sub_duration"
arguments
( "("
reference_expression
& "&"
identifier "rhs"
) ")"
. "."
field_identifier "expect"
arguments
( "("
string_literal
" "\""
string_content "duration subtraction underflow"
" "\""
) ")"
} "}"
} "}"
trait_item
visibility_modifier
pub "pub"
trait "trait"
type_identifier "Clock"
declaration_list
{ "{"
function_signature_item
fn "fn"
identifier "now"
parameters
( "("
self_parameter
& "&"
self "self"
) ")"
-> "->"
type_identifier "Instant"
; ";"
} "}"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "DefaultClock"
; ";"
impl_item (+67 nodes collapsed)