2018-08-30 12:18:55 +00:00
|
|
|
//@ run-pass
|
2018-09-25 21:51:35 +00:00
|
|
|
#![allow(dead_code)]
|
2015-01-08 01:25:56 +00:00
|
|
|
|
2015-03-30 13:38:27 +00:00
|
|
|
#[derive(Copy, Clone)]
|
2015-03-26 00:06:52 +00:00
|
|
|
struct LM { resize_at: usize, size: usize }
|
2013-01-26 06:46:32 +00:00
|
|
|
|
2013-04-03 13:28:36 +00:00
|
|
|
enum HashMap<K,V> {
|
2015-02-12 15:29:52 +00:00
|
|
|
HashMap_(LM, Vec<(K,V)>)
|
2012-08-22 02:51:43 +00:00
|
|
|
}
|
|
|
|
|
2013-04-03 13:28:36 +00:00
|
|
|
fn linear_map<K,V>() -> HashMap<K,V> {
|
2014-11-06 08:05:53 +00:00
|
|
|
HashMap::HashMap_(LM{
|
2012-08-22 02:51:43 +00:00
|
|
|
resize_at: 32,
|
2015-02-12 15:29:52 +00:00
|
|
|
size: 0}, Vec::new())
|
2012-08-22 02:51:43 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 22:17:22 +00:00
|
|
|
impl<K,V> HashMap<K,V> {
|
2015-03-26 00:06:52 +00:00
|
|
|
pub fn len(&mut self) -> usize {
|
2013-10-31 22:29:15 +00:00
|
|
|
match *self {
|
2015-02-12 15:29:52 +00:00
|
|
|
HashMap::HashMap_(ref l, _) => l.size
|
2013-10-31 22:29:15 +00:00
|
|
|
}
|
2012-08-22 02:51:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-02 03:43:17 +00:00
|
|
|
pub fn main() {
|
2021-08-25 00:39:40 +00:00
|
|
|
let mut m: Box<_> = Box::new(linear_map::<(),()>());
|
2013-05-19 02:02:45 +00:00
|
|
|
assert_eq!(m.len(), 0);
|
2012-08-22 02:51:43 +00:00
|
|
|
}
|