Skip to content

Commit

Permalink
fix warnings; bump 0.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Apr 18, 2021
1 parent 1c904df commit 8ed9d19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cirru_edn"
version = "0.0.3"
version = "0.0.4"
authors = ["jiyinyiyong <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -13,5 +13,5 @@ readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cirru_parser = "0.0.6"
cirru_parser = "0.0.8"
regex = "1.4.5"
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod primes;

use cirru_parser::{parse, write_cirru, CirruNode, CirruWriterOptions};
use cirru_parser::{parse_cirru, write_cirru, CirruNode, CirruWriterOptions};
pub use primes::CirruEdn;
use primes::CirruEdn::*;
use regex::Regex;
Expand All @@ -11,7 +11,7 @@ use cirru_parser::CirruNode::*;

/// parse Cirru code into data
pub fn parse_cirru_edn(s: String) -> Result<CirruEdn, String> {
match parse(s) {
match parse_cirru(s) {
Ok(nodes) => match nodes {
CirruLeaf(_) => Err(String::from("Expected exprs")),
CirruList(xs) => {
Expand All @@ -36,7 +36,7 @@ fn extract_cirru_edn(node: &CirruNode) -> Result<CirruEdn, String> {
"true" => Ok(CirruEdnBool(true)),
"false" => Ok(CirruEdnBool(false)),
"" => Err(String::from("Empty string is invalid")),
s1 => match s1.chars().nth(0).unwrap() {
s1 => match s1.chars().next().unwrap() {
'\'' => Ok(CirruEdnSymbol(String::from(&s1[1..]))),
':' => Ok(CirruEdnKeyword(String::from(&s1[1..]))),
'"' | '|' => Ok(CirruEdnString(String::from(&s1[1..]))),
Expand All @@ -51,7 +51,7 @@ fn extract_cirru_edn(node: &CirruNode) -> Result<CirruEdn, String> {
},
},
CirruList(xs) => {
if xs.len() == 0 {
if xs.is_empty() {
Err(String::from("empty expr is invalid"))
} else {
match &xs[0] {
Expand Down Expand Up @@ -147,7 +147,7 @@ fn extract_cirru_edn(node: &CirruNode) -> Result<CirruEdn, String> {
}
Ok(CirruEdnRecord(name, fields, values))
} else {
Err(format!("Not enough items for record"))
Err(String::from("Not enough items for record"))
}
}
a => Err(format!("Invalid operator: {}", a)),
Expand Down Expand Up @@ -178,14 +178,14 @@ fn assemble_cirru_node(data: &CirruEdn) -> CirruNode {
for x in xs {
ys.push(assemble_cirru_node(x));
}
return CirruList(ys);
CirruList(ys)
}
CirruEdnSet(xs) => {
let mut ys: Vec<CirruNode> = vec![CirruLeaf(String::from("#{}"))];
for x in xs {
ys.push(assemble_cirru_node(x));
}
return CirruList(ys);
CirruList(ys)
}
CirruEdnMap(xs) => {
let mut ys: Vec<CirruNode> = vec![CirruLeaf(String::from("{}"))];
Expand Down
4 changes: 1 addition & 3 deletions tests/edn_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ fn demo_parsing() {
}

#[test]
fn debug_format() -> Result<(), String> {
fn debug_format() {
// TODO order for hashmap is unstable

// let DICT_INLINE2: &str =
Expand Down Expand Up @@ -217,6 +217,4 @@ fn debug_format() -> Result<(), String> {
]))]);

assert_eq!(format!("{}", code), "([] (quote (a b)))");

Ok(())
}

0 comments on commit 8ed9d19

Please sign in to comment.