cursive/src/view/identifiable.rs

18 lines
456 B
Rust
Raw Normal View History

use views::IdView;
use view::View;
/// Makes a view wrappable in an [`IdView`].
///
/// [`IdView`]: ../views/struct.IdView.html
pub trait Identifiable: View + Sized {
/// Wraps this view into an IdView with the given id.
2016-09-21 01:32:31 +00:00
///
/// This is just a shortcut for `IdView::new(id, self)`
fn with_id(self, id: &str) -> IdView<Self> {
IdView::new(id, self)
}
}
2016-09-21 01:32:31 +00:00
/// Any `View` implements this trait.
impl<T: View> Identifiable for T {}