rust中使用本地lib

定义lib接口

新建一个lib工程,目录结构如下:

在lib.rs中定义如下函数:

pub fn foo(){
    println!("lib pub foo get called")
}

pub fn foo_indirect(){
    foo_private()
}

fn foo_private(){
    println!("lib private foo get called indirect")
}

foo和foo_indirect通过pub修饰,是对外可见的接口。foo_private没有pub修饰,是私有内部函数

在其他项目中使用该lib

定义依赖项,这里要指定正确的文件路径名:

[dependencies]
mylib = {path = "../../mylib"}

通过use关键字引入库:

use mylib;
fn main() {
    mylib::foo();
    //mylib::foo_private(); //执行错误
    mylib::foo_indirect();
}


《 “rust中使用本地lib” 》 有 3 条评论

  1. Mechanisms of Ca 2 transport in the intestine and kidney can i order cheap cytotec In contrast to the potent action of tamoxifen on both glioma and breast cancer cells, tamoxifen had no significant effects on astrocytic calcium signaling

  2. Compared to supplementation with milk protein, consumption of a diet supplemented with soy protein isolate high in isoflavones 107 mg day limited the rise in androgen receptor density in prostate tissue after six months but did not modify prostatic estrogen receptor ОІ expression or circulating sex steroid hormone profile in men at high risk of developing prostate cancer 45 60mg priligy At later postnatal stages, dorsal and ventral skin of K14 Cre52; Bmpr1a cl cl and K14 Cre40; Bmpr1a cl cl mice, and mid ventral skin of bcre 32; Bmpr1a cl null mice, showed striking defects in hair follicle morphology

  3. GO analyses and KEGG pathways enrichment results were based on the following A Biological Processes; B Cellular Components; C Molecular Functions; D KEGG pathways generic priligy online Lentivirus Human Single polycistronic lentiviral vector for the expression of human Oct4, Klf4, Sox2, and

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

About Me

一位程序员,会弹吉他,喜欢读诗。
有一颗感恩的心,一位美丽的妻子,两个可爱的女儿
mail: geraldlee0825@gmail.com
github: https://github.com/lisuxiaoqi
medium: https://medium.com/@geraldlee0825