diff --git a/aptos-move/framework/aptos-stdlib/doc/any.md b/aptos-move/framework/aptos-stdlib/doc/any.md
index e8198a8d9bdbd..1a4704525137b 100644
--- a/aptos-move/framework/aptos-stdlib/doc/any.md
+++ b/aptos-move/framework/aptos-stdlib/doc/any.md
@@ -120,7 +120,7 @@ also required from T.
Unpack a value from the Any representation. This aborts if the value has not the expected type T.
-
public fun unpack<T>(x: any::Any): T
+public fun unpack<T>(self: any::Any): T
@@ -129,9 +129,9 @@ Unpack a value from the Any repres
Implementation
-public fun unpack<T>(x: Any): T {
- assert!(type_info::type_name<T>() == x.type_name, error::invalid_argument(ETYPE_MISMATCH));
- from_bytes<T>(x.data)
+public fun unpack<T>(self: Any): T {
+ assert!(type_info::type_name<T>() == self.type_name, error::invalid_argument(ETYPE_MISMATCH));
+ from_bytes<T>(self.data)
}
@@ -146,7 +146,7 @@ Unpack a value from the Any repres
Returns the type name of this Any
-public fun type_name(x: &any::Any): &string::String
+public fun type_name(self: &any::Any): &string::String
@@ -155,8 +155,8 @@ Returns the type name of this Any
Implementation
-public fun type_name(x: &Any): &String {
- &x.type_name
+public fun type_name(self: &Any): &String {
+ &self.type_name
}
@@ -195,14 +195,14 @@ Returns the type name of this Any
### Function `unpack`
-public fun unpack<T>(x: any::Any): T
+public fun unpack<T>(self: any::Any): T
include UnpackAbortsIf<T>;
-ensures result == from_bcs::deserialize<T>(x.data);
+ensures result == from_bcs::deserialize<T>(self.data);
@@ -212,9 +212,9 @@ Returns the type name of this Any
schema UnpackAbortsIf<T> {
- x: Any;
- aborts_if type_info::type_name<T>() != x.type_name;
- aborts_if !from_bcs::deserializable<T>(x.data);
+ self: Any;
+ aborts_if type_info::type_name<T>() != self.type_name;
+ aborts_if !from_bcs::deserializable<T>(self.data);
}
@@ -225,9 +225,9 @@ Returns the type name of this Any
schema UnpackRequirement<T> {
- x: Any;
- requires type_info::type_name<T>() == x.type_name;
- requires from_bcs::deserializable<T>(x.data);
+ self: Any;
+ requires type_info::type_name<T>() == self.type_name;
+ requires from_bcs::deserializable<T>(self.data);
}
@@ -238,14 +238,14 @@ Returns the type name of this Any
### Function `type_name`
-public fun type_name(x: &any::Any): &string::String
+public fun type_name(self: &any::Any): &string::String
aborts_if false;
-ensures result == x.type_name;
+ensures result == self.type_name;
diff --git a/aptos-move/framework/aptos-stdlib/doc/big_vector.md b/aptos-move/framework/aptos-stdlib/doc/big_vector.md
index cd3c8996c6564..7d785a5b730a1 100644
--- a/aptos-move/framework/aptos-stdlib/doc/big_vector.md
+++ b/aptos-move/framework/aptos-stdlib/doc/big_vector.md
@@ -197,11 +197,11 @@ Create a vector of length 1 containing the passed in element.
## Function `destroy_empty`
-Destroy the vector v.
-Aborts if v is not empty.
+Destroy the vector self.
+Aborts if self is not empty.
-public fun destroy_empty<T>(v: big_vector::BigVector<T>)
+public fun destroy_empty<T>(self: big_vector::BigVector<T>)
@@ -210,9 +210,9 @@ Aborts if v is not empty.
Implementation
-public fun destroy_empty<T>(v: BigVector<T>) {
- assert!(is_empty(&v), error::invalid_argument(EVECTOR_NOT_EMPTY));
- let BigVector { buckets, end_index: _, bucket_size: _ } = v;
+public fun destroy_empty<T>(self: BigVector<T>) {
+ assert!(is_empty(&self), error::invalid_argument(EVECTOR_NOT_EMPTY));
+ let BigVector { buckets, end_index: _, bucket_size: _ } = self;
table_with_length::destroy_empty(buckets);
}
@@ -225,10 +225,10 @@ Aborts if v is not empty.
## Function `destroy`
-Destroy the vector v if T has drop
+Destroy the vector self if T has drop
-public fun destroy<T: drop>(v: big_vector::BigVector<T>)
+public fun destroy<T: drop>(self: big_vector::BigVector<T>)
@@ -237,8 +237,8 @@ Destroy the vector v if T has drop
Implementation
-public fun destroy<T: drop>(v: BigVector<T>) {
- let BigVector { buckets, end_index, bucket_size: _ } = v;
+public fun destroy<T: drop>(self: BigVector<T>) {
+ let BigVector { buckets, end_index, bucket_size: _ } = self;
let i = 0;
while (end_index > 0) {
let num_elements = vector::length(&table_with_length::remove(&mut buckets, i));
@@ -257,11 +257,11 @@ Destroy the vector v if T has drop
## Function `borrow`
-Acquire an immutable reference to the ith element of the vector v.
+Acquire an immutable reference to the ith element of the vector self.
Aborts if i is out of bounds.
-public fun borrow<T>(v: &big_vector::BigVector<T>, i: u64): &T
+public fun borrow<T>(self: &big_vector::BigVector<T>, i: u64): &T
@@ -270,9 +270,9 @@ Aborts if i is out of bounds.
Implementation
-public fun borrow<T>(v: &BigVector<T>, i: u64): &T {
- assert!(i < length(v), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
- vector::borrow(table_with_length::borrow(&v.buckets, i / v.bucket_size), i % v.bucket_size)
+public fun borrow<T>(self: &BigVector<T>, i: u64): &T {
+ assert!(i < length(self), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
+ vector::borrow(table_with_length::borrow(&self.buckets, i / self.bucket_size), i % self.bucket_size)
}
@@ -284,11 +284,11 @@ Aborts if i is out of bounds.
## Function `borrow_mut`
-Return a mutable reference to the ith element in the vector v.
+Return a mutable reference to the ith element in the vector self.
Aborts if i is out of bounds.
-public fun borrow_mut<T>(v: &mut big_vector::BigVector<T>, i: u64): &mut T
+public fun borrow_mut<T>(self: &mut big_vector::BigVector<T>, i: u64): &mut T
@@ -297,9 +297,9 @@ Aborts if i is out of bounds.
Implementation
-public fun borrow_mut<T>(v: &mut BigVector<T>, i: u64): &mut T {
- assert!(i < length(v), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
- vector::borrow_mut(table_with_length::borrow_mut(&mut v.buckets, i / v.bucket_size), i % v.bucket_size)
+public fun borrow_mut<T>(self: &mut BigVector<T>, i: u64): &mut T {
+ assert!(i < length(self), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
+ vector::borrow_mut(table_with_length::borrow_mut(&mut self.buckets, i / self.bucket_size), i % self.bucket_size)
}
@@ -311,12 +311,12 @@ Aborts if i is out of bounds.
## Function `append`
-Empty and destroy the other vector, and push each of the elements in the other vector onto the lhs vector in the
+Empty and destroy the other vector, and push each of the elements in the other vector onto the self vector in the
same order as they occurred in other.
Disclaimer: This function is costly. Use it at your own discretion.
-public fun append<T: store>(lhs: &mut big_vector::BigVector<T>, other: big_vector::BigVector<T>)
+public fun append<T: store>(self: &mut big_vector::BigVector<T>, other: big_vector::BigVector<T>)
@@ -325,16 +325,16 @@ Disclaimer: This function is costly. Use it at your own discretion.
Implementation
-public fun append<T: store>(lhs: &mut BigVector<T>, other: BigVector<T>) {
+public fun append<T: store>(self: &mut BigVector<T>, other: BigVector<T>) {
let other_len = length(&other);
let half_other_len = other_len / 2;
let i = 0;
while (i < half_other_len) {
- push_back(lhs, swap_remove(&mut other, i));
+ push_back(self, swap_remove(&mut other, i));
i = i + 1;
};
while (i < other_len) {
- push_back(lhs, pop_back(&mut other));
+ push_back(self, pop_back(&mut other));
i = i + 1;
};
destroy_empty(other);
@@ -349,11 +349,11 @@ Disclaimer: This function is costly. Use it at your own discretion.
## Function `push_back`
-Add element val to the end of the vector v. It grows the buckets when the current buckets are full.
+Add element val to the end of the vector self. It grows the buckets when the current buckets are full.
This operation will cost more gas when it adds new bucket.
-public fun push_back<T: store>(v: &mut big_vector::BigVector<T>, val: T)
+public fun push_back<T: store>(self: &mut big_vector::BigVector<T>, val: T)
@@ -362,15 +362,15 @@ This operation will cost more gas when it adds new bucket.
Implementation
-public fun push_back<T: store>(v: &mut BigVector<T>, val: T) {
- let num_buckets = table_with_length::length(&v.buckets);
- if (v.end_index == num_buckets * v.bucket_size) {
- table_with_length::add(&mut v.buckets, num_buckets, vector::empty());
- vector::push_back(table_with_length::borrow_mut(&mut v.buckets, num_buckets), val);
+public fun push_back<T: store>(self: &mut BigVector<T>, val: T) {
+ let num_buckets = table_with_length::length(&self.buckets);
+ if (self.end_index == num_buckets * self.bucket_size) {
+ table_with_length::add(&mut self.buckets, num_buckets, vector::empty());
+ vector::push_back(table_with_length::borrow_mut(&mut self.buckets, num_buckets), val);
} else {
- vector::push_back(table_with_length::borrow_mut(&mut v.buckets, num_buckets - 1), val);
+ vector::push_back(table_with_length::borrow_mut(&mut self.buckets, num_buckets - 1), val);
};
- v.end_index = v.end_index + 1;
+ self.end_index = self.end_index + 1;
}
@@ -382,12 +382,12 @@ This operation will cost more gas when it adds new bucket.
## Function `pop_back`
-Pop an element from the end of vector v. It doesn't shrink the buckets even if they're empty.
+Pop an element from the end of vector self. It doesn't shrink the buckets even if they're empty.
Call shrink_to_fit explicity to deallocate empty buckets.
-Aborts if v is empty.
+Aborts if self is empty.
-public fun pop_back<T>(v: &mut big_vector::BigVector<T>): T
+public fun pop_back<T>(self: &mut big_vector::BigVector<T>): T
@@ -396,17 +396,17 @@ Aborts if v is empty.
Implementation
-public fun pop_back<T>(v: &mut BigVector<T>): T {
- assert!(!is_empty(v), error::invalid_state(EVECTOR_EMPTY));
- let num_buckets = table_with_length::length(&v.buckets);
- let last_bucket = table_with_length::borrow_mut(&mut v.buckets, num_buckets - 1);
+public fun pop_back<T>(self: &mut BigVector<T>): T {
+ assert!(!is_empty(self), error::invalid_state(EVECTOR_EMPTY));
+ let num_buckets = table_with_length::length(&self.buckets);
+ let last_bucket = table_with_length::borrow_mut(&mut self.buckets, num_buckets - 1);
let val = vector::pop_back(last_bucket);
// Shrink the table if the last vector is empty.
if (vector::is_empty(last_bucket)) {
move last_bucket;
- vector::destroy_empty(table_with_length::remove(&mut v.buckets, num_buckets - 1));
+ vector::destroy_empty(table_with_length::remove(&mut self.buckets, num_buckets - 1));
};
- v.end_index = v.end_index - 1;
+ self.end_index = self.end_index - 1;
val
}
@@ -419,12 +419,12 @@ Aborts if v is empty.
## Function `remove`
-Remove the element at index i in the vector v and return the owned value that was previously stored at i in v.
+Remove the element at index i in the vector v and return the owned value that was previously stored at i in self.
All elements occurring at indices greater than i will be shifted down by 1. Will abort if i is out of bounds.
Disclaimer: This function is costly. Use it at your own discretion.
-public fun remove<T>(v: &mut big_vector::BigVector<T>, i: u64): T
+public fun remove<T>(self: &mut big_vector::BigVector<T>, i: u64): T
@@ -433,28 +433,28 @@ Disclaimer: This function is costly. Use it at your own discretion.
Implementation
-public fun remove<T>(v: &mut BigVector<T>, i: u64): T {
- let len = length(v);
+public fun remove<T>(self: &mut BigVector<T>, i: u64): T {
+ let len = length(self);
assert!(i < len, error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
- let num_buckets = table_with_length::length(&v.buckets);
- let cur_bucket_index = i / v.bucket_size + 1;
- let cur_bucket = table_with_length::borrow_mut(&mut v.buckets, cur_bucket_index - 1);
- let res = vector::remove(cur_bucket, i % v.bucket_size);
- v.end_index = v.end_index - 1;
+ let num_buckets = table_with_length::length(&self.buckets);
+ let cur_bucket_index = i / self.bucket_size + 1;
+ let cur_bucket = table_with_length::borrow_mut(&mut self.buckets, cur_bucket_index - 1);
+ let res = vector::remove(cur_bucket, i % self.bucket_size);
+ self.end_index = self.end_index - 1;
move cur_bucket;
while ({
spec {
invariant cur_bucket_index <= num_buckets;
- invariant table_with_length::spec_len(v.buckets) == num_buckets;
+ invariant table_with_length::spec_len(self.buckets) == num_buckets;
};
(cur_bucket_index < num_buckets)
}) {
// remove one element from the start of current vector
- let cur_bucket = table_with_length::borrow_mut(&mut v.buckets, cur_bucket_index);
+ let cur_bucket = table_with_length::borrow_mut(&mut self.buckets, cur_bucket_index);
let t = vector::remove(cur_bucket, 0);
move cur_bucket;
// and put it at the end of the last one
- let prev_bucket = table_with_length::borrow_mut(&mut v.buckets, cur_bucket_index - 1);
+ let prev_bucket = table_with_length::borrow_mut(&mut self.buckets, cur_bucket_index - 1);
vector::push_back(prev_bucket, t);
cur_bucket_index = cur_bucket_index + 1;
};
@@ -463,10 +463,10 @@ Disclaimer: This function is costly. Use it at your own discretion.
};
// Shrink the table if the last vector is empty.
- let last_bucket = table_with_length::borrow_mut(&mut v.buckets, num_buckets - 1);
+ let last_bucket = table_with_length::borrow_mut(&mut self.buckets, num_buckets - 1);
if (vector::is_empty(last_bucket)) {
move last_bucket;
- vector::destroy_empty(table_with_length::remove(&mut v.buckets, num_buckets - 1));
+ vector::destroy_empty(table_with_length::remove(&mut self.buckets, num_buckets - 1));
};
res
@@ -481,12 +481,12 @@ Disclaimer: This function is costly. Use it at your own discretion.
## Function `swap_remove`
-Swap the ith element of the vector v with the last element and then pop the vector.
+Swap the ith element of the vector self with the last element and then pop the vector.
This is O(1), but does not preserve ordering of elements in the vector.
Aborts if i is out of bounds.
-public fun swap_remove<T>(v: &mut big_vector::BigVector<T>, i: u64): T
+public fun swap_remove<T>(self: &mut big_vector::BigVector<T>, i: u64): T
@@ -495,20 +495,20 @@ Aborts if i is out of bounds.
Implementation
-public fun swap_remove<T>(v: &mut BigVector<T>, i: u64): T {
- assert!(i < length(v), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
- let last_val = pop_back(v);
+public fun swap_remove<T>(self: &mut BigVector<T>, i: u64): T {
+ assert!(i < length(self), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
+ let last_val = pop_back(self);
// if the requested value is the last one, return it
- if (v.end_index == i) {
+ if (self.end_index == i) {
return last_val
};
// because the lack of mem::swap, here we swap remove the requested value from the bucket
// and append the last_val to the bucket then swap the last bucket val back
- let bucket = table_with_length::borrow_mut(&mut v.buckets, i / v.bucket_size);
+ let bucket = table_with_length::borrow_mut(&mut self.buckets, i / self.bucket_size);
let bucket_len = vector::length(bucket);
- let val = vector::swap_remove(bucket, i % v.bucket_size);
+ let val = vector::swap_remove(bucket, i % self.bucket_size);
vector::push_back(bucket, last_val);
- vector::swap(bucket, i % v.bucket_size, bucket_len - 1);
+ vector::swap(bucket, i % self.bucket_size, bucket_len - 1);
val
}
@@ -521,11 +521,11 @@ Aborts if i is out of bounds.
## Function `swap`
-Swap the elements at the i'th and j'th indices in the vector v. Will abort if either of i or j are out of bounds
-for v.
+Swap the elements at the i'th and j'th indices in the vector self. Will abort if either of i or j are out of bounds
+for self.
-public fun swap<T>(v: &mut big_vector::BigVector<T>, i: u64, j: u64)
+public fun swap<T>(self: &mut big_vector::BigVector<T>, i: u64, j: u64)
@@ -534,19 +534,19 @@ for v.
Implementation
-public fun swap<T>(v: &mut BigVector<T>, i: u64, j: u64) {
- assert!(i < length(v) && j < length(v), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
- let i_bucket_index = i / v.bucket_size;
- let j_bucket_index = j / v.bucket_size;
- let i_vector_index = i % v.bucket_size;
- let j_vector_index = j % v.bucket_size;
+public fun swap<T>(self: &mut BigVector<T>, i: u64, j: u64) {
+ assert!(i < length(self) && j < length(self), error::invalid_argument(EINDEX_OUT_OF_BOUNDS));
+ let i_bucket_index = i / self.bucket_size;
+ let j_bucket_index = j / self.bucket_size;
+ let i_vector_index = i % self.bucket_size;
+ let j_vector_index = j % self.bucket_size;
if (i_bucket_index == j_bucket_index) {
- vector::swap(table_with_length::borrow_mut(&mut v.buckets, i_bucket_index), i_vector_index, j_vector_index);
+ vector::swap(table_with_length::borrow_mut(&mut self.buckets, i_bucket_index), i_vector_index, j_vector_index);
return
};
// If i and j are in different buckets, take the buckets out first for easy mutation.
- let bucket_i = table_with_length::remove(&mut v.buckets, i_bucket_index);
- let bucket_j = table_with_length::remove(&mut v.buckets, j_bucket_index);
+ let bucket_i = table_with_length::remove(&mut self.buckets, i_bucket_index);
+ let bucket_j = table_with_length::remove(&mut self.buckets, j_bucket_index);
// Get the elements from buckets by calling `swap_remove`.
let element_i = vector::swap_remove(&mut bucket_i, i_vector_index);
let element_j = vector::swap_remove(&mut bucket_j, j_vector_index);
@@ -559,8 +559,8 @@ for v.
vector::swap(&mut bucket_i, i_vector_index, last_index_in_bucket_i);
vector::swap(&mut bucket_j, j_vector_index, last_index_in_bucket_j);
// Add back the buckets.
- table_with_length::add(&mut v.buckets, i_bucket_index, bucket_i);
- table_with_length::add(&mut v.buckets, j_bucket_index, bucket_j);
+ table_with_length::add(&mut self.buckets, i_bucket_index, bucket_i);
+ table_with_length::add(&mut self.buckets, j_bucket_index, bucket_j);
}
@@ -572,11 +572,11 @@ for v.
## Function `reverse`
-Reverse the order of the elements in the vector v in-place.
+Reverse the order of the elements in the vector self in-place.
Disclaimer: This function is costly. Use it at your own discretion.
-public fun reverse<T>(v: &mut big_vector::BigVector<T>)
+public fun reverse<T>(self: &mut big_vector::BigVector<T>)
@@ -585,17 +585,17 @@ Disclaimer: This function is costly. Use it at your own discretion.
Implementation
-public fun reverse<T>(v: &mut BigVector<T>) {
+public fun reverse<T>(self: &mut BigVector<T>) {
let new_buckets = vector[];
let push_bucket = vector[];
- let num_buckets = table_with_length::length(&v.buckets);
+ let num_buckets = table_with_length::length(&self.buckets);
let num_buckets_left = num_buckets;
while (num_buckets_left > 0) {
- let pop_bucket = table_with_length::remove(&mut v.buckets, num_buckets_left - 1);
+ let pop_bucket = table_with_length::remove(&mut self.buckets, num_buckets_left - 1);
vector::for_each_reverse(pop_bucket, |val| {
vector::push_back(&mut push_bucket, val);
- if (vector::length(&push_bucket) == v.bucket_size) {
+ if (vector::length(&push_bucket) == self.bucket_size) {
vector::push_back(&mut new_buckets, push_bucket);
push_bucket = vector[];
};
@@ -611,9 +611,9 @@ Disclaimer: This function is costly. Use it at your own discretion.
vector::reverse(&mut new_buckets);
let i = 0;
- assert!(table_with_length::length(&v.buckets) == 0, 0);
+ assert!(table_with_length::length(&self.buckets) == 0, 0);
while (i < num_buckets) {
- table_with_length::add(&mut v.buckets, i, vector::pop_back(&mut new_buckets));
+ table_with_length::add(&mut self.buckets, i, vector::pop_back(&mut new_buckets));
i = i + 1;
};
vector::destroy_empty(new_buckets);
@@ -628,12 +628,12 @@ Disclaimer: This function is costly. Use it at your own discretion.
## Function `index_of`
-Return the index of the first occurrence of an element in v that is equal to e. Returns (true, index) if such an
+Return the index of the first occurrence of an element in self that is equal to e. Returns (true, index) if such an
element was found, and (false, 0) otherwise.
Disclaimer: This function is costly. Use it at your own discretion.
-public fun index_of<T>(v: &big_vector::BigVector<T>, val: &T): (bool, u64)
+public fun index_of<T>(self: &big_vector::BigVector<T>, val: &T): (bool, u64)
@@ -642,14 +642,14 @@ Disclaimer: This function is costly. Use it at your own discretion.
Implementation
-public fun index_of<T>(v: &BigVector<T>, val: &T): (bool, u64) {
- let num_buckets = table_with_length::length(&v.buckets);
+public fun index_of<T>(self: &BigVector<T>, val: &T): (bool, u64) {
+ let num_buckets = table_with_length::length(&self.buckets);
let bucket_index = 0;
while (bucket_index < num_buckets) {
- let cur = table_with_length::borrow(&v.buckets, bucket_index);
+ let cur = table_with_length::borrow(&self.buckets, bucket_index);
let (found, i) = vector::index_of(cur, val);
if (found) {
- return (true, bucket_index * v.bucket_size + i)
+ return (true, bucket_index * self.bucket_size + i)
};
bucket_index = bucket_index + 1;
};
@@ -665,11 +665,11 @@ Disclaimer: This function is costly. Use it at your own discretion.
## Function `contains`
-Return if an element equal to e exists in the vector v.
+Return if an element equal to e exists in the vector self.
Disclaimer: This function is costly. Use it at your own discretion.
-public fun contains<T>(v: &big_vector::BigVector<T>, val: &T): bool
+public fun contains<T>(self: &big_vector::BigVector<T>, val: &T): bool
@@ -678,9 +678,9 @@ Disclaimer: This function is costly. Use it at your own discretion.
Implementation
-public fun contains<T>(v: &BigVector<T>, val: &T): bool {
- if (is_empty(v)) return false;
- let (exist, _) = index_of(v, val);
+public fun contains<T>(self: &BigVector<T>, val: &T): bool {
+ if (is_empty(self)) return false;
+ let (exist, _) = index_of(self, val);
exist
}
@@ -698,7 +698,7 @@ atomic view of the whole vector.
Disclaimer: This function may be costly as the big vector may be huge in size. Use it at your own discretion.
-public fun to_vector<T: copy>(v: &big_vector::BigVector<T>): vector<T>
+public fun to_vector<T: copy>(self: &big_vector::BigVector<T>): vector<T>
@@ -707,12 +707,12 @@ Disclaimer: This function may be costly as the big vector may be huge in size. U
Implementation
-public fun to_vector<T: copy>(v: &BigVector<T>): vector<T> {
+public fun to_vector<T: copy>(self: &BigVector<T>): vector<T> {
let res = vector[];
- let num_buckets = table_with_length::length(&v.buckets);
+ let num_buckets = table_with_length::length(&self.buckets);
let i = 0;
while (i < num_buckets) {
- vector::append(&mut res, *table_with_length::borrow(&v.buckets, i));
+ vector::append(&mut res, *table_with_length::borrow(&self.buckets, i));
i = i + 1;
};
res
@@ -730,7 +730,7 @@ Disclaimer: This function may be costly as the big vector may be huge in size. U
Return the length of the vector.
-public fun length<T>(v: &big_vector::BigVector<T>): u64
+public fun length<T>(self: &big_vector::BigVector<T>): u64
@@ -739,8 +739,8 @@ Return the length of the vector.
Implementation
-public fun length<T>(v: &BigVector<T>): u64 {
- v.end_index
+public fun length<T>(self: &BigVector<T>): u64 {
+ self.end_index
}
@@ -755,7 +755,7 @@ Return the length of the vector.
Return true if the vector v has no elements and false otherwise.
-public fun is_empty<T>(v: &big_vector::BigVector<T>): bool
+public fun is_empty<T>(self: &big_vector::BigVector<T>): bool
@@ -764,8 +764,8 @@ Return true if the vector v has no elements and
Implementation
-public fun is_empty<T>(v: &BigVector<T>): bool {
- length(v) == 0
+public fun is_empty<T>(self: &BigVector<T>): bool {
+ length(self) == 0
}
@@ -876,13 +876,13 @@ Return true if the vector v has no elements and
### Function `destroy_empty`
-public fun destroy_empty<T>(v: big_vector::BigVector<T>)
+public fun destroy_empty<T>(self: big_vector::BigVector<T>)
-aborts_if !is_empty(v);
+aborts_if !is_empty(self);
@@ -892,14 +892,14 @@ Return true if the vector v has no elements and
### Function `borrow`
-public fun borrow<T>(v: &big_vector::BigVector<T>, i: u64): &T
+public fun borrow<T>(self: &big_vector::BigVector<T>, i: u64): &T
-aborts_if i >= length(v);
-ensures result == spec_at(v, i);
+aborts_if i >= length(self);
+ensures result == spec_at(self, i);
@@ -909,14 +909,14 @@ Return true if the vector v has no elements and
### Function `borrow_mut`
-public fun borrow_mut<T>(v: &mut big_vector::BigVector<T>, i: u64): &mut T
+public fun borrow_mut<T>(self: &mut big_vector::BigVector<T>, i: u64): &mut T
-aborts_if i >= length(v);
-ensures result == spec_at(v, i);
+aborts_if i >= length(self);
+ensures result == spec_at(self, i);
@@ -926,7 +926,7 @@ Return true if the vector v has no elements and
### Function `append`
-public fun append<T: store>(lhs: &mut big_vector::BigVector<T>, other: big_vector::BigVector<T>)
+public fun append<T: store>(self: &mut big_vector::BigVector<T>, other: big_vector::BigVector<T>)
@@ -942,19 +942,19 @@ Return true if the vector v has no elements and
### Function `push_back`
-public fun push_back<T: store>(v: &mut big_vector::BigVector<T>, val: T)
+public fun push_back<T: store>(self: &mut big_vector::BigVector<T>, val: T)
-let num_buckets = spec_table_len(v.buckets);
+let num_buckets = spec_table_len(self.buckets);
include PushbackAbortsIf<T>;
-ensures length(v) == length(old(v)) + 1;
-ensures v.end_index == old(v.end_index) + 1;
-ensures spec_at(v, v.end_index-1) == val;
-ensures forall i in 0..v.end_index-1: spec_at(v, i) == spec_at(old(v), i);
-ensures v.bucket_size == old(v).bucket_size;
+ensures length(self) == length(old(self)) + 1;
+ensures self.end_index == old(self.end_index) + 1;
+ensures spec_at(self, self.end_index-1) == val;
+ensures forall i in 0..self.end_index-1: spec_at(self, i) == spec_at(old(self), i);
+ensures self.bucket_size == old(self).bucket_size;
@@ -964,10 +964,10 @@ Return true if the vector v has no elements and
schema PushbackAbortsIf<T> {
- v: BigVector<T>;
- let num_buckets = spec_table_len(v.buckets);
- aborts_if num_buckets * v.bucket_size > MAX_U64;
- aborts_if v.end_index + 1 > MAX_U64;
+ self: BigVector<T>;
+ let num_buckets = spec_table_len(self.buckets);
+ aborts_if num_buckets * self.bucket_size > MAX_U64;
+ aborts_if self.end_index + 1 > MAX_U64;
}
@@ -978,16 +978,16 @@ Return true if the vector v has no elements and
### Function `pop_back`
-public fun pop_back<T>(v: &mut big_vector::BigVector<T>): T
+public fun pop_back<T>(self: &mut big_vector::BigVector<T>): T
-aborts_if is_empty(v);
-ensures length(v) == length(old(v)) - 1;
-ensures result == old(spec_at(v, v.end_index-1));
-ensures forall i in 0..v.end_index: spec_at(v, i) == spec_at(old(v), i);
+aborts_if is_empty(self);
+ensures length(self) == length(old(self)) - 1;
+ensures result == old(spec_at(self, self.end_index-1));
+ensures forall i in 0..self.end_index: spec_at(self, i) == spec_at(old(self), i);
@@ -997,7 +997,7 @@ Return true if the vector v has no elements and
### Function `remove`
-public fun remove<T>(v: &mut big_vector::BigVector<T>, i: u64): T
+public fun remove<T>(self: &mut big_vector::BigVector<T>, i: u64): T
@@ -1013,16 +1013,16 @@ Return true if the vector v has no elements and
### Function `swap_remove`
-public fun swap_remove<T>(v: &mut big_vector::BigVector<T>, i: u64): T
+public fun swap_remove<T>(self: &mut big_vector::BigVector<T>, i: u64): T
pragma verify_duration_estimate = 120;
-aborts_if i >= length(v);
-ensures length(v) == length(old(v)) - 1;
-ensures result == spec_at(old(v), i);
+aborts_if i >= length(self);
+ensures length(self) == length(old(self)) - 1;
+ensures result == spec_at(old(self), i);
@@ -1032,20 +1032,20 @@ Return true if the vector v has no elements and
### Function `swap`
-public fun swap<T>(v: &mut big_vector::BigVector<T>, i: u64, j: u64)
+public fun swap<T>(self: &mut big_vector::BigVector<T>, i: u64, j: u64)
pragma verify_duration_estimate = 1000;
-aborts_if i >= length(v) || j >= length(v);
-ensures length(v) == length(old(v));
-ensures spec_at(v, i) == spec_at(old(v), j);
-ensures spec_at(v, j) == spec_at(old(v), i);
-ensures forall idx in 0..length(v)
+aborts_if i >= length(self) || j >= length(self);
+ensures length(self) == length(old(self));
+ensures spec_at(self, i) == spec_at(old(self), j);
+ensures spec_at(self, j) == spec_at(old(self), i);
+ensures forall idx in 0..length(self)
where idx != i && idx != j:
- spec_at(v, idx) == spec_at(old(v), idx);
+ spec_at(self, idx) == spec_at(old(self), idx);
@@ -1055,7 +1055,7 @@ Return true if the vector v has no elements and
### Function `reverse`
-public fun reverse<T>(v: &mut big_vector::BigVector<T>)
+public fun reverse<T>(self: &mut big_vector::BigVector<T>)
@@ -1071,7 +1071,7 @@ Return true if the vector v has no elements and
### Function `index_of`
-public fun index_of<T>(v: &big_vector::BigVector<T>, val: &T): (bool, u64)
+public fun index_of<T>(self: &big_vector::BigVector<T>, val: &T): (bool, u64)
diff --git a/aptos-move/framework/aptos-stdlib/doc/capability.md b/aptos-move/framework/aptos-stdlib/doc/capability.md
index 5daf02b7ad916..2d2aef644e829 100644
--- a/aptos-move/framework/aptos-stdlib/doc/capability.md
+++ b/aptos-move/framework/aptos-stdlib/doc/capability.md
@@ -400,7 +400,7 @@ Returns the root address associated with the given capability token. Only the ow
of the feature can do this.
-public fun root_addr<Feature>(cap: capability::Cap<Feature>, _feature_witness: &Feature): address
+public fun root_addr<Feature>(self: capability::Cap<Feature>, _feature_witness: &Feature): address
@@ -409,8 +409,8 @@ of the feature can do this.
Implementation
-public fun root_addr<Feature>(cap: Cap<Feature>, _feature_witness: &Feature): address {
- cap.root
+public fun root_addr<Feature>(self: Cap<Feature>, _feature_witness: &Feature): address {
+ self.root
}
@@ -425,7 +425,7 @@ of the feature can do this.
Returns the root address associated with the given linear capability token.
-public fun linear_root_addr<Feature>(cap: capability::LinearCap<Feature>, _feature_witness: &Feature): address
+public fun linear_root_addr<Feature>(self: capability::LinearCap<Feature>, _feature_witness: &Feature): address
@@ -434,8 +434,8 @@ Returns the root address associated with the given linear capability token.
Implementation
-public fun linear_root_addr<Feature>(cap: LinearCap<Feature>, _feature_witness: &Feature): address {
- cap.root
+public fun linear_root_addr<Feature>(self: LinearCap<Feature>, _feature_witness: &Feature): address {
+ self.root
}
@@ -451,7 +451,7 @@ Registers a delegation relation. If the relation already exists, this function d
nothing.
-public fun delegate<Feature>(cap: capability::Cap<Feature>, _feature_witness: &Feature, to: &signer)
+public fun delegate<Feature>(self: capability::Cap<Feature>, _feature_witness: &Feature, to: &signer)
@@ -460,12 +460,12 @@ nothing.
Implementation
-public fun delegate<Feature>(cap: Cap<Feature>, _feature_witness: &Feature, to: &signer)
+public fun delegate<Feature>(self: Cap<Feature>, _feature_witness: &Feature, to: &signer)
acquires CapState {
let addr = signer::address_of(to);
if (exists<CapDelegateState<Feature>>(addr)) return;
- move_to(to, CapDelegateState<Feature> { root: cap.root });
- add_element(&mut borrow_global_mut<CapState<Feature>>(cap.root).delegates, addr);
+ move_to(to, CapDelegateState<Feature> { root: self.root });
+ add_element(&mut borrow_global_mut<CapState<Feature>>(self.root).delegates, addr);
}
@@ -480,7 +480,7 @@ nothing.
Revokes a delegation relation. If no relation exists, this function does nothing.
-public fun revoke<Feature>(cap: capability::Cap<Feature>, _feature_witness: &Feature, from: address)
+public fun revoke<Feature>(self: capability::Cap<Feature>, _feature_witness: &Feature, from: address)
@@ -489,12 +489,12 @@ Revokes a delegation relation. If no relation exists, this function does nothing
Implementation
-public fun revoke<Feature>(cap: Cap<Feature>, _feature_witness: &Feature, from: address)
+public fun revoke<Feature>(self: Cap<Feature>, _feature_witness: &Feature, from: address)
acquires CapState, CapDelegateState
{
if (!exists<CapDelegateState<Feature>>(from)) return;
let CapDelegateState { root: _root } = move_from<CapDelegateState<Feature>>(from);
- remove_element(&mut borrow_global_mut<CapState<Feature>>(cap.root).delegates, &from);
+ remove_element(&mut borrow_global_mut<CapState<Feature>>(self.root).delegates, &from);
}
@@ -676,7 +676,7 @@ Helper specification function to check whether a delegated capability exists at
### Function `delegate`
-public fun delegate<Feature>(cap: capability::Cap<Feature>, _feature_witness: &Feature, to: &signer)
+public fun delegate<Feature>(self: capability::Cap<Feature>, _feature_witness: &Feature, to: &signer)
@@ -684,8 +684,8 @@ Helper specification function to check whether a delegated capability exists at
let addr = signer::address_of(to);
ensures spec_has_delegate_cap<Feature>(addr);
-ensures !old(spec_has_delegate_cap<Feature>(addr)) ==> global<CapDelegateState<Feature>>(addr).root == cap.root;
-ensures !old(spec_has_delegate_cap<Feature>(addr)) ==> vector::spec_contains(spec_delegates<Feature>(cap.root), addr);
+ensures !old(spec_has_delegate_cap<Feature>(addr)) ==> global<CapDelegateState<Feature>>(addr).root == self.root;
+ensures !old(spec_has_delegate_cap<Feature>(addr)) ==> vector::spec_contains(spec_delegates<Feature>(self.root), addr);
@@ -695,7 +695,7 @@ Helper specification function to check whether a delegated capability exists at
### Function `revoke`
-public fun revoke<Feature>(cap: capability::Cap<Feature>, _feature_witness: &Feature, from: address)
+public fun revoke<Feature>(self: capability::Cap<Feature>, _feature_witness: &Feature, from: address)
diff --git a/aptos-move/framework/aptos-stdlib/doc/comparator.md b/aptos-move/framework/aptos-stdlib/doc/comparator.md
index 1949f5812c5aa..527e13d59a077 100644
--- a/aptos-move/framework/aptos-stdlib/doc/comparator.md
+++ b/aptos-move/framework/aptos-stdlib/doc/comparator.md
@@ -92,7 +92,7 @@ Provides a framework for comparing two elements
-public fun is_equal(result: &comparator::Result): bool
+public fun is_equal(self: &comparator::Result): bool
@@ -101,8 +101,8 @@ Provides a framework for comparing two elements
Implementation
-public fun is_equal(result: &Result): bool {
- result.inner == EQUAL
+public fun is_equal(self: &Result): bool {
+ self.inner == EQUAL
}
@@ -116,7 +116,7 @@ Provides a framework for comparing two elements
-public fun is_smaller_than(result: &comparator::Result): bool
+public fun is_smaller_than(self: &comparator::Result): bool
@@ -125,8 +125,8 @@ Provides a framework for comparing two elements
Implementation
-public fun is_smaller_than(result: &Result): bool {
- result.inner == SMALLER
+public fun is_smaller_than(self: &Result): bool {
+ self.inner == SMALLER
}
@@ -140,7 +140,7 @@ Provides a framework for comparing two elements
-public fun is_greater_than(result: &comparator::Result): bool
+public fun is_greater_than(self: &comparator::Result): bool
@@ -149,8 +149,8 @@ Provides a framework for comparing two elements
Implementation
-public fun is_greater_than(result: &Result): bool {
- result.inner == GREATER
+public fun is_greater_than(self: &Result): bool {
+ self.inner == GREATER
}
@@ -268,14 +268,14 @@ Provides a framework for comparing two elements
### Function `is_equal`
-public fun is_equal(result: &comparator::Result): bool
+public fun is_equal(self: &comparator::Result): bool
aborts_if false;
-let res = result;
+let res = self;
ensures result == (res.inner == EQUAL);
@@ -286,14 +286,14 @@ Provides a framework for comparing two elements
### Function `is_smaller_than`
-public fun is_smaller_than(result: &comparator::Result): bool
+public fun is_smaller_than(self: &comparator::Result): bool
aborts_if false;
-let res = result;
+let res = self;
ensures result == (res.inner == SMALLER);
@@ -304,14 +304,14 @@ Provides a framework for comparing two elements
### Function `is_greater_than`
-public fun is_greater_than(result: &comparator::Result): bool
+public fun is_greater_than(self: &comparator::Result): bool
aborts_if false;
-let res = result;
+let res = self;
ensures result == (res.inner == GREATER);
diff --git a/aptos-move/framework/aptos-stdlib/doc/copyable_any.md b/aptos-move/framework/aptos-stdlib/doc/copyable_any.md
index 7ac120437e652..ab34a75e7e8ed 100644
--- a/aptos-move/framework/aptos-stdlib/doc/copyable_any.md
+++ b/aptos-move/framework/aptos-stdlib/doc/copyable_any.md
@@ -110,7 +110,7 @@ also required from T.
Unpack a value from the Any representation. This aborts if the value has not the expected type T.
-public fun unpack<T>(x: copyable_any::Any): T
+public fun unpack<T>(self: copyable_any::Any): T
@@ -119,9 +119,9 @@ Unpack a value from the Any
Implementation
-public fun unpack<T>(x: Any): T {
- assert!(type_info::type_name<T>() == x.type_name, error::invalid_argument(ETYPE_MISMATCH));
- from_bytes<T>(x.data)
+public fun unpack<T>(self: Any): T {
+ assert!(type_info::type_name<T>() == self.type_name, error::invalid_argument(ETYPE_MISMATCH));
+ from_bytes<T>(self.data)
}
@@ -136,7 +136,7 @@ Unpack a value from the Any
Returns the type name of this Any
-public fun type_name(x: ©able_any::Any): &string::String
+public fun type_name(self: ©able_any::Any): &string::String
@@ -145,8 +145,8 @@ Returns the type name of this Any
Implementation
-public fun type_name(x: &Any): &String {
- &x.type_name
+public fun type_name(self: &Any): &String {
+ &self.type_name
}
@@ -186,14 +186,14 @@ Returns the type name of this Any
### Function `unpack`
-public fun unpack<T>(x: copyable_any::Any): T
+public fun unpack<T>(self: copyable_any::Any): T
include UnpackAbortsIf<T>;
-ensures result == from_bcs::deserialize<T>(x.data);
+ensures result == from_bcs::deserialize<T>(self.data);
@@ -203,9 +203,9 @@ Returns the type name of this Any
schema UnpackAbortsIf<T> {
- x: Any;
- aborts_if type_info::type_name<T>() != x.type_name;
- aborts_if !from_bcs::deserializable<T>(x.data);
+ self: Any;
+ aborts_if type_info::type_name<T>() != self.type_name;
+ aborts_if !from_bcs::deserializable<T>(self.data);
}
@@ -216,14 +216,14 @@ Returns the type name of this Any
### Function `type_name`
-public fun type_name(x: ©able_any::Any): &string::String
+public fun type_name(self: ©able_any::Any): &string::String
aborts_if false;
-ensures result == x.type_name;
+ensures result == self.type_name;
diff --git a/aptos-move/framework/aptos-stdlib/doc/fixed_point64.md b/aptos-move/framework/aptos-stdlib/doc/fixed_point64.md
index 642601dc34a1b..aa572e69c7a73 100644
--- a/aptos-move/framework/aptos-stdlib/doc/fixed_point64.md
+++ b/aptos-move/framework/aptos-stdlib/doc/fixed_point64.md
@@ -169,10 +169,10 @@ The computed ratio when converting to a sub(x: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
+public fun sub(self: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
@@ -181,8 +181,8 @@ Returns x - y. x must be not less than y.
Implementation
-public fun sub(x: FixedPoint64, y: FixedPoint64): FixedPoint64 {
- let x_raw = get_raw_value(x);
+public fun sub(self: FixedPoint64, y: FixedPoint64): FixedPoint64 {
+ let x_raw = get_raw_value(self);
let y_raw = get_raw_value(y);
assert!(x_raw >= y_raw, ENEGATIVE_RESULT);
create_from_raw_value(x_raw - y_raw)
@@ -197,10 +197,10 @@ Returns x - y. x must be not less than y.
## Function `add`
-Returns x + y. The result cannot be greater than MAX_U128.
+Returns self + y. The result cannot be greater than MAX_U128.
-public fun add(x: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
+public fun add(self: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
@@ -209,8 +209,8 @@ Returns x + y. The result cannot be greater than MAX_U128.
Implementation
-public fun add(x: FixedPoint64, y: FixedPoint64): FixedPoint64 {
- let x_raw = get_raw_value(x);
+public fun add(self: FixedPoint64, y: FixedPoint64): FixedPoint64 {
+ let x_raw = get_raw_value(self);
let y_raw = get_raw_value(y);
let result = (x_raw as u256) + (y_raw as u256);
assert!(result <= MAX_U128, ERATIO_OUT_OF_RANGE);
@@ -403,7 +403,7 @@ adding or subtracting FixedPoint64 values, can be done using the raw
values directly.
-public fun get_raw_value(num: fixed_point64::FixedPoint64): u128
+public fun get_raw_value(self: fixed_point64::FixedPoint64): u128
@@ -412,8 +412,8 @@ values directly.
Implementation
-public fun get_raw_value(num: FixedPoint64): u128 {
- num.value
+public fun get_raw_value(self: FixedPoint64): u128 {
+ self.value
}
@@ -428,7 +428,7 @@ values directly.
Returns true if the ratio is zero.
-public fun is_zero(num: fixed_point64::FixedPoint64): bool
+public fun is_zero(self: fixed_point64::FixedPoint64): bool
@@ -437,8 +437,8 @@ Returns true if the ratio is zero.
Implementation
-public fun is_zero(num: FixedPoint64): bool {
- num.value == 0
+public fun is_zero(self: FixedPoint64): bool {
+ self.value == 0
}
@@ -508,10 +508,10 @@ Returns the larger of the two FixedPoint64 numbers.
## Function `less_or_equal`
-Returns true if num1 <= num2
+Returns true if self <= num2
-public fun less_or_equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun less_or_equal(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -520,8 +520,8 @@ Returns true if num1 <= num2
Implementation
-public fun less_or_equal(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value <= num2.value
+public fun less_or_equal(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value <= num2.value
}
@@ -533,10 +533,10 @@ Returns true if num1 <= num2
## Function `less`
-Returns true if num1 < num2
+Returns true if self < num2
-public fun less(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun less(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -545,8 +545,8 @@ Returns true if num1 < num2
Implementation
-public fun less(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value < num2.value
+public fun less(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value < num2.value
}
@@ -558,10 +558,10 @@ Returns true if num1 < num2
## Function `greater_or_equal`
-Returns true if num1 >= num2
+Returns true if self >= num2
-public fun greater_or_equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun greater_or_equal(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -570,8 +570,8 @@ Returns true if num1 >= num2
Implementation
-public fun greater_or_equal(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value >= num2.value
+public fun greater_or_equal(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value >= num2.value
}
@@ -583,10 +583,10 @@ Returns true if num1 >= num2
## Function `greater`
-Returns true if num1 > num2
+Returns true if self > num2
-public fun greater(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun greater(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -595,8 +595,8 @@ Returns true if num1 > num2
Implementation
-public fun greater(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value > num2.value
+public fun greater(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value > num2.value
}
@@ -608,10 +608,10 @@ Returns true if num1 > num2
## Function `equal`
-Returns true if num1 = num2
+Returns true if self = num2
-public fun equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun equal(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -620,8 +620,8 @@ Returns true if num1 = num2
Implementation
-public fun equal(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value == num2.value
+public fun equal(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value == num2.value
}
@@ -633,10 +633,10 @@ Returns true if num1 = num2
## Function `almost_equal`
-Returns true if num1 almost equals to num2, which means abs(num1-num2) <= precision
+Returns true if self almost equals to num2, which means abs(num1-num2) <= precision
-public fun almost_equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64, precision: fixed_point64::FixedPoint64): bool
+public fun almost_equal(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64, precision: fixed_point64::FixedPoint64): bool
@@ -645,11 +645,11 @@ Returns true if num1 almost equals to num2, which means abs(num1-num2) <= precis
Implementation
-public fun almost_equal(num1: FixedPoint64, num2: FixedPoint64, precision: FixedPoint64): bool {
- if (num1.value > num2.value) {
- (num1.value - num2.value <= precision.value)
+public fun almost_equal(self: FixedPoint64, num2: FixedPoint64, precision: FixedPoint64): bool {
+ if (self.value > num2.value) {
+ (self.value - num2.value <= precision.value)
} else {
- (num2.value - num1.value <= precision.value)
+ (num2.value - self.value <= precision.value)
}
}
@@ -692,7 +692,7 @@ Create a fixedpoint value from a u128 value.
Returns the largest integer less than or equal to a given number.
-public fun floor(num: fixed_point64::FixedPoint64): u128
+public fun floor(self: fixed_point64::FixedPoint64): u128
@@ -701,8 +701,8 @@ Returns the largest integer less than or equal to a given number.
Implementation
-public fun floor(num: FixedPoint64): u128 {
- num.value >> 64
+public fun floor(self: FixedPoint64): u128 {
+ self.value >> 64
}
@@ -717,7 +717,7 @@ Returns the largest integer less than or equal to a given number.
Rounds up the given FixedPoint64 to the next largest integer.
-public fun ceil(num: fixed_point64::FixedPoint64): u128
+public fun ceil(self: fixed_point64::FixedPoint64): u128
@@ -726,9 +726,9 @@ Rounds up the given FixedPoint64 to the next largest integer.
Implementation
-public fun ceil(num: FixedPoint64): u128 {
- let floored_num = floor(num) << 64;
- if (num.value == floored_num) {
+public fun ceil(self: FixedPoint64): u128 {
+ let floored_num = floor(self) << 64;
+ if (self.value == floored_num) {
return floored_num >> 64
};
let val = ((floored_num as u256) + (1 << 64));
@@ -747,7 +747,7 @@ Rounds up the given FixedPoint64 to the next largest integer.
Returns the value of a FixedPoint64 to the nearest integer.
-public fun round(num: fixed_point64::FixedPoint64): u128
+public fun round(self: fixed_point64::FixedPoint64): u128
@@ -756,13 +756,13 @@ Returns the value of a FixedPoint64 to the nearest integer.
Implementation
-public fun round(num: FixedPoint64): u128 {
- let floored_num = floor(num) << 64;
+public fun round(self: FixedPoint64): u128 {
+ let floored_num = floor(self) << 64;
let boundary = floored_num + ((1 << 64) / 2);
- if (num.value < boundary) {
+ if (self.value < boundary) {
floored_num >> 64
} else {
- ceil(num)
+ ceil(self)
}
}
@@ -788,15 +788,15 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `sub`
-public fun sub(x: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
+public fun sub(self: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
pragma opaque;
-aborts_if x.value < y.value with ENEGATIVE_RESULT;
-ensures result.value == x.value - y.value;
+aborts_if self.value < y.value with ENEGATIVE_RESULT;
+ensures result.value == self.value - y.value;
@@ -806,15 +806,15 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `add`
-public fun add(x: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
+public fun add(self: fixed_point64::FixedPoint64, y: fixed_point64::FixedPoint64): fixed_point64::FixedPoint64
pragma opaque;
-aborts_if (x.value as u256) + (y.value as u256) > MAX_U128 with ERATIO_OUT_OF_RANGE;
-ensures result.value == x.value + y.value;
+aborts_if (self.value as u256) + (y.value as u256) > MAX_U128 with ERATIO_OUT_OF_RANGE;
+ensures result.value == self.value + y.value;
@@ -1041,7 +1041,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `less_or_equal`
-public fun less_or_equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun less_or_equal(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -1049,7 +1049,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
pragma opaque;
aborts_if false;
-ensures result == spec_less_or_equal(num1, num2);
+ensures result == spec_less_or_equal(self, num2);
@@ -1058,8 +1058,8 @@ Returns the value of a FixedPoint64 to the nearest integer.
-fun spec_less_or_equal(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value <= num2.value
+fun spec_less_or_equal(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value <= num2.value
}
@@ -1070,7 +1070,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `less`
-public fun less(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun less(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -1078,7 +1078,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
pragma opaque;
aborts_if false;
-ensures result == spec_less(num1, num2);
+ensures result == spec_less(self, num2);
@@ -1087,8 +1087,8 @@ Returns the value of a FixedPoint64 to the nearest integer.
-fun spec_less(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value < num2.value
+fun spec_less(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value < num2.value
}
@@ -1099,7 +1099,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `greater_or_equal`
-public fun greater_or_equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun greater_or_equal(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -1107,7 +1107,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
pragma opaque;
aborts_if false;
-ensures result == spec_greater_or_equal(num1, num2);
+ensures result == spec_greater_or_equal(self, num2);
@@ -1116,8 +1116,8 @@ Returns the value of a FixedPoint64 to the nearest integer.
-fun spec_greater_or_equal(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value >= num2.value
+fun spec_greater_or_equal(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value >= num2.value
}
@@ -1128,7 +1128,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `greater`
-public fun greater(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+public fun greater(self: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
@@ -1136,7 +1136,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
pragma opaque;
aborts_if false;
-ensures result == spec_greater(num1, num2);
+ensures result == spec_greater(self, num2);
@@ -1145,8 +1145,8 @@ Returns the value of a FixedPoint64 to the nearest integer.
-fun spec_greater(num1: FixedPoint64, num2: FixedPoint64): bool {
- num1.value > num2.value
+fun spec_greater(self: FixedPoint64, num2: FixedPoint64): bool {
+ self.value > num2.value
}
@@ -1157,7 +1157,7 @@ Returns the value of a FixedPoint64 to the nearest integer.
### Function `equal`
-public fun equal(num1: fixed_point64::FixedPoint64, num2: fixed_point64::FixedPoint64): bool
+