Skip to content

Commit

Permalink
Update lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
mtshiba committed Aug 20, 2024
1 parent 4f653ff commit 51453b7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,31 +253,29 @@ impl Playground {
.replace("Erg transpiler", "Erg Playground (experimental)")
}

/// returns `Box<[JsValue]>` instead of `Vec<ErgVarEntry>`
pub fn dir(&mut self) -> Box<[JsValue]> {
pub fn dir(&mut self) -> Box<[ErgVarEntry]> {
self.transpiler
.dir()
.into_iter()
.map(|(n, vi)| JsValue::from(ErgVarEntry::new(n.clone(), vi.clone())))
.map(|(n, vi)| ErgVarEntry::new(n.clone(), vi.clone()))
.collect::<Vec<_>>()
.into_boxed_slice()
}

/// returns `Box<[JsValue]>` instead of `Vec<ErgError>`
pub fn check(&mut self, input: &str) -> Box<[JsValue]> {
pub fn check(&mut self, input: &str) -> Box<[ErgError]> {
match self.transpiler.transpile(input.to_string(), "exec") {
Ok(artifact) => artifact
.warns
.into_iter()
.map(|err| ErgError::from(err).into())
.map(ErgError::from)
.collect::<Vec<_>>()
.into_boxed_slice(),
Err(mut err_artifact) => {
err_artifact.errors.extend(err_artifact.warns);
let errs = err_artifact
.errors
.into_iter()
.map(|err| ErgError::from(err).into())
.map(ErgError::from)
.collect::<Vec<_>>();
errs.into_boxed_slice()
}
Expand Down

0 comments on commit 51453b7

Please sign in to comment.