MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / to_rust

Method to_rust

bindings/frankenswig/enums.py:118–144  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

116 return self
117
118 def to_rust(self):
119 decl = super().to_rust()
120
121 for t1, t2 in [(self.type.c_name, self.type.orig_name), (self.type.orig_name, self.type.c_name)]:
122 start = s(f'''\
123 impl Into<{t2}> for {t1} {{
124 fn into(self) -> {t2} {{
125 match self {{
126 ''&#x27;)
127
128 body = ''
129 for variant,_ in self.variants:
130 body += f'{t1}::{variant} => {t2}::{variant},\n'
131 body += f'_ => {t2}::{self.variants[0][0]},\n'
132
133
134 end = s(f''&#x27;\
135 }}
136 }}
137 }}
138 ''&#x27;)
139
140 decl += start + s(body, indent=12) + end
141
142 methods = '\n'.join(m.to_rust() for m in self.methods)
143
144 return decl + methods
145
146 def to_c(self):
147 methods = '\n'.join(m.to_c() for m in self.methods)

Callers

nothing calls this directly

Calls 2

sFunction · 0.85
to_rustMethod · 0.45

Tested by

no test coverage detected