Skip to content

Commit 4d119e4

Browse files
committed
Rename build to init_with
1 parent b887144 commit 4d119e4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/arc_str.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl ArcStr {
172172
/// UTF-8 text.
173173
///
174174
/// This function returns `None` if memory allocation fails, see
175-
/// [`ArcStr::build_unchecked`] for a version which calls
175+
/// [`ArcStr::init_with_unchecked`] for a version which calls
176176
/// [`handle_alloc_error`](alloc::alloc::handle_alloc_error).
177177
///
178178
/// # Safety
@@ -185,14 +185,14 @@ impl ArcStr {
185185
/// # use arcstr::ArcStr;
186186
/// # use core::mem::MaybeUninit;
187187
/// let arcstr = unsafe {
188-
/// ArcStr::try_build_unchecked(10, |s: &mut [MaybeUninit<u8>]| {
188+
/// ArcStr::try_init_with_unchecked(10, |s: &mut [MaybeUninit<u8>]| {
189189
/// s.fill(MaybeUninit::new(b'a'));
190190
/// }).unwrap()
191191
/// };
192192
/// assert_eq!(arcstr, "aaaaaaaaaa")
193193
/// ```
194194
#[inline]
195-
pub unsafe fn try_build_unchecked<F>(n: usize, initializer: F) -> Option<Self>
195+
pub unsafe fn try_init_with_unchecked<F>(n: usize, initializer: F) -> Option<Self>
196196
where
197197
F: FnOnce(&mut [MaybeUninit<u8>]),
198198
{
@@ -208,7 +208,7 @@ impl ArcStr {
208208
///
209209
/// This function calls
210210
/// [`handle_alloc_error`](alloc::alloc::handle_alloc_error) if memory
211-
/// allocation fails, see [`ArcStr::try_build_unchecked`] for a version
211+
/// allocation fails, see [`ArcStr::try_init_with_unchecked`] for a version
212212
/// which returns `None`
213213
///
214214
/// # Safety
@@ -221,14 +221,14 @@ impl ArcStr {
221221
/// # use arcstr::ArcStr;
222222
/// # use core::mem::MaybeUninit;
223223
/// let arcstr = unsafe {
224-
/// ArcStr::build_unchecked(10, |s: &mut [MaybeUninit<u8>]| {
224+
/// ArcStr::init_with_unchecked(10, |s: &mut [MaybeUninit<u8>]| {
225225
/// s.fill(MaybeUninit::new(b'a'));
226226
/// })
227227
/// };
228228
/// assert_eq!(arcstr, "aaaaaaaaaa")
229229
/// ```
230230
#[inline]
231-
pub unsafe fn build_unchecked<F>(n: usize, initializer: F) -> Self
231+
pub unsafe fn init_with_unchecked<F>(n: usize, initializer: F) -> Self
232232
where
233233
F: FnOnce(&mut [MaybeUninit<u8>]),
234234
{
@@ -246,7 +246,7 @@ impl ArcStr {
246246
/// Note: This function is provided with a zeroed buffer, and performs UTF-8
247247
/// validation after calling the initializer. While both of these are fast
248248
/// operations, some high-performance use cases will be better off using
249-
/// [`ArcStr::try_build_unchecked`] as the building block.
249+
/// [`ArcStr::try_init_with_unchecked`] as the building block.
250250
///
251251
/// # Errors
252252
/// The provided `initializer` callback must initialize the provided buffer
@@ -257,7 +257,7 @@ impl ArcStr {
257257
/// ```
258258
/// # use arcstr::ArcStr;
259259
///
260-
/// let s = ArcStr::build(5, |slice| {
260+
/// let s = ArcStr::init_with(5, |slice| {
261261
/// slice
262262
/// .iter_mut()
263263
/// .zip(b'0'..b'5')
@@ -266,7 +266,7 @@ impl ArcStr {
266266
/// assert_eq!(s, "01234");
267267
/// ```
268268
#[inline]
269-
pub fn build<F>(n: usize, initializer: F) -> Result<Self, core::str::Utf8Error>
269+
pub fn init_with<F>(n: usize, initializer: F) -> Result<Self, core::str::Utf8Error>
270270
where
271271
F: FnOnce(&mut [u8]),
272272
{

0 commit comments

Comments
 (0)