惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recent Announcements
Recent Announcements
博客园 - 聂微东
B
Blog RSS Feed
人人都是产品经理
人人都是产品经理
U
Unit 42
博客园 - 三生石上(FineUI控件)
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
T
Troy Hunt's Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Schneier on Security
Schneier on Security
AI
AI
T
Tailwind CSS Blog
A
About on SuperTechFans
小众软件
小众软件
云风的 BLOG
云风的 BLOG
Google Online Security Blog
Google Online Security Blog
Forbes - Security
Forbes - Security
WordPress大学
WordPress大学
Martin Fowler
Martin Fowler
Cisco Talos Blog
Cisco Talos Blog
有赞技术团队
有赞技术团队
Recorded Future
Recorded Future
MongoDB | Blog
MongoDB | Blog
B
Blog
The GitHub Blog
The GitHub Blog
IT之家
IT之家
SecWiki News
SecWiki News
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CERT Recently Published Vulnerability Notes
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Know Your Adversary
Know Your Adversary
大猫的无限游戏
大猫的无限游戏
D
Docker
I
Intezer
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
PCI Perspectives
PCI Perspectives
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
V
Vulnerabilities – Threatpost
C
Check Point Blog
The Register - Security
The Register - Security
Scott Helme
Scott Helme
G
GRAHAM CLULEY
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

博客园 - dcrenl

解决CapabilityAccessManager.db-wal 文件过大 Java 应用程序在linux环境中读取和写入 Microsoft Access 数据库(包括 .mdb 和 .accdb 格式)的开源库 windows 版本nginx报错:maximum number of descriptors supported by select() is 1024 while 删除多个网关 dot net6 在win7上运行报错 远程重启服务器 sqlserver 20008 R2 关闭TLS1.0无法启动服务的解决办法 nohup java按天输出日志 idea 社区版本创建android原生项目 解决win11输入法自定义短语有多个当前日期只有最后一个生效 postgresql使用for循环 Win10打开IE自动跳转至Edge解决办法 身份认证与授权 pnpm : 无法加载文件 \AppData\Roaming\npm\pnpm.ps1,因为在此系统上禁止运行脚本。 - dcrenl C# 获取时间戳 win11 输入法自定义短语输出日期时间变量 SM系列国密算法 Opera打不开网页解决办法 excel 数字转中文大写金额 nginx http跳转到https
rust 模块和引用
dcrenl · 2025-10-10 · via 博客园 - dcrenl

rust的模块声明有两种方式:

1、mod.rs文件方式

在 2018 年后的版本中已逐渐被新的模块系统取代,Rust 官方文档中已删除对 mod.rs 的介绍,主要因为该功能在 Rust 1.30 版本后被新的模块命名约定替代。

目录结构为:

backyard
├── Cargo.lock
├── Cargo.toml
└── src
    ├── garden
        ├── mod.rs
    │   └── vegetables.rs
    └── main.rs

mod.rs文件需要写入pub mod vegetables;

main.rs需要写mod garden;才能在main.rs中使用vegetables.rs文件中的方法,例如:crate::garden::vegetables::funxxx()

2、使用文件夹命名管理模块方式

1.30 版本后被推荐写法,但是旧写法目前任然兼容

目录结构为:

backyard
├── Cargo.lock
├── Cargo.toml
└── src
    ├── garden
    │   └── vegetables.rs
    ├── garden.rs
    └── main.rs

需要在garden目录同级目录下创建一个garden.rs文件,内容为pub mod vegetables;
main.rs需要写mod garden;才能在main.rs中使用vegetables.rs文件中的方法,例如:crate::garden::vegetables::funxxx()

两种方式最终生成的模块路径完全一致,避免混合使用两种方式