util docs cleanup pt.1
This commit is contained in:
parent
694590e19d
commit
ea13fd3c0e
@ -1,3 +1,5 @@
|
|||||||
|
//! Calculates heapsize of util types.
|
||||||
|
|
||||||
use uint::*;
|
use uint::*;
|
||||||
use hash::*;
|
use hash::*;
|
||||||
|
|
||||||
|
@ -8,30 +8,55 @@
|
|||||||
//! Ethcore-util library
|
//! Ethcore-util library
|
||||||
//!
|
//!
|
||||||
//! ### Rust version:
|
//! ### Rust version:
|
||||||
//! - beta
|
|
||||||
//! - nightly
|
//! - nightly
|
||||||
//!
|
//!
|
||||||
//! ### Supported platforms:
|
//! ### Supported platforms:
|
||||||
//! - OSX
|
//! - OSX
|
||||||
//! - Linux
|
//! - Linux
|
||||||
//!
|
//!
|
||||||
//! ### Dependencies:
|
//! ### Building:
|
||||||
//! - RocksDB 3.13
|
|
||||||
//!
|
//!
|
||||||
//! ### Dependencies Installation:
|
//! - Ubuntu 14.04 and later:
|
||||||
|
//!
|
||||||
|
//! ```bash
|
||||||
|
//! # install rocksdb
|
||||||
|
//! add-apt-repository "deb http://ppa.launchpad.net/giskou/librocksdb/ubuntu trusty main"
|
||||||
|
//! apt-get update
|
||||||
|
//! apt-get install -y --force-yes librocksdb
|
||||||
|
//!
|
||||||
|
//! # install multirust
|
||||||
|
//! curl -sf https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh | sh -s -- --yes
|
||||||
|
//!
|
||||||
|
//! # install nightly and make it default
|
||||||
|
//! multirust update nightly && multirust default nightly
|
||||||
|
//!
|
||||||
|
//! # export rust LIBRARY_PATH
|
||||||
|
//! export LIBRARY_PATH=/usr/local/lib
|
||||||
|
//!
|
||||||
|
//! # download and build parity
|
||||||
|
//! git clone https://github.com/ethcore/parity
|
||||||
|
//! cd parity
|
||||||
|
//! cargo build --release
|
||||||
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! - OSX:
|
//! - OSX:
|
||||||
//!
|
//!
|
||||||
//! ```bash
|
//! ```bash
|
||||||
|
//! # install rocksdb && multirust
|
||||||
|
//! brew update
|
||||||
//! brew install rocksdb
|
//! brew install rocksdb
|
||||||
//! ```
|
//! brew install multirust
|
||||||
//!
|
//!
|
||||||
//! - From source:
|
//! # install nightly and make it default
|
||||||
|
//! multirust update nightly && multirust default nightly
|
||||||
//!
|
//!
|
||||||
//! ```bash
|
//! # export rust LIBRARY_PATH
|
||||||
//! wget https://github.com/facebook/rocksdb/archive/rocksdb-3.13.tar.gz
|
//! export LIBRARY_PATH=/usr/local/lib
|
||||||
//! tar xvf rocksdb-3.13.tar.gz && cd rocksdb-rocksdb-3.13 && make shared_lib
|
//!
|
||||||
//! sudo make install
|
//! # download and build parity
|
||||||
|
//! git clone https://github.com/ethcore/parity
|
||||||
|
//! cd parity
|
||||||
|
//! cargo build --release
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
extern crate slab;
|
extern crate slab;
|
||||||
@ -89,8 +114,7 @@ pub mod triehash;
|
|||||||
/// TODO [Gav Wood] Please document me
|
/// TODO [Gav Wood] Please document me
|
||||||
pub mod trie;
|
pub mod trie;
|
||||||
pub mod nibbleslice;
|
pub mod nibbleslice;
|
||||||
/// TODO [Gav Wood] Please document me
|
mod heapsizeof;
|
||||||
pub mod heapsizeof;
|
|
||||||
pub mod squeeze;
|
pub mod squeeze;
|
||||||
/// TODO [Gav Wood] Please document me
|
/// TODO [Gav Wood] Please document me
|
||||||
pub mod semantic_version;
|
pub mod semantic_version;
|
||||||
@ -114,7 +138,6 @@ pub use crypto::*;
|
|||||||
pub use triehash::*;
|
pub use triehash::*;
|
||||||
pub use trie::*;
|
pub use trie::*;
|
||||||
pub use nibbleslice::*;
|
pub use nibbleslice::*;
|
||||||
pub use heapsizeof::*;
|
|
||||||
pub use squeeze::*;
|
pub use squeeze::*;
|
||||||
pub use semantic_version::*;
|
pub use semantic_version::*;
|
||||||
pub use network::*;
|
pub use network::*;
|
||||||
|
@ -1,40 +1,4 @@
|
|||||||
//! vector util functions
|
//! Vector extensions.
|
||||||
|
|
||||||
use std::ptr;
|
|
||||||
|
|
||||||
/// TODO [debris] Please document me
|
|
||||||
pub trait InsertSlice<T> {
|
|
||||||
/// TODO [debris] Please document me
|
|
||||||
fn insert_slice(&mut self, index: usize, elements: &[T]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// based on `insert` function implementation from standard library
|
|
||||||
impl<T> InsertSlice<T> for Vec<T> {
|
|
||||||
fn insert_slice(&mut self, index: usize, elements: &[T]) {
|
|
||||||
let e_len = elements.len();
|
|
||||||
if e_len == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let len = self.len();
|
|
||||||
assert!(index <= len);
|
|
||||||
|
|
||||||
// space for the new element
|
|
||||||
self.reserve(e_len);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
{
|
|
||||||
let p = self.as_mut_ptr().offset(index as isize);
|
|
||||||
let ep = elements.as_ptr().offset(0);
|
|
||||||
// shift everything by e_len, to make space
|
|
||||||
ptr::copy(p, p.offset(e_len as isize), len - index);
|
|
||||||
// write new element
|
|
||||||
ptr::copy(ep, p, e_len);
|
|
||||||
}
|
|
||||||
self.set_len(len + e_len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns len of prefix shared with elem
|
/// Returns len of prefix shared with elem
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user