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.
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:
cargo add flextableThat adds the latest version from crates.io to your 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:
use flextable::Table;
fn main() {
let t = Table::new();
t.push("hello").unwrap();
t.push("table").unwrap();
println!("{}", t.concat(", ").unwrap());
}Then run it:
cargo runhello, tableWhat to import#
Everything is re-exported from the crate root. Most code needs only the first three:
| Import | Use it for |
|---|---|
Table | The table itself. |
Value | A dynamic value read from or stored in a table. |
table! | Building tables with literal syntax. |
Error, Result | Handling the failures a table operation can report. |
Key, KeyRef, AsKey | Working with keys directly, which most code never needs. |