News for hackers. Stuff that matters.
Re:Learning Rust – Day 4 – Understanding Modules by sophacles on Thursday May 12, 2022 @11:52AM (#31355908)
I don't think it's "so different". Lets look at rust v some other common languages:

rust:

top-level for a crate: lib.rs

module: $modulename.rs or $modulename/mod.rs or a `mod $modulename` block in lib.rs

sub_module: $parent/$sub_module.rs or $parent/$sub_module/mod.rs or a `mod $sub_module` block in $parent/mod.rs

python:

top-level: have the right directory or file in python path

module: $module_name.py or $module_name/__init__.py

sub_module: $parent/$submodule.py or $parent/$submodule/__init__.py

ruby:

top level: have the right file or directory in import path

module: $libname.rb with `module $libname` block

submodule $libname/$submodule.rb with `module $submodule` block

go:

top-level: somewhere in gopath have dir $module that declares `package $module` (convention, you could have a different package name)

module: all files in $module_name that declare `package $module_name`

module: $moddir/$submodule where module files declare `package $submodule`

It's not wildy different. Whats this FUD about?

There are no comments on this comment yet.