8000 Link to creating methods in struct documentation · unicode-rs/unicode-segmentation@915fdcd · GitHub
[go: up one dir, main page]

Skip to content

Commit 915fdcd

Browse files
committed
Link to creating methods in struct documentation
The Rust standard library has a nice practice for documentation for public structs. Documentation for these structs include links to the method that creates them. This is very useful for beginners who may stumble upon the documentation for the struct when they would really like documentation for the method. Add documentation for all of the structs that are created by methods on the `UnicodeSegmentation` trait with links back to the creating methods.
1 parent fbba2a6 commit 915fdcd

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/grapheme.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ use core::cmp;
1313
use tables::grapheme::GraphemeCat;
1414

1515
/// External iterator for grapheme clusters and byte offsets.
16+
///
17+
/// This struct is created by the [`grapheme_indices`] method on the [`UnicodeSegmentation`]
18+
/// trait. See its documentation for more.
19+
///
20+
/// [`grapheme_indices`]: trait.UnicodeSegmentation.html#tymethod.grapheme_indices
21+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
1622
#[derive(Clone)]
1723
pub struct GraphemeIndices<'a> {
1824
start_offset: usize,
@@ -61,6 +67,12 @@ impl<'a> DoubleEndedIterator for GraphemeIndices<'a> {
6167

6268
/// External iterator for a string's
6369
/// [grapheme clusters](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries).
70+
///
71+
/// This struct is created by the [`graphemes`] method on the [`UnicodeSegmentation`] trait. See its
72+
/// documentation for more.
73+
///
74+
/// [`graphemes`]: trait.UnicodeSegmentation.html#tymethod.graphemes
75+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
6476
#[derive(Clone)]
6577
pub struct Graphemes<'a> {
6678
string: &'a str,

src/sentence.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,38 @@ mod fwd {
274274
/// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic)
275275
/// property, or with
276276
/// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values).
277+
///
278+
/// This struct is created by the [`unicode_sentences`] method on the [`UnicodeSegmentation`]
279+
/// trait. See its documentation for more.
280+
///
281+
/// [`unicode_sentences`]: trait.UnicodeSegmentation.html#tymethod.unicode_sentences
282+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
277283
#[derive(Clone)]
278284
pub struct UnicodeSentences<'a> {
279285
inner: Filter<USentenceBounds<'a>, fn(&&str) -> bool>,
280286
}
281287

282288
/// External iterator for a string's
283289
/// [sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries).
290+
///
291+
/// This struct is created by the [`split_sentence_bounds`] method on the [`UnicodeSegmentation`]
292+
/// trait. See its documentation for more.
293+
///
294+
/// [`split_sentence_bounds`]: trait.UnicodeSegmentation.html#tymethod.split_sentence_bounds
295+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
284296
#[derive(Clone)]
285297
pub struct USentenceBounds<'a> {
286298
iter: fwd::SentenceBreaks<'a>,
287299
sentence_start: Option<usize>
288300
}
289301

290302
/// External iterator for sentence boundaries and byte offsets.
303+
///
304+
/// This struct is created by the [`split_sentence_bound_indices`] method on the
305+
/// [`UnicodeSegmentation`] trait. See its documentation for more.
306+
///
307+
/// [`split_sentence_bound_indices`]: trait.UnicodeSegmentation.html#tymethod.split_sentence_bound_indices
308+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
291309
#[derive(Clone)]
292310
pub struct USentenceBoundIndices<'a> {
293311
start_offset: usize,

src/word.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ use tables::word::WordCat;
1919
/// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic)
2020
/// property, or with
2121
/// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values).
22+
///
23+
/// This struct is created by the [`unicode_words`] method on the [`UnicodeSegmentation`] trait. See
24+
/// its documentation for more.
25+
///
26+
/// [`unicode_words`]: trait.UnicodeSegmentation.html#tymethod.unicode_words
27+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
2228
pub struct UnicodeWords<'a> {
2329
inner: Filter<UWordBounds<'a>, fn(&&str) -> bool>,
2430
}
@@ -36,6 +42,12 @@ impl<'a> DoubleEndedIterator for UnicodeWords<'a> {
3642

3743
/// External iterator for a string's
3844
/// [word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries).
45+
///
46+
/// This struct is created by the [`split_word_bounds`] method on the [`UnicodeSegmentation`]
47+
/// trait. See its documentation for more.
48+
///
49+
/// [`split_word_bounds`]: trait.UnicodeSegmentation.html#tymethod.split_word_bounds
50+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
3951
#[derive(Clone)]
4052
pub struct UWordBounds<'a> {
4153
string: &'a str,
@@ -44,6 +56,12 @@ pub struct UWordBounds<'a> {
4456
}
4557

4658
/// External iterator for word boundaries and byte offsets.
59+
///
60+
/// This struct is created by the [`split_word_bound_indices`] method on the
61+
/// [`UnicodeSegmentation`] trait. See its documentation for more.
62+
///
63+
/// [`split_word_bound_indices`]: trait.UnicodeSegmentation.html#tymethod.split_word_bound_indices
64+
/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html
4765
#[derive(Clone)]
4866
pub struct UWordBoundIndices<'a> {
4967
start_offset: usize,

0 commit comments

Comments
 (0)
0