python2rust 0.1.0__py3-none-any.whl
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.
- python2rust/__init__.py +8 -0
- python2rust/__main__.py +5 -0
- python2rust/_core.py +44 -0
- python2rust/agent/__init__.py +0 -0
- python2rust/agent/agents.py +333 -0
- python2rust/agent/apply.py +516 -0
- python2rust/agent/finish.py +295 -0
- python2rust/agent/fixers.py +229 -0
- python2rust/agent/loop.py +441 -0
- python2rust/agent/patches.py +1165 -0
- python2rust/agent/port.py +579 -0
- python2rust/agent/prompts/judge_v2.md +96 -0
- python2rust/agent/review.py +34 -0
- python2rust/agent/rustlex.py +232 -0
- python2rust/cli/__init__.py +0 -0
- python2rust/cli/doctor.py +62 -0
- python2rust/cli/inputs.py +105 -0
- python2rust/cli/main.py +1162 -0
- python2rust/cli/ops.py +642 -0
- python2rust/cli/workflow.py +178 -0
- python2rust/core/__init__.py +38 -0
- python2rust/core/config.py +263 -0
- python2rust/core/constructs.py +124 -0
- python2rust/core/diagnostics.py +280 -0
- python2rust/core/emit/__init__.py +5 -0
- python2rust/core/emit/crates.py +51 -0
- python2rust/core/emit/render.py +561 -0
- python2rust/core/emit/schema.py +168 -0
- python2rust/core/emit/translate.py +304 -0
- python2rust/core/frontend/__init__.py +1 -0
- python2rust/core/frontend/module.py +896 -0
- python2rust/core/frontend/names.py +129 -0
- python2rust/core/frontend/project.py +277 -0
- python2rust/core/frontend/project_imports.py +173 -0
- python2rust/core/frontend/symbols.py +132 -0
- python2rust/core/frontend/walrus.py +59 -0
- python2rust/core/ir/__init__.py +1 -0
- python2rust/core/ir/nodes.py +675 -0
- python2rust/core/ir/rtypes.py +122 -0
- python2rust/core/ir/types.py +326 -0
- python2rust/core/lower/__init__.py +1 -0
- python2rust/core/lower/calls.py +1125 -0
- python2rust/core/lower/context.py +223 -0
- python2rust/core/lower/exceptions.py +317 -0
- python2rust/core/lower/exprs.py +845 -0
- python2rust/core/lower/fstrings.py +141 -0
- python2rust/core/lower/funcs.py +276 -0
- python2rust/core/lower/lowerer.py +366 -0
- python2rust/core/lower/modelcalls.py +195 -0
- python2rust/core/lower/models.py +645 -0
- python2rust/core/lower/stmts.py +722 -0
- python2rust/core/lower/testing.py +601 -0
- python2rust/core/lower/validation.py +253 -0
- python2rust/core/passes/__init__.py +1 -0
- python2rust/core/passes/aliasing.py +311 -0
- python2rust/core/passes/analysis.py +207 -0
- python2rust/core/passes/devirt.py +329 -0
- python2rust/core/passes/ownership.py +259 -0
- python2rust/core/passes/raises.py +275 -0
- python2rust/core/rt_lib.rs +2071 -0
- python2rust/data/README.md +81 -0
- python2rust/data/py2many_builtins.toml +4744 -0
- python2rust/errors.py +28 -0
- python2rust/py.typed +0 -0
- python2rust/report/__init__.py +0 -0
- python2rust/report/constructs.py +31 -0
- python2rust/report/contract.py +688 -0
- python2rust/report/corpus.py +323 -0
- python2rust/report/explain.py +168 -0
- python2rust/report/schemas.py +914 -0
- python2rust/server/__init__.py +0 -0
- python2rust/server/mcp_server.py +289 -0
- python2rust/server/mcp_workflow.py +100 -0
- python2rust/skill/SKILL.md +214 -0
- python2rust/verify/__init__.py +0 -0
- python2rust/verify/check.py +1135 -0
- python2rust/verify/equiv/__init__.py +1264 -0
- python2rust/verify/equiv/compare.py +455 -0
- python2rust/verify/equiv/harness.py +505 -0
- python2rust/verify/equiv/judge.py +358 -0
- python2rust/verify/equiv/procs.py +255 -0
- python2rust/verify/equiv/runner.py +248 -0
- python2rust/verify/equiv/types.py +543 -0
- python2rust/verify/keystore.py +76 -0
- python2rust/verify/ladder.py +396 -0
- python2rust/verify/sandbox.py +370 -0
- python2rust/verify/testrun.py +280 -0
- python2rust/workflow/__init__.py +0 -0
- python2rust/workflow/brief.py +312 -0
- python2rust/workflow/interview.py +366 -0
- python2rust/workflow/layout.py +103 -0
- python2rust/workflow/planner.py +409 -0
- python2rust/workflow/project.py +134 -0
- python2rust/workflow/schemas.py +265 -0
- python2rust/workflow/state.py +392 -0
- python2rust/workflow/staticscan.py +209 -0
- python2rust-0.1.0.dist-info/METADATA +395 -0
- python2rust-0.1.0.dist-info/RECORD +102 -0
- python2rust-0.1.0.dist-info/WHEEL +4 -0
- python2rust-0.1.0.dist-info/entry_points.txt +4 -0
- python2rust-0.1.0.dist-info/licenses/LICENSE +21 -0
- python2rust-0.1.0.dist-info/licenses/NOTICE +65 -0
|
@@ -0,0 +1,4744 @@
|
|
|
1
|
+
# GENERATED by tools/mine_py2many.py -- do not edit by hand; edit CURATED in the script.
|
|
2
|
+
# Mined from py2many (MIT). See NOTICE at the repository root.
|
|
3
|
+
|
|
4
|
+
schema_version = 1
|
|
5
|
+
|
|
6
|
+
[meta]
|
|
7
|
+
source_project = "py2many"
|
|
8
|
+
source_version = "0.9"
|
|
9
|
+
source_license = "MIT"
|
|
10
|
+
source_url = "https://github.com/py2many/py2many"
|
|
11
|
+
int_policy = "Python int maps to i64 here (py2many: i32)."
|
|
12
|
+
placeholders = "$0..$9 arguments, $self receiver, $args all arguments comma-joined, $T element type, other $name = keyword argument or generated name"
|
|
13
|
+
runtime_crate = "p2r (placeholder name for the python2rust runtime helper crate; helpers listed in [[helper]])"
|
|
14
|
+
|
|
15
|
+
[status_values]
|
|
16
|
+
direct = "faithful for the stated types; caveats (if any) are edge cases listed in notes"
|
|
17
|
+
corrected = "py2many has a mapping but it is wrong or lossy; the template here replaces it"
|
|
18
|
+
needs-runtime-helper = "no faithful inline Rust; call the named helper from the runtime crate"
|
|
19
|
+
compile-time = "resolved during transpilation, no runtime code"
|
|
20
|
+
unsupported = "reject loudly; py2many's output is not usable"
|
|
21
|
+
unreviewed = "present in this py2many version but not yet reviewed (re-mine produced it)"
|
|
22
|
+
|
|
23
|
+
[keywords]
|
|
24
|
+
rust_reserved = ["Self", "abstract", "as", "async", "await", "become", "box", "break", "const", "continue", "crate", "do", "dyn", "else", "enum", "extern", "false", "final", "fn", "for", "gen", "if", "impl", "in", "let", "loop", "macro", "match", "mod", "move", "mut", "override", "priv", "pub", "ref", "return", "self", "static", "struct", "super", "trait", "true", "try", "type", "typeof", "unsafe", "unsized", "use", "virtual", "where", "while", "yield"]
|
|
25
|
+
collides_with_python_identifiers = ["Self", "abstract", "become", "box", "const", "crate", "do", "dyn", "enum", "extern", "false", "final", "fn", "gen", "impl", "let", "loop", "macro", "match", "mod", "move", "mut", "override", "priv", "pub", "ref", "self", "static", "struct", "super", "trait", "true", "type", "typeof", "unsafe", "unsized", "use", "virtual", "where"]
|
|
26
|
+
py2many_covered = ["const", "enum", "extern", "fn", "impl", "loop", "match", "move", "mut", "pub", "ref", "struct", "trait", "type", "unsafe", "use", "where"]
|
|
27
|
+
py2many_missing = ["Self", "abstract", "become", "box", "crate", "do", "dyn", "false", "final", "gen", "let", "macro", "mod", "override", "priv", "self", "static", "super", "true", "typeof", "unsized", "virtual"]
|
|
28
|
+
cannot_be_raw_identifier = ["crate", "self", "Self", "super"]
|
|
29
|
+
python_soft_keywords = ["_", "case", "lazy", "match", "type"]
|
|
30
|
+
|
|
31
|
+
[width_rank]
|
|
32
|
+
# py2many's numeric widening order (pyrs/inference.py:RUST_WIDTH_RANK). Reference only:
|
|
33
|
+
# it is the mechanism behind i8 + i8 -> i16, which we do not copy.
|
|
34
|
+
bool = 0
|
|
35
|
+
i8 = 1
|
|
36
|
+
u8 = 2
|
|
37
|
+
i16 = 3
|
|
38
|
+
u16 = 4
|
|
39
|
+
i32 = 5
|
|
40
|
+
u32 = 6
|
|
41
|
+
i64 = 7
|
|
42
|
+
u64 = 8
|
|
43
|
+
f32 = 9
|
|
44
|
+
f64 = 10
|
|
45
|
+
|
|
46
|
+
[[builtin]]
|
|
47
|
+
python = "len"
|
|
48
|
+
kind = "function"
|
|
49
|
+
types = ["str"]
|
|
50
|
+
arity = "1"
|
|
51
|
+
rust = "p2r::str_len($0)"
|
|
52
|
+
status = "needs-runtime-helper"
|
|
53
|
+
helper = "str_len"
|
|
54
|
+
origin = "py2many"
|
|
55
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['len']"
|
|
56
|
+
py2many_emits = "$0.len() as i32"
|
|
57
|
+
notes = "Python len(str) counts code points. Rust str::len counts UTF-8 bytes (verified: \"héllo\".len() == 6, Python gives 5) and py2many also casts to i32. Inline equivalent: $0.chars().count() as i64 (O(n)); the helper can add an ASCII fast path."
|
|
58
|
+
|
|
59
|
+
[[builtin]]
|
|
60
|
+
python = "len"
|
|
61
|
+
kind = "function"
|
|
62
|
+
types = ["list", "dict", "set", "bytes"]
|
|
63
|
+
arity = "1"
|
|
64
|
+
rust = "$0.len() as i64"
|
|
65
|
+
status = "corrected"
|
|
66
|
+
origin = "py2many"
|
|
67
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['len']"
|
|
68
|
+
py2many_emits = "$0.len() as i32"
|
|
69
|
+
notes = "Same call as py2many but i64 instead of i32 (i32 truncates past 2^31 elements). Tuple len is a compile-time constant."
|
|
70
|
+
|
|
71
|
+
[[builtin]]
|
|
72
|
+
python = "str"
|
|
73
|
+
kind = "function"
|
|
74
|
+
types = ["int"]
|
|
75
|
+
arity = "1"
|
|
76
|
+
rust = "$0.to_string()"
|
|
77
|
+
status = "corrected"
|
|
78
|
+
origin = "py2many"
|
|
79
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['str']"
|
|
80
|
+
py2many_emits = "&$0.to_string() [no args: \"\"]"
|
|
81
|
+
notes = "py2many emits `&$0.to_string()`, a borrow of a temporary: it cannot be returned or stored (verified: `-> &str { &x.to_string() }` is emitted for str(x)). Always produce an owned String."
|
|
82
|
+
|
|
83
|
+
[[builtin]]
|
|
84
|
+
python = "str"
|
|
85
|
+
kind = "function"
|
|
86
|
+
types = ["float"]
|
|
87
|
+
arity = "1"
|
|
88
|
+
rust = "p2r::float_repr($0)"
|
|
89
|
+
status = "needs-runtime-helper"
|
|
90
|
+
helper = "float_repr"
|
|
91
|
+
origin = "py2many"
|
|
92
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['str']"
|
|
93
|
+
py2many_emits = "&$0.to_string() [no args: \"\"]"
|
|
94
|
+
notes = "Rust Display prints 1.0 as `1` and 1e16 as `10000000000000000` (verified); Python prints `1.0` and `1e+16`. Needs the shortest-repr algorithm with Python's exponent thresholds (repr switches to exponent form at 1e16 and below 1e-4). nan/inf print as `nan`/`inf`."
|
|
95
|
+
|
|
96
|
+
[[builtin]]
|
|
97
|
+
python = "str"
|
|
98
|
+
kind = "function"
|
|
99
|
+
types = ["bool"]
|
|
100
|
+
arity = "1"
|
|
101
|
+
rust = "(if $0 { \"True\" } else { \"False\" }).to_string()"
|
|
102
|
+
status = "corrected"
|
|
103
|
+
origin = "py2many"
|
|
104
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['str']"
|
|
105
|
+
py2many_emits = "&$0.to_string() [no args: \"\"]"
|
|
106
|
+
notes = "Display of a Rust bool is `true`/`false`; Python is `True`/`False`."
|
|
107
|
+
|
|
108
|
+
[[builtin]]
|
|
109
|
+
python = "str"
|
|
110
|
+
kind = "function"
|
|
111
|
+
types = ["str"]
|
|
112
|
+
arity = "1"
|
|
113
|
+
rust = "$0.to_string()"
|
|
114
|
+
status = "direct"
|
|
115
|
+
origin = "py2many"
|
|
116
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['str']"
|
|
117
|
+
py2many_emits = "&$0.to_string() [no args: \"\"]"
|
|
118
|
+
notes = "Identity on str; clone into an owned String."
|
|
119
|
+
|
|
120
|
+
[[builtin]]
|
|
121
|
+
python = "str"
|
|
122
|
+
kind = "function"
|
|
123
|
+
types = ["list", "dict", "set", "tuple", "None", "Optional"]
|
|
124
|
+
arity = "1"
|
|
125
|
+
rust = "p2r::py_repr(&$0)"
|
|
126
|
+
status = "needs-runtime-helper"
|
|
127
|
+
helper = "py_repr"
|
|
128
|
+
origin = "py2many"
|
|
129
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['str']"
|
|
130
|
+
py2many_emits = "&$0.to_string() [no args: \"\"]"
|
|
131
|
+
notes = "Containers print Python-style: `[1, 2]`, `{'a': 1}`, `(1, 2)`, `None`; str elements are shown with repr quoting, not Rust Debug escaping."
|
|
132
|
+
|
|
133
|
+
[[builtin]]
|
|
134
|
+
python = "str"
|
|
135
|
+
kind = "function"
|
|
136
|
+
arity = "0"
|
|
137
|
+
rust = "String::new()"
|
|
138
|
+
status = "direct"
|
|
139
|
+
origin = "py2many"
|
|
140
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['str']"
|
|
141
|
+
py2many_emits = "\"\""
|
|
142
|
+
notes = "py2many emits a &'static str literal here."
|
|
143
|
+
|
|
144
|
+
[[builtin]]
|
|
145
|
+
python = "int"
|
|
146
|
+
kind = "function"
|
|
147
|
+
types = ["str"]
|
|
148
|
+
arity = "1"
|
|
149
|
+
rust = "p2r::int_from_str($0)"
|
|
150
|
+
status = "needs-runtime-helper"
|
|
151
|
+
helper = "int_from_str"
|
|
152
|
+
origin = "py2many"
|
|
153
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['int']"
|
|
154
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
155
|
+
notes = "py2many emits `$0 as i32`, which does not compile for a str. Python strips surrounding whitespace, accepts a sign and `_` separators and raises ValueError otherwise; Rust str::parse::<i64> rejects whitespace and `_`."
|
|
156
|
+
|
|
157
|
+
[[builtin]]
|
|
158
|
+
python = "int"
|
|
159
|
+
kind = "function"
|
|
160
|
+
types = ["str"]
|
|
161
|
+
arity = "2"
|
|
162
|
+
rust = "p2r::int_from_str_radix($0, $1)"
|
|
163
|
+
status = "needs-runtime-helper"
|
|
164
|
+
helper = "int_from_str_radix"
|
|
165
|
+
origin = "py2many"
|
|
166
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['int']"
|
|
167
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
168
|
+
notes = "int(s, base): base 0 and prefix handling (0x, 0o, 0b) follow Python."
|
|
169
|
+
|
|
170
|
+
[[builtin]]
|
|
171
|
+
python = "int"
|
|
172
|
+
kind = "function"
|
|
173
|
+
types = ["float"]
|
|
174
|
+
arity = "1"
|
|
175
|
+
rust = "p2r::float_to_int($0)"
|
|
176
|
+
status = "needs-runtime-helper"
|
|
177
|
+
helper = "float_to_int"
|
|
178
|
+
origin = "py2many"
|
|
179
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['int']"
|
|
180
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
181
|
+
notes = "Truncates toward zero like Python, but Python raises ValueError for nan and OverflowError for inf; Rust `as` saturates and maps nan to 0 (verified: f64::NAN as i64 == 0, 1e30 as i64 == i64::MAX). py2many also uses i32, which saturates at 2^31."
|
|
182
|
+
|
|
183
|
+
[[builtin]]
|
|
184
|
+
python = "int"
|
|
185
|
+
kind = "function"
|
|
186
|
+
types = ["bool"]
|
|
187
|
+
arity = "1"
|
|
188
|
+
rust = "$0 as i64"
|
|
189
|
+
status = "direct"
|
|
190
|
+
origin = "py2many"
|
|
191
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['int']"
|
|
192
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
193
|
+
notes = "py2many uses i32; this build maps Python int to i64."
|
|
194
|
+
|
|
195
|
+
[[builtin]]
|
|
196
|
+
python = "int"
|
|
197
|
+
kind = "function"
|
|
198
|
+
types = ["int"]
|
|
199
|
+
arity = "1"
|
|
200
|
+
rust = "$0"
|
|
201
|
+
status = "direct"
|
|
202
|
+
origin = "py2many"
|
|
203
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['int']"
|
|
204
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
205
|
+
notes = "Identity."
|
|
206
|
+
|
|
207
|
+
[[builtin]]
|
|
208
|
+
python = "int"
|
|
209
|
+
kind = "function"
|
|
210
|
+
arity = "0"
|
|
211
|
+
rust = "0i64"
|
|
212
|
+
status = "direct"
|
|
213
|
+
origin = "py2many"
|
|
214
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['int']"
|
|
215
|
+
py2many_emits = "0"
|
|
216
|
+
|
|
217
|
+
[[builtin]]
|
|
218
|
+
python = "float"
|
|
219
|
+
kind = "function"
|
|
220
|
+
types = ["int"]
|
|
221
|
+
arity = "1"
|
|
222
|
+
rust = "$0 as f64"
|
|
223
|
+
status = "direct"
|
|
224
|
+
origin = "py2many"
|
|
225
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['float']"
|
|
226
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
227
|
+
notes = "Both round to nearest; Python raises OverflowError only for huge bigints."
|
|
228
|
+
|
|
229
|
+
[[builtin]]
|
|
230
|
+
python = "float"
|
|
231
|
+
kind = "function"
|
|
232
|
+
types = ["str"]
|
|
233
|
+
arity = "1"
|
|
234
|
+
rust = "p2r::float_from_str($0)"
|
|
235
|
+
status = "needs-runtime-helper"
|
|
236
|
+
helper = "float_from_str"
|
|
237
|
+
origin = "py2many"
|
|
238
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['float']"
|
|
239
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
240
|
+
notes = "Python accepts whitespace padding, `_` separators, `inf`, `nan`, `infinity` (any case); Rust f64::from_str accepts a different subset."
|
|
241
|
+
|
|
242
|
+
[[builtin]]
|
|
243
|
+
python = "float"
|
|
244
|
+
kind = "function"
|
|
245
|
+
types = ["float"]
|
|
246
|
+
arity = "1"
|
|
247
|
+
rust = "$0"
|
|
248
|
+
status = "direct"
|
|
249
|
+
origin = "py2many"
|
|
250
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['float']"
|
|
251
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_cast>"
|
|
252
|
+
notes = "Identity."
|
|
253
|
+
|
|
254
|
+
[[builtin]]
|
|
255
|
+
python = "float"
|
|
256
|
+
kind = "function"
|
|
257
|
+
arity = "0"
|
|
258
|
+
rust = "0.0f64"
|
|
259
|
+
status = "direct"
|
|
260
|
+
origin = "py2many"
|
|
261
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['float']"
|
|
262
|
+
py2many_emits = "0.0"
|
|
263
|
+
|
|
264
|
+
[[builtin]]
|
|
265
|
+
python = "bool"
|
|
266
|
+
kind = "function"
|
|
267
|
+
types = ["int"]
|
|
268
|
+
arity = "1"
|
|
269
|
+
rust = "($0 != 0)"
|
|
270
|
+
status = "direct"
|
|
271
|
+
origin = "py2many"
|
|
272
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['bool']"
|
|
273
|
+
py2many_emits = "($0 != 0) [no args: false]"
|
|
274
|
+
notes = "py2many applies `!= 0` to every type, which is invalid for str/list."
|
|
275
|
+
|
|
276
|
+
[[builtin]]
|
|
277
|
+
python = "bool"
|
|
278
|
+
kind = "function"
|
|
279
|
+
types = ["float"]
|
|
280
|
+
arity = "1"
|
|
281
|
+
rust = "($0 != 0.0)"
|
|
282
|
+
status = "corrected"
|
|
283
|
+
origin = "py2many"
|
|
284
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['bool']"
|
|
285
|
+
py2many_emits = "($0 != 0) [no args: false]"
|
|
286
|
+
notes = "nan is truthy in Python and `nan != 0.0` is true in Rust, so this agrees."
|
|
287
|
+
|
|
288
|
+
[[builtin]]
|
|
289
|
+
python = "bool"
|
|
290
|
+
kind = "function"
|
|
291
|
+
types = ["str", "list", "dict", "set", "bytes"]
|
|
292
|
+
arity = "1"
|
|
293
|
+
rust = "!$0.is_empty()"
|
|
294
|
+
status = "corrected"
|
|
295
|
+
origin = "py2many"
|
|
296
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['bool']"
|
|
297
|
+
py2many_emits = "($0 != 0) [no args: false]"
|
|
298
|
+
notes = "Truthiness of containers is non-emptiness. py2many's `!= 0` does not compile."
|
|
299
|
+
|
|
300
|
+
[[builtin]]
|
|
301
|
+
python = "bool"
|
|
302
|
+
kind = "function"
|
|
303
|
+
types = ["Optional", "user-class"]
|
|
304
|
+
arity = "1"
|
|
305
|
+
rust = "p2r::truthy(&$0)"
|
|
306
|
+
status = "needs-runtime-helper"
|
|
307
|
+
helper = "truthy"
|
|
308
|
+
origin = "py2many"
|
|
309
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['bool']"
|
|
310
|
+
py2many_emits = "($0 != 0) [no args: false]"
|
|
311
|
+
notes = "Option<i64> is truthy only when Some and non-zero; classes follow __bool__ then __len__. A Truthy trait implemented per type."
|
|
312
|
+
|
|
313
|
+
[[builtin]]
|
|
314
|
+
python = "bool"
|
|
315
|
+
kind = "function"
|
|
316
|
+
arity = "0"
|
|
317
|
+
rust = "false"
|
|
318
|
+
status = "direct"
|
|
319
|
+
origin = "py2many"
|
|
320
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['bool']"
|
|
321
|
+
py2many_emits = "($0 != 0) [no args: false]"
|
|
322
|
+
|
|
323
|
+
[[builtin]]
|
|
324
|
+
python = "abs"
|
|
325
|
+
kind = "function"
|
|
326
|
+
types = ["int", "float"]
|
|
327
|
+
arity = "1"
|
|
328
|
+
rust = "$0.abs()"
|
|
329
|
+
status = "direct"
|
|
330
|
+
origin = "original"
|
|
331
|
+
source = "python2rust (py2many has no mapping)"
|
|
332
|
+
notes = "py2many has no abs mapping (verified: `abs(-3)` is emitted verbatim as an undefined function). i64::MIN.abs() overflows (panic in debug, wrap in release); Python never overflows."
|
|
333
|
+
|
|
334
|
+
[[builtin]]
|
|
335
|
+
python = "round"
|
|
336
|
+
kind = "function"
|
|
337
|
+
types = ["float"]
|
|
338
|
+
arity = "1"
|
|
339
|
+
rust = "p2r::round_half_even($0)"
|
|
340
|
+
status = "needs-runtime-helper"
|
|
341
|
+
helper = "round_half_even"
|
|
342
|
+
min_rust = "1.77"
|
|
343
|
+
origin = "original"
|
|
344
|
+
source = "python2rust (py2many has no mapping)"
|
|
345
|
+
notes = "Python 3 rounds half to even (round(2.5) == 2) and returns int; f64::round rounds half away from zero (verified: 2.5.round() == 3). Inline $0.round_ties_even() as i64 is correct for finite values, but Python raises ValueError/OverflowError for nan/inf, hence the helper. py2many has no mapping."
|
|
346
|
+
|
|
347
|
+
[[builtin]]
|
|
348
|
+
python = "round"
|
|
349
|
+
kind = "function"
|
|
350
|
+
types = ["float"]
|
|
351
|
+
arity = "2"
|
|
352
|
+
rust = "p2r::round_ndigits($0, $1)"
|
|
353
|
+
status = "needs-runtime-helper"
|
|
354
|
+
helper = "round_ndigits"
|
|
355
|
+
origin = "original"
|
|
356
|
+
source = "python2rust (py2many has no mapping)"
|
|
357
|
+
notes = "round(x, n) is correctly rounded on the exact binary value (round(2.675, 2) == 2.67). Multiply-round-divide is wrong; use a decimal-exact algorithm."
|
|
358
|
+
|
|
359
|
+
[[builtin]]
|
|
360
|
+
python = "round"
|
|
361
|
+
kind = "function"
|
|
362
|
+
types = ["int"]
|
|
363
|
+
arity = "2"
|
|
364
|
+
rust = "p2r::round_ndigits_int($0, $1)"
|
|
365
|
+
status = "needs-runtime-helper"
|
|
366
|
+
helper = "round_ndigits_int"
|
|
367
|
+
origin = "original"
|
|
368
|
+
source = "python2rust (py2many has no mapping)"
|
|
369
|
+
notes = "Negative ndigits rounds an int half to even (round(25, -1) == 20)."
|
|
370
|
+
|
|
371
|
+
[[builtin]]
|
|
372
|
+
python = "min"
|
|
373
|
+
kind = "function"
|
|
374
|
+
types = ["int", "str"]
|
|
375
|
+
arity = "2"
|
|
376
|
+
rust = "std::cmp::min($0, $1)"
|
|
377
|
+
status = "direct"
|
|
378
|
+
origin = "py2many"
|
|
379
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
380
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
381
|
+
notes = "cmp::min returns the first argument on a tie, like Python."
|
|
382
|
+
|
|
383
|
+
[[builtin]]
|
|
384
|
+
python = "min"
|
|
385
|
+
kind = "function"
|
|
386
|
+
types = ["int", "str"]
|
|
387
|
+
arity = "3+"
|
|
388
|
+
rust = "[$args].into_iter().min().unwrap()"
|
|
389
|
+
status = "corrected"
|
|
390
|
+
origin = "py2many"
|
|
391
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
392
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
393
|
+
notes = "py2many emits cmp::min with every argument, but cmp::min takes exactly two."
|
|
394
|
+
|
|
395
|
+
[[builtin]]
|
|
396
|
+
python = "max"
|
|
397
|
+
kind = "function"
|
|
398
|
+
types = ["int", "str"]
|
|
399
|
+
arity = "2"
|
|
400
|
+
rust = "std::cmp::max($0, $1)"
|
|
401
|
+
status = "direct"
|
|
402
|
+
origin = "py2many"
|
|
403
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['max']"
|
|
404
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
405
|
+
notes = "cmp::max returns the SECOND argument on a tie; Python returns the first. Unobservable for plain ints/strs, observable for objects compared by key."
|
|
406
|
+
|
|
407
|
+
[[builtin]]
|
|
408
|
+
python = "max"
|
|
409
|
+
kind = "function"
|
|
410
|
+
types = ["int", "str"]
|
|
411
|
+
arity = "3+"
|
|
412
|
+
rust = "[$args].into_iter().max().unwrap()"
|
|
413
|
+
status = "corrected"
|
|
414
|
+
origin = "py2many"
|
|
415
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['max']"
|
|
416
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
417
|
+
notes = "Iterator::max returns the LAST maximal element; Python returns the first. Unobservable for totally ordered scalars."
|
|
418
|
+
|
|
419
|
+
[[builtin]]
|
|
420
|
+
python = "min"
|
|
421
|
+
kind = "function"
|
|
422
|
+
types = ["float"]
|
|
423
|
+
arity = "2"
|
|
424
|
+
rust = "p2r::min_f64($0, $1)"
|
|
425
|
+
status = "needs-runtime-helper"
|
|
426
|
+
helper = "min_f64"
|
|
427
|
+
origin = "py2many"
|
|
428
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
429
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
430
|
+
notes = "py2many wraps floats in float_ord::FloatOrd (total order: nan greatest, -0.0 < 0.0) and adds a crate dependency. Python min(a, b) is `b if b < a else a`, so min(nan, 1.0) is nan and min(1.0, nan) is 1.0. f64::min ignores nan."
|
|
431
|
+
|
|
432
|
+
[[builtin]]
|
|
433
|
+
python = "max"
|
|
434
|
+
kind = "function"
|
|
435
|
+
types = ["float"]
|
|
436
|
+
arity = "2"
|
|
437
|
+
rust = "p2r::max_f64($0, $1)"
|
|
438
|
+
status = "needs-runtime-helper"
|
|
439
|
+
helper = "max_f64"
|
|
440
|
+
origin = "py2many"
|
|
441
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['max']"
|
|
442
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
443
|
+
notes = "Python max(a, b) is `b if b > a else a`; see min notes for nan."
|
|
444
|
+
|
|
445
|
+
[[builtin]]
|
|
446
|
+
python = "min"
|
|
447
|
+
kind = "function"
|
|
448
|
+
types = ["list[int]", "list[str]", "set"]
|
|
449
|
+
arity = "1"
|
|
450
|
+
rust = "$0.iter().cloned().min().expect(\"min() arg is an empty sequence\")"
|
|
451
|
+
status = "corrected"
|
|
452
|
+
origin = "py2many"
|
|
453
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
454
|
+
py2many_emits = "$0.iter().min() (+ `?` appended by result_type)"
|
|
455
|
+
notes = "py2many leaves an Option and appends `?`, which does not compile in a function that returns a plain value (verified: `max(xs)?`). Python raises ValueError on empty input."
|
|
456
|
+
|
|
457
|
+
[[builtin]]
|
|
458
|
+
python = "max"
|
|
459
|
+
kind = "function"
|
|
460
|
+
types = ["list[int]", "list[str]", "set"]
|
|
461
|
+
arity = "1"
|
|
462
|
+
rust = "$0.iter().cloned().max().expect(\"max() arg is an empty sequence\")"
|
|
463
|
+
status = "corrected"
|
|
464
|
+
origin = "py2many"
|
|
465
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['max']"
|
|
466
|
+
py2many_emits = "$0.iter().max() (+ `?` appended by result_type)"
|
|
467
|
+
notes = "Last-maximal vs first-maximal is unobservable for scalars."
|
|
468
|
+
|
|
469
|
+
[[builtin]]
|
|
470
|
+
python = "min"
|
|
471
|
+
kind = "function"
|
|
472
|
+
types = ["list[float]"]
|
|
473
|
+
arity = "1"
|
|
474
|
+
rust = "p2r::iter_min_f64($0.iter().copied())"
|
|
475
|
+
status = "needs-runtime-helper"
|
|
476
|
+
helper = "iter_min_f64"
|
|
477
|
+
origin = "py2many"
|
|
478
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
479
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
480
|
+
notes = "f64 is not Ord; nan handling must follow Python's `<` scan."
|
|
481
|
+
|
|
482
|
+
[[builtin]]
|
|
483
|
+
python = "max"
|
|
484
|
+
kind = "function"
|
|
485
|
+
types = ["list[float]"]
|
|
486
|
+
arity = "1"
|
|
487
|
+
rust = "p2r::iter_max_f64($0.iter().copied())"
|
|
488
|
+
status = "needs-runtime-helper"
|
|
489
|
+
helper = "iter_max_f64"
|
|
490
|
+
origin = "py2many"
|
|
491
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['max']"
|
|
492
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
493
|
+
notes = "See helper `iter_max_f64` in [[helper]] for the exact semantics."
|
|
494
|
+
|
|
495
|
+
[[builtin]]
|
|
496
|
+
python = "min"
|
|
497
|
+
kind = "function"
|
|
498
|
+
types = ["list"]
|
|
499
|
+
arity = "1+key"
|
|
500
|
+
rust = "$0.iter().min_by_key($key).expect(\"min() arg is an empty sequence\")"
|
|
501
|
+
status = "direct"
|
|
502
|
+
origin = "py2many"
|
|
503
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
504
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
505
|
+
notes = "min_by_key returns the first minimal element, like Python."
|
|
506
|
+
|
|
507
|
+
[[builtin]]
|
|
508
|
+
python = "max"
|
|
509
|
+
kind = "function"
|
|
510
|
+
types = ["list"]
|
|
511
|
+
arity = "1+key"
|
|
512
|
+
rust = "p2r::max_by_key_first($0.iter(), $key)"
|
|
513
|
+
status = "needs-runtime-helper"
|
|
514
|
+
helper = "max_by_key_first"
|
|
515
|
+
origin = "py2many"
|
|
516
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['max']"
|
|
517
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
518
|
+
notes = "Iterator::max_by_key returns the last maximal element; Python's max(key=) returns the first."
|
|
519
|
+
|
|
520
|
+
[[builtin]]
|
|
521
|
+
python = "min"
|
|
522
|
+
kind = "function"
|
|
523
|
+
types = ["list[int]"]
|
|
524
|
+
arity = "1+default"
|
|
525
|
+
rust = "$0.iter().cloned().min().unwrap_or($default)"
|
|
526
|
+
status = "direct"
|
|
527
|
+
origin = "py2many"
|
|
528
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['min']"
|
|
529
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_min_max>"
|
|
530
|
+
|
|
531
|
+
[[builtin]]
|
|
532
|
+
python = "sum"
|
|
533
|
+
kind = "function"
|
|
534
|
+
types = ["list[int]"]
|
|
535
|
+
arity = "1"
|
|
536
|
+
rust = "$0.iter().sum::<i64>()"
|
|
537
|
+
status = "direct"
|
|
538
|
+
origin = "py2many"
|
|
539
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['sum']"
|
|
540
|
+
py2many_emits = "$0.iter().sum()"
|
|
541
|
+
notes = "py2many emits `.iter().sum()` with no type, which fails inference (E0283) unless a let annotation happens to exist. Overflow panics in debug and wraps in release; Python ints never overflow."
|
|
542
|
+
|
|
543
|
+
[[builtin]]
|
|
544
|
+
python = "sum"
|
|
545
|
+
kind = "function"
|
|
546
|
+
types = ["list[float]"]
|
|
547
|
+
arity = "1"
|
|
548
|
+
rust = "p2r::sum_f64($0.iter().copied())"
|
|
549
|
+
status = "needs-runtime-helper"
|
|
550
|
+
helper = "sum_f64"
|
|
551
|
+
origin = "py2many"
|
|
552
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['sum']"
|
|
553
|
+
py2many_emits = "$0.iter().sum()"
|
|
554
|
+
notes = "CPython 3.12+ sums floats with Neumaier compensated summation, so a naive fold gives different last digits (sum([0.1] * 10) is 1.0 in CPython 3.12+, 0.9999999999999999 with a plain fold). The helper must mirror that."
|
|
555
|
+
|
|
556
|
+
[[builtin]]
|
|
557
|
+
python = "sum"
|
|
558
|
+
kind = "function"
|
|
559
|
+
types = ["list[int]"]
|
|
560
|
+
arity = "2"
|
|
561
|
+
rust = "$0.iter().sum::<i64>() + $1"
|
|
562
|
+
status = "direct"
|
|
563
|
+
origin = "py2many"
|
|
564
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['sum']"
|
|
565
|
+
py2many_emits = "$0.iter().sum()"
|
|
566
|
+
notes = "sum(xs, start)."
|
|
567
|
+
|
|
568
|
+
[[builtin]]
|
|
569
|
+
python = "range"
|
|
570
|
+
kind = "function"
|
|
571
|
+
arity = "1"
|
|
572
|
+
rust = "(0..$0)"
|
|
573
|
+
status = "direct"
|
|
574
|
+
origin = "py2many"
|
|
575
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['range']"
|
|
576
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_range>"
|
|
577
|
+
notes = "Negative stop yields an empty range in both languages. Cast the loop variable to usize before indexing."
|
|
578
|
+
|
|
579
|
+
[[builtin]]
|
|
580
|
+
python = "range"
|
|
581
|
+
kind = "function"
|
|
582
|
+
arity = "2"
|
|
583
|
+
rust = "($0..$1)"
|
|
584
|
+
status = "direct"
|
|
585
|
+
origin = "py2many"
|
|
586
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['range']"
|
|
587
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_range>"
|
|
588
|
+
|
|
589
|
+
[[builtin]]
|
|
590
|
+
python = "range"
|
|
591
|
+
kind = "function"
|
|
592
|
+
arity = "3 (positive literal step)"
|
|
593
|
+
rust = "($0..$1).step_by($2 as usize)"
|
|
594
|
+
status = "direct"
|
|
595
|
+
origin = "py2many"
|
|
596
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['range']"
|
|
597
|
+
py2many_emits = "($0..$1).step_by($2)"
|
|
598
|
+
notes = "py2many does the same but emits the step unchanged."
|
|
599
|
+
|
|
600
|
+
[[builtin]]
|
|
601
|
+
python = "range"
|
|
602
|
+
kind = "function"
|
|
603
|
+
arity = "3 (negative literal step)"
|
|
604
|
+
rust = "(($1 + 1)..=$0).rev().step_by(((-($2)) as i64) as usize)"
|
|
605
|
+
status = "corrected"
|
|
606
|
+
origin = "py2many"
|
|
607
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['range']"
|
|
608
|
+
py2many_emits = "($0..$1).step_by($2)"
|
|
609
|
+
notes = "Verified: py2many emits `(10..0).step_by(-1)` for range(10, 0, -1), which does not compile and would be empty anyway. $1 + 1 overflows only when $1 == i64::MAX."
|
|
610
|
+
|
|
611
|
+
[[builtin]]
|
|
612
|
+
python = "range"
|
|
613
|
+
kind = "function"
|
|
614
|
+
arity = "3 (dynamic step)"
|
|
615
|
+
rust = "p2r::range3($0, $1, $2)"
|
|
616
|
+
status = "needs-runtime-helper"
|
|
617
|
+
helper = "range3"
|
|
618
|
+
origin = "py2many"
|
|
619
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['range']"
|
|
620
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_range>"
|
|
621
|
+
notes = "Step sign is unknown at compile time. Step 0 raises ValueError."
|
|
622
|
+
|
|
623
|
+
[[builtin]]
|
|
624
|
+
python = "xrange"
|
|
625
|
+
kind = "function"
|
|
626
|
+
arity = "1"
|
|
627
|
+
rust = "(0..$0)"
|
|
628
|
+
status = "unsupported"
|
|
629
|
+
origin = "py2many"
|
|
630
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['xrange']"
|
|
631
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_range>"
|
|
632
|
+
notes = "Python 2 only; reject instead of aliasing to range."
|
|
633
|
+
|
|
634
|
+
[[builtin]]
|
|
635
|
+
python = "print"
|
|
636
|
+
kind = "function"
|
|
637
|
+
arity = "0"
|
|
638
|
+
rust = "println!()"
|
|
639
|
+
status = "direct"
|
|
640
|
+
origin = "py2many"
|
|
641
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
642
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
643
|
+
|
|
644
|
+
[[builtin]]
|
|
645
|
+
python = "print"
|
|
646
|
+
kind = "function"
|
|
647
|
+
types = ["str", "int"]
|
|
648
|
+
arity = "1"
|
|
649
|
+
rust = "println!(\"{}\", $0)"
|
|
650
|
+
status = "direct"
|
|
651
|
+
origin = "py2many"
|
|
652
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
653
|
+
py2many_emits = "println!(\"{}\", $0);"
|
|
654
|
+
notes = "Same output as Python for str and i64."
|
|
655
|
+
|
|
656
|
+
[[builtin]]
|
|
657
|
+
python = "print"
|
|
658
|
+
kind = "function"
|
|
659
|
+
types = ["bool"]
|
|
660
|
+
arity = "1"
|
|
661
|
+
rust = "println!(\"{}\", if $0 { \"True\" } else { \"False\" })"
|
|
662
|
+
status = "direct"
|
|
663
|
+
origin = "py2many"
|
|
664
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
665
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
666
|
+
notes = "py2many does this via PrintBoolRewriter but only for a single argument."
|
|
667
|
+
|
|
668
|
+
[[builtin]]
|
|
669
|
+
python = "print"
|
|
670
|
+
kind = "function"
|
|
671
|
+
types = ["float"]
|
|
672
|
+
arity = "1"
|
|
673
|
+
rust = "println!(\"{}\", p2r::float_repr($0))"
|
|
674
|
+
status = "needs-runtime-helper"
|
|
675
|
+
helper = "float_repr"
|
|
676
|
+
origin = "py2many"
|
|
677
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
678
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
679
|
+
notes = "Verified: py2many prints `println!(\"{}\", x)`, giving `1` for 1.0."
|
|
680
|
+
|
|
681
|
+
[[builtin]]
|
|
682
|
+
python = "print"
|
|
683
|
+
kind = "function"
|
|
684
|
+
types = ["list", "dict", "set", "tuple", "None"]
|
|
685
|
+
arity = "1"
|
|
686
|
+
rust = "println!(\"{}\", p2r::py_repr(&$0))"
|
|
687
|
+
status = "needs-runtime-helper"
|
|
688
|
+
helper = "py_repr"
|
|
689
|
+
origin = "py2many"
|
|
690
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
691
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
692
|
+
notes = "py2many special-cases only list printing (quotes str elements); dicts, tuples, None and nested lists are not handled."
|
|
693
|
+
|
|
694
|
+
[[builtin]]
|
|
695
|
+
python = "print"
|
|
696
|
+
kind = "function"
|
|
697
|
+
arity = "2+"
|
|
698
|
+
rust = "p2r::print_args!($args)"
|
|
699
|
+
status = "needs-runtime-helper"
|
|
700
|
+
helper = "print_args"
|
|
701
|
+
origin = "py2many"
|
|
702
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
703
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
704
|
+
notes = "Arguments are joined by a single space and each is formatted like str(). py2many builds `{} {}` but formats each with Display, so bool/float/None differ. A macro because the arguments have different types."
|
|
705
|
+
|
|
706
|
+
[[builtin]]
|
|
707
|
+
python = "print"
|
|
708
|
+
kind = "function"
|
|
709
|
+
types = ["str"]
|
|
710
|
+
arity = "1+end=\"\""
|
|
711
|
+
rust = "print!(\"{}\", $0)"
|
|
712
|
+
status = "direct"
|
|
713
|
+
origin = "py2many"
|
|
714
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
715
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
716
|
+
notes = "Verified: py2many drops end= and sep= keywords and still emits println!. Flush is not forced; Python's stdout is also line-buffered on a tty."
|
|
717
|
+
|
|
718
|
+
[[builtin]]
|
|
719
|
+
python = "print"
|
|
720
|
+
kind = "function"
|
|
721
|
+
types = ["str"]
|
|
722
|
+
arity = "1+file=sys.stderr"
|
|
723
|
+
rust = "eprintln!(\"{}\", $0)"
|
|
724
|
+
status = "direct"
|
|
725
|
+
origin = "py2many"
|
|
726
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
727
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
728
|
+
|
|
729
|
+
[[builtin]]
|
|
730
|
+
python = "print"
|
|
731
|
+
kind = "function"
|
|
732
|
+
arity = "2+sep"
|
|
733
|
+
rust = "p2r::print_args_sep!($sep, $args)"
|
|
734
|
+
status = "needs-runtime-helper"
|
|
735
|
+
helper = "print_args"
|
|
736
|
+
origin = "py2many"
|
|
737
|
+
source = "pyrs/plugins.py:DISPATCH_MAP['print']"
|
|
738
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_print>"
|
|
739
|
+
notes = "See helper `print_args` in [[helper]] for the exact semantics."
|
|
740
|
+
|
|
741
|
+
[[builtin]]
|
|
742
|
+
python = "sys.exit"
|
|
743
|
+
kind = "function"
|
|
744
|
+
types = ["int"]
|
|
745
|
+
arity = "1"
|
|
746
|
+
rust = "std::process::exit($0)"
|
|
747
|
+
status = "direct"
|
|
748
|
+
origin = "py2many"
|
|
749
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['sys.exit']"
|
|
750
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_exit>"
|
|
751
|
+
notes = "Python raises SystemExit, so `finally` blocks and atexit handlers run; process::exit skips destructors and unflushed BufWriters."
|
|
752
|
+
|
|
753
|
+
[[builtin]]
|
|
754
|
+
python = "sys.exit"
|
|
755
|
+
kind = "function"
|
|
756
|
+
arity = "0"
|
|
757
|
+
rust = "std::process::exit(0)"
|
|
758
|
+
status = "direct"
|
|
759
|
+
origin = "py2many"
|
|
760
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['sys.exit']"
|
|
761
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_exit>"
|
|
762
|
+
|
|
763
|
+
[[builtin]]
|
|
764
|
+
python = "sys.exit"
|
|
765
|
+
kind = "function"
|
|
766
|
+
types = ["str"]
|
|
767
|
+
arity = "1"
|
|
768
|
+
rust = "{ eprintln!(\"{}\", $0); std::process::exit(1) }"
|
|
769
|
+
status = "corrected"
|
|
770
|
+
origin = "py2many"
|
|
771
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['sys.exit']"
|
|
772
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_exit>"
|
|
773
|
+
notes = "sys.exit(\"msg\") prints msg to stderr and exits with status 1. py2many passes the string to process::exit, which does not compile."
|
|
774
|
+
|
|
775
|
+
[[builtin]]
|
|
776
|
+
python = "input"
|
|
777
|
+
kind = "function"
|
|
778
|
+
arity = "0-1"
|
|
779
|
+
rust = "p2r::input($0)"
|
|
780
|
+
status = "needs-runtime-helper"
|
|
781
|
+
helper = "input"
|
|
782
|
+
origin = "original"
|
|
783
|
+
source = "python2rust (py2many has no mapping)"
|
|
784
|
+
notes = "Writes the prompt, flushes stdout, strips the trailing newline, raises EOFError at end of input."
|
|
785
|
+
|
|
786
|
+
[[builtin]]
|
|
787
|
+
python = "isinstance"
|
|
788
|
+
kind = "function"
|
|
789
|
+
types = ["statically known"]
|
|
790
|
+
arity = "2"
|
|
791
|
+
rust = "true"
|
|
792
|
+
status = "compile-time"
|
|
793
|
+
origin = "original"
|
|
794
|
+
source = "python2rust (py2many has no mapping)"
|
|
795
|
+
notes = "py2many has no Rust mapping. Resolve from IR types at transpile time and emit a constant; there is no runtime type test for monomorphic code."
|
|
796
|
+
|
|
797
|
+
[[builtin]]
|
|
798
|
+
python = "isinstance"
|
|
799
|
+
kind = "function"
|
|
800
|
+
types = ["Union"]
|
|
801
|
+
arity = "2"
|
|
802
|
+
rust = "matches!($0, $Enum::$Variant(_))"
|
|
803
|
+
status = "compile-time"
|
|
804
|
+
origin = "original"
|
|
805
|
+
source = "python2rust (py2many has no mapping)"
|
|
806
|
+
notes = "A Union[int, str] value becomes a generated enum; isinstance becomes a match."
|
|
807
|
+
|
|
808
|
+
[[builtin]]
|
|
809
|
+
python = "type"
|
|
810
|
+
kind = "function"
|
|
811
|
+
arity = "1"
|
|
812
|
+
rust = ""
|
|
813
|
+
status = "unsupported"
|
|
814
|
+
origin = "original"
|
|
815
|
+
source = "python2rust (py2many has no mapping)"
|
|
816
|
+
notes = "type(x) == int is compile-time; a runtime type object has no Rust form. Reject loudly."
|
|
817
|
+
|
|
818
|
+
[[builtin]]
|
|
819
|
+
python = "getattr"
|
|
820
|
+
kind = "function"
|
|
821
|
+
arity = "1"
|
|
822
|
+
rust = ""
|
|
823
|
+
status = "unsupported"
|
|
824
|
+
origin = "original"
|
|
825
|
+
source = "python2rust (py2many has no mapping)"
|
|
826
|
+
notes = "dynamic attribute access; py2many emits `obj: object` and the call verbatim. Reject loudly."
|
|
827
|
+
|
|
828
|
+
[[builtin]]
|
|
829
|
+
python = "setattr"
|
|
830
|
+
kind = "function"
|
|
831
|
+
arity = "1"
|
|
832
|
+
rust = ""
|
|
833
|
+
status = "unsupported"
|
|
834
|
+
origin = "original"
|
|
835
|
+
source = "python2rust (py2many has no mapping)"
|
|
836
|
+
notes = "dynamic attribute mutation. Reject loudly."
|
|
837
|
+
|
|
838
|
+
[[builtin]]
|
|
839
|
+
python = "hasattr"
|
|
840
|
+
kind = "function"
|
|
841
|
+
arity = "1"
|
|
842
|
+
rust = ""
|
|
843
|
+
status = "unsupported"
|
|
844
|
+
origin = "original"
|
|
845
|
+
source = "python2rust (py2many has no mapping)"
|
|
846
|
+
notes = "dynamic attribute test. Reject loudly."
|
|
847
|
+
|
|
848
|
+
[[builtin]]
|
|
849
|
+
python = "eval"
|
|
850
|
+
kind = "function"
|
|
851
|
+
arity = "1"
|
|
852
|
+
rust = ""
|
|
853
|
+
status = "unsupported"
|
|
854
|
+
origin = "original"
|
|
855
|
+
source = "python2rust (py2many has no mapping)"
|
|
856
|
+
notes = "no embedded interpreter. Reject loudly."
|
|
857
|
+
|
|
858
|
+
[[builtin]]
|
|
859
|
+
python = "exec"
|
|
860
|
+
kind = "function"
|
|
861
|
+
arity = "1"
|
|
862
|
+
rust = ""
|
|
863
|
+
status = "unsupported"
|
|
864
|
+
origin = "original"
|
|
865
|
+
source = "python2rust (py2many has no mapping)"
|
|
866
|
+
notes = "no embedded interpreter. Reject loudly."
|
|
867
|
+
|
|
868
|
+
[[builtin]]
|
|
869
|
+
python = "id"
|
|
870
|
+
kind = "function"
|
|
871
|
+
arity = "1"
|
|
872
|
+
rust = ""
|
|
873
|
+
status = "unsupported"
|
|
874
|
+
origin = "original"
|
|
875
|
+
source = "python2rust (py2many has no mapping)"
|
|
876
|
+
notes = "object identity has no stable Rust equivalent. Reject loudly."
|
|
877
|
+
|
|
878
|
+
[[builtin]]
|
|
879
|
+
python = "hash"
|
|
880
|
+
kind = "function"
|
|
881
|
+
arity = "1"
|
|
882
|
+
rust = ""
|
|
883
|
+
status = "unsupported"
|
|
884
|
+
origin = "original"
|
|
885
|
+
source = "python2rust (py2many has no mapping)"
|
|
886
|
+
notes = "str hashing is randomised per process in CPython (PYTHONHASHSEED); values cannot be reproduced. Reject loudly."
|
|
887
|
+
|
|
888
|
+
[[builtin]]
|
|
889
|
+
python = "callable"
|
|
890
|
+
kind = "function"
|
|
891
|
+
arity = "1"
|
|
892
|
+
rust = ""
|
|
893
|
+
status = "unsupported"
|
|
894
|
+
origin = "original"
|
|
895
|
+
source = "python2rust (py2many has no mapping)"
|
|
896
|
+
notes = "decide statically from the type. Reject loudly."
|
|
897
|
+
|
|
898
|
+
[[builtin]]
|
|
899
|
+
python = "chr"
|
|
900
|
+
kind = "function"
|
|
901
|
+
types = ["int"]
|
|
902
|
+
arity = "1"
|
|
903
|
+
rust = "p2r::chr($0)"
|
|
904
|
+
status = "needs-runtime-helper"
|
|
905
|
+
helper = "chr"
|
|
906
|
+
origin = "original"
|
|
907
|
+
source = "python2rust (py2many has no mapping)"
|
|
908
|
+
notes = "py2many has no mapping. char::from_u32 rejects surrogates (0xD800..0xDFFF), which Python str allows; Python raises ValueError above 0x10FFFF."
|
|
909
|
+
|
|
910
|
+
[[builtin]]
|
|
911
|
+
python = "ord"
|
|
912
|
+
kind = "function"
|
|
913
|
+
types = ["str"]
|
|
914
|
+
arity = "1"
|
|
915
|
+
rust = "p2r::ord(&$0)"
|
|
916
|
+
status = "needs-runtime-helper"
|
|
917
|
+
helper = "ord"
|
|
918
|
+
origin = "original"
|
|
919
|
+
source = "python2rust (py2many has no mapping)"
|
|
920
|
+
notes = "Requires a string of exactly one code point, else TypeError."
|
|
921
|
+
|
|
922
|
+
[[builtin]]
|
|
923
|
+
python = "hex"
|
|
924
|
+
kind = "function"
|
|
925
|
+
types = ["int"]
|
|
926
|
+
arity = "1"
|
|
927
|
+
rust = "p2r::hex($0)"
|
|
928
|
+
status = "needs-runtime-helper"
|
|
929
|
+
helper = "hex"
|
|
930
|
+
origin = "original"
|
|
931
|
+
source = "python2rust (py2many has no mapping)"
|
|
932
|
+
notes = "hex(-255) is '-0xff'; Rust {:x} on a negative i64 prints two's complement (verified: ffffffffffffff01)."
|
|
933
|
+
|
|
934
|
+
[[builtin]]
|
|
935
|
+
python = "bin"
|
|
936
|
+
kind = "function"
|
|
937
|
+
types = ["int"]
|
|
938
|
+
arity = "1"
|
|
939
|
+
rust = "p2r::bin($0)"
|
|
940
|
+
status = "needs-runtime-helper"
|
|
941
|
+
helper = "bin"
|
|
942
|
+
origin = "original"
|
|
943
|
+
source = "python2rust (py2many has no mapping)"
|
|
944
|
+
notes = "Same sign handling as hex; prefix 0b."
|
|
945
|
+
|
|
946
|
+
[[builtin]]
|
|
947
|
+
python = "oct"
|
|
948
|
+
kind = "function"
|
|
949
|
+
types = ["int"]
|
|
950
|
+
arity = "1"
|
|
951
|
+
rust = "p2r::oct($0)"
|
|
952
|
+
status = "needs-runtime-helper"
|
|
953
|
+
helper = "oct"
|
|
954
|
+
origin = "original"
|
|
955
|
+
source = "python2rust (py2many has no mapping)"
|
|
956
|
+
notes = "Same sign handling as hex; prefix 0o."
|
|
957
|
+
|
|
958
|
+
[[builtin]]
|
|
959
|
+
python = "divmod"
|
|
960
|
+
kind = "function"
|
|
961
|
+
types = ["int", "float"]
|
|
962
|
+
arity = "2"
|
|
963
|
+
rust = "p2r::divmod($0, $1)"
|
|
964
|
+
status = "needs-runtime-helper"
|
|
965
|
+
helper = "divmod"
|
|
966
|
+
origin = "original"
|
|
967
|
+
source = "python2rust (py2many has no mapping)"
|
|
968
|
+
notes = "Floor semantics: the remainder takes the divisor's sign."
|
|
969
|
+
|
|
970
|
+
[[builtin]]
|
|
971
|
+
python = "pow"
|
|
972
|
+
kind = "function"
|
|
973
|
+
types = ["int"]
|
|
974
|
+
arity = "2"
|
|
975
|
+
rust = "p2r::int_pow($0, $1)"
|
|
976
|
+
status = "needs-runtime-helper"
|
|
977
|
+
helper = "int_pow"
|
|
978
|
+
origin = "original"
|
|
979
|
+
source = "python2rust (py2many has no mapping)"
|
|
980
|
+
notes = "Negative exponent returns a float in Python; restrict to a non-negative literal exponent or reject. Overflow must be checked."
|
|
981
|
+
|
|
982
|
+
[[builtin]]
|
|
983
|
+
python = "pow"
|
|
984
|
+
kind = "function"
|
|
985
|
+
types = ["int"]
|
|
986
|
+
arity = "3"
|
|
987
|
+
rust = "p2r::pow_mod($0, $1, $2)"
|
|
988
|
+
status = "needs-runtime-helper"
|
|
989
|
+
helper = "pow_mod"
|
|
990
|
+
origin = "original"
|
|
991
|
+
source = "python2rust (py2many has no mapping)"
|
|
992
|
+
notes = "Modular exponentiation without intermediate overflow."
|
|
993
|
+
|
|
994
|
+
[[builtin]]
|
|
995
|
+
python = "pow"
|
|
996
|
+
kind = "function"
|
|
997
|
+
types = ["float"]
|
|
998
|
+
arity = "2"
|
|
999
|
+
rust = "$0.powf($1)"
|
|
1000
|
+
status = "direct"
|
|
1001
|
+
origin = "original"
|
|
1002
|
+
source = "python2rust (py2many has no mapping)"
|
|
1003
|
+
notes = "Python float ** float raises on 0.0 ** -1 and returns complex for a negative base with fractional exponent."
|
|
1004
|
+
|
|
1005
|
+
[[builtin]]
|
|
1006
|
+
python = "any"
|
|
1007
|
+
kind = "function"
|
|
1008
|
+
types = ["list[bool]"]
|
|
1009
|
+
arity = "1"
|
|
1010
|
+
rust = "$0.iter().any(|b| *b)"
|
|
1011
|
+
status = "direct"
|
|
1012
|
+
origin = "original"
|
|
1013
|
+
source = "python2rust (py2many has no mapping)"
|
|
1014
|
+
notes = "A generator argument any(p(x) for x in xs) becomes xs.iter().any(|x| p(x))."
|
|
1015
|
+
|
|
1016
|
+
[[builtin]]
|
|
1017
|
+
python = "all"
|
|
1018
|
+
kind = "function"
|
|
1019
|
+
types = ["list[bool]"]
|
|
1020
|
+
arity = "1"
|
|
1021
|
+
rust = "$0.iter().all(|b| *b)"
|
|
1022
|
+
status = "direct"
|
|
1023
|
+
origin = "original"
|
|
1024
|
+
source = "python2rust (py2many has no mapping)"
|
|
1025
|
+
notes = "all([]) is True, as for Iterator::all."
|
|
1026
|
+
|
|
1027
|
+
[[builtin]]
|
|
1028
|
+
python = "sorted"
|
|
1029
|
+
kind = "function"
|
|
1030
|
+
types = ["list[int]", "list[str]"]
|
|
1031
|
+
arity = "1"
|
|
1032
|
+
rust = "{ let mut v = $0.to_vec(); v.sort(); v }"
|
|
1033
|
+
status = "direct"
|
|
1034
|
+
origin = "original"
|
|
1035
|
+
source = "python2rust (py2many has no mapping)"
|
|
1036
|
+
notes = "Both sorts are stable. UTF-8 byte order equals code-point order, so str ordering matches Python."
|
|
1037
|
+
|
|
1038
|
+
[[builtin]]
|
|
1039
|
+
python = "sorted"
|
|
1040
|
+
kind = "function"
|
|
1041
|
+
types = ["list[float]"]
|
|
1042
|
+
arity = "1"
|
|
1043
|
+
rust = "p2r::sorted_f64($0)"
|
|
1044
|
+
status = "needs-runtime-helper"
|
|
1045
|
+
helper = "sorted_f64"
|
|
1046
|
+
origin = "original"
|
|
1047
|
+
source = "python2rust (py2many has no mapping)"
|
|
1048
|
+
notes = "f64 is not Ord. total_cmp orders -0.0 before 0.0 while Python treats them equal and keeps input order; use partial_cmp semantics."
|
|
1049
|
+
|
|
1050
|
+
[[builtin]]
|
|
1051
|
+
python = "sorted"
|
|
1052
|
+
kind = "function"
|
|
1053
|
+
types = ["list"]
|
|
1054
|
+
arity = "1+key"
|
|
1055
|
+
rust = "{ let mut v = $0.to_vec(); v.sort_by_cached_key($key); v }"
|
|
1056
|
+
status = "direct"
|
|
1057
|
+
origin = "original"
|
|
1058
|
+
source = "python2rust (py2many has no mapping)"
|
|
1059
|
+
notes = "sort_by_cached_key calls the key once per element, like Python."
|
|
1060
|
+
|
|
1061
|
+
[[builtin]]
|
|
1062
|
+
python = "sorted"
|
|
1063
|
+
kind = "function"
|
|
1064
|
+
types = ["list[int]", "list[str]"]
|
|
1065
|
+
arity = "1+reverse=True"
|
|
1066
|
+
rust = "{ let mut v = $0.to_vec(); v.sort_by(|a, b| b.cmp(a)); v }"
|
|
1067
|
+
status = "direct"
|
|
1068
|
+
origin = "original"
|
|
1069
|
+
source = "python2rust (py2many has no mapping)"
|
|
1070
|
+
notes = "Python's reverse=True keeps equal elements in original order. Do NOT sort() then reverse(): that reverses ties."
|
|
1071
|
+
|
|
1072
|
+
[[builtin]]
|
|
1073
|
+
python = "reversed"
|
|
1074
|
+
kind = "function"
|
|
1075
|
+
types = ["list"]
|
|
1076
|
+
arity = "1"
|
|
1077
|
+
rust = "$0.iter().rev()"
|
|
1078
|
+
status = "direct"
|
|
1079
|
+
origin = "py2many"
|
|
1080
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['reversed']"
|
|
1081
|
+
py2many_emits = "$0.iter().rev()"
|
|
1082
|
+
notes = "Yields references; add .cloned() where values are needed."
|
|
1083
|
+
|
|
1084
|
+
[[builtin]]
|
|
1085
|
+
python = "reversed"
|
|
1086
|
+
kind = "function"
|
|
1087
|
+
types = ["str"]
|
|
1088
|
+
arity = "1"
|
|
1089
|
+
rust = "$0.chars().rev()"
|
|
1090
|
+
status = "direct"
|
|
1091
|
+
origin = "py2many"
|
|
1092
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['reversed']"
|
|
1093
|
+
py2many_emits = "$0.iter().rev()"
|
|
1094
|
+
notes = "py2many's .iter().rev() does not exist on str."
|
|
1095
|
+
|
|
1096
|
+
[[builtin]]
|
|
1097
|
+
python = "enumerate"
|
|
1098
|
+
kind = "function"
|
|
1099
|
+
types = ["list"]
|
|
1100
|
+
arity = "1"
|
|
1101
|
+
rust = "$0.iter().enumerate().map(|(i, x)| (i as i64, x))"
|
|
1102
|
+
status = "corrected"
|
|
1103
|
+
origin = "py2many"
|
|
1104
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['enumerate']"
|
|
1105
|
+
py2many_emits = "$0.iter().enumerate()"
|
|
1106
|
+
notes = "py2many yields (usize, &T); Python yields (int, T)."
|
|
1107
|
+
|
|
1108
|
+
[[builtin]]
|
|
1109
|
+
python = "enumerate"
|
|
1110
|
+
kind = "function"
|
|
1111
|
+
types = ["list"]
|
|
1112
|
+
arity = "2"
|
|
1113
|
+
rust = "$0.iter().enumerate().map(|(i, x)| (i as i64 + $1, x))"
|
|
1114
|
+
status = "corrected"
|
|
1115
|
+
origin = "py2many"
|
|
1116
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['enumerate']"
|
|
1117
|
+
py2many_emits = "$0.iter().enumerate()"
|
|
1118
|
+
notes = "Verified: py2many drops the start argument."
|
|
1119
|
+
|
|
1120
|
+
[[builtin]]
|
|
1121
|
+
python = "zip"
|
|
1122
|
+
kind = "function"
|
|
1123
|
+
types = ["list"]
|
|
1124
|
+
arity = "2"
|
|
1125
|
+
rust = "$0.iter().zip($1.iter())"
|
|
1126
|
+
status = "direct"
|
|
1127
|
+
origin = "original"
|
|
1128
|
+
source = "python2rust (py2many has no mapping)"
|
|
1129
|
+
notes = "py2many has no zip mapping (verified: emitted as `zip(xs, xs)`). Both stop at the shortest input. zip(strict=True) is unsupported."
|
|
1130
|
+
|
|
1131
|
+
[[builtin]]
|
|
1132
|
+
python = "zip"
|
|
1133
|
+
kind = "function"
|
|
1134
|
+
types = ["list"]
|
|
1135
|
+
arity = "3"
|
|
1136
|
+
rust = "$0.iter().zip($1.iter()).zip($2.iter()).map(|((a, b), c)| (a, b, c))"
|
|
1137
|
+
status = "direct"
|
|
1138
|
+
origin = "original"
|
|
1139
|
+
source = "python2rust (py2many has no mapping)"
|
|
1140
|
+
|
|
1141
|
+
[[builtin]]
|
|
1142
|
+
python = "map"
|
|
1143
|
+
kind = "function"
|
|
1144
|
+
arity = "2"
|
|
1145
|
+
rust = "$1.iter().map($0)"
|
|
1146
|
+
status = "direct"
|
|
1147
|
+
origin = "py2many"
|
|
1148
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['map']"
|
|
1149
|
+
py2many_emits = "$1.iter().map($0)"
|
|
1150
|
+
notes = "Lazy in both languages. The closure receives &T. Multi-iterable map is unsupported."
|
|
1151
|
+
|
|
1152
|
+
[[builtin]]
|
|
1153
|
+
python = "filter"
|
|
1154
|
+
kind = "function"
|
|
1155
|
+
arity = "2"
|
|
1156
|
+
rust = "$1.iter().filter($0)"
|
|
1157
|
+
status = "corrected"
|
|
1158
|
+
origin = "py2many"
|
|
1159
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['filter']"
|
|
1160
|
+
py2many_emits = "$1.into_iter().filter($0)"
|
|
1161
|
+
notes = "py2many consumes the list with into_iter(); that moves it and breaks later uses. The closure receives &&T. filter(None, xs) is unsupported."
|
|
1162
|
+
|
|
1163
|
+
[[builtin]]
|
|
1164
|
+
python = "list"
|
|
1165
|
+
kind = "function"
|
|
1166
|
+
types = ["iterator"]
|
|
1167
|
+
arity = "1"
|
|
1168
|
+
rust = "$0.collect::<Vec<_>>()"
|
|
1169
|
+
status = "direct"
|
|
1170
|
+
origin = "py2many"
|
|
1171
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['list']"
|
|
1172
|
+
py2many_emits = "$0.collect::<Vec<_>>()"
|
|
1173
|
+
notes = "Valid only when $0 is already an iterator; py2many applies it to every type."
|
|
1174
|
+
|
|
1175
|
+
[[builtin]]
|
|
1176
|
+
python = "list"
|
|
1177
|
+
kind = "function"
|
|
1178
|
+
types = ["list"]
|
|
1179
|
+
arity = "1"
|
|
1180
|
+
rust = "$0.clone()"
|
|
1181
|
+
status = "corrected"
|
|
1182
|
+
origin = "py2many"
|
|
1183
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['list']"
|
|
1184
|
+
py2many_emits = "$0.collect::<Vec<_>>()"
|
|
1185
|
+
|
|
1186
|
+
[[builtin]]
|
|
1187
|
+
python = "list"
|
|
1188
|
+
kind = "function"
|
|
1189
|
+
types = ["str"]
|
|
1190
|
+
arity = "1"
|
|
1191
|
+
rust = "$0.chars().map(|c| c.to_string()).collect::<Vec<String>>()"
|
|
1192
|
+
status = "corrected"
|
|
1193
|
+
origin = "py2many"
|
|
1194
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['list']"
|
|
1195
|
+
py2many_emits = "$0.collect::<Vec<_>>()"
|
|
1196
|
+
|
|
1197
|
+
[[builtin]]
|
|
1198
|
+
python = "list"
|
|
1199
|
+
kind = "function"
|
|
1200
|
+
types = ["dict"]
|
|
1201
|
+
arity = "1"
|
|
1202
|
+
rust = "$0.keys().cloned().collect::<Vec<_>>()"
|
|
1203
|
+
status = "corrected"
|
|
1204
|
+
crates = ["indexmap"]
|
|
1205
|
+
origin = "py2many"
|
|
1206
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['list']"
|
|
1207
|
+
py2many_emits = "$0.collect::<Vec<_>>()"
|
|
1208
|
+
notes = "Order is insertion order only with IndexMap; HashMap order is arbitrary."
|
|
1209
|
+
|
|
1210
|
+
[[builtin]]
|
|
1211
|
+
python = "list"
|
|
1212
|
+
kind = "function"
|
|
1213
|
+
types = ["set"]
|
|
1214
|
+
arity = "1"
|
|
1215
|
+
rust = "$0.iter().cloned().collect::<Vec<_>>()"
|
|
1216
|
+
status = "corrected"
|
|
1217
|
+
origin = "py2many"
|
|
1218
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['list']"
|
|
1219
|
+
py2many_emits = "$0.collect::<Vec<_>>()"
|
|
1220
|
+
notes = "Set iteration order is unspecified in both languages; never rely on it."
|
|
1221
|
+
|
|
1222
|
+
[[builtin]]
|
|
1223
|
+
python = "list"
|
|
1224
|
+
kind = "function"
|
|
1225
|
+
arity = "0"
|
|
1226
|
+
rust = "Vec::new()"
|
|
1227
|
+
status = "direct"
|
|
1228
|
+
origin = "py2many"
|
|
1229
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['list']"
|
|
1230
|
+
py2many_emits = "$0.collect::<Vec<_>>()"
|
|
1231
|
+
|
|
1232
|
+
[[builtin]]
|
|
1233
|
+
python = "set"
|
|
1234
|
+
kind = "function"
|
|
1235
|
+
types = ["list"]
|
|
1236
|
+
arity = "1"
|
|
1237
|
+
rust = "$0.iter().cloned().collect::<HashSet<_>>()"
|
|
1238
|
+
status = "direct"
|
|
1239
|
+
imports = ["std::collections::HashSet"]
|
|
1240
|
+
origin = "original"
|
|
1241
|
+
source = "python2rust (py2many has no mapping)"
|
|
1242
|
+
notes = "py2many has no set() mapping. Iteration order differs from CPython."
|
|
1243
|
+
|
|
1244
|
+
[[builtin]]
|
|
1245
|
+
python = "set"
|
|
1246
|
+
kind = "function"
|
|
1247
|
+
arity = "0"
|
|
1248
|
+
rust = "HashSet::new()"
|
|
1249
|
+
status = "direct"
|
|
1250
|
+
imports = ["std::collections::HashSet"]
|
|
1251
|
+
origin = "original"
|
|
1252
|
+
source = "python2rust (py2many has no mapping)"
|
|
1253
|
+
|
|
1254
|
+
[[builtin]]
|
|
1255
|
+
python = "dict"
|
|
1256
|
+
kind = "function"
|
|
1257
|
+
arity = "0"
|
|
1258
|
+
rust = "IndexMap::new()"
|
|
1259
|
+
status = "direct"
|
|
1260
|
+
imports = ["indexmap::IndexMap"]
|
|
1261
|
+
crates = ["indexmap"]
|
|
1262
|
+
origin = "original"
|
|
1263
|
+
source = "python2rust (py2many has no mapping)"
|
|
1264
|
+
notes = "Python dicts keep insertion order; std HashMap does not, and py2many maps dict to HashMap."
|
|
1265
|
+
|
|
1266
|
+
[[builtin]]
|
|
1267
|
+
python = "dict"
|
|
1268
|
+
kind = "function"
|
|
1269
|
+
types = ["list[tuple]"]
|
|
1270
|
+
arity = "1"
|
|
1271
|
+
rust = "$0.into_iter().collect::<IndexMap<_, _>>()"
|
|
1272
|
+
status = "direct"
|
|
1273
|
+
imports = ["indexmap::IndexMap"]
|
|
1274
|
+
crates = ["indexmap"]
|
|
1275
|
+
origin = "original"
|
|
1276
|
+
source = "python2rust (py2many has no mapping)"
|
|
1277
|
+
|
|
1278
|
+
[[builtin]]
|
|
1279
|
+
python = "tuple"
|
|
1280
|
+
kind = "function"
|
|
1281
|
+
types = ["any"]
|
|
1282
|
+
arity = "1"
|
|
1283
|
+
rust = ""
|
|
1284
|
+
status = "unsupported"
|
|
1285
|
+
origin = "original"
|
|
1286
|
+
source = "python2rust (py2many has no mapping)"
|
|
1287
|
+
notes = "Tuple arity is part of the Rust type; only literal tuples are supported."
|
|
1288
|
+
|
|
1289
|
+
[[builtin]]
|
|
1290
|
+
python = "open"
|
|
1291
|
+
kind = "function"
|
|
1292
|
+
arity = "1-2"
|
|
1293
|
+
rust = ""
|
|
1294
|
+
status = "unsupported"
|
|
1295
|
+
origin = "py2many"
|
|
1296
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['open']"
|
|
1297
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_open>"
|
|
1298
|
+
notes = "py2many emits File::open with `pylib::FileReadString`-style traits from an external crate that python2rust does not depend on. Text mode also translates newlines and decodes with a locale default; map the `with open(...) as f: f.read()` idiom to a helper later."
|
|
1299
|
+
|
|
1300
|
+
[[builtin]]
|
|
1301
|
+
python = "f.read"
|
|
1302
|
+
kind = "function"
|
|
1303
|
+
arity = "0-1"
|
|
1304
|
+
rust = ""
|
|
1305
|
+
status = "unsupported"
|
|
1306
|
+
origin = "py2many"
|
|
1307
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['f.read']"
|
|
1308
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_read>"
|
|
1309
|
+
notes = "py2many dispatches on the literal variable name `f`; any variable named f triggers it. Do not copy name-based dispatch."
|
|
1310
|
+
|
|
1311
|
+
[[builtin]]
|
|
1312
|
+
python = "f.write"
|
|
1313
|
+
kind = "function"
|
|
1314
|
+
arity = "1"
|
|
1315
|
+
rust = ""
|
|
1316
|
+
status = "unsupported"
|
|
1317
|
+
origin = "py2many"
|
|
1318
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['f.write']"
|
|
1319
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_write>"
|
|
1320
|
+
notes = "Name-based dispatch on `f`; see f.read."
|
|
1321
|
+
|
|
1322
|
+
[[builtin]]
|
|
1323
|
+
python = "f.close"
|
|
1324
|
+
kind = "function"
|
|
1325
|
+
arity = "0"
|
|
1326
|
+
rust = ""
|
|
1327
|
+
status = "unsupported"
|
|
1328
|
+
origin = "py2many"
|
|
1329
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['f.close']"
|
|
1330
|
+
py2many_emits = "drop(f)"
|
|
1331
|
+
notes = "py2many emits drop(f); with-statements need scope-based closing."
|
|
1332
|
+
|
|
1333
|
+
[[builtin]]
|
|
1334
|
+
python = "tempfile.NamedTemporaryFile"
|
|
1335
|
+
kind = "function"
|
|
1336
|
+
rust = ""
|
|
1337
|
+
status = "unsupported"
|
|
1338
|
+
origin = "py2many"
|
|
1339
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['NamedTemporaryFile']"
|
|
1340
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_named_temp_file>"
|
|
1341
|
+
|
|
1342
|
+
[[builtin]]
|
|
1343
|
+
python = "io.TextIOWrapper.read"
|
|
1344
|
+
kind = "function"
|
|
1345
|
+
rust = ""
|
|
1346
|
+
status = "unsupported"
|
|
1347
|
+
origin = "py2many"
|
|
1348
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['io.TextIOWrapper.read']"
|
|
1349
|
+
py2many_emits = "<handler RustTranspilerPlugins.visit_textio_write>"
|
|
1350
|
+
notes = "py2many's table defines this key twice (a read handler and a write handler); the second silently replaces the first. Both handlers return None."
|
|
1351
|
+
|
|
1352
|
+
[[builtin]]
|
|
1353
|
+
python = "parse_args"
|
|
1354
|
+
kind = "function"
|
|
1355
|
+
rust = ""
|
|
1356
|
+
status = "unsupported"
|
|
1357
|
+
origin = "py2many"
|
|
1358
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['parse_args']"
|
|
1359
|
+
py2many_emits = "::from_args()"
|
|
1360
|
+
notes = "py2many dispatches any `.parse_args` call to structopt."
|
|
1361
|
+
|
|
1362
|
+
[[builtin]]
|
|
1363
|
+
python = "Error"
|
|
1364
|
+
kind = "function"
|
|
1365
|
+
rust = ""
|
|
1366
|
+
status = "unsupported"
|
|
1367
|
+
origin = "py2many"
|
|
1368
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['Error']"
|
|
1369
|
+
py2many_emits = "anyhow::bail!($0)"
|
|
1370
|
+
notes = "py2many emits anyhow::bail!(...) for any call named Error."
|
|
1371
|
+
|
|
1372
|
+
[[builtin]]
|
|
1373
|
+
python = "os.unlink"
|
|
1374
|
+
kind = "function"
|
|
1375
|
+
arity = "1"
|
|
1376
|
+
rust = "std::fs::remove_file($0).expect(\"os.unlink failed\")"
|
|
1377
|
+
status = "corrected"
|
|
1378
|
+
origin = "py2many"
|
|
1379
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['os.unlink']"
|
|
1380
|
+
py2many_emits = "std::fs::remove_file($0)?"
|
|
1381
|
+
notes = "py2many appends `?`, which requires the caller to return Result."
|
|
1382
|
+
|
|
1383
|
+
[[builtin]]
|
|
1384
|
+
python = "time.time"
|
|
1385
|
+
kind = "function"
|
|
1386
|
+
arity = "0"
|
|
1387
|
+
rust = "std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).expect(\"clock before epoch\").as_secs_f64()"
|
|
1388
|
+
status = "corrected"
|
|
1389
|
+
origin = "py2many"
|
|
1390
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['time.time']"
|
|
1391
|
+
py2many_emits = "pylib::time()"
|
|
1392
|
+
notes = "py2many calls a `pylib` crate that does not exist outside py2many."
|
|
1393
|
+
|
|
1394
|
+
[[builtin]]
|
|
1395
|
+
python = "time.sleep"
|
|
1396
|
+
kind = "function"
|
|
1397
|
+
arity = "1"
|
|
1398
|
+
rust = "std::thread::sleep(std::time::Duration::from_secs_f64($0))"
|
|
1399
|
+
status = "direct"
|
|
1400
|
+
origin = "original"
|
|
1401
|
+
source = "python2rust (py2many has no mapping)"
|
|
1402
|
+
notes = "Negative values raise ValueError in Python and panic in Duration."
|
|
1403
|
+
|
|
1404
|
+
[[builtin]]
|
|
1405
|
+
python = "time.perf_counter"
|
|
1406
|
+
kind = "function"
|
|
1407
|
+
arity = "0"
|
|
1408
|
+
rust = "p2r::perf_counter()"
|
|
1409
|
+
status = "needs-runtime-helper"
|
|
1410
|
+
helper = "perf_counter"
|
|
1411
|
+
origin = "original"
|
|
1412
|
+
source = "python2rust (py2many has no mapping)"
|
|
1413
|
+
notes = "Needs a process-wide Instant anchor."
|
|
1414
|
+
|
|
1415
|
+
[[builtin]]
|
|
1416
|
+
python = "random.seed"
|
|
1417
|
+
kind = "function"
|
|
1418
|
+
arity = "1"
|
|
1419
|
+
rust = "p2r::random_seed($0)"
|
|
1420
|
+
status = "needs-runtime-helper"
|
|
1421
|
+
helper = "random_seed"
|
|
1422
|
+
origin = "py2many"
|
|
1423
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['random.seed']"
|
|
1424
|
+
py2many_emits = "pylib::random::reseed_from_f64($0)"
|
|
1425
|
+
notes = "py2many calls pylib::random::reseed_from_f64. A seed only reproduces CPython output if MT19937 and seeding match; the rand crate does not."
|
|
1426
|
+
|
|
1427
|
+
[[builtin]]
|
|
1428
|
+
python = "random.random"
|
|
1429
|
+
kind = "function"
|
|
1430
|
+
arity = "0"
|
|
1431
|
+
rust = "p2r::random_random()"
|
|
1432
|
+
status = "needs-runtime-helper"
|
|
1433
|
+
helper = "random_random"
|
|
1434
|
+
origin = "py2many"
|
|
1435
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['random.random']"
|
|
1436
|
+
py2many_emits = "pylib::random::random()"
|
|
1437
|
+
notes = "See helper `random_random` in [[helper]] for the exact semantics."
|
|
1438
|
+
|
|
1439
|
+
[[builtin]]
|
|
1440
|
+
python = "random.randint"
|
|
1441
|
+
kind = "function"
|
|
1442
|
+
arity = "2"
|
|
1443
|
+
rust = "p2r::random_randint($0, $1)"
|
|
1444
|
+
status = "needs-runtime-helper"
|
|
1445
|
+
helper = "random_randint"
|
|
1446
|
+
origin = "original"
|
|
1447
|
+
source = "python2rust (py2many has no mapping)"
|
|
1448
|
+
notes = "Inclusive of both ends."
|
|
1449
|
+
|
|
1450
|
+
[[builtin]]
|
|
1451
|
+
python = "random.choice"
|
|
1452
|
+
kind = "function"
|
|
1453
|
+
arity = "1"
|
|
1454
|
+
rust = "p2r::random_choice(&$0)"
|
|
1455
|
+
status = "needs-runtime-helper"
|
|
1456
|
+
helper = "random_choice"
|
|
1457
|
+
origin = "original"
|
|
1458
|
+
source = "python2rust (py2many has no mapping)"
|
|
1459
|
+
notes = "See helper `random_choice` in [[helper]] for the exact semantics."
|
|
1460
|
+
|
|
1461
|
+
[[builtin]]
|
|
1462
|
+
python = "asyncio.run"
|
|
1463
|
+
kind = "function"
|
|
1464
|
+
arity = "1"
|
|
1465
|
+
rust = ""
|
|
1466
|
+
status = "unsupported"
|
|
1467
|
+
origin = "py2many"
|
|
1468
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['asyncio.run']"
|
|
1469
|
+
py2many_emits = "block_on($0) [use futures::executor::block_on]"
|
|
1470
|
+
notes = "Needs an executor decision (tokio vs futures). Verified: py2many treats locals of an async def as module-level (`pub const x = ...`) because its scope tracking ignores AsyncFunctionDef."
|
|
1471
|
+
|
|
1472
|
+
[[builtin]]
|
|
1473
|
+
python = "sys.argv"
|
|
1474
|
+
kind = "attribute"
|
|
1475
|
+
rust = "std::env::args().collect::<Vec<String>>()"
|
|
1476
|
+
status = "corrected"
|
|
1477
|
+
origin = "py2many"
|
|
1478
|
+
source = "pyrs/transpiler.py:visit_Attribute"
|
|
1479
|
+
py2many_emits = "env::args().map(|s| &*Box::leak(s.into_boxed_str())).collect()"
|
|
1480
|
+
notes = "py2many leaks every argument with Box::leak to obtain &'static str."
|
|
1481
|
+
|
|
1482
|
+
[[builtin]]
|
|
1483
|
+
python = "os.getenv"
|
|
1484
|
+
kind = "function"
|
|
1485
|
+
types = ["str"]
|
|
1486
|
+
arity = "1"
|
|
1487
|
+
rust = "std::env::var($0).ok()"
|
|
1488
|
+
status = "direct"
|
|
1489
|
+
origin = "original"
|
|
1490
|
+
source = "python2rust (py2many has no mapping)"
|
|
1491
|
+
notes = "Returns Option<String>; os.getenv(k, d) is .unwrap_or_else(|| d)."
|
|
1492
|
+
|
|
1493
|
+
[[builtin]]
|
|
1494
|
+
python = "i8"
|
|
1495
|
+
kind = "function"
|
|
1496
|
+
arity = "1"
|
|
1497
|
+
rust = "$0 as i8"
|
|
1498
|
+
status = "direct"
|
|
1499
|
+
origin = "py2many"
|
|
1500
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['i8']"
|
|
1501
|
+
py2many_emits = "$0 as i8 [no args: 0 for i32]"
|
|
1502
|
+
notes = "py2many dialect (also spelled ctypes.c_int8). `as` wraps integers like ctypes but saturates floats."
|
|
1503
|
+
|
|
1504
|
+
[[builtin]]
|
|
1505
|
+
python = "i16"
|
|
1506
|
+
kind = "function"
|
|
1507
|
+
arity = "1"
|
|
1508
|
+
rust = "$0 as i16"
|
|
1509
|
+
status = "direct"
|
|
1510
|
+
origin = "py2many"
|
|
1511
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['i16']"
|
|
1512
|
+
py2many_emits = "$0 as i16 [no args: 0 for i32]"
|
|
1513
|
+
notes = "py2many dialect (also spelled ctypes.c_int16). `as` wraps integers like ctypes but saturates floats."
|
|
1514
|
+
|
|
1515
|
+
[[builtin]]
|
|
1516
|
+
python = "i32"
|
|
1517
|
+
kind = "function"
|
|
1518
|
+
arity = "1"
|
|
1519
|
+
rust = "$0 as i32"
|
|
1520
|
+
status = "direct"
|
|
1521
|
+
origin = "py2many"
|
|
1522
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['i32']"
|
|
1523
|
+
py2many_emits = "$0 as i32 [no args: 0 for i32]"
|
|
1524
|
+
notes = "py2many dialect (also spelled ctypes.c_int32). `as` wraps integers like ctypes but saturates floats."
|
|
1525
|
+
|
|
1526
|
+
[[builtin]]
|
|
1527
|
+
python = "i64"
|
|
1528
|
+
kind = "function"
|
|
1529
|
+
arity = "1"
|
|
1530
|
+
rust = "$0 as i64"
|
|
1531
|
+
status = "direct"
|
|
1532
|
+
origin = "py2many"
|
|
1533
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['i64']"
|
|
1534
|
+
py2many_emits = "$0 as i64 [no args: 0 for i32]"
|
|
1535
|
+
notes = "py2many dialect (also spelled ctypes.c_int64). `as` wraps integers like ctypes but saturates floats."
|
|
1536
|
+
|
|
1537
|
+
[[builtin]]
|
|
1538
|
+
python = "u8"
|
|
1539
|
+
kind = "function"
|
|
1540
|
+
arity = "1"
|
|
1541
|
+
rust = "$0 as u8"
|
|
1542
|
+
status = "direct"
|
|
1543
|
+
origin = "py2many"
|
|
1544
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['u8']"
|
|
1545
|
+
py2many_emits = "$0 as u8 [no args: 0 for i32]"
|
|
1546
|
+
notes = "py2many dialect (also spelled ctypes.c_uint8). `as` wraps integers like ctypes but saturates floats."
|
|
1547
|
+
|
|
1548
|
+
[[builtin]]
|
|
1549
|
+
python = "u16"
|
|
1550
|
+
kind = "function"
|
|
1551
|
+
arity = "1"
|
|
1552
|
+
rust = "$0 as u16"
|
|
1553
|
+
status = "direct"
|
|
1554
|
+
origin = "py2many"
|
|
1555
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['u16']"
|
|
1556
|
+
py2many_emits = "$0 as u16 [no args: 0 for i32]"
|
|
1557
|
+
notes = "py2many dialect (also spelled ctypes.c_uint16). `as` wraps integers like ctypes but saturates floats."
|
|
1558
|
+
|
|
1559
|
+
[[builtin]]
|
|
1560
|
+
python = "u32"
|
|
1561
|
+
kind = "function"
|
|
1562
|
+
arity = "1"
|
|
1563
|
+
rust = "$0 as u32"
|
|
1564
|
+
status = "direct"
|
|
1565
|
+
origin = "py2many"
|
|
1566
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['u32']"
|
|
1567
|
+
py2many_emits = "$0 as u32 [no args: 0 for i32]"
|
|
1568
|
+
notes = "py2many dialect (also spelled ctypes.c_uint32). `as` wraps integers like ctypes but saturates floats."
|
|
1569
|
+
|
|
1570
|
+
[[builtin]]
|
|
1571
|
+
python = "u64"
|
|
1572
|
+
kind = "function"
|
|
1573
|
+
arity = "1"
|
|
1574
|
+
rust = "$0 as u64"
|
|
1575
|
+
status = "direct"
|
|
1576
|
+
origin = "py2many"
|
|
1577
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['u64']"
|
|
1578
|
+
py2many_emits = "$0 as u64 [no args: 0 for i32]"
|
|
1579
|
+
notes = "py2many dialect (also spelled ctypes.c_uint64). `as` wraps integers like ctypes but saturates floats."
|
|
1580
|
+
|
|
1581
|
+
[[builtin]]
|
|
1582
|
+
python = "math.sin"
|
|
1583
|
+
kind = "function"
|
|
1584
|
+
types = ["float"]
|
|
1585
|
+
arity = "1"
|
|
1586
|
+
rust = "$0.sin()"
|
|
1587
|
+
status = "direct"
|
|
1588
|
+
origin = "py2many"
|
|
1589
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.sin']"
|
|
1590
|
+
py2many_emits = "$0.sin()"
|
|
1591
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1592
|
+
|
|
1593
|
+
[[builtin]]
|
|
1594
|
+
python = "math.cos"
|
|
1595
|
+
kind = "function"
|
|
1596
|
+
types = ["float"]
|
|
1597
|
+
arity = "1"
|
|
1598
|
+
rust = "$0.cos()"
|
|
1599
|
+
status = "direct"
|
|
1600
|
+
origin = "py2many"
|
|
1601
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.cos']"
|
|
1602
|
+
py2many_emits = "$0.cos()"
|
|
1603
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1604
|
+
|
|
1605
|
+
[[builtin]]
|
|
1606
|
+
python = "math.tan"
|
|
1607
|
+
kind = "function"
|
|
1608
|
+
types = ["float"]
|
|
1609
|
+
arity = "1"
|
|
1610
|
+
rust = "$0.tan()"
|
|
1611
|
+
status = "direct"
|
|
1612
|
+
origin = "py2many"
|
|
1613
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.tan']"
|
|
1614
|
+
py2many_emits = "$0.tan()"
|
|
1615
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1616
|
+
|
|
1617
|
+
[[builtin]]
|
|
1618
|
+
python = "math.asin"
|
|
1619
|
+
kind = "function"
|
|
1620
|
+
types = ["float"]
|
|
1621
|
+
arity = "1"
|
|
1622
|
+
rust = "$0.asin()"
|
|
1623
|
+
status = "direct"
|
|
1624
|
+
origin = "py2many"
|
|
1625
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.asin']"
|
|
1626
|
+
py2many_emits = "$0.asin()"
|
|
1627
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1628
|
+
|
|
1629
|
+
[[builtin]]
|
|
1630
|
+
python = "math.acos"
|
|
1631
|
+
kind = "function"
|
|
1632
|
+
types = ["float"]
|
|
1633
|
+
arity = "1"
|
|
1634
|
+
rust = "$0.acos()"
|
|
1635
|
+
status = "direct"
|
|
1636
|
+
origin = "py2many"
|
|
1637
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.acos']"
|
|
1638
|
+
py2many_emits = "$0.acos()"
|
|
1639
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1640
|
+
|
|
1641
|
+
[[builtin]]
|
|
1642
|
+
python = "math.atan"
|
|
1643
|
+
kind = "function"
|
|
1644
|
+
types = ["float"]
|
|
1645
|
+
arity = "1"
|
|
1646
|
+
rust = "$0.atan()"
|
|
1647
|
+
status = "direct"
|
|
1648
|
+
origin = "py2many"
|
|
1649
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.atan']"
|
|
1650
|
+
py2many_emits = "$0.atan()"
|
|
1651
|
+
|
|
1652
|
+
[[builtin]]
|
|
1653
|
+
python = "math.pow"
|
|
1654
|
+
kind = "function"
|
|
1655
|
+
types = ["float"]
|
|
1656
|
+
arity = "2"
|
|
1657
|
+
rust = "$0.powf($1)"
|
|
1658
|
+
status = "direct"
|
|
1659
|
+
origin = "py2many"
|
|
1660
|
+
source = "pyrs/plugins.py:FUNC_DISPATCH_TABLE['math.pow']"
|
|
1661
|
+
py2many_emits = "$0.powf($1)"
|
|
1662
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1663
|
+
|
|
1664
|
+
[[builtin]]
|
|
1665
|
+
python = "math.floor"
|
|
1666
|
+
kind = "function"
|
|
1667
|
+
types = ["float"]
|
|
1668
|
+
arity = "1"
|
|
1669
|
+
rust = "$0.floor() as i64"
|
|
1670
|
+
status = "corrected"
|
|
1671
|
+
origin = "py2many"
|
|
1672
|
+
source = "pyrs/plugins.py:SMALL_DISPATCH_MAP['floor']"
|
|
1673
|
+
py2many_emits = "$0.floor() as i32"
|
|
1674
|
+
notes = "py2many casts to i32 with a comment calling it a hack. Python raises on nan/inf; `as` saturates."
|
|
1675
|
+
|
|
1676
|
+
[[builtin]]
|
|
1677
|
+
python = "math.ceil"
|
|
1678
|
+
kind = "function"
|
|
1679
|
+
types = ["float"]
|
|
1680
|
+
arity = "1"
|
|
1681
|
+
rust = "$0.ceil() as i64"
|
|
1682
|
+
status = "direct"
|
|
1683
|
+
origin = "original"
|
|
1684
|
+
source = "python2rust (py2many has no mapping)"
|
|
1685
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1686
|
+
|
|
1687
|
+
[[builtin]]
|
|
1688
|
+
python = "math.trunc"
|
|
1689
|
+
kind = "function"
|
|
1690
|
+
types = ["float"]
|
|
1691
|
+
arity = "1"
|
|
1692
|
+
rust = "$0.trunc() as i64"
|
|
1693
|
+
status = "direct"
|
|
1694
|
+
origin = "original"
|
|
1695
|
+
source = "python2rust (py2many has no mapping)"
|
|
1696
|
+
|
|
1697
|
+
[[builtin]]
|
|
1698
|
+
python = "math.sqrt"
|
|
1699
|
+
kind = "function"
|
|
1700
|
+
types = ["float"]
|
|
1701
|
+
arity = "1"
|
|
1702
|
+
rust = "$0.sqrt()"
|
|
1703
|
+
status = "direct"
|
|
1704
|
+
origin = "original"
|
|
1705
|
+
source = "python2rust (py2many has no mapping)"
|
|
1706
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1707
|
+
|
|
1708
|
+
[[builtin]]
|
|
1709
|
+
python = "math.exp"
|
|
1710
|
+
kind = "function"
|
|
1711
|
+
types = ["float"]
|
|
1712
|
+
arity = "1"
|
|
1713
|
+
rust = "$0.exp()"
|
|
1714
|
+
status = "direct"
|
|
1715
|
+
origin = "original"
|
|
1716
|
+
source = "python2rust (py2many has no mapping)"
|
|
1717
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1718
|
+
|
|
1719
|
+
[[builtin]]
|
|
1720
|
+
python = "math.expm1"
|
|
1721
|
+
kind = "function"
|
|
1722
|
+
types = ["float"]
|
|
1723
|
+
arity = "1"
|
|
1724
|
+
rust = "$0.exp_m1()"
|
|
1725
|
+
status = "direct"
|
|
1726
|
+
origin = "original"
|
|
1727
|
+
source = "python2rust (py2many has no mapping)"
|
|
1728
|
+
|
|
1729
|
+
[[builtin]]
|
|
1730
|
+
python = "math.log10"
|
|
1731
|
+
kind = "function"
|
|
1732
|
+
types = ["float"]
|
|
1733
|
+
arity = "1"
|
|
1734
|
+
rust = "$0.log10()"
|
|
1735
|
+
status = "direct"
|
|
1736
|
+
origin = "original"
|
|
1737
|
+
source = "python2rust (py2many has no mapping)"
|
|
1738
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1739
|
+
|
|
1740
|
+
[[builtin]]
|
|
1741
|
+
python = "math.log2"
|
|
1742
|
+
kind = "function"
|
|
1743
|
+
types = ["float"]
|
|
1744
|
+
arity = "1"
|
|
1745
|
+
rust = "$0.log2()"
|
|
1746
|
+
status = "direct"
|
|
1747
|
+
origin = "original"
|
|
1748
|
+
source = "python2rust (py2many has no mapping)"
|
|
1749
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1750
|
+
|
|
1751
|
+
[[builtin]]
|
|
1752
|
+
python = "math.log1p"
|
|
1753
|
+
kind = "function"
|
|
1754
|
+
types = ["float"]
|
|
1755
|
+
arity = "1"
|
|
1756
|
+
rust = "$0.ln_1p()"
|
|
1757
|
+
status = "direct"
|
|
1758
|
+
origin = "original"
|
|
1759
|
+
source = "python2rust (py2many has no mapping)"
|
|
1760
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1761
|
+
|
|
1762
|
+
[[builtin]]
|
|
1763
|
+
python = "math.cbrt"
|
|
1764
|
+
kind = "function"
|
|
1765
|
+
types = ["float"]
|
|
1766
|
+
arity = "1"
|
|
1767
|
+
rust = "$0.cbrt()"
|
|
1768
|
+
status = "direct"
|
|
1769
|
+
origin = "original"
|
|
1770
|
+
source = "python2rust (py2many has no mapping)"
|
|
1771
|
+
|
|
1772
|
+
[[builtin]]
|
|
1773
|
+
python = "math.exp2"
|
|
1774
|
+
kind = "function"
|
|
1775
|
+
types = ["float"]
|
|
1776
|
+
arity = "1"
|
|
1777
|
+
rust = "$0.exp2()"
|
|
1778
|
+
status = "direct"
|
|
1779
|
+
origin = "original"
|
|
1780
|
+
source = "python2rust (py2many has no mapping)"
|
|
1781
|
+
|
|
1782
|
+
[[builtin]]
|
|
1783
|
+
python = "math.fabs"
|
|
1784
|
+
kind = "function"
|
|
1785
|
+
types = ["float"]
|
|
1786
|
+
arity = "1"
|
|
1787
|
+
rust = "$0.abs()"
|
|
1788
|
+
status = "direct"
|
|
1789
|
+
origin = "original"
|
|
1790
|
+
source = "python2rust (py2many has no mapping)"
|
|
1791
|
+
|
|
1792
|
+
[[builtin]]
|
|
1793
|
+
python = "math.sinh"
|
|
1794
|
+
kind = "function"
|
|
1795
|
+
types = ["float"]
|
|
1796
|
+
arity = "1"
|
|
1797
|
+
rust = "$0.sinh()"
|
|
1798
|
+
status = "direct"
|
|
1799
|
+
origin = "original"
|
|
1800
|
+
source = "python2rust (py2many has no mapping)"
|
|
1801
|
+
|
|
1802
|
+
[[builtin]]
|
|
1803
|
+
python = "math.cosh"
|
|
1804
|
+
kind = "function"
|
|
1805
|
+
types = ["float"]
|
|
1806
|
+
arity = "1"
|
|
1807
|
+
rust = "$0.cosh()"
|
|
1808
|
+
status = "direct"
|
|
1809
|
+
origin = "original"
|
|
1810
|
+
source = "python2rust (py2many has no mapping)"
|
|
1811
|
+
|
|
1812
|
+
[[builtin]]
|
|
1813
|
+
python = "math.tanh"
|
|
1814
|
+
kind = "function"
|
|
1815
|
+
types = ["float"]
|
|
1816
|
+
arity = "1"
|
|
1817
|
+
rust = "$0.tanh()"
|
|
1818
|
+
status = "direct"
|
|
1819
|
+
origin = "original"
|
|
1820
|
+
source = "python2rust (py2many has no mapping)"
|
|
1821
|
+
|
|
1822
|
+
[[builtin]]
|
|
1823
|
+
python = "math.asinh"
|
|
1824
|
+
kind = "function"
|
|
1825
|
+
types = ["float"]
|
|
1826
|
+
arity = "1"
|
|
1827
|
+
rust = "$0.asinh()"
|
|
1828
|
+
status = "direct"
|
|
1829
|
+
origin = "original"
|
|
1830
|
+
source = "python2rust (py2many has no mapping)"
|
|
1831
|
+
|
|
1832
|
+
[[builtin]]
|
|
1833
|
+
python = "math.acosh"
|
|
1834
|
+
kind = "function"
|
|
1835
|
+
types = ["float"]
|
|
1836
|
+
arity = "1"
|
|
1837
|
+
rust = "$0.acosh()"
|
|
1838
|
+
status = "direct"
|
|
1839
|
+
origin = "original"
|
|
1840
|
+
source = "python2rust (py2many has no mapping)"
|
|
1841
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1842
|
+
|
|
1843
|
+
[[builtin]]
|
|
1844
|
+
python = "math.atanh"
|
|
1845
|
+
kind = "function"
|
|
1846
|
+
types = ["float"]
|
|
1847
|
+
arity = "1"
|
|
1848
|
+
rust = "$0.atanh()"
|
|
1849
|
+
status = "direct"
|
|
1850
|
+
origin = "original"
|
|
1851
|
+
source = "python2rust (py2many has no mapping)"
|
|
1852
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1853
|
+
|
|
1854
|
+
[[builtin]]
|
|
1855
|
+
python = "math.degrees"
|
|
1856
|
+
kind = "function"
|
|
1857
|
+
types = ["float"]
|
|
1858
|
+
arity = "1"
|
|
1859
|
+
rust = "$0.to_degrees()"
|
|
1860
|
+
status = "direct"
|
|
1861
|
+
origin = "original"
|
|
1862
|
+
source = "python2rust (py2many has no mapping)"
|
|
1863
|
+
|
|
1864
|
+
[[builtin]]
|
|
1865
|
+
python = "math.radians"
|
|
1866
|
+
kind = "function"
|
|
1867
|
+
types = ["float"]
|
|
1868
|
+
arity = "1"
|
|
1869
|
+
rust = "$0.to_radians()"
|
|
1870
|
+
status = "direct"
|
|
1871
|
+
origin = "original"
|
|
1872
|
+
source = "python2rust (py2many has no mapping)"
|
|
1873
|
+
|
|
1874
|
+
[[builtin]]
|
|
1875
|
+
python = "math.isnan"
|
|
1876
|
+
kind = "function"
|
|
1877
|
+
types = ["float"]
|
|
1878
|
+
arity = "1"
|
|
1879
|
+
rust = "$0.is_nan()"
|
|
1880
|
+
status = "direct"
|
|
1881
|
+
origin = "original"
|
|
1882
|
+
source = "python2rust (py2many has no mapping)"
|
|
1883
|
+
|
|
1884
|
+
[[builtin]]
|
|
1885
|
+
python = "math.isinf"
|
|
1886
|
+
kind = "function"
|
|
1887
|
+
types = ["float"]
|
|
1888
|
+
arity = "1"
|
|
1889
|
+
rust = "$0.is_infinite()"
|
|
1890
|
+
status = "direct"
|
|
1891
|
+
origin = "original"
|
|
1892
|
+
source = "python2rust (py2many has no mapping)"
|
|
1893
|
+
|
|
1894
|
+
[[builtin]]
|
|
1895
|
+
python = "math.isfinite"
|
|
1896
|
+
kind = "function"
|
|
1897
|
+
types = ["float"]
|
|
1898
|
+
arity = "1"
|
|
1899
|
+
rust = "$0.is_finite()"
|
|
1900
|
+
status = "direct"
|
|
1901
|
+
origin = "original"
|
|
1902
|
+
source = "python2rust (py2many has no mapping)"
|
|
1903
|
+
|
|
1904
|
+
[[builtin]]
|
|
1905
|
+
python = "math.log"
|
|
1906
|
+
kind = "function"
|
|
1907
|
+
types = ["float"]
|
|
1908
|
+
arity = "1"
|
|
1909
|
+
rust = "$0.ln()"
|
|
1910
|
+
status = "direct"
|
|
1911
|
+
origin = "original"
|
|
1912
|
+
source = "python2rust (py2many has no mapping)"
|
|
1913
|
+
notes = "ERROR-GAP: Python raises ValueError (math domain error) or OverflowError; Rust returns nan/inf."
|
|
1914
|
+
|
|
1915
|
+
[[builtin]]
|
|
1916
|
+
python = "math.log"
|
|
1917
|
+
kind = "function"
|
|
1918
|
+
types = ["float"]
|
|
1919
|
+
arity = "2"
|
|
1920
|
+
rust = "$0.ln() / $1.ln()"
|
|
1921
|
+
status = "direct"
|
|
1922
|
+
origin = "original"
|
|
1923
|
+
source = "python2rust (py2many has no mapping)"
|
|
1924
|
+
notes = "Python also computes log(x) / log(base)."
|
|
1925
|
+
|
|
1926
|
+
[[builtin]]
|
|
1927
|
+
python = "math.atan2"
|
|
1928
|
+
kind = "function"
|
|
1929
|
+
types = ["float"]
|
|
1930
|
+
arity = "2"
|
|
1931
|
+
rust = "$0.atan2($1)"
|
|
1932
|
+
status = "direct"
|
|
1933
|
+
origin = "original"
|
|
1934
|
+
source = "python2rust (py2many has no mapping)"
|
|
1935
|
+
|
|
1936
|
+
[[builtin]]
|
|
1937
|
+
python = "math.hypot"
|
|
1938
|
+
kind = "function"
|
|
1939
|
+
types = ["float"]
|
|
1940
|
+
arity = "2"
|
|
1941
|
+
rust = "$0.hypot($1)"
|
|
1942
|
+
status = "direct"
|
|
1943
|
+
origin = "original"
|
|
1944
|
+
source = "python2rust (py2many has no mapping)"
|
|
1945
|
+
|
|
1946
|
+
[[builtin]]
|
|
1947
|
+
python = "math.copysign"
|
|
1948
|
+
kind = "function"
|
|
1949
|
+
types = ["float"]
|
|
1950
|
+
arity = "2"
|
|
1951
|
+
rust = "$0.copysign($1)"
|
|
1952
|
+
status = "direct"
|
|
1953
|
+
origin = "original"
|
|
1954
|
+
source = "python2rust (py2many has no mapping)"
|
|
1955
|
+
|
|
1956
|
+
[[builtin]]
|
|
1957
|
+
python = "math.fmod"
|
|
1958
|
+
kind = "function"
|
|
1959
|
+
types = ["float"]
|
|
1960
|
+
arity = "2"
|
|
1961
|
+
rust = "($0 % $1)"
|
|
1962
|
+
status = "direct"
|
|
1963
|
+
origin = "original"
|
|
1964
|
+
source = "python2rust (py2many has no mapping)"
|
|
1965
|
+
notes = "Rust f64 % is C fmod (sign of dividend), identical to math.fmod. It is NOT Python's % operator (sign of divisor). ERROR-GAP: fmod(x, 0.0) raises."
|
|
1966
|
+
|
|
1967
|
+
[[builtin]]
|
|
1968
|
+
python = "math.gcd"
|
|
1969
|
+
kind = "function"
|
|
1970
|
+
types = ["int"]
|
|
1971
|
+
arity = "2"
|
|
1972
|
+
rust = "p2r::gcd($0, $1)"
|
|
1973
|
+
status = "needs-runtime-helper"
|
|
1974
|
+
helper = "gcd"
|
|
1975
|
+
origin = "original"
|
|
1976
|
+
source = "python2rust (py2many has no mapping)"
|
|
1977
|
+
notes = "Result is non-negative; gcd(0, 0) == 0."
|
|
1978
|
+
|
|
1979
|
+
[[builtin]]
|
|
1980
|
+
python = "math.lcm"
|
|
1981
|
+
kind = "function"
|
|
1982
|
+
types = ["int"]
|
|
1983
|
+
arity = "2"
|
|
1984
|
+
rust = "p2r::lcm($0, $1)"
|
|
1985
|
+
status = "needs-runtime-helper"
|
|
1986
|
+
helper = "lcm"
|
|
1987
|
+
origin = "original"
|
|
1988
|
+
source = "python2rust (py2many has no mapping)"
|
|
1989
|
+
notes = "See helper `lcm` in [[helper]] for the exact semantics."
|
|
1990
|
+
|
|
1991
|
+
[[builtin]]
|
|
1992
|
+
python = "math.factorial"
|
|
1993
|
+
kind = "function"
|
|
1994
|
+
types = ["int"]
|
|
1995
|
+
arity = "1"
|
|
1996
|
+
rust = "p2r::factorial($0)"
|
|
1997
|
+
status = "needs-runtime-helper"
|
|
1998
|
+
helper = "factorial"
|
|
1999
|
+
origin = "original"
|
|
2000
|
+
source = "python2rust (py2many has no mapping)"
|
|
2001
|
+
notes = "Overflows i64 at 21!; Python returns a bigint."
|
|
2002
|
+
|
|
2003
|
+
[[builtin]]
|
|
2004
|
+
python = "math.comb"
|
|
2005
|
+
kind = "function"
|
|
2006
|
+
types = ["int"]
|
|
2007
|
+
arity = "2"
|
|
2008
|
+
rust = "p2r::comb($0, $1)"
|
|
2009
|
+
status = "needs-runtime-helper"
|
|
2010
|
+
helper = "comb"
|
|
2011
|
+
origin = "original"
|
|
2012
|
+
source = "python2rust (py2many has no mapping)"
|
|
2013
|
+
notes = "See helper `comb` in [[helper]] for the exact semantics."
|
|
2014
|
+
|
|
2015
|
+
[[builtin]]
|
|
2016
|
+
python = "math.perm"
|
|
2017
|
+
kind = "function"
|
|
2018
|
+
types = ["int"]
|
|
2019
|
+
arity = "2"
|
|
2020
|
+
rust = "p2r::perm($0, $1)"
|
|
2021
|
+
status = "needs-runtime-helper"
|
|
2022
|
+
helper = "perm"
|
|
2023
|
+
origin = "original"
|
|
2024
|
+
source = "python2rust (py2many has no mapping)"
|
|
2025
|
+
notes = "See helper `perm` in [[helper]] for the exact semantics."
|
|
2026
|
+
|
|
2027
|
+
[[builtin]]
|
|
2028
|
+
python = "math.isqrt"
|
|
2029
|
+
kind = "function"
|
|
2030
|
+
types = ["int"]
|
|
2031
|
+
arity = "1"
|
|
2032
|
+
rust = "p2r::isqrt($0)"
|
|
2033
|
+
status = "needs-runtime-helper"
|
|
2034
|
+
helper = "isqrt"
|
|
2035
|
+
origin = "original"
|
|
2036
|
+
source = "python2rust (py2many has no mapping)"
|
|
2037
|
+
notes = "Exact integer square root; (x as f64).sqrt() is wrong above 2^52."
|
|
2038
|
+
|
|
2039
|
+
[[builtin]]
|
|
2040
|
+
python = "math.prod"
|
|
2041
|
+
kind = "function"
|
|
2042
|
+
types = ["list[int]"]
|
|
2043
|
+
arity = "1"
|
|
2044
|
+
rust = "$0.iter().product::<i64>()"
|
|
2045
|
+
status = "direct"
|
|
2046
|
+
origin = "original"
|
|
2047
|
+
source = "python2rust (py2many has no mapping)"
|
|
2048
|
+
notes = "Overflow as for sum."
|
|
2049
|
+
|
|
2050
|
+
[[builtin]]
|
|
2051
|
+
python = "math.fsum"
|
|
2052
|
+
kind = "function"
|
|
2053
|
+
types = ["list[float]"]
|
|
2054
|
+
arity = "1"
|
|
2055
|
+
rust = "p2r::fsum($0.iter().copied())"
|
|
2056
|
+
status = "needs-runtime-helper"
|
|
2057
|
+
helper = "fsum"
|
|
2058
|
+
origin = "original"
|
|
2059
|
+
source = "python2rust (py2many has no mapping)"
|
|
2060
|
+
notes = "Exact partial sums (Shewchuk), unlike sum()."
|
|
2061
|
+
|
|
2062
|
+
[[builtin]]
|
|
2063
|
+
python = "math.isclose"
|
|
2064
|
+
kind = "function"
|
|
2065
|
+
types = ["float"]
|
|
2066
|
+
arity = "2"
|
|
2067
|
+
rust = "p2r::isclose($0, $1)"
|
|
2068
|
+
status = "needs-runtime-helper"
|
|
2069
|
+
helper = "isclose"
|
|
2070
|
+
origin = "original"
|
|
2071
|
+
source = "python2rust (py2many has no mapping)"
|
|
2072
|
+
notes = "Defaults rel_tol=1e-09, abs_tol=0.0; symmetric test."
|
|
2073
|
+
|
|
2074
|
+
[[builtin]]
|
|
2075
|
+
python = "math.pi"
|
|
2076
|
+
kind = "constant"
|
|
2077
|
+
rust = "std::f64::consts::PI"
|
|
2078
|
+
status = "direct"
|
|
2079
|
+
origin = "original"
|
|
2080
|
+
source = "python2rust (py2many has no mapping)"
|
|
2081
|
+
|
|
2082
|
+
[[builtin]]
|
|
2083
|
+
python = "math.e"
|
|
2084
|
+
kind = "constant"
|
|
2085
|
+
rust = "std::f64::consts::E"
|
|
2086
|
+
status = "direct"
|
|
2087
|
+
origin = "original"
|
|
2088
|
+
source = "python2rust (py2many has no mapping)"
|
|
2089
|
+
|
|
2090
|
+
[[builtin]]
|
|
2091
|
+
python = "math.tau"
|
|
2092
|
+
kind = "constant"
|
|
2093
|
+
rust = "std::f64::consts::TAU"
|
|
2094
|
+
status = "direct"
|
|
2095
|
+
origin = "original"
|
|
2096
|
+
source = "python2rust (py2many has no mapping)"
|
|
2097
|
+
|
|
2098
|
+
[[builtin]]
|
|
2099
|
+
python = "math.inf"
|
|
2100
|
+
kind = "constant"
|
|
2101
|
+
rust = "f64::INFINITY"
|
|
2102
|
+
status = "direct"
|
|
2103
|
+
origin = "original"
|
|
2104
|
+
source = "python2rust (py2many has no mapping)"
|
|
2105
|
+
|
|
2106
|
+
[[builtin]]
|
|
2107
|
+
python = "math.nan"
|
|
2108
|
+
kind = "constant"
|
|
2109
|
+
rust = "f64::NAN"
|
|
2110
|
+
status = "direct"
|
|
2111
|
+
origin = "original"
|
|
2112
|
+
source = "python2rust (py2many has no mapping)"
|
|
2113
|
+
|
|
2114
|
+
[[builtin]]
|
|
2115
|
+
python = "+"
|
|
2116
|
+
kind = "operator"
|
|
2117
|
+
types = ["int"]
|
|
2118
|
+
arity = "2"
|
|
2119
|
+
rust = "p2r::int_add($0, $1)"
|
|
2120
|
+
status = "needs-runtime-helper"
|
|
2121
|
+
helper = "int_add"
|
|
2122
|
+
origin = "py2many"
|
|
2123
|
+
source = "py2many/clike.py:symbols['Add']"
|
|
2124
|
+
py2many_emits = "$0 + $1"
|
|
2125
|
+
notes = "Python ints are unbounded. A faithful build needs checked arithmetic (panic with a clear message), i128, or a bigint; wrapping silently changes results."
|
|
2126
|
+
|
|
2127
|
+
[[builtin]]
|
|
2128
|
+
python = "+"
|
|
2129
|
+
kind = "operator"
|
|
2130
|
+
types = ["int"]
|
|
2131
|
+
arity = "2 (range-proven)"
|
|
2132
|
+
rust = "($0 + $1)"
|
|
2133
|
+
status = "direct"
|
|
2134
|
+
origin = "py2many"
|
|
2135
|
+
source = "py2many/clike.py:symbols['Add']"
|
|
2136
|
+
py2many_emits = "$0 + $1"
|
|
2137
|
+
notes = "Use only when range analysis proves no overflow (e.g. loop counters bounded by a len())."
|
|
2138
|
+
|
|
2139
|
+
[[builtin]]
|
|
2140
|
+
python = "+"
|
|
2141
|
+
kind = "operator"
|
|
2142
|
+
types = ["float"]
|
|
2143
|
+
arity = "2"
|
|
2144
|
+
rust = "($0 + $1)"
|
|
2145
|
+
status = "direct"
|
|
2146
|
+
origin = "py2many"
|
|
2147
|
+
source = "py2many/clike.py:symbols['Add']"
|
|
2148
|
+
py2many_emits = "$0 + $1"
|
|
2149
|
+
notes = "py2many also widens narrower operands with `as` casts using its width-rank table (i8 + i8 yields i16); that changes the declared type of the result relative to the source annotation."
|
|
2150
|
+
|
|
2151
|
+
[[builtin]]
|
|
2152
|
+
python = "-"
|
|
2153
|
+
kind = "operator"
|
|
2154
|
+
types = ["int"]
|
|
2155
|
+
arity = "2"
|
|
2156
|
+
rust = "p2r::int_sub($0, $1)"
|
|
2157
|
+
status = "needs-runtime-helper"
|
|
2158
|
+
helper = "int_sub"
|
|
2159
|
+
origin = "py2many"
|
|
2160
|
+
source = "py2many/clike.py:symbols['Sub']"
|
|
2161
|
+
py2many_emits = "$0 - $1"
|
|
2162
|
+
notes = "Python ints are unbounded. A faithful build needs checked arithmetic (panic with a clear message), i128, or a bigint; wrapping silently changes results."
|
|
2163
|
+
|
|
2164
|
+
[[builtin]]
|
|
2165
|
+
python = "-"
|
|
2166
|
+
kind = "operator"
|
|
2167
|
+
types = ["int"]
|
|
2168
|
+
arity = "2 (range-proven)"
|
|
2169
|
+
rust = "($0 - $1)"
|
|
2170
|
+
status = "direct"
|
|
2171
|
+
origin = "py2many"
|
|
2172
|
+
source = "py2many/clike.py:symbols['Sub']"
|
|
2173
|
+
py2many_emits = "$0 - $1"
|
|
2174
|
+
notes = "Use only when range analysis proves no overflow (e.g. loop counters bounded by a len())."
|
|
2175
|
+
|
|
2176
|
+
[[builtin]]
|
|
2177
|
+
python = "-"
|
|
2178
|
+
kind = "operator"
|
|
2179
|
+
types = ["float"]
|
|
2180
|
+
arity = "2"
|
|
2181
|
+
rust = "($0 - $1)"
|
|
2182
|
+
status = "direct"
|
|
2183
|
+
origin = "py2many"
|
|
2184
|
+
source = "py2many/clike.py:symbols['Sub']"
|
|
2185
|
+
py2many_emits = "$0 - $1"
|
|
2186
|
+
notes = "py2many also widens narrower operands with `as` casts using its width-rank table (i8 + i8 yields i16); that changes the declared type of the result relative to the source annotation."
|
|
2187
|
+
|
|
2188
|
+
[[builtin]]
|
|
2189
|
+
python = "*"
|
|
2190
|
+
kind = "operator"
|
|
2191
|
+
types = ["int"]
|
|
2192
|
+
arity = "2"
|
|
2193
|
+
rust = "p2r::int_mul($0, $1)"
|
|
2194
|
+
status = "needs-runtime-helper"
|
|
2195
|
+
helper = "int_mul"
|
|
2196
|
+
origin = "py2many"
|
|
2197
|
+
source = "py2many/clike.py:symbols['Mult']"
|
|
2198
|
+
py2many_emits = "$0 * $1"
|
|
2199
|
+
notes = "Python ints are unbounded. A faithful build needs checked arithmetic (panic with a clear message), i128, or a bigint; wrapping silently changes results."
|
|
2200
|
+
|
|
2201
|
+
[[builtin]]
|
|
2202
|
+
python = "*"
|
|
2203
|
+
kind = "operator"
|
|
2204
|
+
types = ["int"]
|
|
2205
|
+
arity = "2 (range-proven)"
|
|
2206
|
+
rust = "($0 * $1)"
|
|
2207
|
+
status = "direct"
|
|
2208
|
+
origin = "py2many"
|
|
2209
|
+
source = "py2many/clike.py:symbols['Mult']"
|
|
2210
|
+
py2many_emits = "$0 * $1"
|
|
2211
|
+
notes = "Use only when range analysis proves no overflow (e.g. loop counters bounded by a len())."
|
|
2212
|
+
|
|
2213
|
+
[[builtin]]
|
|
2214
|
+
python = "*"
|
|
2215
|
+
kind = "operator"
|
|
2216
|
+
types = ["float"]
|
|
2217
|
+
arity = "2"
|
|
2218
|
+
rust = "($0 * $1)"
|
|
2219
|
+
status = "direct"
|
|
2220
|
+
origin = "py2many"
|
|
2221
|
+
source = "py2many/clike.py:symbols['Mult']"
|
|
2222
|
+
py2many_emits = "$0 * $1"
|
|
2223
|
+
notes = "py2many also widens narrower operands with `as` casts using its width-rank table (i8 + i8 yields i16); that changes the declared type of the result relative to the source annotation."
|
|
2224
|
+
|
|
2225
|
+
[[builtin]]
|
|
2226
|
+
python = "+"
|
|
2227
|
+
kind = "operator"
|
|
2228
|
+
types = ["str"]
|
|
2229
|
+
arity = "2"
|
|
2230
|
+
rust = "format!(\"{}{}\", $0, $1)"
|
|
2231
|
+
status = "direct"
|
|
2232
|
+
origin = "original"
|
|
2233
|
+
source = "python2rust (py2many has no mapping)"
|
|
2234
|
+
notes = "Avoids moving the left operand."
|
|
2235
|
+
|
|
2236
|
+
[[builtin]]
|
|
2237
|
+
python = "+"
|
|
2238
|
+
kind = "operator"
|
|
2239
|
+
types = ["list"]
|
|
2240
|
+
arity = "2"
|
|
2241
|
+
rust = "[$0.as_slice(), $1.as_slice()].concat()"
|
|
2242
|
+
status = "direct"
|
|
2243
|
+
origin = "original"
|
|
2244
|
+
source = "python2rust (py2many has no mapping)"
|
|
2245
|
+
|
|
2246
|
+
[[builtin]]
|
|
2247
|
+
python = "/"
|
|
2248
|
+
kind = "operator"
|
|
2249
|
+
types = ["int", "float"]
|
|
2250
|
+
arity = "2"
|
|
2251
|
+
rust = "p2r::truediv($0 as f64, $1 as f64)"
|
|
2252
|
+
status = "needs-runtime-helper"
|
|
2253
|
+
helper = "truediv"
|
|
2254
|
+
origin = "py2many"
|
|
2255
|
+
source = "py2many/clike.py:symbols['Div']"
|
|
2256
|
+
py2many_emits = "$0 / $1"
|
|
2257
|
+
notes = "Python true division always yields float and raises ZeroDivisionError for a zero divisor (even 1.0 / 0.0); Rust yields inf/nan. py2many does emit the `as f64` casts for int/int but has no zero check."
|
|
2258
|
+
|
|
2259
|
+
[[builtin]]
|
|
2260
|
+
python = "//"
|
|
2261
|
+
kind = "operator"
|
|
2262
|
+
types = ["int"]
|
|
2263
|
+
arity = "2"
|
|
2264
|
+
rust = "p2r::floordiv($0, $1)"
|
|
2265
|
+
status = "needs-runtime-helper"
|
|
2266
|
+
helper = "floordiv"
|
|
2267
|
+
origin = "py2many"
|
|
2268
|
+
source = "py2many/clike.py:symbols['FloorDiv']"
|
|
2269
|
+
py2many_emits = "$0 / $1"
|
|
2270
|
+
notes = "Verified: py2many maps // to `/`. Rust truncates toward zero, Python floors (-7 // 2 == -4, Rust -7 / 2 == -3). Also raises ZeroDivisionError. div_euclid is not a fix: (-7).div_euclid(-2) == 4, Python gives 3."
|
|
2271
|
+
|
|
2272
|
+
[[builtin]]
|
|
2273
|
+
python = "//"
|
|
2274
|
+
kind = "operator"
|
|
2275
|
+
types = ["float"]
|
|
2276
|
+
arity = "2"
|
|
2277
|
+
rust = "p2r::floordiv_f64($0, $1)"
|
|
2278
|
+
status = "needs-runtime-helper"
|
|
2279
|
+
helper = "floordiv_f64"
|
|
2280
|
+
origin = "py2many"
|
|
2281
|
+
source = "py2many/clike.py:symbols['FloorDiv']"
|
|
2282
|
+
py2many_emits = "$0 / $1"
|
|
2283
|
+
notes = "Not (a / b).floor(): 1 // 0.1 is 9.0 in Python but floor(1 / 0.1) is 10.0."
|
|
2284
|
+
|
|
2285
|
+
[[builtin]]
|
|
2286
|
+
python = "%"
|
|
2287
|
+
kind = "operator"
|
|
2288
|
+
types = ["int"]
|
|
2289
|
+
arity = "2"
|
|
2290
|
+
rust = "p2r::mod_floor($0, $1)"
|
|
2291
|
+
status = "needs-runtime-helper"
|
|
2292
|
+
helper = "mod_floor"
|
|
2293
|
+
origin = "py2many"
|
|
2294
|
+
source = "py2many/clike.py:symbols['Mod']"
|
|
2295
|
+
py2many_emits = "$0 % $1"
|
|
2296
|
+
notes = "Verified: py2many maps % to Rust %. The result takes the dividend's sign in Rust (-7 % 2 == -1) and the divisor's in Python (== 1). rem_euclid is wrong for a negative divisor (7 % -2 is -1 in Python)."
|
|
2297
|
+
|
|
2298
|
+
[[builtin]]
|
|
2299
|
+
python = "%"
|
|
2300
|
+
kind = "operator"
|
|
2301
|
+
types = ["float"]
|
|
2302
|
+
arity = "2"
|
|
2303
|
+
rust = "p2r::fmod_py($0, $1)"
|
|
2304
|
+
status = "needs-runtime-helper"
|
|
2305
|
+
helper = "fmod_py"
|
|
2306
|
+
origin = "py2many"
|
|
2307
|
+
source = "py2many/clike.py:symbols['Mod']"
|
|
2308
|
+
py2many_emits = "$0 % $1"
|
|
2309
|
+
notes = "Result has the divisor's sign; ZeroDivisionError on 0.0."
|
|
2310
|
+
|
|
2311
|
+
[[builtin]]
|
|
2312
|
+
python = "%"
|
|
2313
|
+
kind = "operator"
|
|
2314
|
+
types = ["str"]
|
|
2315
|
+
arity = "2"
|
|
2316
|
+
rust = ""
|
|
2317
|
+
status = "unsupported"
|
|
2318
|
+
origin = "original"
|
|
2319
|
+
source = "python2rust (py2many has no mapping)"
|
|
2320
|
+
notes = "printf-style formatting: translate a literal template to format! at compile time or reject."
|
|
2321
|
+
|
|
2322
|
+
[[builtin]]
|
|
2323
|
+
python = "**"
|
|
2324
|
+
kind = "operator"
|
|
2325
|
+
types = ["int"]
|
|
2326
|
+
arity = "2"
|
|
2327
|
+
rust = "p2r::int_pow($0, $1)"
|
|
2328
|
+
status = "needs-runtime-helper"
|
|
2329
|
+
helper = "int_pow"
|
|
2330
|
+
origin = "py2many"
|
|
2331
|
+
source = "py2many (see py2many_emits)"
|
|
2332
|
+
py2many_emits = "pow($0, $1)"
|
|
2333
|
+
notes = "Verified: py2many emits a call to an undefined `pow` function. Negative exponents give floats; overflow must be checked."
|
|
2334
|
+
|
|
2335
|
+
[[builtin]]
|
|
2336
|
+
python = "**"
|
|
2337
|
+
kind = "operator"
|
|
2338
|
+
types = ["float"]
|
|
2339
|
+
arity = "2 (int literal exponent)"
|
|
2340
|
+
rust = "$0.powi($1 as i32)"
|
|
2341
|
+
status = "direct"
|
|
2342
|
+
origin = "original"
|
|
2343
|
+
source = "python2rust (py2many has no mapping)"
|
|
2344
|
+
notes = "powi can differ from pow in the last ulp."
|
|
2345
|
+
|
|
2346
|
+
[[builtin]]
|
|
2347
|
+
python = "**"
|
|
2348
|
+
kind = "operator"
|
|
2349
|
+
types = ["float"]
|
|
2350
|
+
arity = "2"
|
|
2351
|
+
rust = "p2r::float_pow($0, $1)"
|
|
2352
|
+
status = "needs-runtime-helper"
|
|
2353
|
+
helper = "float_pow"
|
|
2354
|
+
origin = "py2many"
|
|
2355
|
+
source = "py2many (see py2many_emits)"
|
|
2356
|
+
py2many_emits = "pow($0, $1)"
|
|
2357
|
+
notes = "Negative base with fractional exponent returns complex in Python; 0.0 ** -1 raises ZeroDivisionError."
|
|
2358
|
+
|
|
2359
|
+
[[builtin]]
|
|
2360
|
+
python = "@"
|
|
2361
|
+
kind = "operator"
|
|
2362
|
+
arity = "2"
|
|
2363
|
+
rust = ""
|
|
2364
|
+
status = "unsupported"
|
|
2365
|
+
origin = "original"
|
|
2366
|
+
source = "python2rust (py2many has no mapping)"
|
|
2367
|
+
notes = "Matrix multiply."
|
|
2368
|
+
|
|
2369
|
+
[[builtin]]
|
|
2370
|
+
python = "<<"
|
|
2371
|
+
kind = "operator"
|
|
2372
|
+
types = ["int"]
|
|
2373
|
+
arity = "2"
|
|
2374
|
+
rust = "p2r::shl($0, $1)"
|
|
2375
|
+
status = "needs-runtime-helper"
|
|
2376
|
+
helper = "shl"
|
|
2377
|
+
origin = "py2many"
|
|
2378
|
+
source = "py2many/clike.py:symbols['LShift']"
|
|
2379
|
+
py2many_emits = "$0 << $1"
|
|
2380
|
+
notes = "Python shifts never overflow and a negative count raises ValueError; Rust panics (debug) or masks the count (release) when it is >= 64."
|
|
2381
|
+
|
|
2382
|
+
[[builtin]]
|
|
2383
|
+
python = ">>"
|
|
2384
|
+
kind = "operator"
|
|
2385
|
+
types = ["int"]
|
|
2386
|
+
arity = "2"
|
|
2387
|
+
rust = "p2r::shr($0, $1)"
|
|
2388
|
+
status = "needs-runtime-helper"
|
|
2389
|
+
helper = "shr"
|
|
2390
|
+
origin = "py2many"
|
|
2391
|
+
source = "py2many/clike.py:symbols['RShift']"
|
|
2392
|
+
py2many_emits = "$0 >> $1"
|
|
2393
|
+
notes = "Shifting by >= 64 gives 0 or -1 in Python."
|
|
2394
|
+
|
|
2395
|
+
[[builtin]]
|
|
2396
|
+
python = "&"
|
|
2397
|
+
kind = "operator"
|
|
2398
|
+
types = ["int", "bool"]
|
|
2399
|
+
arity = "2"
|
|
2400
|
+
rust = "($0 & $1)"
|
|
2401
|
+
status = "direct"
|
|
2402
|
+
origin = "py2many"
|
|
2403
|
+
source = "py2many/clike.py:symbols['BitAnd']"
|
|
2404
|
+
py2many_emits = "$0 & $1"
|
|
2405
|
+
notes = "Two's-complement semantics agree with Python within i64 range."
|
|
2406
|
+
|
|
2407
|
+
[[builtin]]
|
|
2408
|
+
python = "|"
|
|
2409
|
+
kind = "operator"
|
|
2410
|
+
types = ["int", "bool"]
|
|
2411
|
+
arity = "2"
|
|
2412
|
+
rust = "($0 | $1)"
|
|
2413
|
+
status = "direct"
|
|
2414
|
+
origin = "py2many"
|
|
2415
|
+
source = "py2many/clike.py:symbols['BitOr']"
|
|
2416
|
+
py2many_emits = "$0 | $1"
|
|
2417
|
+
notes = "Two's-complement semantics agree with Python within i64 range."
|
|
2418
|
+
|
|
2419
|
+
[[builtin]]
|
|
2420
|
+
python = "^"
|
|
2421
|
+
kind = "operator"
|
|
2422
|
+
types = ["int", "bool"]
|
|
2423
|
+
arity = "2"
|
|
2424
|
+
rust = "($0 ^ $1)"
|
|
2425
|
+
status = "direct"
|
|
2426
|
+
origin = "py2many"
|
|
2427
|
+
source = "py2many/clike.py:symbols['BitXor']"
|
|
2428
|
+
py2many_emits = "$0 ^ $1"
|
|
2429
|
+
notes = "Two's-complement semantics agree with Python within i64 range."
|
|
2430
|
+
|
|
2431
|
+
[[builtin]]
|
|
2432
|
+
python = "-"
|
|
2433
|
+
kind = "operator"
|
|
2434
|
+
types = ["int", "float"]
|
|
2435
|
+
arity = "1"
|
|
2436
|
+
rust = "-$0"
|
|
2437
|
+
status = "direct"
|
|
2438
|
+
origin = "py2many"
|
|
2439
|
+
source = "py2many/clike.py:symbols['USub']"
|
|
2440
|
+
py2many_emits = "$0 - $1"
|
|
2441
|
+
notes = "-i64::MIN overflows."
|
|
2442
|
+
|
|
2443
|
+
[[builtin]]
|
|
2444
|
+
python = "+"
|
|
2445
|
+
kind = "operator"
|
|
2446
|
+
types = ["int", "float"]
|
|
2447
|
+
arity = "1"
|
|
2448
|
+
rust = "$0"
|
|
2449
|
+
status = "direct"
|
|
2450
|
+
origin = "original"
|
|
2451
|
+
source = "python2rust (py2many has no mapping)"
|
|
2452
|
+
notes = "Unary plus: py2many has no UAdd entry and fails on it."
|
|
2453
|
+
|
|
2454
|
+
[[builtin]]
|
|
2455
|
+
python = "~"
|
|
2456
|
+
kind = "operator"
|
|
2457
|
+
types = ["int"]
|
|
2458
|
+
arity = "1"
|
|
2459
|
+
rust = "!$0"
|
|
2460
|
+
status = "corrected"
|
|
2461
|
+
origin = "original"
|
|
2462
|
+
source = "python2rust (py2many has no mapping)"
|
|
2463
|
+
notes = "Verified: py2many has no Invert entry and emits `None(x)` for ~x. On signed Rust ints `!x` is bitwise not and equals -x - 1 like Python."
|
|
2464
|
+
|
|
2465
|
+
[[builtin]]
|
|
2466
|
+
python = "not"
|
|
2467
|
+
kind = "operator"
|
|
2468
|
+
types = ["bool"]
|
|
2469
|
+
arity = "1"
|
|
2470
|
+
rust = "!$0"
|
|
2471
|
+
status = "direct"
|
|
2472
|
+
origin = "py2many"
|
|
2473
|
+
source = "py2many/clike.py:symbols['Not']"
|
|
2474
|
+
py2many_emits = "$0 ! $1"
|
|
2475
|
+
|
|
2476
|
+
[[builtin]]
|
|
2477
|
+
python = "not"
|
|
2478
|
+
kind = "operator"
|
|
2479
|
+
types = ["non-bool"]
|
|
2480
|
+
arity = "1"
|
|
2481
|
+
rust = "!p2r::truthy(&$0)"
|
|
2482
|
+
status = "needs-runtime-helper"
|
|
2483
|
+
helper = "truthy"
|
|
2484
|
+
origin = "original"
|
|
2485
|
+
source = "python2rust (py2many has no mapping)"
|
|
2486
|
+
notes = "not [] is True; not 0 is True."
|
|
2487
|
+
|
|
2488
|
+
[[builtin]]
|
|
2489
|
+
python = "=="
|
|
2490
|
+
kind = "operator"
|
|
2491
|
+
types = ["int", "float", "str", "list", "tuple"]
|
|
2492
|
+
arity = "2"
|
|
2493
|
+
rust = "($0 == $1)"
|
|
2494
|
+
status = "direct"
|
|
2495
|
+
origin = "py2many"
|
|
2496
|
+
source = "py2many/clike.py:symbols['Eq']"
|
|
2497
|
+
py2many_emits = "$0 == $1"
|
|
2498
|
+
notes = "str and Vec/tuple orderings are lexicographic by code point, matching Python. Mixed int/float compares exactly in Python; casting the int to f64 (what py2many does) loses precision above 2^53."
|
|
2499
|
+
|
|
2500
|
+
[[builtin]]
|
|
2501
|
+
python = "!="
|
|
2502
|
+
kind = "operator"
|
|
2503
|
+
types = ["int", "float", "str", "list", "tuple"]
|
|
2504
|
+
arity = "2"
|
|
2505
|
+
rust = "($0 != $1)"
|
|
2506
|
+
status = "direct"
|
|
2507
|
+
origin = "py2many"
|
|
2508
|
+
source = "py2many/clike.py:symbols['NotEq']"
|
|
2509
|
+
py2many_emits = "$0 != $1"
|
|
2510
|
+
notes = "Same ordering notes as ==."
|
|
2511
|
+
|
|
2512
|
+
[[builtin]]
|
|
2513
|
+
python = "<"
|
|
2514
|
+
kind = "operator"
|
|
2515
|
+
types = ["int", "float", "str", "list", "tuple"]
|
|
2516
|
+
arity = "2"
|
|
2517
|
+
rust = "($0 < $1)"
|
|
2518
|
+
status = "direct"
|
|
2519
|
+
origin = "py2many"
|
|
2520
|
+
source = "py2many/clike.py:symbols['Lt']"
|
|
2521
|
+
py2many_emits = "$0 < $1"
|
|
2522
|
+
notes = "Same ordering notes as ==."
|
|
2523
|
+
|
|
2524
|
+
[[builtin]]
|
|
2525
|
+
python = ">"
|
|
2526
|
+
kind = "operator"
|
|
2527
|
+
types = ["int", "float", "str", "list", "tuple"]
|
|
2528
|
+
arity = "2"
|
|
2529
|
+
rust = "($0 > $1)"
|
|
2530
|
+
status = "direct"
|
|
2531
|
+
origin = "py2many"
|
|
2532
|
+
source = "py2many/clike.py:symbols['Gt']"
|
|
2533
|
+
py2many_emits = "$0 > $1"
|
|
2534
|
+
notes = "Same ordering notes as ==."
|
|
2535
|
+
|
|
2536
|
+
[[builtin]]
|
|
2537
|
+
python = "<="
|
|
2538
|
+
kind = "operator"
|
|
2539
|
+
types = ["int", "float", "str", "list", "tuple"]
|
|
2540
|
+
arity = "2"
|
|
2541
|
+
rust = "($0 <= $1)"
|
|
2542
|
+
status = "direct"
|
|
2543
|
+
origin = "py2many"
|
|
2544
|
+
source = "py2many/clike.py:symbols['LtE']"
|
|
2545
|
+
py2many_emits = "$0 <= $1"
|
|
2546
|
+
notes = "Same ordering notes as ==."
|
|
2547
|
+
|
|
2548
|
+
[[builtin]]
|
|
2549
|
+
python = ">="
|
|
2550
|
+
kind = "operator"
|
|
2551
|
+
types = ["int", "float", "str", "list", "tuple"]
|
|
2552
|
+
arity = "2"
|
|
2553
|
+
rust = "($0 >= $1)"
|
|
2554
|
+
status = "direct"
|
|
2555
|
+
origin = "py2many"
|
|
2556
|
+
source = "py2many/clike.py:symbols['GtE']"
|
|
2557
|
+
py2many_emits = "$0 >= $1"
|
|
2558
|
+
notes = "Same ordering notes as ==."
|
|
2559
|
+
|
|
2560
|
+
[[builtin]]
|
|
2561
|
+
python = "chained comparison"
|
|
2562
|
+
kind = "operator"
|
|
2563
|
+
arity = "3+"
|
|
2564
|
+
rust = "{ let __a = $0; let __b = $1; __a < __b && __b < $2 }"
|
|
2565
|
+
status = "corrected"
|
|
2566
|
+
origin = "py2many"
|
|
2567
|
+
source = "py2many/clike.py:symbols['Lt']"
|
|
2568
|
+
py2many_emits = "$0 < $1"
|
|
2569
|
+
notes = "Shown for `<`; the same shape applies to every operator pair. Verified: py2many keeps only the first comparison (`1 < a < 10` becomes `1 < a`) with no error. The middle operand is evaluated once; the later comparison short-circuits."
|
|
2570
|
+
|
|
2571
|
+
[[builtin]]
|
|
2572
|
+
python = "is None"
|
|
2573
|
+
kind = "operator"
|
|
2574
|
+
types = ["Optional"]
|
|
2575
|
+
arity = "1"
|
|
2576
|
+
rust = "$0.is_none()"
|
|
2577
|
+
status = "direct"
|
|
2578
|
+
origin = "py2many"
|
|
2579
|
+
source = "py2many (see py2many_emits)"
|
|
2580
|
+
py2many_emits = "Some($0) == None"
|
|
2581
|
+
notes = "py2many rewrites to `Some(x) == None`, which does not compile for a non-Option x."
|
|
2582
|
+
|
|
2583
|
+
[[builtin]]
|
|
2584
|
+
python = "is not None"
|
|
2585
|
+
kind = "operator"
|
|
2586
|
+
types = ["Optional"]
|
|
2587
|
+
arity = "1"
|
|
2588
|
+
rust = "$0.is_some()"
|
|
2589
|
+
status = "direct"
|
|
2590
|
+
origin = "original"
|
|
2591
|
+
source = "python2rust (py2many has no mapping)"
|
|
2592
|
+
|
|
2593
|
+
[[builtin]]
|
|
2594
|
+
python = "is"
|
|
2595
|
+
kind = "operator"
|
|
2596
|
+
arity = "2"
|
|
2597
|
+
rust = ""
|
|
2598
|
+
status = "unsupported"
|
|
2599
|
+
origin = "py2many"
|
|
2600
|
+
source = "py2many/clike.py:symbols['Is']"
|
|
2601
|
+
py2many_emits = "$0 == $1"
|
|
2602
|
+
notes = "Verified: py2many maps `is` to `==`, so `a is b` on two equal lists is true. Identity needs Rc::ptr_eq or rejection."
|
|
2603
|
+
|
|
2604
|
+
[[builtin]]
|
|
2605
|
+
python = "is not"
|
|
2606
|
+
kind = "operator"
|
|
2607
|
+
arity = "2"
|
|
2608
|
+
rust = ""
|
|
2609
|
+
status = "unsupported"
|
|
2610
|
+
origin = "py2many"
|
|
2611
|
+
source = "py2many/clike.py:symbols['IsNot']"
|
|
2612
|
+
py2many_emits = "$0 != $1"
|
|
2613
|
+
notes = "py2many maps `is not` to `!=`; same identity-vs-equality problem as `is`."
|
|
2614
|
+
|
|
2615
|
+
[[builtin]]
|
|
2616
|
+
python = "is True"
|
|
2617
|
+
kind = "operator"
|
|
2618
|
+
types = ["bool"]
|
|
2619
|
+
arity = "1"
|
|
2620
|
+
rust = "($0 == true)"
|
|
2621
|
+
status = "direct"
|
|
2622
|
+
origin = "original"
|
|
2623
|
+
source = "python2rust (py2many has no mapping)"
|
|
2624
|
+
|
|
2625
|
+
[[builtin]]
|
|
2626
|
+
python = "in"
|
|
2627
|
+
kind = "operator"
|
|
2628
|
+
types = ["str"]
|
|
2629
|
+
arity = "2"
|
|
2630
|
+
rust = "$1.contains($0)"
|
|
2631
|
+
status = "direct"
|
|
2632
|
+
origin = "py2many"
|
|
2633
|
+
source = "py2many/clike.py:symbols['In']"
|
|
2634
|
+
py2many_emits = "$0 in $1"
|
|
2635
|
+
notes = "Substring test; $0 may be &str or char."
|
|
2636
|
+
|
|
2637
|
+
[[builtin]]
|
|
2638
|
+
python = "in"
|
|
2639
|
+
kind = "operator"
|
|
2640
|
+
types = ["list", "set", "range"]
|
|
2641
|
+
arity = "2"
|
|
2642
|
+
rust = "$1.contains(&$0)"
|
|
2643
|
+
status = "direct"
|
|
2644
|
+
origin = "py2many"
|
|
2645
|
+
source = "py2many/clike.py:symbols['In']"
|
|
2646
|
+
py2many_emits = "$0 in $1"
|
|
2647
|
+
|
|
2648
|
+
[[builtin]]
|
|
2649
|
+
python = "in"
|
|
2650
|
+
kind = "operator"
|
|
2651
|
+
types = ["dict"]
|
|
2652
|
+
arity = "2"
|
|
2653
|
+
rust = "$1.contains_key(&$0)"
|
|
2654
|
+
status = "direct"
|
|
2655
|
+
origin = "py2many"
|
|
2656
|
+
source = "py2many/clike.py:symbols['In']"
|
|
2657
|
+
py2many_emits = "$0 in $1"
|
|
2658
|
+
notes = "py2many handles this through annotation sniffing and string surgery on the generated text (`.keys()` suffix removal)."
|
|
2659
|
+
|
|
2660
|
+
[[builtin]]
|
|
2661
|
+
python = "not in"
|
|
2662
|
+
kind = "operator"
|
|
2663
|
+
types = ["list", "set", "range"]
|
|
2664
|
+
arity = "2"
|
|
2665
|
+
rust = "!$1.contains(&$0)"
|
|
2666
|
+
status = "direct"
|
|
2667
|
+
origin = "original"
|
|
2668
|
+
source = "python2rust (py2many has no mapping)"
|
|
2669
|
+
|
|
2670
|
+
[[builtin]]
|
|
2671
|
+
python = "and"
|
|
2672
|
+
kind = "operator"
|
|
2673
|
+
types = ["bool"]
|
|
2674
|
+
arity = "2"
|
|
2675
|
+
rust = "($0 && $1)"
|
|
2676
|
+
status = "direct"
|
|
2677
|
+
origin = "py2many"
|
|
2678
|
+
source = "py2many/clike.py:symbols['And']"
|
|
2679
|
+
py2many_emits = "$0 && $1"
|
|
2680
|
+
|
|
2681
|
+
[[builtin]]
|
|
2682
|
+
python = "or"
|
|
2683
|
+
kind = "operator"
|
|
2684
|
+
types = ["bool"]
|
|
2685
|
+
arity = "2"
|
|
2686
|
+
rust = "($0 || $1)"
|
|
2687
|
+
status = "direct"
|
|
2688
|
+
origin = "py2many"
|
|
2689
|
+
source = "py2many/clike.py:symbols['Or']"
|
|
2690
|
+
py2many_emits = "$0 || $1"
|
|
2691
|
+
|
|
2692
|
+
[[builtin]]
|
|
2693
|
+
python = "or"
|
|
2694
|
+
kind = "operator"
|
|
2695
|
+
types = ["non-bool"]
|
|
2696
|
+
arity = "2"
|
|
2697
|
+
rust = "{ let __t = $0; if p2r::truthy(&__t) { __t } else { $1 } }"
|
|
2698
|
+
status = "needs-runtime-helper"
|
|
2699
|
+
helper = "truthy"
|
|
2700
|
+
origin = "original"
|
|
2701
|
+
source = "python2rust (py2many has no mapping)"
|
|
2702
|
+
notes = "`x or default` returns an operand, not a bool. py2many always emits `||`."
|
|
2703
|
+
|
|
2704
|
+
[[builtin]]
|
|
2705
|
+
python = "and"
|
|
2706
|
+
kind = "operator"
|
|
2707
|
+
types = ["non-bool"]
|
|
2708
|
+
arity = "2"
|
|
2709
|
+
rust = "{ let __t = $0; if p2r::truthy(&__t) { $1 } else { __t } }"
|
|
2710
|
+
status = "needs-runtime-helper"
|
|
2711
|
+
helper = "truthy"
|
|
2712
|
+
origin = "original"
|
|
2713
|
+
source = "python2rust (py2many has no mapping)"
|
|
2714
|
+
notes = "See helper `truthy` in [[helper]] for the exact semantics."
|
|
2715
|
+
|
|
2716
|
+
[[builtin]]
|
|
2717
|
+
python = "x if c else y"
|
|
2718
|
+
kind = "syntax"
|
|
2719
|
+
arity = "3"
|
|
2720
|
+
rust = "if $1 { $0 } else { $2 }"
|
|
2721
|
+
status = "direct"
|
|
2722
|
+
origin = "original"
|
|
2723
|
+
source = "python2rust (py2many has no mapping)"
|
|
2724
|
+
notes = "$0 is the value when true, $1 the condition, $2 the value when false. Same lazy evaluation as Python."
|
|
2725
|
+
|
|
2726
|
+
[[builtin]]
|
|
2727
|
+
python = "list[i]"
|
|
2728
|
+
kind = "subscript"
|
|
2729
|
+
types = ["list"]
|
|
2730
|
+
arity = "2 (index proven >= 0)"
|
|
2731
|
+
rust = "$0[$1 as usize]"
|
|
2732
|
+
status = "direct"
|
|
2733
|
+
origin = "py2many"
|
|
2734
|
+
source = "py2many (see py2many_emits)"
|
|
2735
|
+
py2many_emits = "$0[$1 as usize]"
|
|
2736
|
+
notes = "Only when the index is a loop variable over range() or otherwise proven non-negative and in range."
|
|
2737
|
+
|
|
2738
|
+
[[builtin]]
|
|
2739
|
+
python = "list[i]"
|
|
2740
|
+
kind = "subscript"
|
|
2741
|
+
types = ["list"]
|
|
2742
|
+
arity = "2"
|
|
2743
|
+
rust = "$0[p2r::index($0.len(), $1)]"
|
|
2744
|
+
status = "needs-runtime-helper"
|
|
2745
|
+
helper = "index"
|
|
2746
|
+
origin = "original"
|
|
2747
|
+
source = "python2rust (py2many has no mapping)"
|
|
2748
|
+
notes = "Verified: py2many emits `xs[-1]` unchanged for xs[-1] (compile error) and `as usize` casts wrap negative values to a huge number. Python accepts -len..len-1 and raises IndexError otherwise."
|
|
2749
|
+
|
|
2750
|
+
[[builtin]]
|
|
2751
|
+
python = "str[i]"
|
|
2752
|
+
kind = "subscript"
|
|
2753
|
+
types = ["str"]
|
|
2754
|
+
arity = "2"
|
|
2755
|
+
rust = "p2r::str_char_at(&$0, $1)"
|
|
2756
|
+
status = "needs-runtime-helper"
|
|
2757
|
+
helper = "str_char_at"
|
|
2758
|
+
origin = "original"
|
|
2759
|
+
source = "python2rust (py2many has no mapping)"
|
|
2760
|
+
notes = "Indexing is by code point and returns a 1-char str. Rust indexes bytes and s[i..i+1] panics on a non-boundary."
|
|
2761
|
+
|
|
2762
|
+
[[builtin]]
|
|
2763
|
+
python = "tuple[i]"
|
|
2764
|
+
kind = "subscript"
|
|
2765
|
+
types = ["tuple"]
|
|
2766
|
+
arity = "2 (literal index)"
|
|
2767
|
+
rust = "$0.$1"
|
|
2768
|
+
status = "direct"
|
|
2769
|
+
origin = "original"
|
|
2770
|
+
source = "python2rust (py2many has no mapping)"
|
|
2771
|
+
|
|
2772
|
+
[[builtin]]
|
|
2773
|
+
python = "dict[k]"
|
|
2774
|
+
kind = "subscript"
|
|
2775
|
+
types = ["dict"]
|
|
2776
|
+
arity = "2"
|
|
2777
|
+
rust = "$0[&$1]"
|
|
2778
|
+
status = "direct"
|
|
2779
|
+
crates = ["indexmap"]
|
|
2780
|
+
origin = "original"
|
|
2781
|
+
source = "python2rust (py2many has no mapping)"
|
|
2782
|
+
notes = "Panics on a missing key where Python raises KeyError. IndexMap and HashMap both implement Index<&Q>."
|
|
2783
|
+
|
|
2784
|
+
[[builtin]]
|
|
2785
|
+
python = "list[a:b]"
|
|
2786
|
+
kind = "slice"
|
|
2787
|
+
types = ["list"]
|
|
2788
|
+
arity = "3"
|
|
2789
|
+
rust = "p2r::slice(&$0, Some($1), Some($2))"
|
|
2790
|
+
status = "needs-runtime-helper"
|
|
2791
|
+
helper = "slice"
|
|
2792
|
+
origin = "original"
|
|
2793
|
+
source = "python2rust (py2many has no mapping)"
|
|
2794
|
+
notes = "Python clamps out-of-range bounds and accepts negatives; Rust `&v[a..b]` panics. Verified: py2many emits `&xs[1..3]` and drops steps."
|
|
2795
|
+
|
|
2796
|
+
[[builtin]]
|
|
2797
|
+
python = "list[a:b:c]"
|
|
2798
|
+
kind = "slice"
|
|
2799
|
+
types = ["list"]
|
|
2800
|
+
arity = "4"
|
|
2801
|
+
rust = "p2r::slice_step(&$0, $1, $2, $3)"
|
|
2802
|
+
status = "needs-runtime-helper"
|
|
2803
|
+
helper = "slice_step"
|
|
2804
|
+
origin = "original"
|
|
2805
|
+
source = "python2rust (py2many has no mapping)"
|
|
2806
|
+
notes = "See helper `slice_step` in [[helper]] for the exact semantics."
|
|
2807
|
+
|
|
2808
|
+
[[builtin]]
|
|
2809
|
+
python = "str[a:b]"
|
|
2810
|
+
kind = "slice"
|
|
2811
|
+
types = ["str"]
|
|
2812
|
+
arity = "3"
|
|
2813
|
+
rust = "p2r::str_slice(&$0, Some($1), Some($2))"
|
|
2814
|
+
status = "needs-runtime-helper"
|
|
2815
|
+
helper = "str_slice"
|
|
2816
|
+
origin = "original"
|
|
2817
|
+
source = "python2rust (py2many has no mapping)"
|
|
2818
|
+
notes = "Bounds are code-point positions. Byte slicing panics on a non-boundary and returns different text on multi-byte input."
|
|
2819
|
+
|
|
2820
|
+
[[builtin]]
|
|
2821
|
+
python = "list[::-1]"
|
|
2822
|
+
kind = "slice"
|
|
2823
|
+
types = ["list"]
|
|
2824
|
+
arity = "1"
|
|
2825
|
+
rust = "$0.iter().rev().cloned().collect::<Vec<_>>()"
|
|
2826
|
+
status = "direct"
|
|
2827
|
+
origin = "original"
|
|
2828
|
+
source = "python2rust (py2many has no mapping)"
|
|
2829
|
+
|
|
2830
|
+
[[builtin]]
|
|
2831
|
+
python = "str[::-1]"
|
|
2832
|
+
kind = "slice"
|
|
2833
|
+
types = ["str"]
|
|
2834
|
+
arity = "1"
|
|
2835
|
+
rust = "$0.chars().rev().collect::<String>()"
|
|
2836
|
+
status = "direct"
|
|
2837
|
+
origin = "original"
|
|
2838
|
+
source = "python2rust (py2many has no mapping)"
|
|
2839
|
+
notes = "Reverses code points, as Python does (not grapheme clusters)."
|
|
2840
|
+
|
|
2841
|
+
[[builtin]]
|
|
2842
|
+
python = "list[i] = v"
|
|
2843
|
+
kind = "subscript-assign"
|
|
2844
|
+
types = ["list"]
|
|
2845
|
+
arity = "3 (index proven >= 0)"
|
|
2846
|
+
rust = "$0[$1 as usize] = $2;"
|
|
2847
|
+
status = "direct"
|
|
2848
|
+
origin = "original"
|
|
2849
|
+
source = "python2rust (py2many has no mapping)"
|
|
2850
|
+
|
|
2851
|
+
[[builtin]]
|
|
2852
|
+
python = "list[i] = v"
|
|
2853
|
+
kind = "subscript-assign"
|
|
2854
|
+
types = ["list"]
|
|
2855
|
+
arity = "3"
|
|
2856
|
+
rust = "p2r::list_set(&mut $0, $1, $2);"
|
|
2857
|
+
status = "needs-runtime-helper"
|
|
2858
|
+
helper = "list_set"
|
|
2859
|
+
origin = "original"
|
|
2860
|
+
source = "python2rust (py2many has no mapping)"
|
|
2861
|
+
notes = "Negative index and IndexError."
|
|
2862
|
+
|
|
2863
|
+
[[builtin]]
|
|
2864
|
+
python = "dict[k] = v"
|
|
2865
|
+
kind = "subscript-assign"
|
|
2866
|
+
types = ["dict"]
|
|
2867
|
+
arity = "3"
|
|
2868
|
+
rust = "$0.insert($1, $2);"
|
|
2869
|
+
status = "corrected"
|
|
2870
|
+
crates = ["indexmap"]
|
|
2871
|
+
origin = "py2many"
|
|
2872
|
+
source = "py2many (see py2many_emits)"
|
|
2873
|
+
py2many_emits = "$0[$1] = $2;"
|
|
2874
|
+
notes = "Verified: py2many emits `d[k] = v`, which does not compile for HashMap (E0594, no IndexMut). insert keeps the original position of an existing key in IndexMap, like Python."
|
|
2875
|
+
|
|
2876
|
+
[[builtin]]
|
|
2877
|
+
python = "del dict[k]"
|
|
2878
|
+
kind = "statement"
|
|
2879
|
+
types = ["dict"]
|
|
2880
|
+
arity = "2"
|
|
2881
|
+
rust = "$0.shift_remove(&$1);"
|
|
2882
|
+
status = "corrected"
|
|
2883
|
+
crates = ["indexmap"]
|
|
2884
|
+
origin = "py2many"
|
|
2885
|
+
source = "py2many (see py2many_emits)"
|
|
2886
|
+
py2many_emits = "drop($0[$1]);"
|
|
2887
|
+
notes = "Verified: py2many maps `del` to drop(target), which does not remove anything. shift_remove keeps insertion order; swap_remove does not."
|
|
2888
|
+
|
|
2889
|
+
[[builtin]]
|
|
2890
|
+
python = "del list[i]"
|
|
2891
|
+
kind = "statement"
|
|
2892
|
+
types = ["list"]
|
|
2893
|
+
arity = "2"
|
|
2894
|
+
rust = "p2r::list_del(&mut $0, $1);"
|
|
2895
|
+
status = "needs-runtime-helper"
|
|
2896
|
+
helper = "list_del"
|
|
2897
|
+
origin = "py2many"
|
|
2898
|
+
source = "py2many (see py2many_emits)"
|
|
2899
|
+
py2many_emits = "drop($0[$1]);"
|
|
2900
|
+
notes = "See helper `list_del` in [[helper]] for the exact semantics."
|
|
2901
|
+
|
|
2902
|
+
[[builtin]]
|
|
2903
|
+
python = "+= (str)"
|
|
2904
|
+
kind = "statement"
|
|
2905
|
+
types = ["str"]
|
|
2906
|
+
arity = "2"
|
|
2907
|
+
rust = "$0.push_str(&$1);"
|
|
2908
|
+
status = "direct"
|
|
2909
|
+
origin = "original"
|
|
2910
|
+
source = "python2rust (py2many has no mapping)"
|
|
2911
|
+
|
|
2912
|
+
[[builtin]]
|
|
2913
|
+
python = "+= (list)"
|
|
2914
|
+
kind = "statement"
|
|
2915
|
+
types = ["list"]
|
|
2916
|
+
arity = "2"
|
|
2917
|
+
rust = "$0.extend_from_slice(&$1);"
|
|
2918
|
+
status = "direct"
|
|
2919
|
+
origin = "original"
|
|
2920
|
+
source = "python2rust (py2many has no mapping)"
|
|
2921
|
+
|
|
2922
|
+
[[builtin]]
|
|
2923
|
+
python = "* (str)"
|
|
2924
|
+
kind = "operator"
|
|
2925
|
+
types = ["str"]
|
|
2926
|
+
arity = "2"
|
|
2927
|
+
rust = "p2r::str_repeat(&$0, $1)"
|
|
2928
|
+
status = "needs-runtime-helper"
|
|
2929
|
+
helper = "str_repeat"
|
|
2930
|
+
origin = "original"
|
|
2931
|
+
source = "python2rust (py2many has no mapping)"
|
|
2932
|
+
notes = "'a' * -1 is '' in Python; `n as usize` on a negative count wraps and tries to allocate exabytes."
|
|
2933
|
+
|
|
2934
|
+
[[builtin]]
|
|
2935
|
+
python = "* (list)"
|
|
2936
|
+
kind = "operator"
|
|
2937
|
+
types = ["list (1 elt)"]
|
|
2938
|
+
arity = "2"
|
|
2939
|
+
rust = "vec![$0; ($1).max(0) as usize]"
|
|
2940
|
+
status = "corrected"
|
|
2941
|
+
origin = "py2many"
|
|
2942
|
+
source = "py2many/clike.py:symbols['Mult']"
|
|
2943
|
+
py2many_emits = "vec![$0; $1] (only when $1 is an int literal)"
|
|
2944
|
+
notes = "py2many handles only an int literal count; a variable count is emitted as `[0]*n`, invalid Rust. Element must be Clone."
|
|
2945
|
+
|
|
2946
|
+
[[builtin]]
|
|
2947
|
+
python = "* (list)"
|
|
2948
|
+
kind = "operator"
|
|
2949
|
+
types = ["list"]
|
|
2950
|
+
arity = "2"
|
|
2951
|
+
rust = "p2r::list_repeat(&$0, $1)"
|
|
2952
|
+
status = "needs-runtime-helper"
|
|
2953
|
+
helper = "list_repeat"
|
|
2954
|
+
origin = "original"
|
|
2955
|
+
source = "python2rust (py2many has no mapping)"
|
|
2956
|
+
notes = "See helper `list_repeat` in [[helper]] for the exact semantics."
|
|
2957
|
+
|
|
2958
|
+
[[builtin]]
|
|
2959
|
+
python = "a, b = b, a"
|
|
2960
|
+
kind = "syntax"
|
|
2961
|
+
arity = "2"
|
|
2962
|
+
rust = "($0, $1) = ($1, $0);"
|
|
2963
|
+
status = "direct"
|
|
2964
|
+
origin = "py2many"
|
|
2965
|
+
source = "py2many (see py2many_emits)"
|
|
2966
|
+
py2many_emits = "let ($0, $1) = ($1, $0);"
|
|
2967
|
+
notes = "Verified: py2many emits `let (a, b) = (b, a + b);` for every tuple assignment, even to existing variables. Inside a loop that shadows the outer a and b, so `fib(n)` returns 0 for every n and compiles cleanly. Rust 1.59+ supports destructuring assignment to existing places."
|
|
2968
|
+
|
|
2969
|
+
[[builtin]]
|
|
2970
|
+
python = "str.lower"
|
|
2971
|
+
kind = "method"
|
|
2972
|
+
types = ["str"]
|
|
2973
|
+
arity = "0"
|
|
2974
|
+
rust = "$self.to_lowercase()"
|
|
2975
|
+
status = "direct"
|
|
2976
|
+
origin = "py2many"
|
|
2977
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['lower']"
|
|
2978
|
+
py2many_emits = "$self.to_lowercase()"
|
|
2979
|
+
notes = "Both use full Unicode lowercasing including the final-sigma rule. casefold() is different."
|
|
2980
|
+
|
|
2981
|
+
[[builtin]]
|
|
2982
|
+
python = "str.upper"
|
|
2983
|
+
kind = "method"
|
|
2984
|
+
types = ["str"]
|
|
2985
|
+
arity = "0"
|
|
2986
|
+
rust = "$self.to_uppercase()"
|
|
2987
|
+
status = "direct"
|
|
2988
|
+
origin = "py2many"
|
|
2989
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['upper']"
|
|
2990
|
+
py2many_emits = "$self.to_uppercase()"
|
|
2991
|
+
notes = "'ß'.upper() is 'SS' in both."
|
|
2992
|
+
|
|
2993
|
+
[[builtin]]
|
|
2994
|
+
python = "str.strip"
|
|
2995
|
+
kind = "method"
|
|
2996
|
+
types = ["str"]
|
|
2997
|
+
arity = "0"
|
|
2998
|
+
rust = "$self.trim()"
|
|
2999
|
+
status = "direct"
|
|
3000
|
+
origin = "py2many"
|
|
3001
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['strip']"
|
|
3002
|
+
py2many_emits = "$self.trim()"
|
|
3003
|
+
notes = "Rust trims Unicode White_Space; Python trims chars with str.isspace(), which also includes U+001C..U+001F (verified: Rust keeps \\x1f)."
|
|
3004
|
+
|
|
3005
|
+
[[builtin]]
|
|
3006
|
+
python = "str.strip"
|
|
3007
|
+
kind = "method"
|
|
3008
|
+
types = ["str"]
|
|
3009
|
+
arity = "1"
|
|
3010
|
+
rust = "$self.trim_matches(|c| $0.contains(c))"
|
|
3011
|
+
status = "corrected"
|
|
3012
|
+
origin = "py2many"
|
|
3013
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['strip']"
|
|
3014
|
+
py2many_emits = "$self.trim()"
|
|
3015
|
+
notes = "Verified: py2many silently drops the chars argument (`s.strip(\"x\")` becomes `s.trim()`). Python's argument is a character SET, not a prefix. Bind $0 to a variable first."
|
|
3016
|
+
|
|
3017
|
+
[[builtin]]
|
|
3018
|
+
python = "str.lstrip"
|
|
3019
|
+
kind = "method"
|
|
3020
|
+
types = ["str"]
|
|
3021
|
+
arity = "0"
|
|
3022
|
+
rust = "$self.trim_start()"
|
|
3023
|
+
status = "direct"
|
|
3024
|
+
origin = "py2many"
|
|
3025
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['lstrip']"
|
|
3026
|
+
py2many_emits = "$self.trim_start()"
|
|
3027
|
+
notes = "Rust trims Unicode White_Space; Python trims chars with str.isspace(), which also includes U+001C..U+001F (verified: Rust keeps \\x1f)."
|
|
3028
|
+
|
|
3029
|
+
[[builtin]]
|
|
3030
|
+
python = "str.lstrip"
|
|
3031
|
+
kind = "method"
|
|
3032
|
+
types = ["str"]
|
|
3033
|
+
arity = "1"
|
|
3034
|
+
rust = "$self.trim_start_matches(|c| $0.contains(c))"
|
|
3035
|
+
status = "corrected"
|
|
3036
|
+
origin = "py2many"
|
|
3037
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['lstrip']"
|
|
3038
|
+
py2many_emits = "$self.trim_start()"
|
|
3039
|
+
notes = "chars argument dropped by py2many."
|
|
3040
|
+
|
|
3041
|
+
[[builtin]]
|
|
3042
|
+
python = "str.rstrip"
|
|
3043
|
+
kind = "method"
|
|
3044
|
+
types = ["str"]
|
|
3045
|
+
arity = "0"
|
|
3046
|
+
rust = "$self.trim_end()"
|
|
3047
|
+
status = "direct"
|
|
3048
|
+
origin = "py2many"
|
|
3049
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['rstrip']"
|
|
3050
|
+
py2many_emits = "$self.trim_end()"
|
|
3051
|
+
notes = "Rust trims Unicode White_Space; Python trims chars with str.isspace(), which also includes U+001C..U+001F (verified: Rust keeps \\x1f)."
|
|
3052
|
+
|
|
3053
|
+
[[builtin]]
|
|
3054
|
+
python = "str.rstrip"
|
|
3055
|
+
kind = "method"
|
|
3056
|
+
types = ["str"]
|
|
3057
|
+
arity = "1"
|
|
3058
|
+
rust = "$self.trim_end_matches(|c| $0.contains(c))"
|
|
3059
|
+
status = "corrected"
|
|
3060
|
+
origin = "py2many"
|
|
3061
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['rstrip']"
|
|
3062
|
+
py2many_emits = "$self.trim_end()"
|
|
3063
|
+
notes = "chars argument dropped by py2many."
|
|
3064
|
+
|
|
3065
|
+
[[builtin]]
|
|
3066
|
+
python = "str.split"
|
|
3067
|
+
kind = "method"
|
|
3068
|
+
types = ["str"]
|
|
3069
|
+
arity = "0"
|
|
3070
|
+
rust = "$self.split_whitespace().collect::<Vec<&str>>()"
|
|
3071
|
+
status = "direct"
|
|
3072
|
+
origin = "py2many"
|
|
3073
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['split']"
|
|
3074
|
+
py2many_emits = "$self.split_whitespace().collect::<Vec<&str>>()"
|
|
3075
|
+
notes = "Splits on runs of whitespace and drops empty fields, like Python's no-arg split. Rust trims Unicode White_Space; Python trims chars with str.isspace(), which also includes U+001C..U+001F (verified: Rust keeps \\x1f). Returns borrowed pieces; use .map(String::from) when the result outlives the receiver."
|
|
3076
|
+
|
|
3077
|
+
[[builtin]]
|
|
3078
|
+
python = "str.split"
|
|
3079
|
+
kind = "method"
|
|
3080
|
+
types = ["str"]
|
|
3081
|
+
arity = "1"
|
|
3082
|
+
rust = "$self.split($0).collect::<Vec<&str>>()"
|
|
3083
|
+
status = "direct"
|
|
3084
|
+
origin = "py2many"
|
|
3085
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['split']"
|
|
3086
|
+
py2many_emits = "<handled in _visit_str_method>"
|
|
3087
|
+
notes = "Same fields as Python for a non-empty separator ('a,b,,'.split(',') has a trailing empty field in both). Python raises ValueError for an empty separator; Rust splits between every char (verified: ['', 'a', 'b', ''])."
|
|
3088
|
+
|
|
3089
|
+
[[builtin]]
|
|
3090
|
+
python = "str.split"
|
|
3091
|
+
kind = "method"
|
|
3092
|
+
types = ["str"]
|
|
3093
|
+
arity = "2 (maxsplit >= 0)"
|
|
3094
|
+
rust = "$self.splitn(($1 + 1) as usize, $0).collect::<Vec<&str>>()"
|
|
3095
|
+
status = "corrected"
|
|
3096
|
+
origin = "py2many"
|
|
3097
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['split']"
|
|
3098
|
+
py2many_emits = "$self.split($0)..."
|
|
3099
|
+
notes = "Verified: py2many ignores maxsplit. maxsplit=-1 means unlimited and must use the 1-arg form."
|
|
3100
|
+
|
|
3101
|
+
[[builtin]]
|
|
3102
|
+
python = "str.rsplit"
|
|
3103
|
+
kind = "method"
|
|
3104
|
+
types = ["str"]
|
|
3105
|
+
arity = "2"
|
|
3106
|
+
rust = "$self.rsplitn(($1 + 1) as usize, $0).collect::<Vec<&str>>().into_iter().rev().collect::<Vec<_>>()"
|
|
3107
|
+
status = "corrected"
|
|
3108
|
+
origin = "original"
|
|
3109
|
+
source = "python2rust (py2many has no mapping)"
|
|
3110
|
+
notes = "rsplitn yields pieces right-to-left; Python returns them left-to-right. py2many only annotates the result type of rsplit and has no emission rule."
|
|
3111
|
+
|
|
3112
|
+
[[builtin]]
|
|
3113
|
+
python = "str.splitlines"
|
|
3114
|
+
kind = "method"
|
|
3115
|
+
types = ["str"]
|
|
3116
|
+
arity = "0"
|
|
3117
|
+
rust = "p2r::str_splitlines(&$self)"
|
|
3118
|
+
status = "needs-runtime-helper"
|
|
3119
|
+
helper = "str_splitlines"
|
|
3120
|
+
origin = "original"
|
|
3121
|
+
source = "python2rust (py2many has no mapping)"
|
|
3122
|
+
notes = "Python splits on \\n \\r \\r\\n \\v \\f \\x1c-\\x1e \\x85 \\u2028 \\u2029; str::lines splits only on \\n and \\r\\n (verified: one piece for 'a\\u2028b\\x0bc')."
|
|
3123
|
+
|
|
3124
|
+
[[builtin]]
|
|
3125
|
+
python = "str.join"
|
|
3126
|
+
kind = "method"
|
|
3127
|
+
types = ["str"]
|
|
3128
|
+
arity = "1"
|
|
3129
|
+
rust = "$0.join($self)"
|
|
3130
|
+
status = "direct"
|
|
3131
|
+
origin = "py2many"
|
|
3132
|
+
source = "py2many (see py2many_emits)"
|
|
3133
|
+
py2many_emits = "$0.join($self) [only when the separator is a string literal]"
|
|
3134
|
+
notes = "$self is the separator, $0 the list. Elements must already be str. py2many's rewriter fires only for a literal separator; `sep.join(xs)` with a variable separator is emitted verbatim."
|
|
3135
|
+
|
|
3136
|
+
[[builtin]]
|
|
3137
|
+
python = "str.replace"
|
|
3138
|
+
kind = "method"
|
|
3139
|
+
types = ["str"]
|
|
3140
|
+
arity = "2"
|
|
3141
|
+
rust = "$self.replace($0, $1)"
|
|
3142
|
+
status = "direct"
|
|
3143
|
+
origin = "py2many"
|
|
3144
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['replace']"
|
|
3145
|
+
py2many_emits = "$self.replace($0, $1)"
|
|
3146
|
+
notes = "'abc'.replace('', '-') is '-a-b-c-' in both."
|
|
3147
|
+
|
|
3148
|
+
[[builtin]]
|
|
3149
|
+
python = "str.replace"
|
|
3150
|
+
kind = "method"
|
|
3151
|
+
types = ["str"]
|
|
3152
|
+
arity = "3 (count >= 0)"
|
|
3153
|
+
rust = "$self.replacen($0, $1, $2 as usize)"
|
|
3154
|
+
status = "corrected"
|
|
3155
|
+
origin = "original"
|
|
3156
|
+
source = "python2rust (py2many has no mapping)"
|
|
3157
|
+
notes = "py2many handles only 2 arguments; count=-1 means all."
|
|
3158
|
+
|
|
3159
|
+
[[builtin]]
|
|
3160
|
+
python = "str.find"
|
|
3161
|
+
kind = "method"
|
|
3162
|
+
types = ["str"]
|
|
3163
|
+
arity = "1"
|
|
3164
|
+
rust = "p2r::str_find(&$self, $0)"
|
|
3165
|
+
status = "needs-runtime-helper"
|
|
3166
|
+
helper = "str_find"
|
|
3167
|
+
origin = "py2many"
|
|
3168
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['find']"
|
|
3169
|
+
py2many_emits = "$self.find($0).map(|i| i as i32).unwrap_or(-1)"
|
|
3170
|
+
notes = "Verified: Rust find returns a BYTE offset; Python returns a code-point index ('héllo'.find('l') is 2 in Python and 3 in Rust). Inline equivalent: map the byte offset through s[..b].chars().count()."
|
|
3171
|
+
|
|
3172
|
+
[[builtin]]
|
|
3173
|
+
python = "str.rfind"
|
|
3174
|
+
kind = "method"
|
|
3175
|
+
types = ["str"]
|
|
3176
|
+
arity = "1"
|
|
3177
|
+
rust = "p2r::str_rfind(&$self, $0)"
|
|
3178
|
+
status = "needs-runtime-helper"
|
|
3179
|
+
helper = "str_rfind"
|
|
3180
|
+
origin = "original"
|
|
3181
|
+
source = "python2rust (py2many has no mapping)"
|
|
3182
|
+
notes = "See helper `str_rfind` in [[helper]] for the exact semantics."
|
|
3183
|
+
|
|
3184
|
+
[[builtin]]
|
|
3185
|
+
python = "str.index"
|
|
3186
|
+
kind = "method"
|
|
3187
|
+
types = ["str"]
|
|
3188
|
+
arity = "1"
|
|
3189
|
+
rust = "p2r::str_index(&$self, $0)"
|
|
3190
|
+
status = "needs-runtime-helper"
|
|
3191
|
+
helper = "str_index"
|
|
3192
|
+
origin = "original"
|
|
3193
|
+
source = "python2rust (py2many has no mapping)"
|
|
3194
|
+
notes = "Like find but raises ValueError."
|
|
3195
|
+
|
|
3196
|
+
[[builtin]]
|
|
3197
|
+
python = "str.count"
|
|
3198
|
+
kind = "method"
|
|
3199
|
+
types = ["str"]
|
|
3200
|
+
arity = "1"
|
|
3201
|
+
rust = "$self.matches($0).count() as i64"
|
|
3202
|
+
status = "direct"
|
|
3203
|
+
origin = "original"
|
|
3204
|
+
source = "python2rust (py2many has no mapping)"
|
|
3205
|
+
notes = "Non-overlapping, like Python. 'abc'.count('') is 4 in both (verified)."
|
|
3206
|
+
|
|
3207
|
+
[[builtin]]
|
|
3208
|
+
python = "str.startswith"
|
|
3209
|
+
kind = "method"
|
|
3210
|
+
types = ["str"]
|
|
3211
|
+
arity = "1"
|
|
3212
|
+
rust = "$self.starts_with($0)"
|
|
3213
|
+
status = "direct"
|
|
3214
|
+
origin = "py2many"
|
|
3215
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['startswith']"
|
|
3216
|
+
py2many_emits = "$self.starts_with($0)"
|
|
3217
|
+
notes = "A tuple argument ('a', 'b') needs [..].iter().any(|p| s.starts_with(p)); start/end arguments are unsupported by py2many."
|
|
3218
|
+
|
|
3219
|
+
[[builtin]]
|
|
3220
|
+
python = "str.endswith"
|
|
3221
|
+
kind = "method"
|
|
3222
|
+
types = ["str"]
|
|
3223
|
+
arity = "1"
|
|
3224
|
+
rust = "$self.ends_with($0)"
|
|
3225
|
+
status = "direct"
|
|
3226
|
+
origin = "py2many"
|
|
3227
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['endswith']"
|
|
3228
|
+
py2many_emits = "$self.ends_with($0)"
|
|
3229
|
+
notes = "See startswith."
|
|
3230
|
+
|
|
3231
|
+
[[builtin]]
|
|
3232
|
+
python = "str.capitalize"
|
|
3233
|
+
kind = "method"
|
|
3234
|
+
types = ["str"]
|
|
3235
|
+
arity = "0"
|
|
3236
|
+
rust = "{ let mut __c = $self.chars(); match __c.next() { Some(__f) => __f.to_uppercase().collect::<String>() + &__c.as_str().to_lowercase(), None => String::new() } }"
|
|
3237
|
+
status = "direct"
|
|
3238
|
+
origin = "py2many"
|
|
3239
|
+
source = "pyrs/transpiler.py:_STR_METHODS + _visit_str_method['capitalize']"
|
|
3240
|
+
py2many_emits = "(same block expression)"
|
|
3241
|
+
notes = "Python title-cases the first char (U+01C6 becomes U+01C5) rather than upper-casing it; only digraph letters differ."
|
|
3242
|
+
|
|
3243
|
+
[[builtin]]
|
|
3244
|
+
python = "str.isdigit"
|
|
3245
|
+
kind = "method"
|
|
3246
|
+
types = ["str"]
|
|
3247
|
+
arity = "0"
|
|
3248
|
+
rust = "p2r::str_isdigit(&$self)"
|
|
3249
|
+
status = "needs-runtime-helper"
|
|
3250
|
+
helper = "str_isdigit"
|
|
3251
|
+
origin = "py2many"
|
|
3252
|
+
source = "pyrs/transpiler.py:_CHAR_PREDICATE + _visit_str_method['isdigit']"
|
|
3253
|
+
py2many_emits = "!$self.is_empty() && $self.chars().all(|c| c.is_ascii_digit())"
|
|
3254
|
+
notes = "Python's isdigit is true for Unicode digits such as '²' and Arabic-Indic digits (Python: '²'.isdigit() is True); is_ascii_digit is ASCII only (verified false). Empty string is False."
|
|
3255
|
+
|
|
3256
|
+
[[builtin]]
|
|
3257
|
+
python = "str.isalpha"
|
|
3258
|
+
kind = "method"
|
|
3259
|
+
types = ["str"]
|
|
3260
|
+
arity = "0"
|
|
3261
|
+
rust = "p2r::str_isalpha(&$self)"
|
|
3262
|
+
status = "needs-runtime-helper"
|
|
3263
|
+
helper = "str_isalpha"
|
|
3264
|
+
origin = "py2many"
|
|
3265
|
+
source = "pyrs/transpiler.py:_CHAR_PREDICATE + _visit_str_method['isalpha']"
|
|
3266
|
+
py2many_emits = "!$self.is_empty() && $self.chars().all(|c| c.is_alphabetic())"
|
|
3267
|
+
notes = "Python: category L*. Rust is_alphabetic is the Alphabetic property, which also includes letter numbers and some combining marks."
|
|
3268
|
+
|
|
3269
|
+
[[builtin]]
|
|
3270
|
+
python = "str.isalnum"
|
|
3271
|
+
kind = "method"
|
|
3272
|
+
types = ["str"]
|
|
3273
|
+
arity = "0"
|
|
3274
|
+
rust = "p2r::str_isalnum(&$self)"
|
|
3275
|
+
status = "needs-runtime-helper"
|
|
3276
|
+
helper = "str_isalnum"
|
|
3277
|
+
origin = "py2many"
|
|
3278
|
+
source = "pyrs/transpiler.py:_CHAR_PREDICATE + _visit_str_method['isalnum']"
|
|
3279
|
+
py2many_emits = "!$self.is_empty() && $self.chars().all(|c| c.is_alphanumeric())"
|
|
3280
|
+
notes = "Python: isalpha or isdecimal or isdigit or isnumeric per char. Rust is_alphanumeric differs on some marks and numbers."
|
|
3281
|
+
|
|
3282
|
+
[[builtin]]
|
|
3283
|
+
python = "str.isspace"
|
|
3284
|
+
kind = "method"
|
|
3285
|
+
types = ["str"]
|
|
3286
|
+
arity = "0"
|
|
3287
|
+
rust = "(!$self.is_empty() && $self.chars().all(|c| c.is_whitespace()))"
|
|
3288
|
+
status = "direct"
|
|
3289
|
+
origin = "py2many"
|
|
3290
|
+
source = "pyrs/transpiler.py:_CHAR_PREDICATE + _visit_str_method['isspace']"
|
|
3291
|
+
py2many_emits = "!$self.is_empty() && $self.chars().all(|c| c.is_whitespace())"
|
|
3292
|
+
notes = "Rust trims Unicode White_Space; Python trims chars with str.isspace(), which also includes U+001C..U+001F (verified: Rust keeps \\x1f). Empty string is False in Python."
|
|
3293
|
+
|
|
3294
|
+
[[builtin]]
|
|
3295
|
+
python = "str.isupper"
|
|
3296
|
+
kind = "method"
|
|
3297
|
+
types = ["str"]
|
|
3298
|
+
arity = "0"
|
|
3299
|
+
rust = "p2r::str_isupper(&$self)"
|
|
3300
|
+
status = "needs-runtime-helper"
|
|
3301
|
+
helper = "str_isupper"
|
|
3302
|
+
origin = "py2many"
|
|
3303
|
+
source = "pyrs/transpiler.py:_CHAR_PREDICATE + _visit_str_method['isupper']"
|
|
3304
|
+
py2many_emits = "!$self.is_empty() && $self.chars().all(|c| c.is_uppercase())"
|
|
3305
|
+
notes = "Python requires at least one cased char and ignores uncased ones: 'A1'.isupper() is True. py2many's all-chars test gives False (verified: 'A1'.chars().all(char::is_uppercase) is false)."
|
|
3306
|
+
|
|
3307
|
+
[[builtin]]
|
|
3308
|
+
python = "str.islower"
|
|
3309
|
+
kind = "method"
|
|
3310
|
+
types = ["str"]
|
|
3311
|
+
arity = "0"
|
|
3312
|
+
rust = "p2r::str_islower(&$self)"
|
|
3313
|
+
status = "needs-runtime-helper"
|
|
3314
|
+
helper = "str_islower"
|
|
3315
|
+
origin = "py2many"
|
|
3316
|
+
source = "pyrs/transpiler.py:_CHAR_PREDICATE + _visit_str_method['islower']"
|
|
3317
|
+
py2many_emits = "!$self.is_empty() && $self.chars().all(|c| c.is_lowercase())"
|
|
3318
|
+
notes = "Same cased-char rule as isupper."
|
|
3319
|
+
|
|
3320
|
+
[[builtin]]
|
|
3321
|
+
python = "str.isnumeric"
|
|
3322
|
+
kind = "method"
|
|
3323
|
+
types = ["str"]
|
|
3324
|
+
arity = "0"
|
|
3325
|
+
rust = "p2r::str_isnumeric(&$self)"
|
|
3326
|
+
status = "needs-runtime-helper"
|
|
3327
|
+
helper = "str_isnumeric"
|
|
3328
|
+
origin = "original"
|
|
3329
|
+
source = "python2rust (py2many has no mapping)"
|
|
3330
|
+
notes = "See helper `str_isnumeric` in [[helper]] for the exact semantics."
|
|
3331
|
+
|
|
3332
|
+
[[builtin]]
|
|
3333
|
+
python = "str.isdecimal"
|
|
3334
|
+
kind = "method"
|
|
3335
|
+
types = ["str"]
|
|
3336
|
+
arity = "0"
|
|
3337
|
+
rust = "p2r::str_isdecimal(&$self)"
|
|
3338
|
+
status = "needs-runtime-helper"
|
|
3339
|
+
helper = "str_isdecimal"
|
|
3340
|
+
origin = "original"
|
|
3341
|
+
source = "python2rust (py2many has no mapping)"
|
|
3342
|
+
notes = "See helper `str_isdecimal` in [[helper]] for the exact semantics."
|
|
3343
|
+
|
|
3344
|
+
[[builtin]]
|
|
3345
|
+
python = "str.isidentifier"
|
|
3346
|
+
kind = "method"
|
|
3347
|
+
types = ["str"]
|
|
3348
|
+
arity = "0"
|
|
3349
|
+
rust = "p2r::str_isidentifier(&$self)"
|
|
3350
|
+
status = "needs-runtime-helper"
|
|
3351
|
+
helper = "str_isidentifier"
|
|
3352
|
+
origin = "original"
|
|
3353
|
+
source = "python2rust (py2many has no mapping)"
|
|
3354
|
+
notes = "See helper `str_isidentifier` in [[helper]] for the exact semantics."
|
|
3355
|
+
|
|
3356
|
+
[[builtin]]
|
|
3357
|
+
python = "str.istitle"
|
|
3358
|
+
kind = "method"
|
|
3359
|
+
types = ["str"]
|
|
3360
|
+
arity = "0"
|
|
3361
|
+
rust = "p2r::str_istitle(&$self)"
|
|
3362
|
+
status = "needs-runtime-helper"
|
|
3363
|
+
helper = "str_istitle"
|
|
3364
|
+
origin = "original"
|
|
3365
|
+
source = "python2rust (py2many has no mapping)"
|
|
3366
|
+
notes = "See helper `str_istitle` in [[helper]] for the exact semantics."
|
|
3367
|
+
|
|
3368
|
+
[[builtin]]
|
|
3369
|
+
python = "str.isascii"
|
|
3370
|
+
kind = "method"
|
|
3371
|
+
types = ["str"]
|
|
3372
|
+
arity = "0"
|
|
3373
|
+
rust = "$self.is_ascii()"
|
|
3374
|
+
status = "direct"
|
|
3375
|
+
origin = "original"
|
|
3376
|
+
source = "python2rust (py2many has no mapping)"
|
|
3377
|
+
notes = "isascii('') is True in both."
|
|
3378
|
+
|
|
3379
|
+
[[builtin]]
|
|
3380
|
+
python = "str.removeprefix"
|
|
3381
|
+
kind = "method"
|
|
3382
|
+
types = ["str"]
|
|
3383
|
+
arity = "1"
|
|
3384
|
+
rust = "$self.strip_prefix($0).unwrap_or($self)"
|
|
3385
|
+
status = "direct"
|
|
3386
|
+
origin = "original"
|
|
3387
|
+
source = "python2rust (py2many has no mapping)"
|
|
3388
|
+
|
|
3389
|
+
[[builtin]]
|
|
3390
|
+
python = "str.removesuffix"
|
|
3391
|
+
kind = "method"
|
|
3392
|
+
types = ["str"]
|
|
3393
|
+
arity = "1"
|
|
3394
|
+
rust = "$self.strip_suffix($0).unwrap_or($self)"
|
|
3395
|
+
status = "direct"
|
|
3396
|
+
origin = "original"
|
|
3397
|
+
source = "python2rust (py2many has no mapping)"
|
|
3398
|
+
|
|
3399
|
+
[[builtin]]
|
|
3400
|
+
python = "str.partition"
|
|
3401
|
+
kind = "method"
|
|
3402
|
+
types = ["str"]
|
|
3403
|
+
arity = "1"
|
|
3404
|
+
rust = "match $self.split_once($0) { Some((a, b)) => (a, $0, b), None => ($self, \"\", \"\") }"
|
|
3405
|
+
status = "direct"
|
|
3406
|
+
origin = "original"
|
|
3407
|
+
source = "python2rust (py2many has no mapping)"
|
|
3408
|
+
notes = "Python always returns a 3-tuple; split_once returns Option."
|
|
3409
|
+
|
|
3410
|
+
[[builtin]]
|
|
3411
|
+
python = "str.ljust"
|
|
3412
|
+
kind = "method"
|
|
3413
|
+
types = ["str"]
|
|
3414
|
+
arity = "1"
|
|
3415
|
+
rust = "format!(\"{:<1$}\", $self, $0 as usize)"
|
|
3416
|
+
status = "direct"
|
|
3417
|
+
origin = "original"
|
|
3418
|
+
source = "python2rust (py2many has no mapping)"
|
|
3419
|
+
notes = "Width counts chars in both languages. A custom fill char needs a helper."
|
|
3420
|
+
|
|
3421
|
+
[[builtin]]
|
|
3422
|
+
python = "str.rjust"
|
|
3423
|
+
kind = "method"
|
|
3424
|
+
types = ["str"]
|
|
3425
|
+
arity = "1"
|
|
3426
|
+
rust = "format!(\"{:>1$}\", $self, $0 as usize)"
|
|
3427
|
+
status = "direct"
|
|
3428
|
+
origin = "original"
|
|
3429
|
+
source = "python2rust (py2many has no mapping)"
|
|
3430
|
+
|
|
3431
|
+
[[builtin]]
|
|
3432
|
+
python = "str.center"
|
|
3433
|
+
kind = "method"
|
|
3434
|
+
types = ["str"]
|
|
3435
|
+
arity = "1"
|
|
3436
|
+
rust = "p2r::str_center(&$self, $0)"
|
|
3437
|
+
status = "needs-runtime-helper"
|
|
3438
|
+
helper = "str_center"
|
|
3439
|
+
origin = "original"
|
|
3440
|
+
source = "python2rust (py2many has no mapping)"
|
|
3441
|
+
notes = "Python puts the extra pad on the LEFT when the width is odd ('ab'.center(5) is ' ab '); Rust `{:^5}` puts it on the right (verified ' ab ')."
|
|
3442
|
+
|
|
3443
|
+
[[builtin]]
|
|
3444
|
+
python = "str.zfill"
|
|
3445
|
+
kind = "method"
|
|
3446
|
+
types = ["str"]
|
|
3447
|
+
arity = "1"
|
|
3448
|
+
rust = "p2r::str_zfill(&$self, $0)"
|
|
3449
|
+
status = "needs-runtime-helper"
|
|
3450
|
+
helper = "str_zfill"
|
|
3451
|
+
origin = "original"
|
|
3452
|
+
source = "python2rust (py2many has no mapping)"
|
|
3453
|
+
notes = "Pads after a leading sign."
|
|
3454
|
+
|
|
3455
|
+
[[builtin]]
|
|
3456
|
+
python = "str.title"
|
|
3457
|
+
kind = "method"
|
|
3458
|
+
types = ["str"]
|
|
3459
|
+
arity = "0"
|
|
3460
|
+
rust = "p2r::str_title(&$self)"
|
|
3461
|
+
status = "needs-runtime-helper"
|
|
3462
|
+
helper = "str_title"
|
|
3463
|
+
origin = "original"
|
|
3464
|
+
source = "python2rust (py2many has no mapping)"
|
|
3465
|
+
notes = "Word-boundary rules differ ('they're')."
|
|
3466
|
+
|
|
3467
|
+
[[builtin]]
|
|
3468
|
+
python = "str.swapcase"
|
|
3469
|
+
kind = "method"
|
|
3470
|
+
types = ["str"]
|
|
3471
|
+
arity = "0"
|
|
3472
|
+
rust = "p2r::str_swapcase(&$self)"
|
|
3473
|
+
status = "needs-runtime-helper"
|
|
3474
|
+
helper = "str_swapcase"
|
|
3475
|
+
origin = "original"
|
|
3476
|
+
source = "python2rust (py2many has no mapping)"
|
|
3477
|
+
notes = "See helper `str_swapcase` in [[helper]] for the exact semantics."
|
|
3478
|
+
|
|
3479
|
+
[[builtin]]
|
|
3480
|
+
python = "str.encode"
|
|
3481
|
+
kind = "method"
|
|
3482
|
+
types = ["str"]
|
|
3483
|
+
arity = "0-1"
|
|
3484
|
+
rust = "$self.as_bytes().to_vec()"
|
|
3485
|
+
status = "direct"
|
|
3486
|
+
origin = "original"
|
|
3487
|
+
source = "python2rust (py2many has no mapping)"
|
|
3488
|
+
notes = "Default encoding is utf-8; other encodings need a helper."
|
|
3489
|
+
|
|
3490
|
+
[[builtin]]
|
|
3491
|
+
python = "bytes.decode"
|
|
3492
|
+
kind = "method"
|
|
3493
|
+
types = ["bytes"]
|
|
3494
|
+
arity = "0-1"
|
|
3495
|
+
rust = "String::from_utf8($self).expect(\"invalid utf-8\")"
|
|
3496
|
+
status = "direct"
|
|
3497
|
+
origin = "original"
|
|
3498
|
+
source = "python2rust (py2many has no mapping)"
|
|
3499
|
+
notes = "errors='strict' raises UnicodeDecodeError; errors='replace' is String::from_utf8_lossy."
|
|
3500
|
+
|
|
3501
|
+
[[builtin]]
|
|
3502
|
+
python = "str.format"
|
|
3503
|
+
kind = "method"
|
|
3504
|
+
types = ["str"]
|
|
3505
|
+
arity = "*"
|
|
3506
|
+
rust = ""
|
|
3507
|
+
status = "unsupported"
|
|
3508
|
+
origin = "original"
|
|
3509
|
+
source = "python2rust (py2many has no mapping)"
|
|
3510
|
+
notes = "Translate a literal template to format! at compile time."
|
|
3511
|
+
|
|
3512
|
+
[[builtin]]
|
|
3513
|
+
python = "list.append"
|
|
3514
|
+
kind = "method"
|
|
3515
|
+
types = ["list"]
|
|
3516
|
+
arity = "1"
|
|
3517
|
+
rust = "$self.push($0);"
|
|
3518
|
+
status = "direct"
|
|
3519
|
+
origin = "py2many"
|
|
3520
|
+
source = "pyrs/transpiler.py:visit_Attribute"
|
|
3521
|
+
py2many_emits = "push (visit_Attribute renames append only when is_list can prove the receiver is a list)"
|
|
3522
|
+
notes = "py2many renames by inspecting how the receiver was assigned; a receiver that came from a function call is missed."
|
|
3523
|
+
|
|
3524
|
+
[[builtin]]
|
|
3525
|
+
python = "list.extend"
|
|
3526
|
+
kind = "method"
|
|
3527
|
+
types = ["list"]
|
|
3528
|
+
arity = "1"
|
|
3529
|
+
rust = "$self.extend($0.iter().cloned());"
|
|
3530
|
+
status = "direct"
|
|
3531
|
+
origin = "original"
|
|
3532
|
+
source = "python2rust (py2many has no mapping)"
|
|
3533
|
+
|
|
3534
|
+
[[builtin]]
|
|
3535
|
+
python = "list.insert"
|
|
3536
|
+
kind = "method"
|
|
3537
|
+
types = ["list"]
|
|
3538
|
+
arity = "2"
|
|
3539
|
+
rust = "p2r::list_insert(&mut $self, $0, $1);"
|
|
3540
|
+
status = "needs-runtime-helper"
|
|
3541
|
+
helper = "list_insert"
|
|
3542
|
+
origin = "original"
|
|
3543
|
+
source = "python2rust (py2many has no mapping)"
|
|
3544
|
+
notes = "Python clamps the index into 0..=len and accepts negatives; Vec::insert panics when the index is past len."
|
|
3545
|
+
|
|
3546
|
+
[[builtin]]
|
|
3547
|
+
python = "list.pop"
|
|
3548
|
+
kind = "method"
|
|
3549
|
+
types = ["list"]
|
|
3550
|
+
arity = "0"
|
|
3551
|
+
rust = "$self.pop().expect(\"pop from empty list\")"
|
|
3552
|
+
status = "direct"
|
|
3553
|
+
origin = "original"
|
|
3554
|
+
source = "python2rust (py2many has no mapping)"
|
|
3555
|
+
|
|
3556
|
+
[[builtin]]
|
|
3557
|
+
python = "list.pop"
|
|
3558
|
+
kind = "method"
|
|
3559
|
+
types = ["list"]
|
|
3560
|
+
arity = "1"
|
|
3561
|
+
rust = "p2r::list_pop_at(&mut $self, $0)"
|
|
3562
|
+
status = "needs-runtime-helper"
|
|
3563
|
+
helper = "list_pop_at"
|
|
3564
|
+
origin = "original"
|
|
3565
|
+
source = "python2rust (py2many has no mapping)"
|
|
3566
|
+
notes = "Negative index support."
|
|
3567
|
+
|
|
3568
|
+
[[builtin]]
|
|
3569
|
+
python = "list.remove"
|
|
3570
|
+
kind = "method"
|
|
3571
|
+
types = ["list"]
|
|
3572
|
+
arity = "1"
|
|
3573
|
+
rust = "{ let __i = $self.iter().position(|e| e == &$0).expect(\"list.remove(x): x not in list\"); $self.remove(__i); }"
|
|
3574
|
+
status = "direct"
|
|
3575
|
+
origin = "original"
|
|
3576
|
+
source = "python2rust (py2many has no mapping)"
|
|
3577
|
+
|
|
3578
|
+
[[builtin]]
|
|
3579
|
+
python = "list.index"
|
|
3580
|
+
kind = "method"
|
|
3581
|
+
types = ["list"]
|
|
3582
|
+
arity = "1"
|
|
3583
|
+
rust = "$self.iter().position(|e| e == &$0).expect(\"x not in list\") as i64"
|
|
3584
|
+
status = "direct"
|
|
3585
|
+
origin = "original"
|
|
3586
|
+
source = "python2rust (py2many has no mapping)"
|
|
3587
|
+
|
|
3588
|
+
[[builtin]]
|
|
3589
|
+
python = "list.count"
|
|
3590
|
+
kind = "method"
|
|
3591
|
+
types = ["list"]
|
|
3592
|
+
arity = "1"
|
|
3593
|
+
rust = "$self.iter().filter(|e| **e == $0).count() as i64"
|
|
3594
|
+
status = "direct"
|
|
3595
|
+
origin = "original"
|
|
3596
|
+
source = "python2rust (py2many has no mapping)"
|
|
3597
|
+
|
|
3598
|
+
[[builtin]]
|
|
3599
|
+
python = "list.reverse"
|
|
3600
|
+
kind = "method"
|
|
3601
|
+
types = ["list"]
|
|
3602
|
+
arity = "0"
|
|
3603
|
+
rust = "$self.reverse();"
|
|
3604
|
+
status = "direct"
|
|
3605
|
+
origin = "original"
|
|
3606
|
+
source = "python2rust (py2many has no mapping)"
|
|
3607
|
+
|
|
3608
|
+
[[builtin]]
|
|
3609
|
+
python = "list.sort"
|
|
3610
|
+
kind = "method"
|
|
3611
|
+
types = ["list[int]", "list[str]"]
|
|
3612
|
+
arity = "0"
|
|
3613
|
+
rust = "$self.sort();"
|
|
3614
|
+
status = "direct"
|
|
3615
|
+
origin = "original"
|
|
3616
|
+
source = "python2rust (py2many has no mapping)"
|
|
3617
|
+
notes = "Verified: py2many binds list literals as immutable references and detects mutation only through `.append`, so `ys.sort()` gets no `mut` and does not compile."
|
|
3618
|
+
|
|
3619
|
+
[[builtin]]
|
|
3620
|
+
python = "list.sort"
|
|
3621
|
+
kind = "method"
|
|
3622
|
+
types = ["list"]
|
|
3623
|
+
arity = "0+key"
|
|
3624
|
+
rust = "$self.sort_by_cached_key($key);"
|
|
3625
|
+
status = "direct"
|
|
3626
|
+
origin = "original"
|
|
3627
|
+
source = "python2rust (py2many has no mapping)"
|
|
3628
|
+
|
|
3629
|
+
[[builtin]]
|
|
3630
|
+
python = "list.copy"
|
|
3631
|
+
kind = "method"
|
|
3632
|
+
types = ["list"]
|
|
3633
|
+
arity = "0"
|
|
3634
|
+
rust = "$self.clone()"
|
|
3635
|
+
status = "direct"
|
|
3636
|
+
origin = "original"
|
|
3637
|
+
source = "python2rust (py2many has no mapping)"
|
|
3638
|
+
|
|
3639
|
+
[[builtin]]
|
|
3640
|
+
python = "list.clear"
|
|
3641
|
+
kind = "method"
|
|
3642
|
+
types = ["list"]
|
|
3643
|
+
arity = "0"
|
|
3644
|
+
rust = "$self.clear();"
|
|
3645
|
+
status = "direct"
|
|
3646
|
+
origin = "original"
|
|
3647
|
+
source = "python2rust (py2many has no mapping)"
|
|
3648
|
+
|
|
3649
|
+
[[builtin]]
|
|
3650
|
+
python = "dict.get"
|
|
3651
|
+
kind = "method"
|
|
3652
|
+
types = ["dict"]
|
|
3653
|
+
arity = "1"
|
|
3654
|
+
rust = "$self.get(&$0).cloned()"
|
|
3655
|
+
status = "direct"
|
|
3656
|
+
crates = ["indexmap"]
|
|
3657
|
+
origin = "original"
|
|
3658
|
+
source = "python2rust (py2many has no mapping)"
|
|
3659
|
+
notes = "Returns Option<V>. Verified: py2many passes `d.get(k, 0)` through unchanged."
|
|
3660
|
+
|
|
3661
|
+
[[builtin]]
|
|
3662
|
+
python = "dict.get"
|
|
3663
|
+
kind = "method"
|
|
3664
|
+
types = ["dict"]
|
|
3665
|
+
arity = "2"
|
|
3666
|
+
rust = "$self.get(&$0).cloned().unwrap_or($1)"
|
|
3667
|
+
status = "direct"
|
|
3668
|
+
crates = ["indexmap"]
|
|
3669
|
+
origin = "original"
|
|
3670
|
+
source = "python2rust (py2many has no mapping)"
|
|
3671
|
+
|
|
3672
|
+
[[builtin]]
|
|
3673
|
+
python = "dict.keys"
|
|
3674
|
+
kind = "method"
|
|
3675
|
+
types = ["dict"]
|
|
3676
|
+
arity = "0"
|
|
3677
|
+
rust = "$self.keys()"
|
|
3678
|
+
status = "direct"
|
|
3679
|
+
crates = ["indexmap"]
|
|
3680
|
+
origin = "original"
|
|
3681
|
+
source = "python2rust (py2many has no mapping)"
|
|
3682
|
+
|
|
3683
|
+
[[builtin]]
|
|
3684
|
+
python = "dict.values"
|
|
3685
|
+
kind = "method"
|
|
3686
|
+
types = ["dict"]
|
|
3687
|
+
arity = "0"
|
|
3688
|
+
rust = "$self.values()"
|
|
3689
|
+
status = "direct"
|
|
3690
|
+
crates = ["indexmap"]
|
|
3691
|
+
origin = "original"
|
|
3692
|
+
source = "python2rust (py2many has no mapping)"
|
|
3693
|
+
|
|
3694
|
+
[[builtin]]
|
|
3695
|
+
python = "dict.items"
|
|
3696
|
+
kind = "method"
|
|
3697
|
+
types = ["dict"]
|
|
3698
|
+
arity = "0"
|
|
3699
|
+
rust = "$self.iter()"
|
|
3700
|
+
status = "direct"
|
|
3701
|
+
crates = ["indexmap"]
|
|
3702
|
+
origin = "py2many"
|
|
3703
|
+
source = "py2many (see py2many_emits)"
|
|
3704
|
+
py2many_emits = "$self.items()"
|
|
3705
|
+
notes = "Verified: py2many emits `d.items()` verbatim, which does not exist on HashMap. Yields (&K, &V)."
|
|
3706
|
+
|
|
3707
|
+
[[builtin]]
|
|
3708
|
+
python = "dict.setdefault"
|
|
3709
|
+
kind = "method"
|
|
3710
|
+
types = ["dict"]
|
|
3711
|
+
arity = "2"
|
|
3712
|
+
rust = "$self.entry($0).or_insert($1)"
|
|
3713
|
+
status = "direct"
|
|
3714
|
+
crates = ["indexmap"]
|
|
3715
|
+
origin = "original"
|
|
3716
|
+
source = "python2rust (py2many has no mapping)"
|
|
3717
|
+
|
|
3718
|
+
[[builtin]]
|
|
3719
|
+
python = "dict.pop"
|
|
3720
|
+
kind = "method"
|
|
3721
|
+
types = ["dict"]
|
|
3722
|
+
arity = "1"
|
|
3723
|
+
rust = "$self.shift_remove(&$0).expect(\"KeyError\")"
|
|
3724
|
+
status = "direct"
|
|
3725
|
+
crates = ["indexmap"]
|
|
3726
|
+
origin = "original"
|
|
3727
|
+
source = "python2rust (py2many has no mapping)"
|
|
3728
|
+
|
|
3729
|
+
[[builtin]]
|
|
3730
|
+
python = "dict.pop"
|
|
3731
|
+
kind = "method"
|
|
3732
|
+
types = ["dict"]
|
|
3733
|
+
arity = "2"
|
|
3734
|
+
rust = "$self.shift_remove(&$0).unwrap_or($1)"
|
|
3735
|
+
status = "direct"
|
|
3736
|
+
crates = ["indexmap"]
|
|
3737
|
+
origin = "original"
|
|
3738
|
+
source = "python2rust (py2many has no mapping)"
|
|
3739
|
+
|
|
3740
|
+
[[builtin]]
|
|
3741
|
+
python = "dict.popitem"
|
|
3742
|
+
kind = "method"
|
|
3743
|
+
types = ["dict"]
|
|
3744
|
+
arity = "0"
|
|
3745
|
+
rust = "$self.pop().expect(\"popitem(): dictionary is empty\")"
|
|
3746
|
+
status = "direct"
|
|
3747
|
+
crates = ["indexmap"]
|
|
3748
|
+
origin = "original"
|
|
3749
|
+
source = "python2rust (py2many has no mapping)"
|
|
3750
|
+
notes = "LIFO, like Python 3.7+."
|
|
3751
|
+
|
|
3752
|
+
[[builtin]]
|
|
3753
|
+
python = "dict.update"
|
|
3754
|
+
kind = "method"
|
|
3755
|
+
types = ["dict"]
|
|
3756
|
+
arity = "1"
|
|
3757
|
+
rust = "$self.extend($0.iter().map(|(k, v)| (k.clone(), v.clone())));"
|
|
3758
|
+
status = "direct"
|
|
3759
|
+
crates = ["indexmap"]
|
|
3760
|
+
origin = "original"
|
|
3761
|
+
source = "python2rust (py2many has no mapping)"
|
|
3762
|
+
notes = "Clones so the argument stays usable, as in Python."
|
|
3763
|
+
|
|
3764
|
+
[[builtin]]
|
|
3765
|
+
python = "dict.clear"
|
|
3766
|
+
kind = "method"
|
|
3767
|
+
types = ["dict"]
|
|
3768
|
+
arity = "0"
|
|
3769
|
+
rust = "$self.clear();"
|
|
3770
|
+
status = "direct"
|
|
3771
|
+
crates = ["indexmap"]
|
|
3772
|
+
origin = "original"
|
|
3773
|
+
source = "python2rust (py2many has no mapping)"
|
|
3774
|
+
|
|
3775
|
+
[[builtin]]
|
|
3776
|
+
python = "dict.copy"
|
|
3777
|
+
kind = "method"
|
|
3778
|
+
types = ["dict"]
|
|
3779
|
+
arity = "0"
|
|
3780
|
+
rust = "$self.clone()"
|
|
3781
|
+
status = "direct"
|
|
3782
|
+
crates = ["indexmap"]
|
|
3783
|
+
origin = "original"
|
|
3784
|
+
source = "python2rust (py2many has no mapping)"
|
|
3785
|
+
|
|
3786
|
+
[[builtin]]
|
|
3787
|
+
python = "dict comprehension"
|
|
3788
|
+
kind = "syntax"
|
|
3789
|
+
arity = "*"
|
|
3790
|
+
rust = "$0.into_iter().map(|($k, $v)| ($key, $value)).collect::<IndexMap<_, _>>()"
|
|
3791
|
+
status = "direct"
|
|
3792
|
+
imports = ["indexmap::IndexMap"]
|
|
3793
|
+
crates = ["indexmap"]
|
|
3794
|
+
origin = "py2many"
|
|
3795
|
+
source = "py2many (see py2many_emits)"
|
|
3796
|
+
py2many_emits = "<not implemented: AstNotImplementedError>"
|
|
3797
|
+
notes = "py2many raises 'dict comprehension not implemented' for any dict comprehension; list comprehensions are handled only for the first generator and the first `if` (verified: a second `if` and a second `for` are dropped)."
|
|
3798
|
+
|
|
3799
|
+
[[builtin]]
|
|
3800
|
+
python = "dict | dict"
|
|
3801
|
+
kind = "operator"
|
|
3802
|
+
types = ["dict"]
|
|
3803
|
+
arity = "2"
|
|
3804
|
+
rust = "{ let mut m = $0.clone(); m.extend($1.clone()); m }"
|
|
3805
|
+
status = "direct"
|
|
3806
|
+
crates = ["indexmap"]
|
|
3807
|
+
origin = "original"
|
|
3808
|
+
source = "python2rust (py2many has no mapping)"
|
|
3809
|
+
|
|
3810
|
+
[[builtin]]
|
|
3811
|
+
python = "set.add"
|
|
3812
|
+
kind = "method"
|
|
3813
|
+
types = ["set"]
|
|
3814
|
+
arity = "1"
|
|
3815
|
+
rust = "$self.insert($0);"
|
|
3816
|
+
status = "direct"
|
|
3817
|
+
imports = ["std::collections::HashSet"]
|
|
3818
|
+
origin = "original"
|
|
3819
|
+
source = "python2rust (py2many has no mapping)"
|
|
3820
|
+
|
|
3821
|
+
[[builtin]]
|
|
3822
|
+
python = "set.remove"
|
|
3823
|
+
kind = "method"
|
|
3824
|
+
types = ["set"]
|
|
3825
|
+
arity = "1"
|
|
3826
|
+
rust = "assert!($self.remove(&$0), \"KeyError\");"
|
|
3827
|
+
status = "direct"
|
|
3828
|
+
imports = ["std::collections::HashSet"]
|
|
3829
|
+
origin = "original"
|
|
3830
|
+
source = "python2rust (py2many has no mapping)"
|
|
3831
|
+
notes = "remove() raises KeyError when absent."
|
|
3832
|
+
|
|
3833
|
+
[[builtin]]
|
|
3834
|
+
python = "set.discard"
|
|
3835
|
+
kind = "method"
|
|
3836
|
+
types = ["set"]
|
|
3837
|
+
arity = "1"
|
|
3838
|
+
rust = "$self.remove(&$0);"
|
|
3839
|
+
status = "direct"
|
|
3840
|
+
imports = ["std::collections::HashSet"]
|
|
3841
|
+
origin = "original"
|
|
3842
|
+
source = "python2rust (py2many has no mapping)"
|
|
3843
|
+
|
|
3844
|
+
[[builtin]]
|
|
3845
|
+
python = "set.union"
|
|
3846
|
+
kind = "method"
|
|
3847
|
+
types = ["set"]
|
|
3848
|
+
arity = "1"
|
|
3849
|
+
rust = "$self.union(&$0).cloned().collect::<HashSet<_>>()"
|
|
3850
|
+
status = "direct"
|
|
3851
|
+
imports = ["std::collections::HashSet"]
|
|
3852
|
+
origin = "original"
|
|
3853
|
+
source = "python2rust (py2many has no mapping)"
|
|
3854
|
+
|
|
3855
|
+
[[builtin]]
|
|
3856
|
+
python = "set.intersection"
|
|
3857
|
+
kind = "method"
|
|
3858
|
+
types = ["set"]
|
|
3859
|
+
arity = "1"
|
|
3860
|
+
rust = "$self.intersection(&$0).cloned().collect::<HashSet<_>>()"
|
|
3861
|
+
status = "direct"
|
|
3862
|
+
imports = ["std::collections::HashSet"]
|
|
3863
|
+
origin = "original"
|
|
3864
|
+
source = "python2rust (py2many has no mapping)"
|
|
3865
|
+
|
|
3866
|
+
[[builtin]]
|
|
3867
|
+
python = "set.difference"
|
|
3868
|
+
kind = "method"
|
|
3869
|
+
types = ["set"]
|
|
3870
|
+
arity = "1"
|
|
3871
|
+
rust = "$self.difference(&$0).cloned().collect::<HashSet<_>>()"
|
|
3872
|
+
status = "direct"
|
|
3873
|
+
imports = ["std::collections::HashSet"]
|
|
3874
|
+
origin = "original"
|
|
3875
|
+
source = "python2rust (py2many has no mapping)"
|
|
3876
|
+
|
|
3877
|
+
[[builtin]]
|
|
3878
|
+
python = "set.issubset"
|
|
3879
|
+
kind = "method"
|
|
3880
|
+
types = ["set"]
|
|
3881
|
+
arity = "1"
|
|
3882
|
+
rust = "$self.is_subset(&$0)"
|
|
3883
|
+
status = "direct"
|
|
3884
|
+
imports = ["std::collections::HashSet"]
|
|
3885
|
+
origin = "original"
|
|
3886
|
+
source = "python2rust (py2many has no mapping)"
|
|
3887
|
+
|
|
3888
|
+
[[builtin]]
|
|
3889
|
+
python = "set.update"
|
|
3890
|
+
kind = "method"
|
|
3891
|
+
types = ["set"]
|
|
3892
|
+
arity = "1"
|
|
3893
|
+
rust = "$self.extend($0.iter().cloned());"
|
|
3894
|
+
status = "direct"
|
|
3895
|
+
imports = ["std::collections::HashSet"]
|
|
3896
|
+
origin = "original"
|
|
3897
|
+
source = "python2rust (py2many has no mapping)"
|
|
3898
|
+
|
|
3899
|
+
[[builtin]]
|
|
3900
|
+
python = "set.pop"
|
|
3901
|
+
kind = "method"
|
|
3902
|
+
types = ["set"]
|
|
3903
|
+
arity = "0"
|
|
3904
|
+
rust = "p2r::set_pop(&mut $self)"
|
|
3905
|
+
status = "needs-runtime-helper"
|
|
3906
|
+
helper = "set_pop"
|
|
3907
|
+
imports = ["std::collections::HashSet"]
|
|
3908
|
+
origin = "original"
|
|
3909
|
+
source = "python2rust (py2many has no mapping)"
|
|
3910
|
+
notes = "Python removes an arbitrary element; the choice cannot match CPython."
|
|
3911
|
+
|
|
3912
|
+
[[builtin]]
|
|
3913
|
+
python = "f-string {x}"
|
|
3914
|
+
kind = "format"
|
|
3915
|
+
types = ["int", "str"]
|
|
3916
|
+
arity = "1"
|
|
3917
|
+
rust = "format!(\"{}\", $0)"
|
|
3918
|
+
status = "direct"
|
|
3919
|
+
origin = "py2many"
|
|
3920
|
+
source = "py2many (see py2many_emits)"
|
|
3921
|
+
py2many_emits = "vec![&x.to_string(), ...].join(\"\") (FStringJoinRewriter)"
|
|
3922
|
+
notes = "Verified: py2many lowers f-strings to str() joins and DROPS format specs and conversions (f\"{x:.2f} {n!r}\" becomes x.to_string() + n.to_string())."
|
|
3923
|
+
|
|
3924
|
+
[[builtin]]
|
|
3925
|
+
python = "f-string {x} (float)"
|
|
3926
|
+
kind = "format"
|
|
3927
|
+
types = ["float"]
|
|
3928
|
+
arity = "1"
|
|
3929
|
+
rust = "format!(\"{}\", p2r::float_repr($0))"
|
|
3930
|
+
status = "needs-runtime-helper"
|
|
3931
|
+
helper = "float_repr"
|
|
3932
|
+
origin = "original"
|
|
3933
|
+
source = "python2rust (py2many has no mapping)"
|
|
3934
|
+
notes = "See helper `float_repr` in [[helper]] for the exact semantics."
|
|
3935
|
+
|
|
3936
|
+
[[builtin]]
|
|
3937
|
+
python = "format-spec :.Nf"
|
|
3938
|
+
kind = "format"
|
|
3939
|
+
types = ["float"]
|
|
3940
|
+
arity = "1"
|
|
3941
|
+
rust = "format!(\"{:.N}\", $0)"
|
|
3942
|
+
status = "direct"
|
|
3943
|
+
origin = "original"
|
|
3944
|
+
source = "python2rust (py2many has no mapping)"
|
|
3945
|
+
notes = "Both round the exact binary value half to even: 0.125 formats to '0.12' in each (verified). N must be a literal."
|
|
3946
|
+
|
|
3947
|
+
[[builtin]]
|
|
3948
|
+
python = "format-spec :N / :<N / :>N / :^N"
|
|
3949
|
+
kind = "format"
|
|
3950
|
+
types = ["str", "int"]
|
|
3951
|
+
arity = "1"
|
|
3952
|
+
rust = "format!(\"{:>N}\", $0)"
|
|
3953
|
+
status = "direct"
|
|
3954
|
+
origin = "original"
|
|
3955
|
+
source = "python2rust (py2many has no mapping)"
|
|
3956
|
+
notes = "Width, fill and alignment syntax matches Python ('{:*^10}'). Python's default for numbers is right-aligned and for str is left-aligned; Rust uses the same defaults. '^' puts the extra pad on the right in Rust but on the left in Python when it is odd."
|
|
3957
|
+
|
|
3958
|
+
[[builtin]]
|
|
3959
|
+
python = "format-spec :0Nd"
|
|
3960
|
+
kind = "format"
|
|
3961
|
+
types = ["int"]
|
|
3962
|
+
arity = "1"
|
|
3963
|
+
rust = "format!(\"{:0N}\", $0)"
|
|
3964
|
+
status = "direct"
|
|
3965
|
+
origin = "original"
|
|
3966
|
+
source = "python2rust (py2many has no mapping)"
|
|
3967
|
+
|
|
3968
|
+
[[builtin]]
|
|
3969
|
+
python = "format-spec :+d"
|
|
3970
|
+
kind = "format"
|
|
3971
|
+
types = ["int", "float"]
|
|
3972
|
+
arity = "1"
|
|
3973
|
+
rust = "format!(\"{:+}\", $0)"
|
|
3974
|
+
status = "direct"
|
|
3975
|
+
origin = "original"
|
|
3976
|
+
source = "python2rust (py2many has no mapping)"
|
|
3977
|
+
|
|
3978
|
+
[[builtin]]
|
|
3979
|
+
python = "format-spec :x / :b / :o"
|
|
3980
|
+
kind = "format"
|
|
3981
|
+
types = ["int"]
|
|
3982
|
+
arity = "1"
|
|
3983
|
+
rust = "format!(\"{:x}\", $0)"
|
|
3984
|
+
status = "needs-runtime-helper"
|
|
3985
|
+
helper = "fmt_radix_signed"
|
|
3986
|
+
origin = "original"
|
|
3987
|
+
source = "python2rust (py2many has no mapping)"
|
|
3988
|
+
notes = "Fine for non-negative values; a negative i64 prints two's complement in Rust (verified) and `-ff` in Python."
|
|
3989
|
+
|
|
3990
|
+
[[builtin]]
|
|
3991
|
+
python = "format-spec :,"
|
|
3992
|
+
kind = "format"
|
|
3993
|
+
types = ["int"]
|
|
3994
|
+
arity = "1"
|
|
3995
|
+
rust = "p2r::fmt_thousands($0)"
|
|
3996
|
+
status = "needs-runtime-helper"
|
|
3997
|
+
helper = "fmt_thousands"
|
|
3998
|
+
origin = "original"
|
|
3999
|
+
source = "python2rust (py2many has no mapping)"
|
|
4000
|
+
notes = "No Rust equivalent."
|
|
4001
|
+
|
|
4002
|
+
[[builtin]]
|
|
4003
|
+
python = "format-spec :e"
|
|
4004
|
+
kind = "format"
|
|
4005
|
+
types = ["float"]
|
|
4006
|
+
arity = "1"
|
|
4007
|
+
rust = "p2r::fmt_exp($0, N)"
|
|
4008
|
+
status = "needs-runtime-helper"
|
|
4009
|
+
helper = "fmt_exp"
|
|
4010
|
+
origin = "original"
|
|
4011
|
+
source = "python2rust (py2many has no mapping)"
|
|
4012
|
+
notes = "Python '1.000000e+00'; Rust {:e} gives '1e0'."
|
|
4013
|
+
|
|
4014
|
+
[[builtin]]
|
|
4015
|
+
python = "format-spec :%"
|
|
4016
|
+
kind = "format"
|
|
4017
|
+
types = ["float"]
|
|
4018
|
+
arity = "1"
|
|
4019
|
+
rust = "p2r::fmt_percent($0, N)"
|
|
4020
|
+
status = "needs-runtime-helper"
|
|
4021
|
+
helper = "fmt_percent"
|
|
4022
|
+
origin = "original"
|
|
4023
|
+
source = "python2rust (py2many has no mapping)"
|
|
4024
|
+
notes = "See helper `fmt_percent` in [[helper]] for the exact semantics."
|
|
4025
|
+
|
|
4026
|
+
[[builtin]]
|
|
4027
|
+
python = "format-spec :g"
|
|
4028
|
+
kind = "format"
|
|
4029
|
+
types = ["float"]
|
|
4030
|
+
arity = "1"
|
|
4031
|
+
rust = "p2r::fmt_general($0, N)"
|
|
4032
|
+
status = "needs-runtime-helper"
|
|
4033
|
+
helper = "fmt_general"
|
|
4034
|
+
origin = "original"
|
|
4035
|
+
source = "python2rust (py2many has no mapping)"
|
|
4036
|
+
notes = "See helper `fmt_general` in [[helper]] for the exact semantics."
|
|
4037
|
+
|
|
4038
|
+
[[builtin]]
|
|
4039
|
+
python = "conversion !r"
|
|
4040
|
+
kind = "format"
|
|
4041
|
+
types = ["str", "any"]
|
|
4042
|
+
arity = "1"
|
|
4043
|
+
rust = "p2r::py_repr(&$0)"
|
|
4044
|
+
status = "needs-runtime-helper"
|
|
4045
|
+
helper = "py_repr"
|
|
4046
|
+
origin = "original"
|
|
4047
|
+
source = "python2rust (py2many has no mapping)"
|
|
4048
|
+
notes = "Rust {:?} always uses double quotes and \\u{..} escapes; Python picks the quote style and escapes differently."
|
|
4049
|
+
|
|
4050
|
+
[[builtin]]
|
|
4051
|
+
python = "conversion !s"
|
|
4052
|
+
kind = "format"
|
|
4053
|
+
types = ["any"]
|
|
4054
|
+
arity = "1"
|
|
4055
|
+
rust = "$0.py_str()"
|
|
4056
|
+
status = "needs-runtime-helper"
|
|
4057
|
+
helper = "PyStr"
|
|
4058
|
+
origin = "original"
|
|
4059
|
+
source = "python2rust (py2many has no mapping)"
|
|
4060
|
+
notes = "See helper `PyStr` in [[helper]] for the exact semantics."
|
|
4061
|
+
|
|
4062
|
+
[[builtin]]
|
|
4063
|
+
python = "int"
|
|
4064
|
+
kind = "type"
|
|
4065
|
+
rust = "i64"
|
|
4066
|
+
status = "direct"
|
|
4067
|
+
origin = "py2many"
|
|
4068
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['int']"
|
|
4069
|
+
py2many_emits = "i32"
|
|
4070
|
+
notes = "py2many maps int to i32, which silently truncates values the Python program handles (and combines with its width-widening casts)."
|
|
4071
|
+
|
|
4072
|
+
[[builtin]]
|
|
4073
|
+
python = "float"
|
|
4074
|
+
kind = "type"
|
|
4075
|
+
rust = "f64"
|
|
4076
|
+
status = "direct"
|
|
4077
|
+
origin = "py2many"
|
|
4078
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['float']"
|
|
4079
|
+
py2many_emits = "f64"
|
|
4080
|
+
|
|
4081
|
+
[[builtin]]
|
|
4082
|
+
python = "bool"
|
|
4083
|
+
kind = "type"
|
|
4084
|
+
rust = "bool"
|
|
4085
|
+
status = "direct"
|
|
4086
|
+
origin = "py2many"
|
|
4087
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['bool']"
|
|
4088
|
+
py2many_emits = "bool"
|
|
4089
|
+
|
|
4090
|
+
[[builtin]]
|
|
4091
|
+
python = "str"
|
|
4092
|
+
kind = "type"
|
|
4093
|
+
rust = "String"
|
|
4094
|
+
status = "direct"
|
|
4095
|
+
origin = "py2many"
|
|
4096
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['str']"
|
|
4097
|
+
py2many_emits = "&str"
|
|
4098
|
+
notes = "py2many maps every str to &str, including owned results, which produces dangling-borrow signatures like `-> &str { &x.to_string() }`. Use &str for borrowed parameters and String for owned values."
|
|
4099
|
+
|
|
4100
|
+
[[builtin]]
|
|
4101
|
+
python = "bytes"
|
|
4102
|
+
kind = "type"
|
|
4103
|
+
rust = "Vec<u8>"
|
|
4104
|
+
status = "direct"
|
|
4105
|
+
origin = "py2many"
|
|
4106
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['bytes']"
|
|
4107
|
+
py2many_emits = "&[u8]"
|
|
4108
|
+
|
|
4109
|
+
[[builtin]]
|
|
4110
|
+
python = "ctypes.c_int8"
|
|
4111
|
+
kind = "type"
|
|
4112
|
+
rust = "i8"
|
|
4113
|
+
status = "direct"
|
|
4114
|
+
origin = "py2many"
|
|
4115
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_int8']"
|
|
4116
|
+
py2many_emits = "i8"
|
|
4117
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4118
|
+
|
|
4119
|
+
[[builtin]]
|
|
4120
|
+
python = "ctypes.c_int16"
|
|
4121
|
+
kind = "type"
|
|
4122
|
+
rust = "i16"
|
|
4123
|
+
status = "direct"
|
|
4124
|
+
origin = "py2many"
|
|
4125
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_int16']"
|
|
4126
|
+
py2many_emits = "i16"
|
|
4127
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4128
|
+
|
|
4129
|
+
[[builtin]]
|
|
4130
|
+
python = "ctypes.c_int32"
|
|
4131
|
+
kind = "type"
|
|
4132
|
+
rust = "i32"
|
|
4133
|
+
status = "direct"
|
|
4134
|
+
origin = "py2many"
|
|
4135
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_int32']"
|
|
4136
|
+
py2many_emits = "i32"
|
|
4137
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4138
|
+
|
|
4139
|
+
[[builtin]]
|
|
4140
|
+
python = "ctypes.c_int64"
|
|
4141
|
+
kind = "type"
|
|
4142
|
+
rust = "i64"
|
|
4143
|
+
status = "direct"
|
|
4144
|
+
origin = "py2many"
|
|
4145
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_int64']"
|
|
4146
|
+
py2many_emits = "i64"
|
|
4147
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4148
|
+
|
|
4149
|
+
[[builtin]]
|
|
4150
|
+
python = "ctypes.c_uint8"
|
|
4151
|
+
kind = "type"
|
|
4152
|
+
rust = "u8"
|
|
4153
|
+
status = "direct"
|
|
4154
|
+
origin = "py2many"
|
|
4155
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_uint8']"
|
|
4156
|
+
py2many_emits = "u8"
|
|
4157
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4158
|
+
|
|
4159
|
+
[[builtin]]
|
|
4160
|
+
python = "ctypes.c_uint16"
|
|
4161
|
+
kind = "type"
|
|
4162
|
+
rust = "u16"
|
|
4163
|
+
status = "direct"
|
|
4164
|
+
origin = "py2many"
|
|
4165
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_uint16']"
|
|
4166
|
+
py2many_emits = "u16"
|
|
4167
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4168
|
+
|
|
4169
|
+
[[builtin]]
|
|
4170
|
+
python = "ctypes.c_uint32"
|
|
4171
|
+
kind = "type"
|
|
4172
|
+
rust = "u32"
|
|
4173
|
+
status = "direct"
|
|
4174
|
+
origin = "py2many"
|
|
4175
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_uint32']"
|
|
4176
|
+
py2many_emits = "u32"
|
|
4177
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4178
|
+
|
|
4179
|
+
[[builtin]]
|
|
4180
|
+
python = "ctypes.c_uint64"
|
|
4181
|
+
kind = "type"
|
|
4182
|
+
rust = "u64"
|
|
4183
|
+
status = "direct"
|
|
4184
|
+
origin = "py2many"
|
|
4185
|
+
source = "pyrs/inference.py:RUST_TYPE_MAP['c_uint64']"
|
|
4186
|
+
py2many_emits = "u64"
|
|
4187
|
+
notes = "py2many dialect for fixed-width ints."
|
|
4188
|
+
|
|
4189
|
+
[[builtin]]
|
|
4190
|
+
python = "list[T]"
|
|
4191
|
+
kind = "type"
|
|
4192
|
+
rust = "Vec<$T>"
|
|
4193
|
+
status = "direct"
|
|
4194
|
+
origin = "py2many"
|
|
4195
|
+
source = "pyrs/inference.py:RUST_CONTAINER_TYPE_MAP['List']"
|
|
4196
|
+
py2many_emits = "Vec"
|
|
4197
|
+
|
|
4198
|
+
[[builtin]]
|
|
4199
|
+
python = "dict[K, V]"
|
|
4200
|
+
kind = "type"
|
|
4201
|
+
rust = "IndexMap<$K, $V>"
|
|
4202
|
+
status = "direct"
|
|
4203
|
+
imports = ["indexmap::IndexMap"]
|
|
4204
|
+
crates = ["indexmap"]
|
|
4205
|
+
origin = "py2many"
|
|
4206
|
+
source = "pyrs/inference.py:RUST_CONTAINER_TYPE_MAP['Dict']"
|
|
4207
|
+
py2many_emits = "HashMap"
|
|
4208
|
+
notes = "HashMap iteration order is random per process; Python dicts preserve insertion order and programs print or serialise them."
|
|
4209
|
+
|
|
4210
|
+
[[builtin]]
|
|
4211
|
+
python = "set[T]"
|
|
4212
|
+
kind = "type"
|
|
4213
|
+
rust = "HashSet<$T>"
|
|
4214
|
+
status = "direct"
|
|
4215
|
+
imports = ["std::collections::HashSet"]
|
|
4216
|
+
origin = "py2many"
|
|
4217
|
+
source = "pyrs/inference.py:RUST_CONTAINER_TYPE_MAP['Set']"
|
|
4218
|
+
py2many_emits = "HashSet"
|
|
4219
|
+
|
|
4220
|
+
[[builtin]]
|
|
4221
|
+
python = "Optional[T]"
|
|
4222
|
+
kind = "type"
|
|
4223
|
+
rust = "Option<$T>"
|
|
4224
|
+
status = "direct"
|
|
4225
|
+
origin = "py2many"
|
|
4226
|
+
source = "pyrs/inference.py:RUST_CONTAINER_TYPE_MAP['Optional']"
|
|
4227
|
+
py2many_emits = "Option"
|
|
4228
|
+
|
|
4229
|
+
[[builtin]]
|
|
4230
|
+
python = "tuple[A, B]"
|
|
4231
|
+
kind = "type"
|
|
4232
|
+
rust = "($A, $B)"
|
|
4233
|
+
status = "direct"
|
|
4234
|
+
origin = "original"
|
|
4235
|
+
source = "python2rust (py2many has no mapping)"
|
|
4236
|
+
|
|
4237
|
+
[[builtin]]
|
|
4238
|
+
python = "None"
|
|
4239
|
+
kind = "type"
|
|
4240
|
+
rust = "()"
|
|
4241
|
+
status = "direct"
|
|
4242
|
+
origin = "original"
|
|
4243
|
+
source = "python2rust (py2many has no mapping)"
|
|
4244
|
+
notes = "Return type of a function without a return value."
|
|
4245
|
+
|
|
4246
|
+
[[builtin]]
|
|
4247
|
+
python = "Any"
|
|
4248
|
+
kind = "type"
|
|
4249
|
+
rust = ""
|
|
4250
|
+
status = "unsupported"
|
|
4251
|
+
origin = "original"
|
|
4252
|
+
source = "python2rust (py2many has no mapping)"
|
|
4253
|
+
notes = "Verified: py2many silently maps Any to the inference placeholder `_`, which is not valid in a signature."
|
|
4254
|
+
|
|
4255
|
+
[[builtin]]
|
|
4256
|
+
python = "Callable[[A], R]"
|
|
4257
|
+
kind = "type"
|
|
4258
|
+
rust = "impl Fn($A) -> $R"
|
|
4259
|
+
status = "direct"
|
|
4260
|
+
origin = "original"
|
|
4261
|
+
source = "python2rust (py2many has no mapping)"
|
|
4262
|
+
notes = "Use Box<dyn Fn> in struct fields."
|
|
4263
|
+
|
|
4264
|
+
[[builtin]]
|
|
4265
|
+
python = "Union[A, B]"
|
|
4266
|
+
kind = "type"
|
|
4267
|
+
rust = "$Enum"
|
|
4268
|
+
status = "needs-runtime-helper"
|
|
4269
|
+
helper = "union-enum"
|
|
4270
|
+
origin = "py2many"
|
|
4271
|
+
source = "py2many (see py2many_emits)"
|
|
4272
|
+
py2many_emits = "Union[A,B] (leaked into the signature text)"
|
|
4273
|
+
notes = "Verified: py2many merges differing return types into the literal text `Union[int,i32]` inside the Rust signature. Generate an enum per distinct union."
|
|
4274
|
+
|
|
4275
|
+
[[builtin]]
|
|
4276
|
+
python = "complex"
|
|
4277
|
+
kind = "type"
|
|
4278
|
+
rust = "num_complex::Complex64"
|
|
4279
|
+
status = "direct"
|
|
4280
|
+
crates = ["num-complex"]
|
|
4281
|
+
origin = "original"
|
|
4282
|
+
source = "python2rust (py2many has no mapping)"
|
|
4283
|
+
|
|
4284
|
+
[[builtin]]
|
|
4285
|
+
python = "Result"
|
|
4286
|
+
kind = "type"
|
|
4287
|
+
rust = "Result"
|
|
4288
|
+
status = "direct"
|
|
4289
|
+
origin = "py2many"
|
|
4290
|
+
source = "pyrs/inference.py:RUST_CONTAINER_TYPE_MAP['Result']"
|
|
4291
|
+
py2many_emits = "Result"
|
|
4292
|
+
|
|
4293
|
+
[[builtin]]
|
|
4294
|
+
python = "typing.Iterator[T]"
|
|
4295
|
+
kind = "type"
|
|
4296
|
+
rust = "impl Iterator<Item = $T>"
|
|
4297
|
+
status = "direct"
|
|
4298
|
+
origin = "original"
|
|
4299
|
+
source = "python2rust (py2many has no mapping)"
|
|
4300
|
+
|
|
4301
|
+
[[helper]]
|
|
4302
|
+
name = "str_len"
|
|
4303
|
+
signature = "fn(&str) -> i64"
|
|
4304
|
+
semantics = "Number of Unicode code points."
|
|
4305
|
+
|
|
4306
|
+
[[helper]]
|
|
4307
|
+
name = "float_repr"
|
|
4308
|
+
signature = "fn(f64) -> String"
|
|
4309
|
+
semantics = "Python repr/str of a float: shortest round-trip digits, exponent form outside 1e-4..1e16, `inf`, `nan`."
|
|
4310
|
+
|
|
4311
|
+
[[helper]]
|
|
4312
|
+
name = "py_repr"
|
|
4313
|
+
signature = "fn<T: PyRepr>(&T) -> String"
|
|
4314
|
+
semantics = "Python repr() of str, numbers, bool, None, list, dict, set, tuple."
|
|
4315
|
+
|
|
4316
|
+
[[helper]]
|
|
4317
|
+
name = "print_args"
|
|
4318
|
+
signature = "macro print_args!(expr, ...) / print_args_sep!(sep, expr, ...)"
|
|
4319
|
+
semantics = "print() of several heterogeneous arguments: each formatted like str(), joined by sep (default a space), newline at the end."
|
|
4320
|
+
|
|
4321
|
+
[[helper]]
|
|
4322
|
+
name = "PyStr"
|
|
4323
|
+
signature = "trait PyStr { fn py_str(&self) -> String }"
|
|
4324
|
+
semantics = "Python str() of any supported value (bool -> True, None, float repr)."
|
|
4325
|
+
|
|
4326
|
+
[[helper]]
|
|
4327
|
+
name = "int_from_str"
|
|
4328
|
+
signature = "fn(&str) -> i64"
|
|
4329
|
+
semantics = "int(s): strip, sign, `_` separators; panic with ValueError text."
|
|
4330
|
+
|
|
4331
|
+
[[helper]]
|
|
4332
|
+
name = "int_from_str_radix"
|
|
4333
|
+
signature = "fn(&str, u32) -> i64"
|
|
4334
|
+
semantics = "int(s, base) including base 0 and prefixes."
|
|
4335
|
+
|
|
4336
|
+
[[helper]]
|
|
4337
|
+
name = "float_to_int"
|
|
4338
|
+
signature = "fn(f64) -> i64"
|
|
4339
|
+
semantics = "int(x): trunc toward zero; ValueError on nan, OverflowError on inf/out of range."
|
|
4340
|
+
|
|
4341
|
+
[[helper]]
|
|
4342
|
+
name = "float_from_str"
|
|
4343
|
+
signature = "fn(&str) -> f64"
|
|
4344
|
+
semantics = "float(s): whitespace, `_`, inf/nan spellings."
|
|
4345
|
+
|
|
4346
|
+
[[helper]]
|
|
4347
|
+
name = "truthy"
|
|
4348
|
+
signature = "fn<T: Truthy>(&T) -> bool"
|
|
4349
|
+
semantics = "Python truth value."
|
|
4350
|
+
|
|
4351
|
+
[[helper]]
|
|
4352
|
+
name = "round_half_even"
|
|
4353
|
+
signature = "fn(f64) -> i64"
|
|
4354
|
+
semantics = "round(x): half to even, error on nan/inf."
|
|
4355
|
+
|
|
4356
|
+
[[helper]]
|
|
4357
|
+
name = "round_ndigits"
|
|
4358
|
+
signature = "fn(f64, i64) -> f64"
|
|
4359
|
+
semantics = "round(x, n) correctly rounded on the exact binary value."
|
|
4360
|
+
|
|
4361
|
+
[[helper]]
|
|
4362
|
+
name = "round_ndigits_int"
|
|
4363
|
+
signature = "fn(i64, i64) -> i64"
|
|
4364
|
+
semantics = "round(int, negative n), half to even."
|
|
4365
|
+
|
|
4366
|
+
[[helper]]
|
|
4367
|
+
name = "min_f64"
|
|
4368
|
+
signature = "fn(f64, f64) -> f64"
|
|
4369
|
+
semantics = "Python min(a, b): `b if b < a else a`."
|
|
4370
|
+
|
|
4371
|
+
[[helper]]
|
|
4372
|
+
name = "max_f64"
|
|
4373
|
+
signature = "fn(f64, f64) -> f64"
|
|
4374
|
+
semantics = "Python max(a, b): `b if b > a else a`."
|
|
4375
|
+
|
|
4376
|
+
[[helper]]
|
|
4377
|
+
name = "iter_min_f64"
|
|
4378
|
+
signature = "fn(impl Iterator<Item = f64>) -> f64"
|
|
4379
|
+
semantics = "min over an iterable of floats with Python's scan semantics; ValueError when empty."
|
|
4380
|
+
|
|
4381
|
+
[[helper]]
|
|
4382
|
+
name = "iter_max_f64"
|
|
4383
|
+
signature = "fn(impl Iterator<Item = f64>) -> f64"
|
|
4384
|
+
semantics = "max over an iterable of floats."
|
|
4385
|
+
|
|
4386
|
+
[[helper]]
|
|
4387
|
+
name = "max_by_key_first"
|
|
4388
|
+
signature = "fn<T, K: Ord>(impl Iterator<Item = T>, impl Fn(&T) -> K) -> T"
|
|
4389
|
+
semantics = "max(key=) returning the FIRST maximal element."
|
|
4390
|
+
|
|
4391
|
+
[[helper]]
|
|
4392
|
+
name = "sum_f64"
|
|
4393
|
+
signature = "fn(impl Iterator<Item = f64>) -> f64"
|
|
4394
|
+
semantics = "sum() of floats: Neumaier compensated summation as in CPython 3.12+."
|
|
4395
|
+
|
|
4396
|
+
[[helper]]
|
|
4397
|
+
name = "range3"
|
|
4398
|
+
signature = "fn(i64, i64, i64) -> impl Iterator<Item = i64>"
|
|
4399
|
+
semantics = "range(a, b, step) with dynamic step; step 0 raises ValueError."
|
|
4400
|
+
|
|
4401
|
+
[[helper]]
|
|
4402
|
+
name = "input"
|
|
4403
|
+
signature = "fn(&str) -> String"
|
|
4404
|
+
semantics = "input(): prompt, flush, strip newline, EOFError."
|
|
4405
|
+
|
|
4406
|
+
[[helper]]
|
|
4407
|
+
name = "chr"
|
|
4408
|
+
signature = "fn(i64) -> String"
|
|
4409
|
+
semantics = "chr(n); ValueError out of range."
|
|
4410
|
+
|
|
4411
|
+
[[helper]]
|
|
4412
|
+
name = "ord"
|
|
4413
|
+
signature = "fn(&str) -> i64"
|
|
4414
|
+
semantics = "ord(s); TypeError unless exactly one code point."
|
|
4415
|
+
|
|
4416
|
+
[[helper]]
|
|
4417
|
+
name = "hex"
|
|
4418
|
+
signature = "fn(i64) -> String"
|
|
4419
|
+
semantics = "hex() with sign and 0x prefix."
|
|
4420
|
+
|
|
4421
|
+
[[helper]]
|
|
4422
|
+
name = "bin"
|
|
4423
|
+
signature = "fn(i64) -> String"
|
|
4424
|
+
semantics = "bin() with sign and 0b prefix."
|
|
4425
|
+
|
|
4426
|
+
[[helper]]
|
|
4427
|
+
name = "oct"
|
|
4428
|
+
signature = "fn(i64) -> String"
|
|
4429
|
+
semantics = "oct() with sign and 0o prefix."
|
|
4430
|
+
|
|
4431
|
+
[[helper]]
|
|
4432
|
+
name = "divmod"
|
|
4433
|
+
signature = "fn<T: PyNum>(T, T) -> (T, T)"
|
|
4434
|
+
semantics = "Floor division and modulo together."
|
|
4435
|
+
|
|
4436
|
+
[[helper]]
|
|
4437
|
+
name = "int_pow"
|
|
4438
|
+
signature = "fn(i64, i64) -> i64"
|
|
4439
|
+
semantics = "a ** b for non-negative b with overflow check."
|
|
4440
|
+
|
|
4441
|
+
[[helper]]
|
|
4442
|
+
name = "pow_mod"
|
|
4443
|
+
signature = "fn(i64, i64, i64) -> i64"
|
|
4444
|
+
semantics = "pow(a, b, m)."
|
|
4445
|
+
|
|
4446
|
+
[[helper]]
|
|
4447
|
+
name = "float_pow"
|
|
4448
|
+
signature = "fn(f64, f64) -> f64"
|
|
4449
|
+
semantics = "a ** b with Python's error cases."
|
|
4450
|
+
|
|
4451
|
+
[[helper]]
|
|
4452
|
+
name = "sorted_f64"
|
|
4453
|
+
signature = "fn(&[f64]) -> Vec<f64>"
|
|
4454
|
+
semantics = "Stable sort by Python's `<` on floats."
|
|
4455
|
+
|
|
4456
|
+
[[helper]]
|
|
4457
|
+
name = "perf_counter"
|
|
4458
|
+
signature = "fn() -> f64"
|
|
4459
|
+
semantics = "Monotonic seconds since a process-wide anchor."
|
|
4460
|
+
|
|
4461
|
+
[[helper]]
|
|
4462
|
+
name = "random_seed"
|
|
4463
|
+
signature = "fn(i64)"
|
|
4464
|
+
semantics = "Seed MT19937 as CPython does."
|
|
4465
|
+
|
|
4466
|
+
[[helper]]
|
|
4467
|
+
name = "random_random"
|
|
4468
|
+
signature = "fn() -> f64"
|
|
4469
|
+
semantics = "random.random() from MT19937."
|
|
4470
|
+
|
|
4471
|
+
[[helper]]
|
|
4472
|
+
name = "random_randint"
|
|
4473
|
+
signature = "fn(i64, i64) -> i64"
|
|
4474
|
+
semantics = "random.randint(a, b), inclusive."
|
|
4475
|
+
|
|
4476
|
+
[[helper]]
|
|
4477
|
+
name = "random_choice"
|
|
4478
|
+
signature = "fn<T: Clone>(&[T]) -> T"
|
|
4479
|
+
semantics = "random.choice()."
|
|
4480
|
+
|
|
4481
|
+
[[helper]]
|
|
4482
|
+
name = "gcd"
|
|
4483
|
+
signature = "fn(i64, i64) -> i64"
|
|
4484
|
+
semantics = "math.gcd."
|
|
4485
|
+
|
|
4486
|
+
[[helper]]
|
|
4487
|
+
name = "lcm"
|
|
4488
|
+
signature = "fn(i64, i64) -> i64"
|
|
4489
|
+
semantics = "math.lcm."
|
|
4490
|
+
|
|
4491
|
+
[[helper]]
|
|
4492
|
+
name = "factorial"
|
|
4493
|
+
signature = "fn(i64) -> i64"
|
|
4494
|
+
semantics = "math.factorial with overflow check."
|
|
4495
|
+
|
|
4496
|
+
[[helper]]
|
|
4497
|
+
name = "comb"
|
|
4498
|
+
signature = "fn(i64, i64) -> i64"
|
|
4499
|
+
semantics = "math.comb."
|
|
4500
|
+
|
|
4501
|
+
[[helper]]
|
|
4502
|
+
name = "perm"
|
|
4503
|
+
signature = "fn(i64, i64) -> i64"
|
|
4504
|
+
semantics = "math.perm."
|
|
4505
|
+
|
|
4506
|
+
[[helper]]
|
|
4507
|
+
name = "isqrt"
|
|
4508
|
+
signature = "fn(i64) -> i64"
|
|
4509
|
+
semantics = "math.isqrt, exact."
|
|
4510
|
+
|
|
4511
|
+
[[helper]]
|
|
4512
|
+
name = "fsum"
|
|
4513
|
+
signature = "fn(impl Iterator<Item = f64>) -> f64"
|
|
4514
|
+
semantics = "math.fsum: exactly rounded."
|
|
4515
|
+
|
|
4516
|
+
[[helper]]
|
|
4517
|
+
name = "isclose"
|
|
4518
|
+
signature = "fn(f64, f64) -> bool"
|
|
4519
|
+
semantics = "math.isclose with default tolerances."
|
|
4520
|
+
|
|
4521
|
+
[[helper]]
|
|
4522
|
+
name = "int_add"
|
|
4523
|
+
signature = "fn(i64, i64) -> i64"
|
|
4524
|
+
semantics = "Checked add; panics with an overflow message."
|
|
4525
|
+
|
|
4526
|
+
[[helper]]
|
|
4527
|
+
name = "int_sub"
|
|
4528
|
+
signature = "fn(i64, i64) -> i64"
|
|
4529
|
+
semantics = "Checked subtract."
|
|
4530
|
+
|
|
4531
|
+
[[helper]]
|
|
4532
|
+
name = "int_mul"
|
|
4533
|
+
signature = "fn(i64, i64) -> i64"
|
|
4534
|
+
semantics = "Checked multiply."
|
|
4535
|
+
|
|
4536
|
+
[[helper]]
|
|
4537
|
+
name = "truediv"
|
|
4538
|
+
signature = "fn(f64, f64) -> f64"
|
|
4539
|
+
semantics = "a / b raising ZeroDivisionError on zero divisor."
|
|
4540
|
+
|
|
4541
|
+
[[helper]]
|
|
4542
|
+
name = "floordiv"
|
|
4543
|
+
signature = "fn(i64, i64) -> i64"
|
|
4544
|
+
semantics = "a // b: floor, ZeroDivisionError. q = a / b; if a % b != 0 && (a < 0) != (b < 0) { q - 1 }."
|
|
4545
|
+
|
|
4546
|
+
[[helper]]
|
|
4547
|
+
name = "floordiv_f64"
|
|
4548
|
+
signature = "fn(f64, f64) -> f64"
|
|
4549
|
+
semantics = "Float floor division as CPython computes it (via fmod), not floor(a / b)."
|
|
4550
|
+
|
|
4551
|
+
[[helper]]
|
|
4552
|
+
name = "mod_floor"
|
|
4553
|
+
signature = "fn(i64, i64) -> i64"
|
|
4554
|
+
semantics = "a % b with the divisor's sign. r = a % b; if r != 0 && (r < 0) != (b < 0) { r + b }."
|
|
4555
|
+
|
|
4556
|
+
[[helper]]
|
|
4557
|
+
name = "fmod_py"
|
|
4558
|
+
signature = "fn(f64, f64) -> f64"
|
|
4559
|
+
semantics = "Python float %: divisor's sign, ZeroDivisionError."
|
|
4560
|
+
|
|
4561
|
+
[[helper]]
|
|
4562
|
+
name = "shl"
|
|
4563
|
+
signature = "fn(i64, i64) -> i64"
|
|
4564
|
+
semantics = "a << n with ValueError on n < 0 and overflow check."
|
|
4565
|
+
|
|
4566
|
+
[[helper]]
|
|
4567
|
+
name = "shr"
|
|
4568
|
+
signature = "fn(i64, i64) -> i64"
|
|
4569
|
+
semantics = "a >> n; n >= 64 gives 0 or -1."
|
|
4570
|
+
|
|
4571
|
+
[[helper]]
|
|
4572
|
+
name = "index"
|
|
4573
|
+
signature = "fn(usize, i64) -> usize"
|
|
4574
|
+
semantics = "Normalise a possibly negative index; panic with IndexError text."
|
|
4575
|
+
|
|
4576
|
+
[[helper]]
|
|
4577
|
+
name = "str_char_at"
|
|
4578
|
+
signature = "fn(&str, i64) -> String"
|
|
4579
|
+
semantics = "s[i] by code point with negative index."
|
|
4580
|
+
|
|
4581
|
+
[[helper]]
|
|
4582
|
+
name = "slice"
|
|
4583
|
+
signature = "fn<T: Clone>(&[T], Option<i64>, Option<i64>) -> Vec<T>"
|
|
4584
|
+
semantics = "Python slice with clamping and negative bounds."
|
|
4585
|
+
|
|
4586
|
+
[[helper]]
|
|
4587
|
+
name = "slice_step"
|
|
4588
|
+
signature = "fn<T: Clone>(&[T], Option<i64>, Option<i64>, i64) -> Vec<T>"
|
|
4589
|
+
semantics = "Extended slice; step 0 raises ValueError."
|
|
4590
|
+
|
|
4591
|
+
[[helper]]
|
|
4592
|
+
name = "str_slice"
|
|
4593
|
+
signature = "fn(&str, Option<i64>, Option<i64>) -> String"
|
|
4594
|
+
semantics = "Slice by code points."
|
|
4595
|
+
|
|
4596
|
+
[[helper]]
|
|
4597
|
+
name = "list_set"
|
|
4598
|
+
signature = "fn<T>(&mut [T], i64, T)"
|
|
4599
|
+
semantics = "xs[i] = v with negative index."
|
|
4600
|
+
|
|
4601
|
+
[[helper]]
|
|
4602
|
+
name = "list_del"
|
|
4603
|
+
signature = "fn<T>(&mut Vec<T>, i64) -> T"
|
|
4604
|
+
semantics = "del xs[i] with negative index."
|
|
4605
|
+
|
|
4606
|
+
[[helper]]
|
|
4607
|
+
name = "list_insert"
|
|
4608
|
+
signature = "fn<T>(&mut Vec<T>, i64, T)"
|
|
4609
|
+
semantics = "xs.insert(i, v) with clamping."
|
|
4610
|
+
|
|
4611
|
+
[[helper]]
|
|
4612
|
+
name = "list_pop_at"
|
|
4613
|
+
signature = "fn<T>(&mut Vec<T>, i64) -> T"
|
|
4614
|
+
semantics = "xs.pop(i) with negative index."
|
|
4615
|
+
|
|
4616
|
+
[[helper]]
|
|
4617
|
+
name = "str_repeat"
|
|
4618
|
+
signature = "fn(&str, i64) -> String"
|
|
4619
|
+
semantics = "s * n; negative n gives empty."
|
|
4620
|
+
|
|
4621
|
+
[[helper]]
|
|
4622
|
+
name = "list_repeat"
|
|
4623
|
+
signature = "fn<T: Clone>(&[T], i64) -> Vec<T>"
|
|
4624
|
+
semantics = "xs * n; negative n gives empty."
|
|
4625
|
+
|
|
4626
|
+
[[helper]]
|
|
4627
|
+
name = "str_find"
|
|
4628
|
+
signature = "fn(&str, &str) -> i64"
|
|
4629
|
+
semantics = "str.find returning a code-point index or -1."
|
|
4630
|
+
|
|
4631
|
+
[[helper]]
|
|
4632
|
+
name = "str_rfind"
|
|
4633
|
+
signature = "fn(&str, &str) -> i64"
|
|
4634
|
+
semantics = "str.rfind."
|
|
4635
|
+
|
|
4636
|
+
[[helper]]
|
|
4637
|
+
name = "str_index"
|
|
4638
|
+
signature = "fn(&str, &str) -> i64"
|
|
4639
|
+
semantics = "str.index, ValueError if absent."
|
|
4640
|
+
|
|
4641
|
+
[[helper]]
|
|
4642
|
+
name = "str_splitlines"
|
|
4643
|
+
signature = "fn(&str) -> Vec<String>"
|
|
4644
|
+
semantics = "str.splitlines with Python's boundary set."
|
|
4645
|
+
|
|
4646
|
+
[[helper]]
|
|
4647
|
+
name = "str_isdigit"
|
|
4648
|
+
signature = "fn(&str) -> bool"
|
|
4649
|
+
semantics = "str.isdigit via Unicode Numeric_Type=Digit/Decimal tables."
|
|
4650
|
+
|
|
4651
|
+
[[helper]]
|
|
4652
|
+
name = "str_isalpha"
|
|
4653
|
+
signature = "fn(&str) -> bool"
|
|
4654
|
+
semantics = "str.isalpha: general category L*."
|
|
4655
|
+
|
|
4656
|
+
[[helper]]
|
|
4657
|
+
name = "str_isalnum"
|
|
4658
|
+
signature = "fn(&str) -> bool"
|
|
4659
|
+
semantics = "str.isalnum."
|
|
4660
|
+
|
|
4661
|
+
[[helper]]
|
|
4662
|
+
name = "str_isupper"
|
|
4663
|
+
signature = "fn(&str) -> bool"
|
|
4664
|
+
semantics = "At least one cased char and no lowercase."
|
|
4665
|
+
|
|
4666
|
+
[[helper]]
|
|
4667
|
+
name = "str_islower"
|
|
4668
|
+
signature = "fn(&str) -> bool"
|
|
4669
|
+
semantics = "At least one cased char and no uppercase."
|
|
4670
|
+
|
|
4671
|
+
[[helper]]
|
|
4672
|
+
name = "str_isnumeric"
|
|
4673
|
+
signature = "fn(&str) -> bool"
|
|
4674
|
+
semantics = "str.isnumeric."
|
|
4675
|
+
|
|
4676
|
+
[[helper]]
|
|
4677
|
+
name = "str_isdecimal"
|
|
4678
|
+
signature = "fn(&str) -> bool"
|
|
4679
|
+
semantics = "str.isdecimal."
|
|
4680
|
+
|
|
4681
|
+
[[helper]]
|
|
4682
|
+
name = "str_isidentifier"
|
|
4683
|
+
signature = "fn(&str) -> bool"
|
|
4684
|
+
semantics = "str.isidentifier (XID_Start/XID_Continue)."
|
|
4685
|
+
|
|
4686
|
+
[[helper]]
|
|
4687
|
+
name = "str_istitle"
|
|
4688
|
+
signature = "fn(&str) -> bool"
|
|
4689
|
+
semantics = "str.istitle."
|
|
4690
|
+
|
|
4691
|
+
[[helper]]
|
|
4692
|
+
name = "str_center"
|
|
4693
|
+
signature = "fn(&str, i64) -> String"
|
|
4694
|
+
semantics = "str.center with Python's odd-pad rule."
|
|
4695
|
+
|
|
4696
|
+
[[helper]]
|
|
4697
|
+
name = "str_zfill"
|
|
4698
|
+
signature = "fn(&str, i64) -> String"
|
|
4699
|
+
semantics = "str.zfill, sign-aware."
|
|
4700
|
+
|
|
4701
|
+
[[helper]]
|
|
4702
|
+
name = "str_title"
|
|
4703
|
+
signature = "fn(&str) -> String"
|
|
4704
|
+
semantics = "str.title."
|
|
4705
|
+
|
|
4706
|
+
[[helper]]
|
|
4707
|
+
name = "str_swapcase"
|
|
4708
|
+
signature = "fn(&str) -> String"
|
|
4709
|
+
semantics = "str.swapcase."
|
|
4710
|
+
|
|
4711
|
+
[[helper]]
|
|
4712
|
+
name = "set_pop"
|
|
4713
|
+
signature = "fn<T: Clone + Eq + Hash>(&mut HashSet<T>) -> T"
|
|
4714
|
+
semantics = "set.pop(); KeyError when empty."
|
|
4715
|
+
|
|
4716
|
+
[[helper]]
|
|
4717
|
+
name = "fmt_radix_signed"
|
|
4718
|
+
signature = "fn(i64, char) -> String"
|
|
4719
|
+
semantics = "Format as x/b/o with a leading minus for negatives."
|
|
4720
|
+
|
|
4721
|
+
[[helper]]
|
|
4722
|
+
name = "fmt_thousands"
|
|
4723
|
+
signature = "fn(i64) -> String"
|
|
4724
|
+
semantics = "Format spec ','."
|
|
4725
|
+
|
|
4726
|
+
[[helper]]
|
|
4727
|
+
name = "fmt_exp"
|
|
4728
|
+
signature = "fn(f64, usize) -> String"
|
|
4729
|
+
semantics = "Format spec 'e'."
|
|
4730
|
+
|
|
4731
|
+
[[helper]]
|
|
4732
|
+
name = "fmt_percent"
|
|
4733
|
+
signature = "fn(f64, usize) -> String"
|
|
4734
|
+
semantics = "Format spec '%'."
|
|
4735
|
+
|
|
4736
|
+
[[helper]]
|
|
4737
|
+
name = "fmt_general"
|
|
4738
|
+
signature = "fn(f64, usize) -> String"
|
|
4739
|
+
semantics = "Format spec 'g'."
|
|
4740
|
+
|
|
4741
|
+
[[helper]]
|
|
4742
|
+
name = "union-enum"
|
|
4743
|
+
signature = "generated enum"
|
|
4744
|
+
semantics = "One enum per distinct Union, with From impls and match-based isinstance."
|