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

Method vec

bindings/frankenswig/__init__.py:398–411  ·  view source on GitHub ↗
(self, type)

Source from the content-addressed store, hash-verified

396 self.strref = namedtuple('StrRef', ['type'])(StrRefType(self.module))
397
398 def vec(self, type):
399 vec = self.struct(f"vec::Vec::<{type.orig_rust()}>", module="std", docs=f"An immutable list of {type.orig_rust()} objects")
400 vec.debug()
401 vec.clone()
402 vec.method(usize.type, "len", [], pyname="__len__", docs="The length of the vector.")
403 # TODO impl option and use .get() instead
404 vec.method(type.ref(), "index", [Var(usize.type, "index")], pyname="__getitem__", docs="Copy an element out of the vector.")
405 vec.pyextra(s(''&#x27;\
406 def __iter__(self):
407 l = len(self)
408 for i in range(l):
409 yield self[i]
410 ''&#x27;))
411 return vec
412
413 def add(self, elem):
414 return self

Callers 1

generate.pyFile · 0.80

Calls 9

structMethod · 0.95
VarClass · 0.85
sFunction · 0.85
debugMethod · 0.80
cloneMethod · 0.80
pyextraMethod · 0.80
orig_rustMethod · 0.45
methodMethod · 0.45
refMethod · 0.45

Tested by

no test coverage detected