Skip to content

the sixty second snippet, compiled and run as it is printed - #318

Merged
tamnd merged 1 commit into
mainfrom
sixty-seconds
Aug 18, 2026
Merged

tamnd merged 1 commit into
mainfrom
sixty-seconds

Conversation

@tamnd

@tamnd tamnd commented Aug 18, 2026

Copy link
Copy Markdown
Owner

DX2 (#168): the 60-second snippet works verbatim in Python and Rust. This is the Rust half; the Python half is tamnd/zu-python#11, merged.

A quickstart is the most read and least compiled code a project has. It lives in a README, it is copied by hand, and it goes wrong quietly, a rename at a time, until a reader's first five minutes go on an error message instead of on a database. So the snippet is a program here.

crates/zu-snippets/examples/sixty-seconds.rs is the program the README prints, and crates/zu-snippets/tests/readme.rs holds the page to it character for character and then runs it. Both halves matter and the second is the one with teeth: compiling proves the names still exist, running proves the statements in it still parse, the file it writes still opens, and the two lines the page claims it prints are the two lines it prints. It runs in a temporary directory, because a reader runs it in the directory they are standing in and finds social.zu1 beside them afterwards.

The package is a package because a crate cannot depend on itself under a second name, and the snippet has to say zudb: that is what a reader types after cargo add zudb, and it is not what this crate is called in this workspace. So the snippets live one level out, depend on zudb = { package = "zu", path = "../zu" }, and read exactly as a reader's file does.

The README gains a ## Sixty seconds section holding the program, a sentence on why create is not open, and a pointer to the same sixty seconds in Python. crates/zu/benches/convert.rs is reformatted, which is nothing to do with any of this and is what cargo fmt --all --check wants on main today.

Local: make lint, make test, cargo xtask terms, api-map and repos all green.

A quickstart is the most read and least compiled code a project has. It
lives in a README, it is copied by hand, and it goes wrong quietly, a
rename at a time, until a reader's first five minutes go on an error
message instead of on a database.

So the snippet is a program. crates/zu-snippets holds it as an example
and a test holds the README to it character for character, then runs it
in a directory of its own and checks what it printed. Compiling proves
the names still exist; running proves the statements still parse, the
file still opens and the two lines on the page are the two lines it
prints.

The package exists because a crate cannot depend on itself under a
second name, and the snippet has to say `zudb`, which is what a reader
types after `cargo add zudb` and not what this crate is called in this
workspace.

crates/zu/benches/convert.rs is reformatted, which is nothing to do with
any of this and is what `cargo fmt --all --check` wants.
@tamnd
tamnd merged commit 37f8fee into main Aug 18, 2026
33 checks passed
@tamnd
tamnd deleted the sixty-seconds branch August 18, 2026 08:26
@tamnd tamnd mentioned this pull request Aug 18, 2026
20 tasks
tamnd added a commit that referenced this pull request Aug 19, 2026
A quickstart is the most read and least compiled code a project has. It
lives in a README, it is copied by hand, and it goes wrong quietly, a
rename at a time, until a reader's first five minutes go on an error
message instead of on a database.

So the snippet is a program. crates/zu-snippets holds it as an example
and a test holds the README to it character for character, then runs it
in a directory of its own and checks what it printed. Compiling proves
the names still exist; running proves the statements still parse, the
file still opens and the two lines on the page are the two lines it
prints.

The package exists because a crate cannot depend on itself under a
second name, and the snippet has to say `zudb`, which is what a reader
types after `cargo add zudb` and not what this crate is called in this
workspace.

crates/zu/benches/convert.rs is reformatted, which is nothing to do with
any of this and is what `cargo fmt --all --check` wants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant