Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Unstructured#get_bytes to Unstructured#bytes #70

Merged
merged 1 commit into from Jan 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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