Здравствуйте, залез в исходники фреймворка rocket Rocket уже работает с stable версией раста, но а вот что что конкретно в этих местах значат слова crate - я такого не знаю, ну и быстрым гуглением не выяснил.
Просьба объяснить или дать ссылку на документацию. Большое Спасибо
Там небольшое описание, на всяк переспрошу (если вы досконально поняли)
Это просто область видимости запрещающая доступ к структуре не из ящика (crate), Ну и в данном случае crate это наверное rocket?
Видимо да. Я сам такими модификаторами никогда не пользовался. Вот что пишут в The Rust Reference:
In addition to public and private, Rust allows users to declare an item as visible within a given scope. The rules for pub restrictions are as follows:
pub(in path) makes an item visible within the provided path . path must be a parent module of the item whose visibility is being declared.
pub(crate) makes an item visible within the current crate.
pub(super) makes an item visible to the parent module. This is equivalent to pub(in super) .
pub(self) makes an item visible to the current module. This is equivalent to pub(in self) .
pub mod a {
struct Priv(i32);
pub(crate) struct R { pub y: i32, z: Priv } // ok: field allowed to be more public
pub struct S { pub y: i32, z: Priv }
pub fn to_r_bad(s: S) -> R { ... } //~ ERROR: `R` restricted solely to this crate
pub(crate) fn to_r(s: S) -> R { R { y: s.y, z: s.z } } // ok: restricted to crate
}
use a::{R, S}; // ok: `a::R` and `a::S` are both visible
pub use a::R as ReexportAttempt; //~ ERROR: `a::R` restricted solely to this crate
Crate c2:
extern crate c1;
use c1::a::S; // ok: `S` is unrestricted
use c1::a::R; //~ ERROR: `c1::a::R` not visible outside of its crate