Skip to content

Commit 22d2387

Browse files
committed
add doc examples for connect/concat
1 parent 6869645 commit 22d2387

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/libcollections/slice.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -993,11 +993,30 @@ impl<T> SliceExt for [T] {
993993
/// An extension trait for concatenating slices
994994
pub trait SliceConcatExt<T: ?Sized, U> {
995995
/// Flattens a slice of `T` into a single value `U`.
996+
///
997+
/// # Examples
998+
///
999+
/// ```
1000+
/// let v = vec!["hello", "world"];
1001+
///
1002+
/// let s: String = v.concat();
1003+
///
1004+
/// println!("{}", s); // prints "helloworld"
1005+
/// ```
9961006
#[stable]
9971007
fn concat(&self) -> U;
9981008

999-
/// Flattens a slice of `T` into a single value `U`, placing a
1000-
/// given separator between each.
1009+
/// Flattens a slice of `T` into a single value `U`, placing a given separator between each.
1010+
///
1011+
/// # Examples
1012+
///
1013+
/// ```
1014+
/// let v = vec!["hello", "world"];
1015+
///
1016+
/// let s: String = v.connect(" ");
1017+
///
1018+
/// println!("{}", s); // prints "hello world"
1019+
/// ```
10011020
#[stable]
10021021
fn connect(&self, sep: &T) -> U;
10031022
}

0 commit comments

Comments
 (0)