December 1, 2023/ Last updated : December 2, 2023adminRust Programming
Rust – use an upstream crate
How to import a crate from git in Rust
cargo new mkgrid --lib
❯ tree -L 2
.
├── Cargo.lock
├── Cargo.toml <--- this one
├── mkgrid
│ ├── Cargo.toml x
│ └── src
├── src
│ └── main.rs
└── target
├── CACHEDIR.TAG
└── debug
5 directories, 5 files
[package]
name = "ldem"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
mkgrid = { path = "mkgrid" }
pub fn foo () {
println!("_|_|_");
println!("_|_|_");
println!(" | | ");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
use mkgrid::foo;
fn main() {
println!("Hello, world!");
foo();
}