Avoid another &Lrc<..>
in a return value.
This commit is contained in:
parent
2123509351
commit
4547c0a990
@ -1380,7 +1380,7 @@ pub enum ExternalSourceKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ExternalSource {
|
impl ExternalSource {
|
||||||
pub fn get_source(&self) -> Option<&Lrc<String>> {
|
pub fn get_source(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
|
ExternalSource::Foreign { kind: ExternalSourceKind::Present(ref src), .. } => Some(src),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -257,7 +257,7 @@ fn t10() {
|
|||||||
);
|
);
|
||||||
imported_src_file.add_external_src(|| Some(unnormalized.to_string()));
|
imported_src_file.add_external_src(|| Some(unnormalized.to_string()));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
imported_src_file.external_src.borrow().get_source().unwrap().as_ref(),
|
imported_src_file.external_src.borrow().get_source().unwrap(),
|
||||||
normalized,
|
normalized,
|
||||||
"imported source file should be normalized"
|
"imported source file should be normalized"
|
||||||
);
|
);
|
||||||
|
@ -287,6 +287,7 @@ pub fn as_str(&self) -> Option<&str> {
|
|||||||
self.sf
|
self.sf
|
||||||
.src
|
.src
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
.map(|src| src.as_str())
|
||||||
.or_else(|| self.sf.external_src.get().and_then(|src| src.get_source()))
|
.or_else(|| self.sf.external_src.get().and_then(|src| src.get_source()))
|
||||||
.and_then(|x| x.get(self.range.clone()))
|
.and_then(|x| x.get(self.range.clone()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user