From a04e2b6b21f5389ba12303b56c33aab0f9780126 Mon Sep 17 00:00:00 2001 From: vms Date: Thu, 28 May 2020 23:22:29 +0300 Subject: [PATCH] use WIT_SECTION_NAME istead of hardcode param --- wit_embedder/src/extracter.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wit_embedder/src/extracter.rs b/wit_embedder/src/extracter.rs index feb394f7..09713331 100644 --- a/wit_embedder/src/extracter.rs +++ b/wit_embedder/src/extracter.rs @@ -1,3 +1,4 @@ +use crate::custom::WIT_SECTION_NAME; use std::path::PathBuf; use walrus::{IdsToIndices, ModuleConfig}; @@ -9,14 +10,14 @@ pub fn extract_wit(wasm_file: PathBuf) -> Result { let sections = module .customs .iter() - .filter(|(_, section)| section.name() == "interface-types") + .filter(|(_, section)| section.name() == WIT_SECTION_NAME) .collect::>(); if sections.is_empty() { - return Err("Wasm binary doesn't contain interface types section".to_string()); + return Err(format!("Wasm binary doesn't contain {} section", WIT_SECTION_NAME)); } if sections.len() > 1 { - return Err("Wasm binary contains more than one interface-types section".to_string()); + return Err(format!("Wasm binary contains more than one {} section", WIT_SECTION_NAME)); } let default_ids = IdsToIndices::default();