This is an example of creating a workspace got from rust offical doc.

Create workspace directory.

1
2
$ mkdir add
$ cd add

create the adder binary crate

  1. Add member adder in Cargo.toml

1
2
3
4
5
[workspace]

members = [
    "adder",
]
  1. Generate code by using cargo new

1
2
$ cargo new adder
     Created binary (application) `adder` package

Create the add_one library crate

  1. Add member add_one in Cargo.toml

1
2
3
4
5
6
[workspace]

members = [
    "adder",
    "add_one",
]
  1. Generate code by using cargo new

1
2
$ cargo new add_one --lib
     Created library `add_one` package

Ref