File: basic.rs

package info (click to toggle)
rust-term-grid 0.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid
  • size: 108 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 489 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extern crate term_grid;
use term_grid::{Grid, GridOptions, Direction, Filling};

fn main() {
    let mut grid = Grid::new(GridOptions {
        direction:  Direction::TopToBottom,
        filling:    Filling::Spaces(2),
    });

    for i in 0..40 {
        grid.add(format!("{}", 2_isize.pow(i)).into())
    }

    if let Some(grid_display) = grid.fit_into_width(40) {
        println!("{}", grid_display);
    }
    else {
        println!("Couldn't fit grid into 40 columns!");
    }
}