near-primitives 0.35.1

This crate provides the base set of primitives used by other nearcore crates
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use near_primitives_core::types::ShardId;
use std::collections::BTreeMap;

pub fn map_keys_to_string<K, V>(map: &BTreeMap<K, V>) -> BTreeMap<String, V>
where
    K: std::fmt::Display,
    V: Clone,
{
    map.iter().map(|(k, v)| (k.to_string(), v.clone())).collect()
}

pub fn map_keys_to_shard_id<V>(
    map: BTreeMap<String, V>,
) -> Result<BTreeMap<ShardId, V>, Box<dyn std::error::Error + Send + Sync>> {
    map.into_iter().map(|(k, v)| Ok((k.parse::<u64>()?.into(), v))).collect()
}