These are chat archives for rust-lang/rust

31st
Dec 2016
Matanel Levi
@matanelevi
Dec 31 2016 03:04
@matklad From what you've said, this is why you can write std::io::readline without use std? Since std is implicitly injected in the code?
Peter Atashian
@retep998
Dec 31 2016 03:59
@matanelevi There is an implicit extern crate std; at the root of your crate (unless you specify #![no_std])
So you can only refer to std::io::readline if you're in the crate root. Inside a submodule you'd have to refer to it as ::std::io::readline, because paths are relative to the current module
Except for use statements which are relative to the crate root
Matanel Levi
@matanelevi
Dec 31 2016 14:18
@retep998 i dont get why so you need these extra ::? What do they mean?
Peter Atashian
@retep998
Dec 31 2016 14:25
@matanelevi :: at the beginning of a path refers to the root of your crate
the root of the crate is the top-level module.
use foo; statements are relative to the crate root by default so use ::foo; is always equivalent to use foo;.
But simply referring to foo anywhere else is relative to the current module, so if you want it from the crate root you have to be explicit by referring to it as ::foo.
Matanel Levi
@matanelevi
Dec 31 2016 14:37
Thanks for the detailed explanation!
@retep998 :smile:
Matanel Levi
@matanelevi
Dec 31 2016 18:30
Rust's Pattern Matching saves information about types in the produced binary? (strings / some other things?)
Diggory Blake
@Diggsey
Dec 31 2016 18:31
not exactly - rust enums have a determinant, which is just an integer identifying which variant of the enum is in use
when you pattern match, it's just comparing the determinant against the known values