If you want a "single file crate" you do something like this:
// Cargo.toml
[package]
name = "function"
version = "0.1.0"
edition = "2021"
[lib]
path = "function.rs"
With a file layout like this:
cargoworkspace
├── Cargo.toml // add a path dependency here to your "function" crate
├── function
│ ├── Cargo.toml // the config above
│ └── function.rs
└── src
└── main.rs
because it is a very small function that i feel has no need to come with a Cargo.toml, Cargo.lock, src directory and a .git directory. however, it can be shared across multiple projects.