diff options
author | Jade <[email protected]> | 2021-05-16 02:51:18 +0100 |
---|---|---|
committer | Jade <[email protected]> | 2021-05-16 02:51:18 +0100 |
commit | de0ed9860d86c3b905a967b1a7b5243499d32d67 (patch) | |
tree | 6c98701c319b32a52fdd6d39ce85c590aaf254f9 /crates/hir_def | |
parent | 78d6b88f211cc9faf88815ce7fb1a91546cfce15 (diff) |
Address final feedback
* rename ConstExtension->ConstExt
* refactor a manual construction of a Const
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/type_ref.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/hir_def/src/type_ref.rs b/crates/hir_def/src/type_ref.rs index 6a3259b27..9e44547cb 100644 --- a/crates/hir_def/src/type_ref.rs +++ b/crates/hir_def/src/type_ref.rs | |||
@@ -336,6 +336,14 @@ impl std::fmt::Display for ConstScalar { | |||
336 | } | 336 | } |
337 | 337 | ||
338 | impl ConstScalar { | 338 | impl ConstScalar { |
339 | /// Gets a target usize out of the ConstScalar | ||
340 | pub fn as_usize(&self) -> Option<u64> { | ||
341 | match self { | ||
342 | &ConstScalar::Usize(us) => Some(us), | ||
343 | _ => None, | ||
344 | } | ||
345 | } | ||
346 | |||
339 | // FIXME: as per the comments on `TypeRef::Array`, this evaluation should not happen at this | 347 | // FIXME: as per the comments on `TypeRef::Array`, this evaluation should not happen at this |
340 | // parse stage. | 348 | // parse stage. |
341 | fn usize_from_literal_expr(expr: ast::Expr) -> ConstScalar { | 349 | fn usize_from_literal_expr(expr: ast::Expr) -> ConstScalar { |