]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_ast/src/util/comments.rs
Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett
[rust.git] / compiler / rustc_ast / src / util / comments.rs
index 8730aeb0f3bffdf182cef918a75c06a4a44bd391..b4fff0022e29547e2cd17c2994ac09f528258456 100644 (file)
@@ -24,6 +24,14 @@ pub struct Comment {
     pub pos: BytePos,
 }
 
+/// A fast conservative estimate on whether the string can contain documentation links.
+/// A pair of square brackets `[]` must exist in the string, but we only search for the
+/// opening bracket because brackets always go in pairs in practice.
+#[inline]
+pub fn may_have_doc_links(s: &str) -> bool {
+    s.contains('[')
+}
+
 /// Makes a doc string more presentable to users.
 /// Used by rustdoc and perhaps other tools, but not by rustc.
 pub fn beautify_doc_string(data: Symbol, kind: CommentKind) -> Symbol {