Skip to content

Commit e055c87

Browse files
committed
release: 0.18.1
- Expose categories() method on AisleConf - Rename package from cooklang-rs to CooklangParser
1 parent 4cef823 commit e055c87

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cooklang"
3-
version = "0.18.0"
3+
version = "0.18.1"
44
edition = "2021"
55
authors = ["Zheoni <zheoni@outlook.es>"]
66
description = "Cooklang parser with opt-in extensions"

bindings/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cooklang-bindings"
3-
version = "0.18.0"
3+
version = "0.18.1"
44
edition = "2021"
55
authors = ["dubadub <dubovskoy.a@gmail.com>"]
66
description = "Cooklang Uniffi bindings"

bindings/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ pub fn deref_timer(recipe: &Arc<CooklangRecipe>, index: u32) -> Timer {
102102
pub fn parse_aisle_config(input: String) -> Arc<AisleConf> {
103103
let mut categories: Vec<AisleCategory> = Vec::new();
104104
let mut cache: AisleReverseCategory = AisleReverseCategory::default();
105-
let mut common_names: std::collections::HashMap<String, String> = std::collections::HashMap::new();
105+
let mut common_names: std::collections::HashMap<String, String> =
106+
std::collections::HashMap::new();
106107

107108
// Use the lenient parser that handles duplicates as warnings
108109
let result = parse_lenient(&input);
@@ -143,7 +144,11 @@ pub fn parse_aisle_config(input: String) -> Arc<AisleConf> {
143144
categories.push(category);
144145
});
145146

146-
let config = AisleConf { categories, cache, common_names };
147+
let config = AisleConf {
148+
categories,
149+
cache,
150+
common_names,
151+
};
147152

148153
Arc::new(config)
149154
}
@@ -1321,10 +1326,7 @@ Serve the @./pasta/spaghetti{1%portion} with sauce
13211326
1.0,
13221327
);
13231328

1324-
let ingredient = recipe
1325-
.ingredients
1326-
.get(0)
1327-
.expect("No ingredients found");
1329+
let ingredient = recipe.ingredients.get(0).expect("No ingredients found");
13281330

13291331
assert_eq!(ingredient.name, "spaghetti");
13301332
assert_eq!(

src/ingredient_list.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,7 @@ beef
552552
let parser = CooklangParser::new(Extensions::all(), converter.clone());
553553

554554
// Recipe with "Chili flakes" (capital C)
555-
let recipe = parser
556-
.parse("@Chili flakes{1%tsp}")
557-
.into_output()
558-
.unwrap();
555+
let recipe = parser.parse("@Chili flakes{1%tsp}").into_output().unwrap();
559556

560557
// Aisle config has "chili flakes" (lowercase)
561558
let aisle_conf = r#"

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ pub mod _features {
7070

7171
#[cfg(feature = "aisle")]
7272
pub mod aisle;
73-
#[cfg(feature = "shopping_list")]
74-
pub mod shopping_list;
7573
pub mod analysis;
7674
pub mod ast;
7775
pub mod convert;
@@ -85,6 +83,8 @@ pub mod pantry;
8583
pub mod parser;
8684
pub mod quantity;
8785
pub mod scale;
86+
#[cfg(feature = "shopping_list")]
87+
pub mod shopping_list;
8888
pub mod span;
8989
pub mod text;
9090

src/shopping_list.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,16 @@ fn parse_recipe_line(line: &ParsedLine<'_>) -> Result<(String, Option<f64>), Sho
198198
if content.ends_with('}') {
199199
let path = content[..brace_start].trim().to_string();
200200
let multiplier_str = &content[brace_start + 1..content.len() - 1];
201-
let multiplier: f64 = multiplier_str.parse().map_err(|_| {
202-
ShoppingListError::InvalidMultiplier {
203-
span: Span::new(
204-
line.offset + 2 + brace_start + 1,
205-
line.offset + 2 + content.len() - 1,
206-
),
207-
message: format!("'{multiplier_str}' is not a valid number"),
208-
}
209-
})?;
201+
let multiplier: f64 =
202+
multiplier_str
203+
.parse()
204+
.map_err(|_| ShoppingListError::InvalidMultiplier {
205+
span: Span::new(
206+
line.offset + 2 + brace_start + 1,
207+
line.offset + 2 + content.len() - 1,
208+
),
209+
message: format!("'{multiplier_str}' is not a valid number"),
210+
})?;
210211
Ok((path, Some(multiplier)))
211212
} else {
212213
Ok((content.trim().to_string(), None))

0 commit comments

Comments
 (0)