kas 0.0.1

GUI Toolkit Abstraction System
Documentation
// widget/mod.rs

/// Widget set trait
pub trait WidgetSet {
    /// The number of widgets in the set
    fn len(&self) -> usize;
    
//     /// Get a widget by index
//     fn get(&self, index: usize) -> Option<&Widget>;
//     
//     /// Mutably get a widget by index
//     fn get_mut(&mut self, index: usize) -> Option<&mut Widget>;
    
    /*
    /// Iterate over widgets
    /// 
    /// The default implementation is built using `len` and `get`.
    fn iter(&self) -> impl Iterator<Item = &Widget> {
        (0..self.len()).map(|i| self.get(i))
    }
    
    /// Mutably iterate over widgets
    /// 
    /// The default implementation is built using `len` and `get_mut`.
    fn iter_mut(&mut self) -> impl Iterator<Item = &mut Widget> {
        (0..self.len()).map(|i| self.get_mut(i))
    }
    */
}

// widget/event.rs

// pub trait Handler<R> {
//     fn handle(&mut self, widgets: &mut WidgetSet, event: Event) -> R;
// }
// 
// pub struct DefaultHandler<R>;
// 
// impl<R> Handler<R> for DefaultHandler<R> {
//     fn handle(&mut self, widgets: &mut WidgetSet, event: Event) -> R {
//         match event {
//         }
//     }
// }


    /// For convenience, `Index<usize>` is implemented via this method.
    /// 
impl ::std::ops::Index<usize> for Widget + 'static {
    type Output = dyn Widget + 'static;
    fn index<'a>(&'a self, i: usize) -> &'a Self::Output {
        self.get(i).unwrap_or_else(|| panic!("Widget::get: index out of bounds"))
    }
}