|
1 | 1 | use std::cell::RefCell;
|
2 | 2 | use std::default::Default;
|
3 | 3 | use std::hash::{Hash, Hasher};
|
4 |
| -use std::iter::FromIterator; |
5 | 4 | use std::lazy::SyncOnceCell as OnceCell;
|
6 | 5 | use std::path::PathBuf;
|
7 | 6 | use std::rc::Rc;
|
@@ -945,16 +944,14 @@ fn add_doc_fragment(out: &mut String, frag: &DocFragment) {
|
945 | 944 | }
|
946 | 945 | }
|
947 | 946 |
|
948 |
| -impl<'a> FromIterator<&'a DocFragment> for String { |
949 |
| - fn from_iter<T>(iter: T) -> Self |
950 |
| - where |
951 |
| - T: IntoIterator<Item = &'a DocFragment>, |
952 |
| - { |
953 |
| - iter.into_iter().fold(String::new(), |mut acc, frag| { |
954 |
| - add_doc_fragment(&mut acc, frag); |
955 |
| - acc |
956 |
| - }) |
| 947 | +/// Collapse a collection of [`DocFragment`]s into one string, |
| 948 | +/// handling indentation and newlines as needed. |
| 949 | +crate fn collapse_doc_fragments(doc_strings: &[DocFragment]) -> String { |
| 950 | + let mut acc = String::new(); |
| 951 | + for frag in doc_strings { |
| 952 | + add_doc_fragment(&mut acc, frag); |
957 | 953 | }
|
| 954 | + acc |
958 | 955 | }
|
959 | 956 |
|
960 | 957 | /// A link that has not yet been rendered.
|
@@ -1083,7 +1080,11 @@ impl Attributes {
|
1083 | 1080 | /// Finds all `doc` attributes as NameValues and returns their corresponding values, joined
|
1084 | 1081 | /// with newlines.
|
1085 | 1082 | crate fn doc_value(&self) -> Option<String> {
|
1086 |
| - if self.doc_strings.is_empty() { None } else { Some(self.doc_strings.iter().collect()) } |
| 1083 | + if self.doc_strings.is_empty() { |
| 1084 | + None |
| 1085 | + } else { |
| 1086 | + Some(collapse_doc_fragments(&self.doc_strings)) |
| 1087 | + } |
1087 | 1088 | }
|
1088 | 1089 |
|
1089 | 1090 | crate fn get_doc_aliases(&self) -> Box<[String]> {
|
|
0 commit comments