fmt.
This commit is contained in:
parent
8a654554d1
commit
7d1d6efe38
|
@ -110,21 +110,16 @@ impl MemoryInstance {
|
|||
pub fn alloc(initial: Pages, maximum: Option<Pages>) -> Result<MemoryRef, Error> {
|
||||
{
|
||||
use std::convert::TryInto;
|
||||
let initial_u32: u32 = initial
|
||||
.0
|
||||
.try_into()
|
||||
.map_err(|_| Error::Memory(format!("initial ({}) can't be coerced to u32", initial.0)))?;
|
||||
let initial_u32: u32 = initial.0.try_into().map_err(|_| {
|
||||
Error::Memory(format!("initial ({}) can't be coerced to u32", initial.0))
|
||||
})?;
|
||||
let maximum_u32: Option<u32> = match maximum {
|
||||
Some(maximum_pages) => Some(
|
||||
maximum_pages
|
||||
.0
|
||||
.try_into()
|
||||
.map_err(|_|
|
||||
Error::Memory(
|
||||
format!("maximum ({}) can't be coerced to u32", maximum_pages.0)
|
||||
)
|
||||
)?,
|
||||
),
|
||||
Some(maximum_pages) => Some(maximum_pages.0.try_into().map_err(|_| {
|
||||
Error::Memory(format!(
|
||||
"maximum ({}) can't be coerced to u32",
|
||||
maximum_pages.0
|
||||
))
|
||||
})?),
|
||||
None => None,
|
||||
};
|
||||
validation::validate_memory(initial_u32, maximum_u32).map_err(Error::Memory)?;
|
||||
|
|
Loading…
Reference in New Issue