.tool-versions in Rust
A Rust library for parsing and manipulating .tool-versions files used by asdf and compatible version managers.
Usage
use ToolVersions;
// Parse from string
let content = "erlang 27.3.4.6\nruby 3.4.1";
let tv = parse?;
// Get a tool's version
assert_eq!;
// Load from a file, modify, and save back
let mut tv = load?;
tv.set;
tv.save?;
// Load or create if the file doesn't exist
let mut tv = load_or_default?;
tv.set;
tv.save?;
// Iterate over all tools
for in &tv
// Convert to a HashMap
use HashMap;
let map: = tv.into;
// Build from a HashMap
let mut map = new;
map.insert;
map.insert;
let tv: ToolVersions = map.into;
// Collect from an iterator
let tv: ToolVersions = .into_iter.collect;
Features
- Parse
.tool-versionsfiles preserving comments and blank lines - Get, set, and remove tool versions
- Round-trip editing (preserves file structure)
- Convert to/from
HashMapandBTreeMap - Iterate, collect, and extend using standard traits
- Optional serde support with the
serdefeature
Serde Support
Enable the serde feature for serialization support:
[]
= { = "1.0", = ["serde"] }
License
This library is double-licensed under the MIT License and the Apache License, Version 2.0.
Copyright
(c) 2025-2026 Michael S. Klishin and Contributors.