diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-02-15 11:43:41 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-02-16 15:26:00 +0000 |
| commit | 8751fa1a9abda9fc7ced6b03315efbd82310830d (patch) | |
| tree | f15613d5ca2fa5aadfdde2df1d94907d1798a5bb /compiler/rustc_span/src/def_id.rs | |
| parent | af3c8b27266e290cf65704284f6862d0f90ee4fc (diff) | |
| download | rust-8751fa1a9abda9fc7ced6b03315efbd82310830d.tar.gz rust-8751fa1a9abda9fc7ced6b03315efbd82310830d.zip | |
`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`
Diffstat (limited to 'compiler/rustc_span/src/def_id.rs')
| -rw-r--r-- | compiler/rustc_span/src/def_id.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index cdda052f529..bcd35066cda 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -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] |
