Skip to content

Commit

Permalink
Func構造体のフィールド名を短縮し、tuber::Funcとの変換を更新
Browse files Browse the repository at this point in the history
  • Loading branch information
todays-mitsui committed Jan 31, 2025
1 parent 61f0bef commit 7f40ec5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ski3/src/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ use wasm_bindgen::prelude::*;
#[derive(Tsify, Serialize, Deserialize, Debug)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct Func {
name: Identifier,
params: Vec<Identifier>,
body: Expr,
n: Identifier,
p: Vec<Identifier>,
b: Expr,
}

impl From<tuber::Func> for Func {
fn from(tuber_func: tuber::Func) -> Func {
Func {
name: tuber_func.name().to_string(),
params: tuber_func
n: tuber_func.name().to_string(),
p: tuber_func
.params()
.iter()
.map(|id| id.as_str().to_string())
.collect(),
body: Expr::from(tuber_func.body().clone()),
b: Expr::from(tuber_func.body().clone()),
}
}
}

impl From<Func> for tuber::Func {
fn from(ski_func: Func) -> tuber::Func {
tuber::Func::new(
ski_func.name.into(),
ski_func.params.into_iter().map(|id| id.into()).collect(),
ski_func.body.into(),
ski_func.n.into(),
ski_func.p.into_iter().map(|id| id.into()).collect(),
ski_func.b.into(),
)
}
}
Expand Down

0 comments on commit 7f40ec5

Please sign in to comment.