Skip to content

Commit

Permalink
feat: add workspace example with foo and utils packages
Browse files Browse the repository at this point in the history
  • Loading branch information
katopz committed Feb 13, 2025
1 parent 8bf8376 commit 8347d4a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/r5/workspace-example/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions examples/r5/workspace-example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[workspace]

members = [
"utils",
"foo"
]
7 changes: 7 additions & 0 deletions examples/r5/workspace-example/foo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[dependencies]
utils = { path = "../utils" }
5 changes: 5 additions & 0 deletions examples/r5/workspace-example/foo/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use utils::add;

fn main() {
println!("{:?}", add(1, 2));
}
6 changes: 6 additions & 0 deletions examples/r5/workspace-example/utils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "utils"
version = "0.1.0"
edition = "2021"

[dependencies]
14 changes: 14 additions & 0 deletions examples/r5/workspace-example/utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pub fn add(left: u64, right: u64) -> u64 {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}

0 comments on commit 8347d4a

Please sign in to comment.