]> git.lizzy.rs Git - rust.git/commitdiff
Make `length_limit` a `usize`
authorCamelid <camelidcamel@gmail.com>
Tue, 24 Nov 2020 03:26:15 +0000 (19:26 -0800)
committerCamelid <camelidcamel@gmail.com>
Thu, 3 Dec 2020 22:11:37 +0000 (14:11 -0800)
src/librustdoc/html/markdown.rs

index 6bba50361912032946c684604e4a1564901325e0..0e4c5410abe1e17255a1ec1dc9687967e1f63f2a 100644 (file)
@@ -1043,13 +1043,11 @@ impl MarkdownSummaryLine<'_> {
 ///
 /// Returns a tuple of the rendered HTML string and whether the output was shortened
 /// due to the provided `length_limit`.
-fn markdown_summary_with_limit(md: &str, length_limit: Option<u16>) -> (String, bool) {
+fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool) {
     if md.is_empty() {
         return (String::new(), false);
     }
 
-    let length_limit = length_limit.unwrap_or(u16::MAX) as usize;
-
     let mut s = String::with_capacity(md.len() * 3 / 2);
     let mut text_length = 0;
     let mut stopped_early = false;
@@ -1115,7 +1113,7 @@ fn push(s: &mut String, text_length: &mut usize, text: &str) {
 ///
 /// See [`markdown_summary_with_limit`] for details about what is rendered and what is not.
 crate fn short_markdown_summary(markdown: &str) -> String {
-    let (mut s, was_shortened) = markdown_summary_with_limit(markdown, Some(59));
+    let (mut s, was_shortened) = markdown_summary_with_limit(markdown, 59);
 
     if was_shortened {
         s.push('…');