Skip to content

Commit 287878f

Browse files
committed
Merge branch 'main' into dpezely/subtype-naming
2 parents 96b3cd4 + cdb2c8e commit 287878f

22 files changed

+220
-212
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ typify = { version = "0.5.0", path = "typify" }
1616
typify-impl = { version = "0.5.0", path = "typify-impl" }
1717
typify-macro = { version = "0.5.0", path = "typify-macro" }
1818

19-
assert_cmd = "2.0.17"
19+
assert_cmd = "2.1.1"
2020
chrono = { version = "0.4.42", features = ["serde"] }
21-
clap = { version = "4.5.49", features = ["derive"] }
21+
clap = { version = "4.5.53", features = ["derive"] }
2222
color-eyre = "0.6"
2323
env_logger = "0.11"
2424
expectorate = "1.2.0"
2525
glob = "0.3.3"
2626
heck = "0.5.0"
2727
ipnetwork = { version = "0.21.1", features = ["schemars"] }
28-
log = "0.4.28"
28+
log = "0.4.29"
2929
newline-converter = "0.3.0"
3030
paste = "1.0.15"
3131
prettyplease = "0.2.37"
32-
proc-macro2 = "1.0.101"
33-
quote = "1.0.41"
34-
regress = "0.10.4"
32+
proc-macro2 = "1.0.103"
33+
quote = "1.0.42"
34+
regress = "0.10.5"
3535
rustfmt-wrapper = "0.2.1"
3636
schema = "0.1.0"
3737
schemars = "0.8.22"
3838
semver = "1.0.27"
3939
serde = "1.0.228"
40-
serde_json = "1.0.145"
41-
syn = { version = "2.0.107", features = ["full"] }
40+
serde_json = "1.0.146"
41+
syn = { version = "2.0.111", features = ["full"] }
4242
tempdir = "0.3.7"
4343
thiserror = "2.0.17"
44-
trybuild = "1.0.112"
45-
unicode-ident = "1.0.19"
44+
trybuild = "1.0.114"
45+
unicode-ident = "1.0.22"
4646
uuid = "1.16.0"

cargo-typify/tests/outputs/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ pub mod builder {
238238
{
239239
self.veggie_like = value
240240
.try_into()
241-
.map_err(|e| format!("error converting supplied value for veggie_like: {}", e));
241+
.map_err(|e| format!("error converting supplied value for veggie_like: {e}"));
242242
self
243243
}
244244
pub fn veggie_name<T>(mut self, value: T) -> Self
@@ -248,7 +248,7 @@ pub mod builder {
248248
{
249249
self.veggie_name = value
250250
.try_into()
251-
.map_err(|e| format!("error converting supplied value for veggie_name: {}", e));
251+
.map_err(|e| format!("error converting supplied value for veggie_name: {e}"));
252252
self
253253
}
254254
}
@@ -291,7 +291,7 @@ pub mod builder {
291291
{
292292
self.fruits = value
293293
.try_into()
294-
.map_err(|e| format!("error converting supplied value for fruits: {}", e));
294+
.map_err(|e| format!("error converting supplied value for fruits: {e}"));
295295
self
296296
}
297297
pub fn vegetables<T>(mut self, value: T) -> Self
@@ -301,7 +301,7 @@ pub mod builder {
301301
{
302302
self.vegetables = value
303303
.try_into()
304-
.map_err(|e| format!("error converting supplied value for vegetables: {}", e));
304+
.map_err(|e| format!("error converting supplied value for vegetables: {e}"));
305305
self
306306
}
307307
}

cargo-typify/tests/outputs/custom_btree_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ pub mod builder {
239239
{
240240
self.veggie_like = value
241241
.try_into()
242-
.map_err(|e| format!("error converting supplied value for veggie_like: {}", e));
242+
.map_err(|e| format!("error converting supplied value for veggie_like: {e}"));
243243
self
244244
}
245245
pub fn veggie_name<T>(mut self, value: T) -> Self
@@ -249,7 +249,7 @@ pub mod builder {
249249
{
250250
self.veggie_name = value
251251
.try_into()
252-
.map_err(|e| format!("error converting supplied value for veggie_name: {}", e));
252+
.map_err(|e| format!("error converting supplied value for veggie_name: {e}"));
253253
self
254254
}
255255
}
@@ -292,7 +292,7 @@ pub mod builder {
292292
{
293293
self.fruits = value
294294
.try_into()
295-
.map_err(|e| format!("error converting supplied value for fruits: {}", e));
295+
.map_err(|e| format!("error converting supplied value for fruits: {e}"));
296296
self
297297
}
298298
pub fn vegetables<T>(mut self, value: T) -> Self
@@ -302,7 +302,7 @@ pub mod builder {
302302
{
303303
self.vegetables = value
304304
.try_into()
305-
.map_err(|e| format!("error converting supplied value for vegetables: {}", e));
305+
.map_err(|e| format!("error converting supplied value for vegetables: {e}"));
306306
self
307307
}
308308
}

typify-impl/src/type_entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ impl TypeEntry {
11471147
prop_doc.push(prop.description.as_ref().map(|d| quote! { #[doc = #d] }));
11481148
prop_name.push(format_ident!("{}", prop.name));
11491149
prop_error.push(format!(
1150-
"error converting supplied value for {}: {{}}",
1150+
"error converting supplied value for {}: {{e}}",
11511151
prop.name,
11521152
));
11531153

@@ -1311,7 +1311,7 @@ impl TypeEntry {
13111311
T::Error: ::std::fmt::Display,
13121312
{
13131313
self.#prop_name = value.try_into()
1314-
.map_err(|e| format!(#prop_error, e));
1314+
.map_err(|e| format!(#prop_error));
13151315
self
13161316
}
13171317
)*

typify-impl/src/util.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,17 @@ pub(crate) fn constant_string_value(schema: &Schema) -> Option<&str> {
544544
}
545545
}
546546

547+
fn decode_segment(segment: &str) -> String {
548+
segment.replace("~1", "/").replace("~0", "~")
549+
}
550+
547551
pub(crate) fn ref_key(ref_name: &str) -> RefKey {
548552
if ref_name == "#" {
549553
RefKey::Root
550554
} else if let Some(idx) = ref_name.rfind('/') {
551-
RefKey::Def(ref_name[idx + 1..].to_string())
555+
let decoded_segment = decode_segment(&ref_name[idx + 1..]);
556+
557+
RefKey::Def(decoded_segment)
552558
} else {
553559
panic!("expected a '/' in $ref: {}", ref_name)
554560
}
@@ -901,7 +907,7 @@ mod tests {
901907
};
902908

903909
use crate::{
904-
util::{sanitize, schemas_mutually_exclusive, Case},
910+
util::{decode_segment, sanitize, schemas_mutually_exclusive, Case},
905911
Name,
906912
};
907913

@@ -1007,6 +1013,12 @@ mod tests {
10071013
assert!(schemas_mutually_exclusive(&b, &a, &BTreeMap::new()));
10081014
}
10091015

1016+
#[test]
1017+
fn test_decode_segment() {
1018+
assert_eq!(decode_segment("foo~1bar"), "foo/bar");
1019+
assert_eq!(decode_segment("foo~0bar"), "foo~bar");
1020+
}
1021+
10101022
#[test]
10111023
fn test_sanitize() {
10121024
assert_eq!(sanitize("type", Case::Snake), "type_");

0 commit comments

Comments
 (0)