let x = y
moves y
to x
. let &x = &y
takes reference to y
, dereferences it and puts result into x
y
implements Copy
or if x
itself is pattern with ref
. In those cases let &x = &y
and let x = y
are same.
let &x = &y
is identical to let x = *&y
. And almost the same as let x = y
format
is not compatible with no_std
, because it creates a String, and String are non no_std, because they allocate. However, I think that write!
macro might be available in no_std environments
impl Into<String> for Error {
fn into(self) -> String {
match self {
Error::Validation(s) => s,
Error::Instantiation(s) => s,
Error::Function(s) => s,
Error::Table(s) => s,
Error::Memory(s) => s,
Error::Global(s) => s,
Error::Value(s) => s,
Error::Trap(s) => write!("trap: {:?}", s),
Error::Host(e) => write!("user: {}", e),
}
}
}
It's told me s format argument must be a string literal.
use alloc::string::String;
{ let mut buff = String::new(); write!(buff, "foo")}
mod.rs
:sweat_smile: I thought it was kinda neat to be able to read basically anyone's code, look into mod.rs
and immediately see what's being exported and a rough overview of how the module was supposed to work
$module_name/mod.rs
, as before, or $module_name.rs
@tanriol Oh you mean the structure could be
main.rs
my_mod/
bla.rs
my_mod.rs
?
mod.rs
. Not both :-)
clippy
will have lints on this matter :-)
mod.rs
support would (a) need to happen on an epoch transition, (b) require everyone to go and move files in their source. Not exactly nice :-)
mod.rs
how do you handle mutiple files in the same module?
foo
with submodules, you can just move src/foo/mod.rs
to src/foo.rs
without changing anything else.
mod.rs
and use folder::module
directly
mod.rs
in the folder or folder.rs
outside to contain pub mod module;
foo.rs
contain pub mod foo
feels super awkward 😅
foo/mod.rs
file ergonomics wise
// lib.rs
mod foo;
use foo::bar;
// foo.rs
pub mod bar;
// foo/bar.rs
struct WhatIWantToSeeHere;
foo.rs
to foo/mod.rs
when you want to add submodules. Oh, and if your editor shows just the filename, you won't have to guess which mod.rs
this one is.
mod.rs
for modules that only do disjointed things :sweat_smile:
mod
declarations, but not in the final RFC.
cp file.rs broken_file_bak.rs
, then I probably don't want that thing to get compiled in.
mod foo
for a module where foo/mod.rs
or foo.rs
doesn't exist loads into scope all public things from foo/*.rs
files
mod
statements into the module root file
map_err
from Result
execute lazily? I see the or_else
but i want access to the error before I map it. thank you!
Result
is an error like or_else
map_err
does nothing if the Result
is not an error