MCPcopy Index your code
hub / github.com/RustPython/RustPython / slot_new

Method slot_new

crates/vm/src/builtins/slice.rs:128–152  ·  view source on GitHub ↗
(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

126
127 #[pyslot]
128 fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
129 let slice: Self = match args.args.len() {
130 0 => {
131 return Err(vm.new_type_error("slice() must have at least one arguments."));
132 }
133 1 => {
134 let stop = args.bind(vm)?;
135 Self {
136 start: None,
137 stop,
138 step: None,
139 }
140 }
141 _ => {
142 let (start, stop, step): (PyObjectRef, PyObjectRef, OptionalArg<PyObjectRef>) =
143 args.bind(vm)?;
144 Self {
145 start: Some(start),
146 stop,
147 step: step.into_option(),
148 }
149 }
150 };
151 slice.into_ref_with_type(vm, cls).map(Into::into)
152 }
153
154 pub(crate) fn inner_indices(
155 &self,

Callers

nothing calls this directly

Calls 8

into_optionMethod · 0.80
into_ref_with_typeMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50
lenMethod · 0.45
bindMethod · 0.45
mapMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected