-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't create IterTable with header row #465
Comments
Really sorry for late response. It would suppose to work something like this use tabled::settings::style::HorizontalLine;
use tabled::settings::Style;
use tabled::tables::IterTable;
fn main() {
let data = [1, 2, 3];
let iter = iter::once([String::from("x"), String::from("x * 2")])
.chain(data.iter().map(|n| [n.to_string(), (n * 2).to_string()]));
let style = Style::sharp().horizontals([(1, HorizontalLine::inherit(Style::modern()))]);
let table = IterTable::new(iter).with(style);
table.build(std::io::stdout().lock()).unwrap();
println!();
} But unfortunately ... it was chosen to remove some capabilities of Anyhow, now I am thinking probably we could do this, with little penalty, maybe in all cases? Do you test use std::iter::{self, FromIterator};
use tabled::settings::style::HorizontalLine;
use tabled::settings::Style;
use tabled::Table;
fn main() {
let data = [1, 2, 3];
let iter = iter::once([String::from("x"), String::from("x * 2")])
.chain(data.iter().map(|n| [n.to_string(), (n * 2).to_string()]));
let style = Style::sharp().horizontals([(1, HorizontalLine::inherit(Style::modern()))]);
let table = Table::from_iter(iter).with(style).to_string();
println!("{table}");
} So what do you think, It's not a hard change, the question just is it worth those a few ifs we will add 😄 Have a great weekend, |
In any case it would need to be mentioned somewhere till then for sure. |
Originally I think the issue was that For example imagine you set a line somewhere on the But see it's kind of was decided to not to back then. |
Hello. I'm having trouble getting an
IterTable
with a header row. Initially, I tried:Expected:
Actual result:
Then, I tried using
ColumnNames
:but that fails with:
Any ideas?
The text was updated successfully, but these errors were encountered: