Skip to content

Commit

Permalink
Rename Unstructured#get_bytes to Unstructured#bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jan 24, 2021
1 parent f16913f commit 4b71866
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Expand Up @@ -28,11 +28,25 @@ Released YYYY-MM-DD.

--------------------------------------------------------------------------------

## Unreleased

### Added

*

### Changed

* Rename `Unstructured#get_bytes` to `Unstructured#bytes`. [#70](https://github.com/rust-fuzz/arbitrary/pull/70)

### Removed

*

## 1.0.0-rc1

Released 2020-11-25.

### Changed
### Added

* The `Arbitrary` trait is now implemented for `&str`. [#63](https://github.com/rust-fuzz/arbitrary/pull/63)

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Expand Up @@ -770,12 +770,12 @@ impl<'a> Arbitrary<'a> for &'a str {
let size = u.arbitrary_len::<u8>()?;
match str::from_utf8(&u.peek_bytes(size).unwrap()) {
Ok(s) => {
u.get_bytes(size).unwrap();
u.bytes(size).unwrap();
Ok(s)
}
Err(e) => {
let i = e.valid_up_to();
let valid = u.get_bytes(i).unwrap();
let valid = u.bytes(i).unwrap();
let s = unsafe {
debug_assert!(str::from_utf8(valid).is_ok());
str::from_utf8_unchecked(valid)
Expand Down
6 changes: 3 additions & 3 deletions src/unstructured.rs
Expand Up @@ -419,10 +419,10 @@ impl<'a> Unstructured<'a> {
///
/// let mut u = Unstructured::new(&[1, 2, 3, 4]);
///
/// assert!(u.get_bytes(2).unwrap() == &[1, 2]);
/// assert!(u.get_bytes(2).unwrap() == &[3, 4]);
/// assert!(u.bytes(2).unwrap() == &[1, 2]);
/// assert!(u.bytes(2).unwrap() == &[3, 4]);
/// ```
pub fn get_bytes(&mut self, size: usize) -> Result<&'a [u8]> {
pub fn bytes(&mut self, size: usize) -> Result<&'a [u8]> {
if self.data.len() < size {
return Err(Error::NotEnoughData);
}
Expand Down

0 comments on commit 4b71866

Please sign in to comment.