A Simple GUI Library

    We will have a number of widgets in our library:

    • : has a title and contains other widgets.
    • Button: has a label and a callback function which is invoked when the button is pressed.

    The widgets will implement a trait, see below.

    The output of the above program can be something simple like this:

    ======== Rust GUI Demo 1.23 ======== This is a small text GUI demo. | Click me! |

    1. fn main() {
    2. println!("centered: |{:/^width$}|", "foo");
    3. println!("right aligned: |{:/>width$}|", "foo");

    Using such alignment tricks, you can for example produce output like this:

    +--------------------------------+ | Rust GUI Demo 1.23 | +================================+ | This is a small text GUI demo. | | +-----------+ | | | Click me! | | | +-----------+ | +--------------------------------+