Skip to content

Commit 48f23d9

Browse files
committed
docs(allocator): add safety constraint for String::from_raw_parts_in
1 parent 8d9618b commit 48f23d9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

crates/oxc_allocator/src/string.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ impl<'alloc> String<'alloc> {
212212
/// * The memory at `ptr` needs to have been previously allocated by the same [`Allocator`].
213213
/// * `length` needs to be less than or equal to `capacity`.
214214
/// * `capacity` needs to be the correct value.
215+
/// * The region of memory starting at `ptr` and spanning `length` bytes must contain a valid
216+
/// UTF-8 string.
215217
///
216218
/// Violating these may cause problems like corrupting the allocator's internal data structures.
217219
///
@@ -221,7 +223,6 @@ impl<'alloc> String<'alloc> {
221223
///
222224
/// # Examples
223225
/// ```
224-
/// use std::mem;
225226
/// use oxc_allocator::{Allocator, String};
226227
///
227228
/// let allocator = Allocator::default();

0 commit comments

Comments
 (0)