pub struct ConcretizedFormals(_);
Expand description

A read/write set state with no unbound formals or type variables

Implementations§

source§

impl ConcretizedFormals

source

pub fn get_keys_(&self, is_write: bool, env: &GlobalEnv) -> Vec<ResourceKey>

Return the ResourceKey’s that may be accessed by self. If is_write is true, return the keys that may be written; otherwise, return the keys that may be read. For example: if self is 0x7/0x1::AModule::AResource/f/g -> ReadWrite, this will return 0x7/0x1::AModule.

source

pub fn get_keys_written(&self, env: &GlobalEnv) -> Vec<ResourceKey>

Return the ResourceKey’s written by self.

source

pub fn get_keys_read(&self, env: &GlobalEnv) -> Vec<ResourceKey>

Return the ResourceKey’s read by self.

source

pub fn from_args( accesses: AccessPathTrie<Access>, signers: &[AccountAddress], actuals: &[Vec<u8>], type_actuals: &[TypeTag], fun_env: &FunctionEnv<'_> ) -> Result<ConcretizedFormals>

Construct a ConcretizedFormals from accesses by binding the formals and type variables in accesses to signers/actuals and type_actuals. For example: if accesses is Formal(0)/0x1::M::S<TypeVar(0)>/f -> Read, signers is 0xA and type_actuals is 0x2::M2::S2, this will return 0xA/0x1::M::S<0x2::M2::S@>/f -> Read

Methods from Deref<Target = AccessPathTrie<Access>>§

pub fn get_child_data(&self) -> Option<T>

pub fn get_local( &self, local_index: usize, fun_env: &FunctionEnv<'_> ) -> Option<&T>

Retrieve the data associated with local_index in the trie. Returns None if there is no associated data

pub fn get_local_node( &self, local_index: usize, fun_env: &FunctionEnv<'_> ) -> Option<&TrieNode<T>>

Retrieve the node associated with local_index in the trie. Returns None if there is no associated node

pub fn local_exists(&self, local_index: usize, fun_env: &FunctionEnv<'_>) -> bool

Return true if there is a value bound to local variable local_index

pub fn keys_statically_known(&self) -> bool

Return true if the keys of self have no dynamic components and thus can be converted into a compact set of concrete access paths.

pub fn iter_offsets<F>(&self, f: F)where F: FnMut(&Offset),

Apply f to each offset in self

pub fn iter_paths_opt<F>(&self, f: F)where F: FnMut(&AccessPath, &Option<&T>),

Apply f to each (access path, Option(data)) pair encoded in self

pub fn iter_paths<F>(&self, f: F)where F: FnMut(&AccessPath, &T),

Apply f to each (access path, data) pair encoded in self

pub fn filter_map_paths<F, R>(&self, f: F) -> Vec<R, Global> where F: FnMut(&AccessPath, &T) -> Option<R>,

Apply f to each (access path, data) pair encoded in self and collects the result when f returns Some(r)

pub fn display<'a>( &'a self, env: &'a FunctionEnv<'_> ) -> AccessPathTrieDisplay<'a, T>

Return a wrapper that of self that implements Display using env

Methods from Deref<Target = MapDomain<Root, TrieNode<T>>>§

pub fn insert_join(&mut self, k: K, v: V) -> JoinResult

Join v with self[k] if k is bound, insert v otherwise

pub fn update_values(&mut self, f: impl FnMut(&mut V))

Updates the values in the range of the map using the given function. Notice that with other kind of map representations we would use iter_mut for this, but this is not available in OrdMap for obvious reasons (because entries are shared), so we need to use this pattern here instead.

Methods from Deref<Target = OrdMap<K, V>>§

pub fn is_empty(&self) -> bool

Test whether a map is empty.

Time: O(1)

Examples
assert!(
  !ordmap!{1 => 2}.is_empty()
);
assert!(
  OrdMap::<i32, i32>::new().is_empty()
);

pub fn ptr_eq(&self, other: &OrdMap<K, V>) -> bool

Test whether two maps refer to the same content in memory.

This is true if the two sides are references to the same map, or if the two maps refer to the same root node.

This would return true if you’re comparing a map to itself, or if you’re comparing a map to a fresh clone of itself.

Time: O(1)

pub fn len(&self) -> usize

Get the size of a map.

Time: O(1)

Examples
assert_eq!(3, ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.len());

pub fn clear(&mut self)

Discard all elements from the map.

This leaves you with an empty map, and all elements that were previously inside it are dropped.

Time: O(n)

Examples
let mut map = ordmap![1=>1, 2=>2, 3=>3];
map.clear();
assert!(map.is_empty());

pub fn get_max(&self) -> Option<&(K, V)>

Get the largest key in a map, along with its value. If the map is empty, return None.

Time: O(log n)

Examples
assert_eq!(Some(&(3, 33)), ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.get_max());

pub fn get_min(&self) -> Option<&(K, V)>

Get the smallest key in a map, along with its value. If the map is empty, return None.

Time: O(log n)

Examples
assert_eq!(Some(&(1, 11)), ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.get_min());

pub fn iter(&self) -> Iter<'_, K, V>

Get an iterator over the key/value pairs of a map.

pub fn range<R, BK>(&self, range: R) -> Iter<'_, K, V>where R: RangeBounds<BK>, K: Borrow<BK>, BK: Ord + ?Sized,

Create an iterator over a range of key/value pairs.

pub fn keys(&self) -> Keys<'_, K, V>

Get an iterator over a map’s keys.

pub fn values(&self) -> Values<'_, K, V>

Get an iterator over a map’s values.

pub fn diff<'a>(&'a self, other: &'a OrdMap<K, V>) -> DiffIter<'a, K, V>

Get an iterator over the differences between this map and another, i.e. the set of entries to add, update, or remove to this map in order to make it equal to the other map.

This function will avoid visiting nodes which are shared between the two maps, meaning that even very large maps can be compared quickly if most of their structure is shared.

Time: O(n) (where n is the number of unique elements across the two maps, minus the number of elements belonging to nodes shared between them)

pub fn get<BK>(&self, key: &BK) -> Option<&V>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the value for a key from a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert_eq!(
  map.get(&123),
  Some(&"lol")
);

pub fn get_key_value<BK>(&self, key: &BK) -> Option<(&K, &V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the key/value pair for a key from a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert_eq!(
  map.get_key_value(&123),
  Some((&123, &"lol"))
);

pub fn get_prev<BK>(&self, key: &BK) -> Option<(&K, &V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest smaller entry in a map to a given key as a mutable reference.

If the map contains the given key, this is returned. Otherwise, the closest key in the map smaller than the given value is returned. If the smallest key in the map is larger than the given key, None is returned.

Examples
let map = ordmap![1 => 1, 3 => 3, 5 => 5];
assert_eq!(Some((&3, &3)), map.get_prev(&4));

pub fn get_next<BK>(&self, key: &BK) -> Option<(&K, &V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest larger entry in a map to a given key as a mutable reference.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let map = ordmap![1 => 1, 3 => 3, 5 => 5];
assert_eq!(Some((&5, &5)), map.get_next(&4));

pub fn contains_key<BK>(&self, k: &BK) -> boolwhere BK: Ord + ?Sized, K: Borrow<BK>,

Test for the presence of a key in a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert!(
  map.contains_key(&123)
);
assert!(
  !map.contains_key(&321)
);

pub fn is_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> boolwhere F: FnMut(&V, &B) -> bool, RM: Borrow<OrdMap<K, B>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Use the provided function to decide whether values are equal.

Time: O(n log n)

pub fn is_proper_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> boolwhere F: FnMut(&V, &B) -> bool, RM: Borrow<OrdMap<K, B>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Use the provided function to decide whether values are equal.

Time: O(n log n)

pub fn is_submap<RM>(&self, other: RM) -> boolwhere V: PartialEq<V>, RM: Borrow<OrdMap<K, V>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Time: O(n log n)

Examples
let map1 = ordmap!{1 => 1, 2 => 2};
let map2 = ordmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_submap(map2));

pub fn is_proper_submap<RM>(&self, other: RM) -> boolwhere V: PartialEq<V>, RM: Borrow<OrdMap<K, V>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Time: O(n log n)

Examples
let map1 = ordmap!{1 => 1, 2 => 2};
let map2 = ordmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_proper_submap(map2));

let map3 = ordmap!{1 => 1, 2 => 2};
let map4 = ordmap!{1 => 1, 2 => 2};
assert!(!map3.is_proper_submap(map4));

pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V>where BK: Ord + ?Sized, K: Borrow<BK>,

Get a mutable reference to the value for a key from a map.

Time: O(log n)

Examples
let mut map = ordmap!{123 => "lol"};
if let Some(value) = map.get_mut(&123) {
    *value = "omg";
}
assert_eq!(
  map.get(&123),
  Some(&"omg")
);

pub fn get_prev_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest smaller entry in a map to a given key as a mutable reference.

If the map contains the given key, this is returned. Otherwise, the closest key in the map smaller than the given value is returned. If the smallest key in the map is larger than the given key, None is returned.

Examples
let mut map = ordmap![1 => 1, 3 => 3, 5 => 5];
if let Some((key, value)) = map.get_prev_mut(&4) {
    *value = 4;
}
assert_eq!(ordmap![1 => 1, 3 => 4, 5 => 5], map);

pub fn get_next_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest larger entry in a map to a given key as a mutable reference.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let mut map = ordmap![1 => 1, 3 => 3, 5 => 5];
if let Some((key, value)) = map.get_next_mut(&4) {
    *value = 4;
}
assert_eq!(ordmap![1 => 1, 3 => 3, 5 => 4], map);

pub fn insert(&mut self, key: K, value: V) -> Option<V>

Insert a key/value mapping into a map.

This is a copy-on-write operation, so that the parts of the map’s structure which are shared with other maps will be safely copied before mutating.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(log n)

Examples
let mut map = ordmap!{};
map.insert(123, "123");
map.insert(456, "456");
assert_eq!(
  map,
  ordmap!{123 => "123", 456 => "456"}
);

pub fn remove<BK>(&mut self, k: &BK) -> Option<V>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value mapping from a map if it exists.

Time: O(log n)

Examples
let mut map = ordmap!{123 => "123", 456 => "456"};
map.remove(&123);
map.remove(&456);
assert!(map.is_empty());

pub fn remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value.

Time: O(log n)

pub fn update(&self, key: K, value: V) -> OrdMap<K, V>

Construct a new map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(log n)

Examples
let map = ordmap!{};
assert_eq!(
  map.update(123, "123"),
  ordmap!{123 => "123"}
);

pub fn alter<F>(&self, f: F, k: K) -> OrdMap<K, V>where F: FnOnce(Option<V>) -> Option<V>,

Update the value for a given key by calling a function with the current value and overwriting it with the function’s return value.

The function gets an Option<V> and returns the same, so that it can decide to delete a mapping instead of updating the value, and decide what to do if the key isn’t in the map.

Time: O(log n)

pub fn without<BK>(&self, k: &BK) -> OrdMap<K, V>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists.

Time: O(log n)

pub fn extract<BK>(&self, k: &BK) -> Option<(V, OrdMap<K, V>)>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed value as well as the updated list.

Time: O(log n)

pub fn extract_with_key<BK>(&self, k: &BK) -> Option<(K, V, OrdMap<K, V>)>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value as well as the updated list.

Time: O(log n)

pub fn split<BK>(&self, split: &BK) -> (OrdMap<K, V>, OrdMap<K, V>)where BK: Ord + ?Sized, K: Borrow<BK>,

Split a map into two, with the left hand map containing keys which are smaller than split, and the right hand map containing keys which are larger than split.

The split mapping is discarded.

pub fn split_lookup<BK>( &self, split: &BK ) -> (OrdMap<K, V>, Option<V>, OrdMap<K, V>)where BK: Ord + ?Sized, K: Borrow<BK>,

Split a map into two, with the left hand map containing keys which are smaller than split, and the right hand map containing keys which are larger than split.

Returns both the two maps and the value of split.

pub fn take(&self, n: usize) -> OrdMap<K, V>

Construct a map with only the n smallest keys from a given map.

pub fn skip(&self, n: usize) -> OrdMap<K, V>

Construct a map with the n smallest keys removed from a given map.

pub fn without_min(&self) -> (Option<V>, OrdMap<K, V>)

Remove the smallest key from a map, and return its value as well as the updated map.

pub fn without_min_with_key(&self) -> (Option<(K, V)>, OrdMap<K, V>)

Remove the smallest key from a map, and return that key, its value as well as the updated map.

pub fn without_max(&self) -> (Option<V>, OrdMap<K, V>)

Remove the largest key from a map, and return its value as well as the updated map.

pub fn without_max_with_key(&self) -> (Option<(K, V)>, OrdMap<K, V>)

Remove the largest key from a map, and return that key, its value as well as the updated map.

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>

Get the Entry for a key in the map for in-place manipulation.

Time: O(log n)

Trait Implementations§

source§

impl Debug for ConcretizedFormals

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for ConcretizedFormals

§

type Target = AccessPathTrie<Access>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V