quicktype-core 23.0.33 → 23.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/language/Rust.js +21 -26
- package/package.json +1 -1
package/dist/language/Rust.js
CHANGED
|
@@ -38,52 +38,48 @@ exports.rustOptions = {
|
|
|
38
38
|
leadingComments: new RendererOptions_1.BooleanOption("leading-comments", "Leading Comments", true)
|
|
39
39
|
};
|
|
40
40
|
const namingStyles = {
|
|
41
|
-
|
|
41
|
+
snake_case: {
|
|
42
42
|
regex: /^[a-z][a-z0-9]*(_[a-z0-9]+)*$/,
|
|
43
|
-
toParts: (name) => name.split(
|
|
44
|
-
fromParts: (parts) => parts.map(p => p.toLowerCase()).join(
|
|
43
|
+
toParts: (name) => name.split("_"),
|
|
44
|
+
fromParts: (parts) => parts.map(p => p.toLowerCase()).join("_")
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
SCREAMING_SNAKE_CASE: {
|
|
47
47
|
regex: /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/,
|
|
48
|
-
toParts: (name) => name.split(
|
|
49
|
-
fromParts: (parts) => parts.map(p => p.toUpperCase()).join(
|
|
48
|
+
toParts: (name) => name.split("_"),
|
|
49
|
+
fromParts: (parts) => parts.map(p => p.toUpperCase()).join("_")
|
|
50
50
|
},
|
|
51
|
-
|
|
51
|
+
camelCase: {
|
|
52
52
|
regex: /^[a-z]+([A-Z0-9][a-z]*)*$/,
|
|
53
53
|
toParts: (name) => namingStyles.snake_case.toParts(name.replace(/(.)([A-Z])/g, "$1_$2")),
|
|
54
54
|
fromParts: (parts) => parts
|
|
55
|
-
.map((p, i) => i === 0
|
|
56
|
-
|
|
57
|
-
: p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase())
|
|
58
|
-
.join(''),
|
|
55
|
+
.map((p, i) => i === 0 ? p.toLowerCase() : p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase())
|
|
56
|
+
.join("")
|
|
59
57
|
},
|
|
60
|
-
|
|
58
|
+
PascalCase: {
|
|
61
59
|
regex: /^[A-Z][a-z]*([A-Z0-9][a-z]*)*$/,
|
|
62
60
|
toParts: (name) => namingStyles.snake_case.toParts(name.replace(/(.)([A-Z])/g, "$1_$2")),
|
|
63
|
-
fromParts: (parts) => parts
|
|
64
|
-
.map(p => p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase())
|
|
65
|
-
.join(''),
|
|
61
|
+
fromParts: (parts) => parts.map(p => p.substring(0, 1).toUpperCase() + p.substring(1).toLowerCase()).join("")
|
|
66
62
|
},
|
|
67
63
|
"kebab-case": {
|
|
68
64
|
regex: /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,
|
|
69
|
-
toParts: (name) => name.split(
|
|
70
|
-
fromParts: (parts) => parts.map(p => p.toLowerCase()).join(
|
|
65
|
+
toParts: (name) => name.split("-"),
|
|
66
|
+
fromParts: (parts) => parts.map(p => p.toLowerCase()).join("-")
|
|
71
67
|
},
|
|
72
68
|
"SCREAMING-KEBAB-CASE": {
|
|
73
69
|
regex: /^[A-Z][A-Z0-9]*(-[A-Z0-9]+)*$/,
|
|
74
|
-
toParts: (name) => name.split(
|
|
75
|
-
fromParts: (parts) => parts.map(p => p.toUpperCase()).join(
|
|
70
|
+
toParts: (name) => name.split("-"),
|
|
71
|
+
fromParts: (parts) => parts.map(p => p.toUpperCase()).join("-")
|
|
76
72
|
},
|
|
77
|
-
|
|
73
|
+
lowercase: {
|
|
78
74
|
regex: /^[a-z][a-z0-9]*$/,
|
|
79
75
|
toParts: (name) => [name],
|
|
80
|
-
fromParts: (parts) => parts.map(p => p.toLowerCase()).join(
|
|
76
|
+
fromParts: (parts) => parts.map(p => p.toLowerCase()).join("")
|
|
81
77
|
},
|
|
82
|
-
|
|
78
|
+
UPPERCASE: {
|
|
83
79
|
regex: /^[A-Z][A-Z0-9]*$/,
|
|
84
80
|
toParts: (name) => [name],
|
|
85
|
-
fromParts: (parts) => parts.map(p => p.toUpperCase()).join(
|
|
86
|
-
}
|
|
81
|
+
fromParts: (parts) => parts.map(p => p.toUpperCase()).join("")
|
|
82
|
+
}
|
|
87
83
|
};
|
|
88
84
|
class RustTargetLanguage extends TargetLanguage_1.TargetLanguage {
|
|
89
85
|
makeRenderer(renderContext, untypedOptionValues) {
|
|
@@ -382,8 +378,7 @@ class RustRenderer extends ConvenienceRenderer_1.ConvenienceRenderer {
|
|
|
382
378
|
exports.RustRenderer = RustRenderer;
|
|
383
379
|
function getPreferedNamingStyle(namingStyleOccurences, defaultStyle) {
|
|
384
380
|
const occurrences = Object.fromEntries(Object.keys(namingStyles).map(key => [key, 0]));
|
|
385
|
-
namingStyleOccurences
|
|
386
|
-
.forEach(style => ++occurrences[style]);
|
|
381
|
+
namingStyleOccurences.forEach(style => ++occurrences[style]);
|
|
387
382
|
const max = Math.max(...Object.values(occurrences));
|
|
388
383
|
const preferedStyles = Object.entries(occurrences)
|
|
389
384
|
.filter(([_style, num]) => num === max)
|