Use try_from instead of the cast crate.

Now that `try_from` is in stable Rust, we can use it here.
This commit is contained in:
Dan Gohman
2019-05-31 09:51:11 -07:00
committed by Benjamin Bouvier
parent fbaffa2c04
commit da1baf7481
3 changed files with 4 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ use crate::translation_utils::{
type_to_type, FuncIndex, Global, GlobalIndex, GlobalInit, Memory, MemoryIndex, SignatureIndex,
Table, TableElementType, TableIndex,
};
use core::convert::TryFrom;
use cranelift_codegen::ir::{self, AbiParam, Signature};
use cranelift_entity::EntityRef;
use std::vec::Vec;
@@ -270,7 +271,7 @@ pub fn parse_element_section<'data>(
ref s => panic!("unsupported init expr in element section: {:?}", s),
};
let items_reader = items.get_items_reader()?;
let mut elems = Vec::with_capacity(cast::usize(items_reader.get_count()));
let mut elems = Vec::with_capacity(usize::try_from(items_reader.get_count()).unwrap());
for item in items_reader {
let x = item?;
elems.push(FuncIndex::from_u32(x));