diff options
Diffstat (limited to 'vendor/bumpalo/src')
-rw-r--r-- | vendor/bumpalo/src/collections/vec.rs | 22 | ||||
-rwxr-xr-x | vendor/bumpalo/src/lib.rs | 8 |
2 files changed, 26 insertions, 4 deletions
diff --git a/vendor/bumpalo/src/collections/vec.rs b/vendor/bumpalo/src/collections/vec.rs index 312aa055b..66c821b10 100644 --- a/vendor/bumpalo/src/collections/vec.rs +++ b/vendor/bumpalo/src/collections/vec.rs @@ -104,6 +104,8 @@ use core::ops::{Index, IndexMut, RangeBounds}; use core::ptr; use core::ptr::NonNull; use core::slice; +#[cfg(feature = "std")] +use std::io; unsafe fn arith_offset<T>(p: *const T, offset: isize) -> *const T { p.offset(offset) @@ -2612,3 +2614,23 @@ where } } } + +#[cfg(feature = "std")] +impl<'bump> io::Write for Vec<'bump, u8> { + #[inline] + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { + self.extend_from_slice(buf); + Ok(buf.len()) + } + + #[inline] + fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { + self.extend_from_slice(buf); + Ok(()) + } + + #[inline] + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } +} diff --git a/vendor/bumpalo/src/lib.rs b/vendor/bumpalo/src/lib.rs index c25e03ca3..a173321e8 100755 --- a/vendor/bumpalo/src/lib.rs +++ b/vendor/bumpalo/src/lib.rs @@ -1,7 +1,7 @@ #![doc = include_str!("../README.md")] #![deny(missing_debug_implementations)] #![deny(missing_docs)] -#![no_std] +#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "allocator_api", feature(allocator_api))] #[doc(hidden)] @@ -1430,7 +1430,7 @@ impl Bump { let aligned_ptr = ptr.wrapping_sub(rem); if aligned_ptr >= start { - let aligned_ptr = NonNull::new_unchecked(aligned_ptr as *mut u8); + let aligned_ptr = NonNull::new_unchecked(aligned_ptr); footer.ptr.set(aligned_ptr); Some(aligned_ptr) } else { @@ -1455,7 +1455,7 @@ impl Bump { let current_footer = self.current_chunk_footer.get(); let current_footer = unsafe { current_footer.as_ref() }; - current_footer as *const _ as usize - current_footer.data.as_ptr() as usize + current_footer.ptr.get().as_ptr() as usize - current_footer.data.as_ptr() as usize } /// Slow path allocation for when we need to allocate a new chunk from the @@ -1529,7 +1529,7 @@ impl Bump { ptr, new_footer ); - let ptr = NonNull::new_unchecked(ptr as *mut u8); + let ptr = NonNull::new_unchecked(ptr); new_footer.ptr.set(ptr); // Return a pointer to the freshly allocated region in this chunk. |