Struct relm4::factory::collections::FactoryVecDeque
source · [−]pub struct FactoryVecDeque<Data> where
Data: FactoryPrototype, { /* private fields */ }
Implementations
sourceimpl<Data> FactoryVecDeque<Data> where
Data: FactoryPrototype,
impl<Data> FactoryVecDeque<Data> where
Data: FactoryPrototype,
sourcepub fn from_vec_deque(data: VecDeque<Data>) -> Self
pub fn from_vec_deque(data: VecDeque<Data>) -> Self
Initialize a new FactoryVecDeque
with a normal VecDeque
.
sourcepub fn into_vec_deque(self) -> VecDeque<Data>
pub fn into_vec_deque(self) -> VecDeque<Data>
Get the internal data of the FactoryVecDeque
.
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all data from the FactoryVecDeque
.
sourcepub fn push_back(&mut self, data: Data)
pub fn push_back(&mut self, data: Data)
Insert an element at the end of a FactoryVecDeque
.
sourcepub fn pop_back(&mut self) -> Option<Data>
pub fn pop_back(&mut self) -> Option<Data>
Remove an element at the end of a FactoryVecDeque
.
Examples found in repository
relm4-examples/examples/factory_advanced_manual.rs (line 40)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
More examples
relm4-examples/examples/factory_advanced.rs (line 40)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
sourcepub fn push_front(&mut self, data: Data)
pub fn push_front(&mut self, data: Data)
Adds an element at the front.
Examples found in repository
relm4-examples/examples/factory_advanced_manual.rs (lines 35-37)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
More examples
relm4-examples/examples/factory_advanced.rs (lines 35-37)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
sourcepub fn insert(&mut self, index: usize, data: Data)
pub fn insert(&mut self, index: usize, data: Data)
Adds an element at a given index. All elements with indices greater than or equal to index will be shifted towards the back.
Examples found in repository
relm4-examples/examples/factory_advanced_manual.rs (lines 56-61)
≺ ≻
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
More examples
relm4-examples/examples/factory_advanced.rs (lines 56-61)
≺ ≻
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
sourcepub fn remove(&mut self, index: usize) -> Option<Data>
pub fn remove(&mut self, index: usize) -> Option<Data>
Removes an element at a given index.
Examples found in repository
relm4-examples/examples/factory_advanced_manual.rs (line 51)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
More examples
relm4-examples/examples/factory_advanced.rs (line 51)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Data>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Data>
Get a mutable reference to data stored at index
.
Assumes that the data will be modified and the corresponding widget needs to be updated.
Examples found in repository
relm4-examples/examples/factory_advanced_manual.rs (line 44)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
More examples
relm4-examples/examples/factory_advanced.rs (line 44)
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
fn update(&mut self, msg: AppMsg, _components: &(), _sender: Sender<AppMsg>) -> bool {
match msg {
AppMsg::AddFirst => {
self.counters.push_front(Counter {
value: self.received_messages,
});
}
AppMsg::RemoveLast => {
self.counters.pop_back();
}
AppMsg::CountAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
if let Some(counter) = self.counters.get_mut(index.current_index()) {
counter.value = counter.value.wrapping_sub(1);
}
}
}
AppMsg::RemoveAt(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.remove(index.current_index());
}
}
AppMsg::InsertBefore(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index(),
Counter {
value: self.received_messages,
},
);
}
}
AppMsg::InsertAfter(weak_index) => {
if let Some(index) = weak_index.upgrade() {
self.counters.insert(
index.current_index() + 1,
Counter {
value: self.received_messages,
},
);
}
}
}
self.received_messages += 1;
true
}
sourceimpl<Data, View> FactoryVecDeque<Data> where
Data: FactoryPrototype<Factory = Self, View = View>,
View: FactoryView<Data::Root>,
impl<Data, View> FactoryVecDeque<Data> where
Data: FactoryPrototype<Factory = Self, View = View>,
View: FactoryView<Data::Root>,
Trait Implementations
sourceimpl<Data: Debug> Debug for FactoryVecDeque<Data> where
Data: FactoryPrototype,
Data::Widgets: Debug,
Data::View: Debug,
Data::Root: Debug,
impl<Data: Debug> Debug for FactoryVecDeque<Data> where
Data: FactoryPrototype,
Data::Widgets: Debug,
Data::View: Debug,
Data::Root: Debug,
sourceimpl<Data: Default> Default for FactoryVecDeque<Data> where
Data: FactoryPrototype,
Data::Widgets: Default,
Data::View: Default,
Data::Root: Default,
impl<Data: Default> Default for FactoryVecDeque<Data> where
Data: FactoryPrototype,
Data::Widgets: Default,
Data::View: Default,
Data::Root: Default,
sourcefn default() -> FactoryVecDeque<Data>
fn default() -> FactoryVecDeque<Data>
Returns the “default value” for a type. Read more
sourceimpl<Data, View> Factory<Data, View> for FactoryVecDeque<Data> where
Data: FactoryPrototype<Factory = Self, View = View>,
View: FactoryView<Data::Root> + FactoryListView<Data::Root>,
<Data as FactoryPrototype>::Root: Clone,
impl<Data, View> Factory<Data, View> for FactoryVecDeque<Data> where
Data: FactoryPrototype<Factory = Self, View = View>,
View: FactoryView<Data::Root> + FactoryListView<Data::Root>,
<Data as FactoryPrototype>::Root: Clone,
type Key = DynamicIndex
type Key = DynamicIndex
Key that provides additional information for the FactoryPrototype
functions.
Auto Trait Implementations
impl<Data> !RefUnwindSafe for FactoryVecDeque<Data>
impl<Data> !Send for FactoryVecDeque<Data>
impl<Data> !Sync for FactoryVecDeque<Data>
impl<Data> Unpin for FactoryVecDeque<Data> where
Data: Unpin,
<<Data as FactoryPrototype>::View as FactoryView<<Data as FactoryPrototype>::Root>>::Root: Unpin,
<Data as FactoryPrototype>::Widgets: Unpin,
impl<Data> !UnwindSafe for FactoryVecDeque<Data>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more