We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 701514f + 37be9a9 commit 3dd3650Copy full SHA for 3dd3650
src/collections/string.rs
@@ -798,6 +798,24 @@ impl<'bump> String<'bump> {
798
String { vec: bytes }
799
}
800
801
+ /// Returns a shared reference to the allocator backing this `String`.
802
+ ///
803
+ /// # Examples
804
805
+ /// ```
806
+ /// use bumpalo::{Bump, collections::String};
807
808
+ /// // uses the same allocator as the provided `String`
809
+ /// fn copy_string<'bump>(s: &String<'bump>) -> &'bump str {
810
+ /// s.bump().alloc_str(s.as_str())
811
+ /// }
812
813
+ #[inline]
814
+ #[must_use]
815
+ pub fn bump(&self) -> &'bump Bump {
816
+ self.vec.bump()
817
+ }
818
+
819
/// Converts a `String` into a byte vector.
820
///
821
/// This consumes the `String`, so we do not need to copy its contents.
0 commit comments