Lock a Rust dependency to a specific version in Cargo.toml using the equals sign operator.
Specify exact dependency versions in your Cargo.toml file by using the = operator before the version number. This forces Cargo to use only that specific version, ignoring newer patch or minor updates.
[dependencies]
serde = "=1.0.193"
Alternatively, you can use a caret (^) with a full version string to lock to a specific minor version range, but = is the strictest method for an exact match.
Specifying exact dependency versions in Rust tells your project to use one specific version of a library and nothing else. It is like ordering a specific part number for a machine; you get exactly that part, not a newer or slightly different one. You use this when you need to guarantee your code works exactly as tested without any surprises from automatic updates.