Skip to content

Commit 31f5c8d

Browse files
jasonthompsonalexcrichton
authored andcommitted
---
yaml --- r: 153067 b: refs/heads/try2 c: 7db691e h: refs/heads/master i: 153065: bf47f8d 153063: 7e4dde4 v: v3
1 parent 6135eaf commit 31f5c8d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 2f355b79ddb49c45fb3396352f464458ad867234
8+
refs/heads/try2: 7db691e010c34d156ff31eda2db0560738c45837
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcollections/str.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,27 @@ pub fn from_chars(chs: &[char]) -> String {
160160
/// Methods for vectors of strings
161161
pub trait StrVector {
162162
/// Concatenate a vector of strings.
163+
///
164+
/// # Example
165+
///
166+
/// ```rust
167+
/// let first = "Restaurant at the End of the".to_string();
168+
/// let second = " Universe".to_string();
169+
/// let string_vec = vec![first, second];
170+
/// assert_eq!(string_vec.concat(), "Restaurant at the End of the Universe".to_string());
171+
/// ```
163172
fn concat(&self) -> String;
164173

165174
/// Concatenate a vector of strings, placing a given separator between each.
175+
///
176+
/// # Example
177+
///
178+
/// ```rust
179+
/// let first = "Roast".to_string();
180+
/// let second = "Sirloin Steak".to_string();
181+
/// let string_vec = vec![first, second];
182+
/// assert_eq!(string_vec.connect(", "), "Roast, Sirloin Steak".to_string());
183+
/// ```
166184
fn connect(&self, sep: &str) -> String;
167185
}
168186

@@ -172,7 +190,7 @@ impl<'a, S: Str> StrVector for &'a [S] {
172190
return String::new();
173191
}
174192

175-
// `len` calculation may overflow but push_str but will check boundaries
193+
// `len` calculation may overflow but push_str will check boundaries
176194
let len = self.iter().map(|s| s.as_slice().len()).sum();
177195

178196
let mut result = String::with_capacity(len);

0 commit comments

Comments
 (0)