python/list/
append_front.rs

1use crate::Object;
2use crate::Int;
3use crate::Float;
4use crate::_String;
5use crate::Char;
6use crate::Bool;
7
8
9use super::List;
10
11
12/// appends to front of the list
13/// meaning: list.insert(o, item)
14pub trait AppendFront<T>: Sized {
15    /// performs the append front
16    fn append_front(&mut self, _: T) -> &mut Self;
17}
18
19
20impl AppendFront<i32> for List {
21    fn append_front(&mut self, _integer: i32) -> &mut Self {
22        self._list
23            .push_front(Object::Int32(Int::<i32>::new(_integer)));
24        self
25    }
26}
27
28
29impl AppendFront<&str> for List {
30    fn append_front(&mut self, _str: &str) -> &mut Self {
31        self._list.push_front(Object::String(_String::from(_str)));
32        self
33    }
34}
35
36impl AppendFront<char> for List {
37    fn append_front(&mut self, _char: char) -> &mut Self {
38        self._list.push_front(Object::Char(Char::new(_char)));
39        self
40    }
41}
42
43impl AppendFront<f32> for List {
44    fn append_front(&mut self, _float: f32) -> &mut Self {
45        self._list.push_front(Object::Float32(Float::from(_float)));
46        self
47    }
48}
49
50impl AppendFront<f64> for List {
51    fn append_front(&mut self, _float: f64) -> &mut Self {
52        self._list.push_front(Object::Float64(Float::from(_float)));
53        self
54    }
55}
56
57
58impl AppendFront<String> for List {
59    fn append_front(&mut self, string: String) -> &mut Self {
60        self._list.push_front(Object::String(_String::from(string)));
61        self
62    }
63}
64
65impl AppendFront<_String> for List {
66    fn append_front(&mut self, _string: _String) -> &mut Self {
67        self._list.push_front(Object::String(_string));
68        self
69    }
70}
71
72impl AppendFront<bool> for List {
73    fn append_front(&mut self, _bool: bool) -> &mut Self {
74        self._list.push_front(Object::Bool(Bool::new(_bool)));
75        self
76    }
77}
78
79
80impl AppendFront<Bool> for List {
81    #[doc = include_str!("../../docs/python_list/append_pbool.md")]
82    fn append_front(&mut self, _bool: Bool) -> &mut Self {
83        self._list.push_front(Object::Bool(_bool));
84        self
85    }
86}
87
88impl AppendFront<List> for List {
89    fn append_front(&mut self, _list: List) -> &mut Self {
90        self._list.push_front(Object::List(_list));
91        self
92    }
93}