feat(interface-types) Remove the 'input lifetime on Instruction.

This commit is contained in:
Ivan Enderlin 2020-03-10 10:37:09 +01:00
parent 47b63bc9c6
commit 8bd3345a79
6 changed files with 12 additions and 13 deletions

View File

@ -89,12 +89,12 @@ pub struct Export<'input> {
/// Represents an adapter.
#[derive(PartialEq, Debug)]
pub struct Adapter<'input> {
pub struct Adapter {
/// The adapter function type.
pub function_type: u32,
/// The instructions.
pub instructions: Vec<Instruction<'input>>,
pub instructions: Vec<Instruction>,
}
/// Represents an implementation.
@ -137,7 +137,7 @@ pub struct Interfaces<'input> {
pub imports: Vec<Import<'input>>,
/// All the adapters.
pub adapters: Vec<Adapter<'input>>,
pub adapters: Vec<Adapter>,
/// All the exported functions.
pub exports: Vec<Export<'input>>,

View File

@ -137,7 +137,7 @@ impl Parse<'_> for InterfaceType {
}
}
impl<'a> Parse<'a> for Instruction<'a> {
impl<'a> Parse<'a> for Instruction {
#[allow(clippy::cognitive_complexity)]
fn parse(parser: Parser<'a>) -> Result<Self> {
let mut lookahead = parser.lookahead1();
@ -392,7 +392,7 @@ impl Parse<'_> for FunctionType {
enum Interface<'a> {
Type(Type),
Import(Import<'a>),
Adapter(Adapter<'a>),
Adapter(Adapter),
Export(Export<'a>),
Implementation(Implementation),
}
@ -520,7 +520,7 @@ impl<'a> Parse<'a> for Implementation {
}
}
impl<'a> Parse<'a> for Adapter<'a> {
impl<'a> Parse<'a> for Adapter {
fn parse(parser: Parser<'a>) -> Result<Self> {
parser.parse::<keyword::func>()?;

View File

@ -162,7 +162,7 @@ where
/// Encode an `Adapter` into bytes.
///
/// Decoder is in `decoders::binary::adapters`.
impl<W> ToBytes<W> for Adapter<'_>
impl<W> ToBytes<W> for Adapter
where
W: Write,
{
@ -244,7 +244,7 @@ where
/// Encode an `Instruction` into bytes.
///
/// Decoder is `decoders::binary::instruction`.
impl<W> ToBytes<W> for Instruction<'_>
impl<W> ToBytes<W> for Instruction
where
W: Write,
{

View File

@ -80,7 +80,7 @@ impl ToString for &InterfaceType {
}
/// Encode an `Instruction` into a string.
impl<'input> ToString for &Instruction<'input> {
impl ToString for &Instruction {
fn to_string(&self) -> String {
match self {
Instruction::ArgumentGet { index } => format!("arg.get {}", index),
@ -194,7 +194,7 @@ impl<'input> ToString for &Import<'input> {
}
/// Encode an `Adapter` into a string.
impl<'input> ToString for &Adapter<'input> {
impl ToString for &Adapter {
fn to_string(&self) -> String {
format!(
r#"(@interface func (type {function_type}){instructions})"#,

View File

@ -2,7 +2,7 @@
/// Represents all the possible WIT instructions.
#[derive(PartialEq, Debug)]
pub enum Instruction<'input> {
pub enum Instruction {
/// The `arg.get` instruction.
ArgumentGet {
/// The argument index.

View File

@ -174,8 +174,7 @@ where
}
/// Transforms a `Vec<Instruction>` into an `Interpreter`.
impl<'binary_input, Instance, Export, LocalImport, Memory, MemoryView>
TryFrom<&Vec<Instruction<'binary_input>>>
impl<Instance, Export, LocalImport, Memory, MemoryView> TryFrom<&Vec<Instruction>>
for Interpreter<Instance, Export, LocalImport, Memory, MemoryView>
where
Export: wasm::structures::Export,