Skip to content

Commit 9ab477c

Browse files
authored
Merge pull request #537 from newAM/fix-lib-example
lib.rs: remove unwrap from example
2 parents 3fcc87d + 7e95905 commit 9ab477c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@
1313
//!
1414
//! // on the stack
1515
//! let mut xs: Vec<u8, 8> = Vec::new(); // can hold up to 8 elements
16-
//! xs.push(42).unwrap();
16+
//! xs.push(42)?;
1717
//! assert_eq!(xs.pop(), Some(42));
1818
//!
1919
//! // in a `static` variable
2020
//! static mut XS: Vec<u8, 8> = Vec::new();
2121
//!
2222
//! let xs = unsafe { &mut XS };
2323
//!
24-
//! xs.push(42);
24+
//! xs.push(42)?;
2525
//! assert_eq!(xs.pop(), Some(42));
2626
//!
2727
//! // in the heap (though kind of pointless because no reallocation)
2828
//! let mut ys: Box<Vec<u8, 8>> = Box::new(Vec::new());
29-
//! ys.push(42).unwrap();
29+
//! ys.push(42)?;
3030
//! assert_eq!(ys.pop(), Some(42));
31+
//! # Ok::<(), u8>(())
3132
//! ```
3233
//!
3334
//! Because they have fixed capacity `heapless` data structures don't implicitly reallocate. This

0 commit comments

Comments
 (0)