There are a few I'm aware of:

  1. Rust-style use (multiple imports per statement, renaming items using as)
  2. Java-style import (single import per statement, no renaming (afaik))
  3. Zig-style let xlib = @import("xlib") (imports as assignments)
  4. C-style #include (no importing, just pastes the code of the named file)
you are viewing a single comment's thread
view the rest of the comments
[–] 4 points 1 day ago (1 child)

It's actually pretty similar to rust, only that rust can import multiple modules (namespaces) in one line, which is just syntax sugar, and the syntax is slightly different.

Your example would be

use my_projext::domain::entities;
use my_project::api::contracts::routes::http as routes;
  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 1 day ago

    Rust adds the curly brace syntax so you can import a specific subset from a module, but I can’t decide if I like that. In C# you just keep adding extra lines which take up more vertical space, but if you sort your using a alphabetically (which your IDE can do), I think you get a very readable list. In sum, Rust adds a feature that I don’t really actually like.

  • source
  • parent