Что такое в расте в структурах crate struct

Здравствуйте, залез в исходники фреймворка rocket
Rocket уже работает с stable версией раста, но а вот что что конкретно в этих местах значат слова crate - я такого не знаю, ну и быстрым гуглением не выяснил.

Просьба объяснить или дать ссылку на документацию. Большое Спасибо

#[derive(Clone)]
pub struct Request<'r> {
    method: Cell<Method>,
    uri: Origin<'r>,
    headers: HeaderMap<'r>,
    remote: Option<SocketAddr>,
    crate state: RequestState<'r>, // <- и в обычной структуре есть
}

#[derive(Clone)]
crate struct RequestState<'r> {
    crate config: &'r Config,
    crate managed: &'r Container,
    crate path_segments: SmallVec<[Indices; 12]>,
    crate query_items: Option<SmallVec<[IndexedFormItem; 6]>>,
    crate route: Cell<Option<&'r Route>>,
    crate cookies: RefCell<CookieJar>,
    crate accept: Storage<Option<Accept>>,
    crate content_type: Storage<Option<ContentType>>,
    crate cache: Rc<Container>,
}
1 лайк

В ночной сборке есть фича для этого:
#![feature(crate_visibility_modifier)]

В readme.md на https://github.com/SergioBenitez/Rocket написано что он для nightly.

3 лайка

А, спасибо!) Просто область видимости… вместо pub

Там небольшое описание, на всяк переспрошу (если вы досконально поняли)
Это просто область видимости запрещающая доступ к структуре не из ящика (crate), Ну и в данном случае crate это наверное rocket?

P.S. Спасибо за unstable book, я о ней не знал)

Видимо да. Я сам такими модификаторами никогда не пользовался. Вот что пишут в 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) .

Еще есть пример в RFC:

Crate c1:

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
5 лайков