openedu101 / rust-bootcamp-2024

Apache License 2.0
35 stars 13 forks source link

Rust Functions - Phân biệt `pub`, `pub(crate)` , `pub(super)` khi định nghĩa 1 hàm trong Rust #5

Open CocDap opened 7 months ago

CocDap commented 7 months ago

Ví dụ: Sử dụng pub

pub fn foo() {}

Sử dụng mặc định

fn bar() {}

Sử dụng pub(crate)

pub(crate) fn baz() {}

Sử dụng pub(super)

pub(super) fn bazz(){}
zrus commented 7 months ago
phapdev commented 7 months ago

@zrus thêm tí ví dụ thì tuyệt vời