From 915fdcd01caa7fb7b663fb0f49f907b09b04cb9a Mon Sep 17 00:00:00 2001 From: Harrison McCullough Date: Mon, 25 May 2020 09:50:03 -0600 Subject: [PATCH] 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. --- src/grapheme.rs | 12 ++++++++++++ src/sentence.rs | 18 ++++++++++++++++++ src/word.rs | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/src/grapheme.rs b/src/grapheme.rs index 176a7aa..e95d478 100644 --- a/src/grapheme.rs +++ b/src/grapheme.rs @@ -13,6 +13,12 @@ use core::cmp; use tables::grapheme::GraphemeCat; /// External iterator for grapheme clusters and byte offsets. +/// +/// This struct is created by the [`grapheme_indices`] method on the [`UnicodeSegmentation`] +/// trait. See its documentation for more. +/// +/// [`grapheme_indices`]: trait.UnicodeSegmentation.html#tymethod.grapheme_indices +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct GraphemeIndices<'a> { start_offset: usize, @@ -61,6 +67,12 @@ impl<'a> DoubleEndedIterator for GraphemeIndices<'a> { /// External iterator for a string's /// [grapheme clusters](http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries). +/// +/// This struct is created by the [`graphemes`] method on the [`UnicodeSegmentation`] trait. See its +/// documentation for more. +/// +/// [`graphemes`]: trait.UnicodeSegmentation.html#tymethod.graphemes +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct Graphemes<'a> { string: &'a str, diff --git a/src/sentence.rs b/src/sentence.rs index 48cafba..275da52 100644 --- a/src/sentence.rs +++ b/src/sentence.rs @@ -274,6 +274,12 @@ mod fwd { /// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic) /// property, or with /// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values). +/// +/// This struct is created by the [`unicode_sentences`] method on the [`UnicodeSegmentation`] +/// trait. See its documentation for more. +/// +/// [`unicode_sentences`]: trait.UnicodeSegmentation.html#tymethod.unicode_sentences +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct UnicodeSentences<'a> { inner: Filter, fn(&&str) -> bool>, @@ -281,6 +287,12 @@ pub struct UnicodeSentences<'a> { /// External iterator for a string's /// [sentence boundaries](http://www.unicode.org/reports/tr29/#Sentence_Boundaries). +/// +/// This struct is created by the [`split_sentence_bounds`] method on the [`UnicodeSegmentation`] +/// trait. See its documentation for more. +/// +/// [`split_sentence_bounds`]: trait.UnicodeSegmentation.html#tymethod.split_sentence_bounds +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct USentenceBounds<'a> { iter: fwd::SentenceBreaks<'a>, @@ -288,6 +300,12 @@ pub struct USentenceBounds<'a> { } /// External iterator for sentence boundaries and byte offsets. +/// +/// This struct is created by the [`split_sentence_bound_indices`] method on the +/// [`UnicodeSegmentation`] trait. See its documentation for more. +/// +/// [`split_sentence_bound_indices`]: trait.UnicodeSegmentation.html#tymethod.split_sentence_bound_indices +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct USentenceBoundIndices<'a> { start_offset: usize, diff --git a/src/word.rs b/src/word.rs index 5cf111a..179d122 100644 --- a/src/word.rs +++ b/src/word.rs @@ -19,6 +19,12 @@ use tables::word::WordCat; /// [Alphabetic](http://unicode.org/reports/tr44/#Alphabetic) /// property, or with /// [General_Category=Number](http://unicode.org/reports/tr44/#General_Category_Values). +/// +/// This struct is created by the [`unicode_words`] method on the [`UnicodeSegmentation`] trait. See +/// its documentation for more. +/// +/// [`unicode_words`]: trait.UnicodeSegmentation.html#tymethod.unicode_words +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html pub struct UnicodeWords<'a> { inner: Filter, fn(&&str) -> bool>, } @@ -36,6 +42,12 @@ impl<'a> DoubleEndedIterator for UnicodeWords<'a> { /// External iterator for a string's /// [word boundaries](http://www.unicode.org/reports/tr29/#Word_Boundaries). +/// +/// This struct is created by the [`split_word_bounds`] method on the [`UnicodeSegmentation`] +/// trait. See its documentation for more. +/// +/// [`split_word_bounds`]: trait.UnicodeSegmentation.html#tymethod.split_word_bounds +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct UWordBounds<'a> { string: &'a str, @@ -44,6 +56,12 @@ pub struct UWordBounds<'a> { } /// External iterator for word boundaries and byte offsets. +/// +/// This struct is created by the [`split_word_bound_indices`] method on the +/// [`UnicodeSegmentation`] trait. See its documentation for more. +/// +/// [`split_word_bound_indices`]: trait.UnicodeSegmentation.html#tymethod.split_word_bound_indices +/// [`UnicodeSegmentation`]: trait.UnicodeSegmentation.html #[derive(Clone)] pub struct UWordBoundIndices<'a> { start_offset: usize, pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy