flextablev0.1.0

Getting Started

Installation

Add flextable to a Rust project and check that everything works.

Before you start#

These docs assume you are comfortable with basic Rust: ownership and borrowing, Result and the ? operator, and iterators. Knowing Rc and RefCell helps explain why tables behave like shared references, but it is not required.

About the examples

Every Rust example in these docs is compiled and run against the library, so the assert_eq! lines are real results. Examples that use ? are assumed to sit inside a function that returns a Result.

Requirements#

  • A Rust toolchain with Cargo. The crate uses the 2021 edition and is tested on current stable Rust on Linux and Windows.
  • No system libraries. The only dependency is hashbrown, which Cargo fetches for you.

Add the dependency#

From your project's folder, run:

Terminal
cargo add flextable

That adds the latest version from crates.io to your Cargo.toml:

Cargo.toml
[dependencies]
flextable = "0.1"

You can also write that line by hand; Cargo downloads the crate on the next build.

Check that it works#

Replace src/main.rs with:

src/main.rs
use flextable::Table;

fn main() {
    let t = Table::new();
    t.push("hello").unwrap();
    t.push("table").unwrap();
    println!("{}", t.concat(", ").unwrap());
}

Then run it:

Terminal
cargo run
Output
hello, table

What to import#

Everything is re-exported from the crate root. Most code needs only the first three:

ImportUse it for
TableThe table itself.
ValueA dynamic value read from or stored in a table.
table!Building tables with literal syntax.
Error, ResultHandling the failures a table operation can report.
Key, KeyRef, AsKeyWorking with keys directly, which most code never needs.