I found code with implementation of b-tree in rust:
where is used uint
pub struct BTreeMap<K, V> {
root: Node<K, V>,
length: uint,
depth: uint,
b: uint,
}
I wanted to rewrite this implementation, copied this fragment and saw error
error[E0412]: cannot find type `uint` in this scope
--> src/bin/prepare-btree.rs:9:13
|
9 | length: uint,
| ^^^^ not found in this scope
I tried to add
use core::prelude::*;
and
use {core::primitive::uint};
but it did not helped.
All "imports" in my file are listed below:
use std::io::{BufRead, BufReader};
use std::fs::File;
use {core::iter::Map};
In original code that I can't find place where uint
is imported.
Docs of uint
:
https://doc.rust-lang.org/core/primitive.unit.html
Questions:
use core::prelude::*;
works and why in code from github link uint
is available?cannot find type
uint in this scope
in my code?This code is very old (2014) before the 1.0 release. uint
was a thing back then. The current code is at https://github.com/rust-lang/rust/blob/3b1c8a94a4e8a6ba8bc7b39cc3580db9e5b72295/library/alloc/src/collections/btree/map.rs#L172:
pub struct BTreeMap<
K,
V,
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator + Clone = Global,
> {
root: Option<Root<K, V>>,
length: usize,
/// `ManuallyDrop` to control drop order (needs to be dropped after all the nodes).
pub(super) alloc: ManuallyDrop<A>,
// For dropck; the `Box` avoids making the `Unpin` impl more strict than before
_marker: PhantomData<crate::boxed::Box<(K, V)>>,
}