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> {
|
pub fn alloc(initial: Pages, maximum: Option<Pages>) -> Result<MemoryRef, Error> {
|
||||||
{
|
{
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
let initial_u32: u32 = initial
|
let initial_u32: u32 = initial.0.try_into().map_err(|_| {
|
||||||
.0
|
Error::Memory(format!("initial ({}) can't be coerced to 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 {
|
let maximum_u32: Option<u32> = match maximum {
|
||||||
Some(maximum_pages) => Some(
|
Some(maximum_pages) => Some(maximum_pages.0.try_into().map_err(|_| {
|
||||||
maximum_pages
|
Error::Memory(format!(
|
||||||
.0
|
"maximum ({}) can't be coerced to u32",
|
||||||
.try_into()
|
maximum_pages.0
|
||||||
.map_err(|_|
|
))
|
||||||
Error::Memory(
|
})?),
|
||||||
format!("maximum ({}) can't be coerced to u32", maximum_pages.0)
|
|
||||||
)
|
|
||||||
)?,
|
|
||||||
),
|
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
validation::validate_memory(initial_u32, maximum_u32).map_err(Error::Memory)?;
|
validation::validate_memory(initial_u32, maximum_u32).map_err(Error::Memory)?;
|
||||||
|
|
Loading…
Reference in New Issue