diff --git a/CHANGELOG.md b/CHANGELOG.md index d6f4010..83d4c54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.1] - 2022-06-08 +### Fixed +- Missing commas between items is output JSON Objects. + +### Changed +- Release profile for smaller binary size. +- Updated deps to latest. +- Linter suggested updates. + ## [0.3.0] - 2022-04-06 ### Changed - Lexer token return signature reducing its size from 12->8 bytes @@ -39,8 +48,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release. -[Unreleased]: https://github.com/rust-playground/ksql/compare/v0.3.0...HEAD -[0.2.0]: https://github.com/rust-playground/ksql/compare/v0.2.0...v0.3.0 +[Unreleased]: https://github.com/rust-playground/ksql/compare/v0.3.1...HEAD +[0.3.1]: https://github.com/rust-playground/ksql/compare/v0.3.0...v0.3.1 +[0.3.0]: https://github.com/rust-playground/ksql/compare/v0.2.0...v0.3.0 [0.2.0]: https://github.com/rust-playground/ksql/compare/v0.1.2...v0.2.0 [0.1.2]: https://github.com/rust-playground/ksql/compare/v0.1.1...v0.1.2 [0.1.1]: https://github.com/rust-playground/ksql/compare/v0.1.0...v0.1.1 diff --git a/Cargo.toml b/Cargo.toml index af58d41..162507e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "ksql" description = "A JSON data expression lexer, parser, cli and library" -version = "0.3.0" +version = "0.3.1" edition = "2021" license = "MIT OR Apache-2.0" readme = "README.md" @@ -16,11 +16,11 @@ keywords = [ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.56" +anyhow = "1.0.57" atty = "0.2.14" -clap = { version = "3.1.8", features = ["derive"] } +clap = { version = "3.1.18", features = ["derive"] } gjson = "0.8.1" -thiserror = "1.0.30" +thiserror = "1.0.31" [dev-dependencies] criterion = { version = "0.3.5", features = ["html_reports"] } @@ -34,4 +34,6 @@ harness = false [profile.release] lto = true +strip = true +codegen-units = 1 panic = 'abort' diff --git a/src/lexer.rs b/src/lexer.rs index ac0e0e0..8d02737 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -33,7 +33,7 @@ use thiserror::Error; /// The lexed token. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct Token { pub start: u32, pub len: u16, @@ -41,7 +41,7 @@ pub struct Token { } /// The kind of `Token`. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum TokenKind { Identifier, QuotedString, @@ -162,7 +162,7 @@ where pub type Result = std::result::Result; /// Error type for the lexer. -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum Error { #[error("invalid identifier: {0}")] InvalidIdentifier(String), @@ -185,7 +185,7 @@ pub enum Error { /// Try to lex a single token from the input stream. fn tokenize_single_token(data: &[u8]) -> Result<(TokenKind, u16)> { - let b = match data.get(0) { + let b = match data.first() { Some(b) => b, None => panic!("invalid data passed"), }; diff --git a/src/parser.rs b/src/parser.rs index 8905bf2..22edfa6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -18,7 +18,7 @@ use crate::lexer::{TokenKind, Tokenizer}; use anyhow::anyhow; use gjson::Kind; use std::collections::BTreeMap; -use std::fmt::{Debug, Display, Formatter}; +use std::fmt::{Debug, Display, Formatter, Write}; use thiserror::Error; /// Represents the calculated Expression result. @@ -43,8 +43,9 @@ impl Display for Value { let mut s = String::new(); s.push('{'); for (k, v) in o.iter() { - s.push_str(&format!(r#""{}":{}"#, k, v)); + let _ = write!(s, r#""{}":{},"#, k, v); } + s = s.trim_end_matches(',').to_string(); s.push('}'); s }), @@ -52,7 +53,7 @@ impl Display for Value { let mut s = String::new(); s.push('['); for v in a.iter() { - s.push_str(&format!("{},", v)); + let _ = write!(s, "{},", v); } s = s.trim_end_matches(',').to_string(); s.push(']'); @@ -740,7 +741,7 @@ impl Expression for Arr { pub type Result = std::result::Result; /// Error type for the expression parser. -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum Error { #[error("unsupported type comparison: {0}")] UnsupportedTypeComparison(String),