in tools/hakari/src/cli_ops/workspace_ops.rs [295:322]
fn inline_table_for_add(
version: &Version,
dep_format: DepFormatVersion,
path: &Utf8Path,
) -> InlineTable {
let mut itable = InlineTable::new();
// Pass in exact_versions = false because we don't want unnecessary churn in the unlikely
// event that a published workspace-hack version has a minor bump in it.
let version_str = format!("{}", VersionDisplay::new(version, false));
if dep_format == DepFormatVersion::V2 {
itable.insert("version", version_str.into());
}
let mut path = Formatted::new(with_forward_slashes(path).into_string());
if dep_format == DepFormatVersion::V1 {
// Previous versions of `cargo hakari` accidentally missed adding the space to the end
// of the line. Newer versions of toml_edit do that automatically, so restore the old
// behavior.
path.decor_mut().set_suffix("");
}
itable.insert("path", Value::String(path));
if dep_format == DepFormatVersion::V2 {
itable.fmt();
}
itable
}