fix: handle escaped chars in doc comments

This commit is contained in:
roife 2024-04-19 14:47:48 +08:00
parent af1fd88c4d
commit a543516ea4
4 changed files with 69 additions and 12 deletions

View file

@ -5,7 +5,7 @@ pub mod builtin;
#[cfg(test)]
mod tests;
use std::{hash::Hash, ops, slice::Iter as SliceIter};
use std::{borrow::Cow, hash::Hash, ops, slice::Iter as SliceIter};
use base_db::CrateId;
use cfg::{CfgExpr, CfgOptions};
@ -573,6 +573,10 @@ impl<'attr> AttrQuery<'attr> {
self.attrs().find_map(|attr| attr.string_value())
}
pub fn string_value_unescape(self) -> Option<Cow<'attr, str>> {
self.attrs().find_map(|attr| attr.string_value_unescape())
}
pub fn exists(self) -> bool {
self.attrs().next().is_some()
}