@@ -2,26 +2,27 @@ use std::borrow::Borrow;
22use std:: error:: Error ;
33use std:: fmt;
44
5- // MarkMap is a key value data structure that uses an API similar to that of
6- // `std::collections::HashMap` and `std::collections::BTreeMap`.
7- //
8- // The current implementation is based on a sorted `Vec` is not optimized for
9- // storing large number of items.
10- //
11- // On top of the familiar `std::collections` API it has a few additions:
12- //
13- // * Marking a key with a condition.
14- // * Marking a key with a merge behavior.
15- // * A merge operator.
16- //
17- // The current *conditions* are [`Used`](MarkMap::mark_used) and [`Required`](MarkMap::mark_required).
18- //
19- // The available merge behaviors are [`Theirs`](MergeBehavior::Theirs), [`Ours`](MergeBehavior::Ours),
20- // and [`MutuallyExclusive`](MergeBehavior::MutuallyExclusive).
21- //
22- // Merge behaviors configure how the merge operator handles cases where both `MarkMaps` being merged
23- // contain a particular key.
5+ /// MarkMap is a key value data structure that uses an API similar to that of
6+ /// `std::collections::HashMap` and `std::collections::BTreeMap`.
7+ ///
8+ /// The current implementation is based on a sorted `Vec` is not optimized for
9+ /// storing large number of items.
10+ ///
11+ /// On top of the familiar `std::collections` API it has a few additions:
12+ ///
13+ /// * Marking a key with a condition.
14+ /// * Marking a key with a merge behavior.
15+ /// * A merge operator.
16+ ///
17+ /// The current *conditions* are [`Used`](MarkMap::mark_used) and [`Required`](MarkMap::mark_required).
18+ ///
19+ /// The available merge behaviors are [`Theirs`](MergeBehavior::Theirs), [`Ours`](MergeBehavior::Ours),
20+ /// and [`MutuallyExclusive`](MergeBehavior::MutuallyExclusive).
21+ ///
22+ /// Merge behaviors configure how the merge operator handles cases where both `MarkMaps` being merged
23+ /// contain a particular key.
2424#[ derive( Debug , PartialEq , Eq ) ]
25+ #[ doc( hidden) ]
2526pub struct MarkMap < K , V > {
2627 contents : Vec < ( K , u16 , Option < V > ) > ,
2728}
@@ -219,7 +220,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
219220 }
220221
221222 /// Inserts a `key` `value` pair.
222- #[ doc( hidden) ]
223223 pub fn insert ( & mut self , key : K , val : V ) -> Option < V > {
224224 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( & key) ) ;
225225 match pos {
@@ -246,7 +246,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
246246 }
247247
248248 /// Marks `key` as used.
249- #[ doc( hidden) ]
250249 pub fn mark_used ( & mut self , key : & K ) {
251250 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( key) ) ;
252251 match pos {
@@ -263,7 +262,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
263262 }
264263
265264 /// Marks `key` as a required value.
266- #[ doc( hidden) ]
267265 pub fn mark_required ( & mut self , key : & K ) {
268266 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( key) ) ;
269267 match pos {
@@ -280,7 +278,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
280278 }
281279
282280 /// Returns whether `key` is required.
283- #[ doc( hidden) ]
284281 pub fn is_required ( & self , key : & K ) -> bool {
285282 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( key) ) ;
286283 match pos {
@@ -290,7 +287,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
290287 }
291288
292289 /// Sets the merge behavior for `key`.
293- #[ doc( hidden) ]
294290 pub fn set_merge_behavior ( & mut self , key : & K , mb : MergeBehavior ) {
295291 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( key) ) ;
296292 match pos {
@@ -312,7 +308,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
312308 }
313309
314310 /// Returns a `Some(value)` associated with `key` if present otherwise `None`.
315- #[ doc( hidden) ]
316311 pub fn get < Q > ( & self , key : & Q ) -> Option < & V >
317312 where
318313 K : Borrow < Q > ,
@@ -329,7 +324,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
329324 }
330325
331326 /// Returns true if the `MarkMap` contains `key` otherwise false.
332- #[ doc( hidden) ]
333327 pub fn contains_key < Q > ( & self , key : & Q ) -> bool
334328 where
335329 K : Borrow < Q > ,
@@ -339,7 +333,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
339333 }
340334
341335 /// Removes `key` from the `MarkMap` and returns the previous value when present.
342- #[ doc( hidden) ]
343336 pub fn remove ( & mut self , key : & K ) -> Option < V > {
344337 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( key) ) ;
345338 match pos {
@@ -349,7 +342,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
349342 }
350343
351344 /// Returns an `Entry` for `key`.
352- #[ doc( hidden) ]
353345 pub fn entry ( & mut self , key : K ) -> Entry < K , V > {
354346 let pos = self . contents . binary_search_by ( |( k, _, _) | k. cmp ( & key) ) ;
355347 match pos {
@@ -382,7 +374,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
382374 ///
383375 /// For the behavior of exclusive or mark the behavior as also `Mark::Required`, then after merge call `missing()`
384376 /// to check all required values.
385- #[ doc( hidden) ]
386377 pub fn merge_from < U > ( & mut self , mut other : MarkMap < K , U > ) -> Result < ( ) , MergeError < K , Box < V > > >
387378 where
388379 U : Into < V > ,
@@ -427,7 +418,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
427418 }
428419
429420 /// Returns whether `key` has been marked as used.
430- #[ doc( hidden) ]
431421 pub fn is_used < Q > ( & self , key : & Q ) -> bool
432422 where
433423 K : Borrow < Q > ,
@@ -444,7 +434,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
444434 }
445435
446436 /// Returns a `Vec` containing all the keys that are not marked as used.
447- #[ doc( hidden) ]
448437 pub fn unused ( & self ) -> Vec < K > {
449438 let mut ret = Vec :: new ( ) ;
450439 for ( k, mark, v) in & self . contents {
@@ -458,7 +447,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
458447
459448 /// Returns a `Vec` containing all the keys that are marked as required,
460449 /// but have values that are not present in the `MarkMap`.
461- #[ doc( hidden) ]
462450 pub fn missing ( & self ) -> Vec < & K > {
463451 let mut ret = Vec :: new ( ) ;
464452 for ( k, mark, v) in & self . contents {
@@ -471,7 +459,6 @@ impl<K: Ord + Clone, V> MarkMap<K, V> {
471459 }
472460
473461 /// Returns an `Iterator` over all the keys of the `MarkMap`.
474- #[ doc( hidden) ]
475462 pub fn keys ( & self ) -> Keys < ' _ , K , V > {
476463 Keys { pos : 0 , map : self }
477464 }
0 commit comments