From c3f2e9ad9c291cbed87bf9ff7d2bdeb068dbadf7 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 17 Jan 2018 11:07:04 -0800 Subject: [PATCH] Add LinearLayout::get_child and get_child_mut --- src/views/linear_layout.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/views/linear_layout.rs b/src/views/linear_layout.rs index 22fa701..9047859 100644 --- a/src/views/linear_layout.rs +++ b/src/views/linear_layout.rs @@ -160,6 +160,16 @@ impl LinearLayout { LinearLayout::new(direction::Orientation::Horizontal) } + /// Returns a reference to a child. + pub fn get_child(&self, i: usize) -> Option<&View> { + self.children.get(i).map(|child| &*child.view) + } + + /// Returns a mutable reference to a child. + pub fn get_child_mut(&mut self, i: usize) -> Option<&mut View> { + self.children.get_mut(i).map(|child| &mut *child.view) + } + // If the cache can be used, return the cached size. // Otherwise, return None. fn get_cache(&self, req: Vec2) -> Option {