New system import


#1

Hi,
Is it possible to import module syntax

main.rs
foo/a.rs
foo/bar/b.rs

in main.rs

import foo/a
import foo/bar/b as b

#2

What do you mean by import module syntax?
Sub-module in the same crate is declared via mod foo. And importing its contents is done via use foo::bar.
See https://doc.rust-lang.org/stable/book/crates-and-modules.html for details.


#3

I suggest that instead of use, mod, extern crate, lib.rs, mod.rs simply use import, like С


#4

TL;DR: there will be no import. use for import symbol, mod for declaring that there’s a module.

You seem to confuse several things.

  1. There’s no ‘import’ in C. There’s only #include via preprocessor
  2. Rust core is stabilized. So:
    a. To explicitly use other crate, you need to use extern crate
    b. mod construct does not import anything, but instead declares that current crate will be compiled with specified module or submodule
    c. use is a unified way to import any symbol into current scope, regardless of whether it’s from other crate, submodule etc.