1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
|
Description: Guard tests that depend on the 'std' feature.
Author: Antonin Delpeuch <antonin@delpeuch.eu>
Forwarded: https://github.com/garro95/priority-queue/pull/77
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
diff --git a/src/double_priority_queue/mod.rs b/src/double_priority_queue/mod.rs
index d15246d..f35ca6b 100644
--- a/src/double_priority_queue/mod.rs
+++ b/src/double_priority_queue/mod.rs
@@ -473,6 +473,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
///
@@ -486,6 +487,7 @@ where
///
/// assert_eq!(pq.peek_min(), Some((&"Bananas", &15)));
/// assert_eq!(pq.into_vec(), vec!["Bananas"]);
+ /// # }
/// ```
pub fn extract_if<F>(&mut self, predicate: F) -> ExtractIf<I, P, F, H>
where
@@ -512,6 +514,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
///
@@ -524,6 +527,7 @@ where
/// }), None);
///
/// assert_eq!(pq.pop_min(), Some(("Bananas", 10)));
+ /// # }
/// ```
pub fn pop_min_if<F>(&mut self, f: F) -> Option<(I, P)>
where
@@ -554,6 +558,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
/// pq.push("Apples", 5);
@@ -563,6 +568,7 @@ where
/// false
/// }), None);
/// assert_eq!(pq.pop_max(), Some(("Apples", 5)));
+ /// # }
/// ```
pub fn pop_max_if<F>(&mut self, f: F) -> Option<(I, P)>
where
@@ -583,6 +589,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
/// assert_eq!(pq.push("Apples", 5), None);
@@ -591,6 +598,7 @@ where
/// assert_eq!(pq.get_priority("Apples"), Some(&6));
/// assert_eq!(pq.push("Apples", 4), Some(6));
/// assert_eq!(pq.get_priority("Apples"), Some(&4));
+ /// # }
/// ```
///
/// Computes in **O(log(N))** time.
@@ -641,6 +649,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
/// assert_eq!(pq.push_increase("Apples", 5), None);
@@ -651,6 +660,7 @@ where
/// // priority is returned.
/// assert_eq!(pq.push_increase("Apples", 4), Some(4));
/// assert_eq!(pq.get_priority("Apples"), Some(&6));
+ /// # }
/// ```
///
/// Computes in **O(log(N))** time.
@@ -679,6 +689,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
/// assert_eq!(pq.push_decrease("Apples", 5), None);
@@ -689,6 +700,7 @@ where
/// // priority is returned.
/// assert_eq!(pq.push_decrease("Apples", 6), Some(6));
/// assert_eq!(pq.get_priority("Apples"), Some(&4));
+ /// # }
/// ```
///
/// Computes in **O(log(N))** time.
@@ -708,6 +720,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::DoublePriorityQueue;
/// let mut pq = DoublePriorityQueue::new();
/// assert_eq!(pq.change_priority("Apples", 5), None);
@@ -716,6 +729,7 @@ where
/// assert_eq!(pq.get_priority("Apples"), Some(&6));
/// assert_eq!(pq.change_priority("Apples", 4), Some(6));
/// assert_eq!(pq.get_priority("Apples"), Some(&4));
+ /// # }
/// ```
///
/// The item is found in **O(1)** thanks to the hash table.
diff --git a/src/lib.rs b/src/lib.rs
index 34ae10d..0664dc8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -54,6 +54,7 @@
//!
//! # Examples
//! ```rust
+//! # #[cfg(feature = "std")] {
//! use priority_queue::PriorityQueue;
//!
//! let mut pq = PriorityQueue::new();
@@ -71,10 +72,12 @@
//! for (item, _) in pq.into_sorted_iter() {
//! println!("{}", item); // Will print Bananas, Strawberries, Apples
//! }
+//! # }
//! ```
//!
//! ## Reverse ordering
//! ```rust
+//! # #[cfg(feature = "std")] {
//! use priority_queue::PriorityQueue;
//! use std::cmp::Reverse;
//!
@@ -90,6 +93,7 @@
//! for (item, _) in pq.into_sorted_iter() {
//! println!("{}", item); // Will print Apples, Bananas, Strawberries
//! }
+//! # }
//! ```
//!
//! # Crate features
diff --git a/src/priority_queue/mod.rs b/src/priority_queue/mod.rs
index 8bc6f91..29cab48 100644
--- a/src/priority_queue/mod.rs
+++ b/src/priority_queue/mod.rs
@@ -62,6 +62,7 @@ use std::mem::replace;
///
/// # Example
/// ```rust
+/// # #[cfg(feature = "std")] {
/// use priority_queue::PriorityQueue;
///
/// let mut pq = PriorityQueue::new();
@@ -79,6 +80,7 @@ use std::mem::replace;
/// for (item, _) in pq.into_sorted_iter() {
/// println!("{}", item);
/// }
+/// # }
/// ```
#[derive(Clone, Debug)]
#[cfg(feature = "std")]
@@ -383,6 +385,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::PriorityQueue;
/// let mut pq = PriorityQueue::new();
///
@@ -396,6 +399,7 @@ where
///
/// assert_eq!(pq.peek(), Some((&"Bananas", &15)));
/// assert_eq!(pq.into_vec(), vec!["Bananas"]);
+ /// # }
/// ```
pub fn extract_if<F>(&mut self, predicate: F) -> ExtractIf<I, P, F, H>
where
@@ -422,6 +426,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::PriorityQueue;
/// let mut pq = PriorityQueue::new();
///
@@ -434,6 +439,7 @@ where
/// }), None);
///
/// assert_eq!(pq.pop(), Some(("Apples", 5)));
+ /// # }
/// ```
pub fn pop_if<F>(&mut self, predicate: F) -> Option<(I, P)>
where
@@ -458,6 +464,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::PriorityQueue;
/// let mut pq = PriorityQueue::new();
/// assert_eq!(pq.push("Apples", 5), None);
@@ -466,6 +473,7 @@ where
/// assert_eq!(pq.get_priority("Apples"), Some(&6));
/// assert_eq!(pq.push("Apples", 4), Some(6));
/// assert_eq!(pq.get_priority("Apples"), Some(&4));
+ /// # }
/// ```
///
/// Computes in **O(log(N))** time.
@@ -515,6 +523,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::PriorityQueue;
/// let mut pq = PriorityQueue::new();
/// assert_eq!(pq.push_increase("Apples", 5), None);
@@ -525,6 +534,7 @@ where
/// // priority is returned.
/// assert_eq!(pq.push_increase("Apples", 4), Some(4));
/// assert_eq!(pq.get_priority("Apples"), Some(&6));
+ /// # }
/// ```
///
/// Computes in **O(log(N))** time.
@@ -553,6 +563,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::PriorityQueue;
/// let mut pq = PriorityQueue::new();
/// assert_eq!(pq.push_decrease("Apples", 5), None);
@@ -563,6 +574,7 @@ where
/// // priority is returned.
/// assert_eq!(pq.push_decrease("Apples", 6), Some(6));
/// assert_eq!(pq.get_priority("Apples"), Some(&4));
+ /// # }
/// ```
///
/// Computes in **O(log(N))** time.
@@ -582,6 +594,7 @@ where
///
/// # Example
/// ```
+ /// # #[cfg(feature = "std")] {
/// # use priority_queue::PriorityQueue;
/// let mut pq = PriorityQueue::new();
/// assert_eq!(pq.change_priority("Apples", 5), None);
@@ -590,6 +603,7 @@ where
/// assert_eq!(pq.get_priority("Apples"), Some(&6));
/// assert_eq!(pq.change_priority("Apples", 4), Some(6));
/// assert_eq!(pq.get_priority("Apples"), Some(&4));
+ /// # }
/// ```
///
/// The item is found in **O(1)** thanks to the hash table.
diff --git a/tests/double_priority_queue.rs b/tests/double_priority_queue.rs
index 396c982..2ab5d7d 100644
--- a/tests/double_priority_queue.rs
+++ b/tests/double_priority_queue.rs
@@ -25,7 +25,7 @@
* obtain one at http://mozilla.org/MPL/2.0/.
*
*/
-
+#[cfg(feature = "std")]
#[cfg(test)]
mod doublepq_tests {
pub use priority_queue::DoublePriorityQueue;
diff --git a/tests/priority_queue.rs b/tests/priority_queue.rs
index 1a7a5b9..1a14281 100644
--- a/tests/priority_queue.rs
+++ b/tests/priority_queue.rs
@@ -26,6 +26,7 @@
*
*/
+#[cfg(feature = "std")]
#[cfg(test)]
mod pqueue_tests {
pub use priority_queue::PriorityQueue;
--
2.51.0
|