Skip to content

Commit

Permalink
DOC: Check for Ok/Err instead of .is_ok()/.is_err()
Browse files Browse the repository at this point in the history
  • Loading branch information
mgeier committed Nov 9, 2020
1 parent cc99b10 commit c66d052
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@
//! # Examples
//!
//! ```
//! use rtrb::RingBuffer;
//! use rtrb::{RingBuffer, PushError, PopError};
//!
//! let (mut producer, mut consumer) = RingBuffer::new(2).split();
//!
//! assert!(producer.push(1).is_ok());
//! assert!(producer.push(2).is_ok());
//! assert!(producer.push(3).is_err());
//! assert_eq!(producer.push(1), Ok(()));
//! assert_eq!(producer.push(2), Ok(()));
//! assert_eq!(producer.push(3), Err(PushError::Full(3)));
//!
//! std::thread::spawn(move || {
//! assert_eq!(consumer.pop(), Ok(1));
//! assert_eq!(consumer.pop(), Ok(2));
//! assert!(consumer.pop().is_err());
//! assert_eq!(consumer.pop(), Err(PopError::Empty));
//! }).join().unwrap();
//!
//! ```
Expand Down Expand Up @@ -99,7 +99,7 @@ impl<T> RingBuffer<T> {
/// use rtrb::RingBuffer;
///
/// let (mut producer, consumer) = RingBuffer::new(100).split();
/// assert!(producer.push(0.0f32).is_ok());
/// assert_eq!(producer.push(0.0f32), Ok(()));
/// ```
pub fn new(capacity: usize) -> RingBuffer<T> {
RingBuffer {
Expand Down Expand Up @@ -316,7 +316,7 @@ impl<T> Producer<T> {
///
/// let (mut p, mut c) = RingBuffer::new(3).split();
///
/// assert!(p.push(10).is_ok());
/// assert_eq!(p.push(10), Ok(()));
/// assert_eq!(c.pop(), Ok(10));
///
/// if let Ok(mut chunk) = p.write_chunk(3) {
Expand Down

0 comments on commit c66d052

Please sign in to comment.