aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def')
-rw-r--r--crates/hir_def/src/type_ref.rs8
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
338impl ConstScalar { 338impl 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 {