if $c:expr { Some($r:expr) } else { None }
=>> $c.then(|| $r)
This commit is contained in:
parent
af3c8b2726
commit
8751fa1a9a
54 changed files with 159 additions and 281 deletions
|
@ -299,7 +299,7 @@ impl DefId {
|
|||
|
||||
#[inline]
|
||||
pub fn as_local(self) -> Option<LocalDefId> {
|
||||
if self.is_local() { Some(LocalDefId { local_def_index: self.index }) } else { None }
|
||||
self.is_local().then(|| LocalDefId { local_def_index: self.index })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -320,7 +320,7 @@ impl DefId {
|
|||
|
||||
#[inline]
|
||||
pub fn as_crate_root(self) -> Option<CrateNum> {
|
||||
if self.is_crate_root() { Some(self.krate) } else { None }
|
||||
self.is_crate_root().then(|| self.krate)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue