Skip to content

Commit

Permalink
refine reference type in format_to_lisp; tag 0.1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Nov 3, 2021
1 parent 36830f7 commit 7f033cb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cirru_parser"
version = "0.1.12"
version = "0.1.13"
authors = ["jiyinyiyong <[email protected]>"]
edition = "2018"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub fn parse(code: &str) -> Result<Vec<Cirru>, String> {

pub fn cirru_to_lisp(code: String) -> String {
match parse(&code) {
Ok(tree) => match format_to_lisp(tree) {
Ok(tree) => match format_to_lisp(&tree) {
Ok(s) => s,
Err(_) => panic!("failed to convert to lisp"),
},
Expand Down
2 changes: 1 addition & 1 deletion src/primes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Cirru {
pub fn to_lisp(&self) -> Result<String, String> {
match self {
Cirru::Leaf(_) => Err(format!("expected list to convert to Lisp, got {}", self)),
Cirru::List(xs) => s_expr::format_to_lisp(xs.to_owned()),
Cirru::List(xs) => s_expr::format_to_lisp(xs),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/s_expr.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::primes::Cirru;

/// format to Cirru to WAT
pub fn format_to_lisp(xs: Vec<Cirru>) -> Result<String, String> {
pub fn format_to_lisp(xs: &[Cirru]) -> Result<String, String> {
let mut content: String = String::from("\n");

for expr in xs {
content = format!("{}{}\n", content, format_expr(&expr, 0)?);
content = format!("{}{}\n", content, format_expr(expr, 0)?);
}

Ok(content)
Expand Down

0 comments on commit 7f033cb

Please sign in to comment.