MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / insert

Method insert

src/objects/list.rs:78–81  ·  view source on GitHub ↗

Inserts an item at the specified index. Panics if the index is out of range.

(&self, _py: Python, index: usize, item: PyObject)

Source from the content-addressed store, hash-verified

76 ///
77 /// Panics if the index is out of range.
78 pub fn insert(&self, _py: Python, index: usize, item: PyObject) {
79 let r = unsafe { ffi::PyList_Insert(self.0.as_ptr(), index as Py_ssize_t, item.as_ptr()) };
80 assert!(r == 0);
81 }
82
83 // Old name for `insert`.
84 #[deprecated(since = "0.3.1", note = "use list.insert() instead")]

Callers 15

get_config_varsFunction · 0.80
mainFunction · 0.80
get_config_varsFunction · 0.80
mainFunction · 0.80
test_lenFunction · 0.80
test_containsFunction · 0.80
test_get_itemFunction · 0.80
test_set_itemFunction · 0.80
test_del_itemFunction · 0.80
test_items_listFunction · 0.80

Calls 1

as_ptrMethod · 0.45

Tested by 15

test_lenFunction · 0.64
test_containsFunction · 0.64
test_get_itemFunction · 0.64
test_set_itemFunction · 0.64
test_del_itemFunction · 0.64
test_items_listFunction · 0.64
test_itemsFunction · 0.64
test_hashmap_to_pythonFunction · 0.64
test_btreemap_to_pythonFunction · 0.64
test_insertFunction · 0.64