From 410590124431aba2af70f8926e38739b2daf2c49 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 20 Sep 2016 13:42:24 -0700 Subject: [PATCH] Rename RingBuf::new -> with_capacity --- src/buf/ring.rs | 2 +- test/test_ring.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/buf/ring.rs b/src/buf/ring.rs index 3c2cac4..4b80cf2 100644 --- a/src/buf/ring.rs +++ b/src/buf/ring.rs @@ -22,7 +22,7 @@ pub struct RingBuf { // TODO: There are most likely many optimizations that can be made impl RingBuf { /// Allocates a new `RingBuf` with the specified capacity. - pub fn new(mut capacity: usize) -> RingBuf { + pub fn with_capacity(mut capacity: usize) -> RingBuf { // Round to the next power of 2 for better alignment capacity = capacity.next_power_of_two(); diff --git a/test/test_ring.rs b/test/test_ring.rs index 0ef9850..88c44f6 100644 --- a/test/test_ring.rs +++ b/test/test_ring.rs @@ -2,7 +2,7 @@ use bytes::{RingBuf, Buf, MutBuf}; #[test] pub fn test_initial_buf_empty() { - let mut buf = RingBuf::new(16); + let mut buf = RingBuf::with_capacity(16); assert_eq!(MutBuf::remaining(&buf), 16); assert_eq!(Buf::remaining(&buf), 0); @@ -32,7 +32,7 @@ pub fn test_initial_buf_empty() { #[test] fn test_wrapping_write() { - let mut buf = RingBuf::new(16); + let mut buf = RingBuf::with_capacity(16); let mut out = [0;10]; buf.copy_from(&[42;12][..]); @@ -54,7 +54,7 @@ fn test_wrapping_write() { #[test] fn test_io_write_and_read() { - let mut buf = RingBuf::new(16); + let mut buf = RingBuf::with_capacity(16); let mut out = [0u8;8]; let written = buf.copy_from(&[1;8][..]); @@ -74,7 +74,7 @@ fn test_io_write_and_read() { #[test] #[should_panic] fn test_wrap_reset() { - let mut buf = RingBuf::new(8); + let mut buf = RingBuf::with_capacity(8); buf.copy_from(&[1, 2, 3, 4, 5, 6, 7][..]); buf.mark(); buf.copy_to(&mut [0; 4][..]); @@ -85,7 +85,7 @@ fn test_wrap_reset() { #[test] // Test that writes across a mark/reset are preserved. fn test_mark_write() { - let mut buf = RingBuf::new(8); + let mut buf = RingBuf::with_capacity(8); buf.copy_from(&[1, 2, 3, 4, 5, 6, 7][..]); buf.mark(); buf.copy_from(&[8][..]); @@ -100,7 +100,7 @@ fn test_mark_write() { // Test that "RingBuf::reset" does not reset the length of a // full buffer to zero. fn test_reset_full() { - let mut buf = RingBuf::new(8); + let mut buf = RingBuf::with_capacity(8); buf.copy_from(&[1, 2, 3, 4, 5, 6, 7, 8][..]); assert_eq!(MutBuf::remaining(&buf), 0); buf.mark(); @@ -112,7 +112,7 @@ fn test_reset_full() { #[test] // Test that "RingBuf::clear" does the full reset fn test_clear() { - let mut buf = RingBuf::new(8); + let mut buf = RingBuf::with_capacity(8); buf.copy_from(&[0; 8][..]); assert_eq!(MutBuf::remaining(&buf), 0); assert_eq!(Buf::remaining(&buf), 8);