Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9dac45f

Browse files
committedFeb 1, 2025·
rename try_extend method
1 parent dc4deae commit 9dac45f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎src/array_string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl<const CAP: usize> ArrayString<CAP>
295295
Ok(())
296296
}
297297

298-
pub fn try_push_iterator<I: IntoIterator<Item = char>>(&mut self, value: I) -> Result<(), CapacityError<()>> {
298+
pub fn try_extend<I: IntoIterator<Item = char>>(&mut self, value: I) -> Result<(), CapacityError<()>> {
299299
let mut len = self.len();
300300
let value = value.into_iter();
301301
if value.size_hint().0 > self.capacity() - len {
@@ -321,7 +321,7 @@ impl<const CAP: usize> ArrayString<CAP>
321321

322322
pub fn try_from_iterator<I: IntoIterator<Item = char>>(value: I) -> Result<Self, CapacityError<()>> {
323323
let mut string = Self::new();
324-
string.try_push_iterator(value)?;
324+
string.try_extend(value)?;
325325
Ok(string)
326326
}
327327

‎tests/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ fn test_string_collect() {
787787
fn test_string_collect_seveal_times() {
788788
let text = "hello world";
789789
let mut u = ArrayString::<22>::try_from_iterator(text.chars()).unwrap();
790-
u.try_push_iterator(text.chars()).unwrap();
790+
u.try_extend(text.chars()).unwrap();
791791
assert_eq!(u.as_str(), &format!("{}{}", text, text));
792792
assert_eq!(u.len(), text.len()*2);
793793
}

0 commit comments

Comments
 (0)
Please sign in to comment.