From de0ed9860d86c3b905a967b1a7b5243499d32d67 Mon Sep 17 00:00:00 2001 From: Jade Date: Sat, 15 May 2021 18:51:18 -0700 Subject: Address final feedback * rename ConstExtension->ConstExt * refactor a manual construction of a Const --- crates/hir_def/src/type_ref.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'crates/hir_def') 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 { } impl ConstScalar { + /// Gets a target usize out of the ConstScalar + pub fn as_usize(&self) -> Option { + match self { + &ConstScalar::Usize(us) => Some(us), + _ => None, + } + } + // FIXME: as per the comments on `TypeRef::Array`, this evaluation should not happen at this // parse stage. fn usize_from_literal_expr(expr: ast::Expr) -> ConstScalar { -- cgit v1.2.3