- 0 Posts
- 14 Comments
RunAwayFrog@sh.itjust.worksto
Rust@programming.dev•If you feel that you need a Rust replacement for 'ls', that apparently exists
3·2 years agoexa(which OP’s readme saysezais built on) supports creation times. Actual creation time (the “Birth” line instatoutput), notctime.
--all-featuresdoesn’t work with that particular crate because two of the features conflict with each other. The features list in my command is the one used for docs.rs from the crate’sCargo.toml.
are there any hurdles or other good reasons to not just adding this to every create?
I’m no expert. But my guess would be that many crate authors may simply not be aware of this feature. It wasn’t always there, and it’s still unstable. You would have to reach the “Unstable features” page of the rustdoc book to know about it.
Or maybe some know about it, but don’t want to use an unstable feature, or are just waiting for it to possibly automatically work without any modifications.
Of course, I would assume none of this applies to the
embassydevs. ThatCargo.tomlfile has aflavorsfield, which is something I’ve never seen before 😉 So, I’m assuming they are way more knowledgable (and up-to-date) about the Rust ecosystem than me.
So, this is being worked on. But for now, that crate needs this line in
lib.rs#![cfg_attr(docsrs, feature(doc_auto_cfg))]And this line in
Cargo.toml’s[]section:rustdoc-args = ["--cfg", "docsrs"]With these changes, feature gating will be displayed in the docs.
To replicate this locally:
RUSTDOCFLAGS='--cfg docsrs' cargo doc --features=nightly,defmt,pender-callback,arch-cortex-m,executor-thread,executor-interrupt
I constantly seem to include something from the docs, only to be told by the compiler that it does not exist, and then I have to open the source for the create to figure out if it’s hidden behind a feature flag.
As others mentioned, the situation is not perfect. And you may need to check
Cargo.toml. Maybe even the source.But as for the quoted part above, the docs should definitely indicate if a part of the API is behind a feature. Let’s take
rustixas an example.Here is the module list:

Here is the view from inside a module:

Here is the view from a function page:

This is also true for platform support. Take this extension trait from
std:
Now, it’s true that one could be navigating to method docs in the middle of a long doc page, where those indicators at the top may be missed. But that’s a UI issue. And it could be argued that repeating those indicators over and over would introduce too much clutter.
RunAwayFrog@sh.itjust.worksto
Rust@programming.dev•What should the getter for a Vec|String| return, &[&str]? What about Option|Vec|String||?
4·2 years agoNote: the ᐸᐳ characters used below are Canadian Aboriginal syllabics because Lemmy devs haven’t fixed broken input sanitization yet.
Well, getters are not an official concept in Rust. You can do whatever works best in your case.
Just worth pointing out that a method with a return value of
OptionᐸVecᐸStringᐳᐳwouldn’t be really a getter, as you must be constructing values, or moving ownership, or cloning. None of these actions conceptually belong to a getter.Also, you should be clear on the what the
Optionabstraction means. Does it mean the vector is empty? Does it mean the vector does not exist or some sort of null (FFI ore serialization contexts)? And make sure the code does what you expect it to do.
RunAwayFrog@sh.itjust.worksto
Rust@programming.dev•New to Rust: How does Rust handle dynamic libraries
1·2 years agoIf you were on GNU/Linux, my answer to your questions would have had nothing to do with Rust. It would have involved tools like
readelfandldd, maybestrace.So, maybe check out what equivalent tools exist on Windows, and try using them.
- I would drop the derive shorthands, and drop the
Cypherprefix from the derive macros. They are already namespaced under the crate. - Regarding the
ty::new()impls, I’m not a hardline devotee of the builder pattern, but when there are multiple private fields of the same type, I would absolutely prefer it, to remove the possibility of field-value confusion at construction.
I didn’t dig deeper because I noticed you posted this to Reddit first 😉
- I would drop the derive shorthands, and drop the
RunAwayFrog@sh.itjust.worksto
Rust@programming.dev•What popular crates are available to build GUIs with widgets WITHOUT GPU?English
141·3 years agoFunny you should mention that. I think
icedas of four days ago can do this!If I’m reading the release notes and
Cargo.tomlright,cargo add iced --no-default-featuresand you should be good to go, astiny-skiawill be used as a rendering backend instead ofwgpu.
RunAwayFrog@sh.itjust.worksto
Rust@programming.dev•Can I make Result<T, E> an integer?English
31·3 years agoDiscriminant is irrelevant and you’re not supposed to fuck with it.
And there is zero reason to use unsafe/transmute for this.
pub enum LibErr { ErrX, ErrY, ErrZ, Unknown(i32), } struct RetVal(i32); impl From<RetVal> for Result<i32, LibErr> { fn from(RetVal(ret_val): RetVal) -> Self { if ret_val < 0 { match ret_val { -1 => Err(LibErr::ErrX), -2 => Err(LibErr::ErrY), -3 => Err(LibErr::ErrZ), unknown => Err(LibErr::Unknown(unknown)), } } else { Ok(ret_val) } } } // RetVal(call_function()).into()
RunAwayFrog@sh.itjust.worksto
Fediverse@lemmy.ml•PSA: Lemmy.world has been compromised! (Edit: Multiple Instances are down)English
13·3 years agoDon’t know if this will be relevant at all, but I’m almost hoping this will force Lemmy devs to abandon the obscure markdown crate they use for pulldown-cmark.
Using an obscure markdown implementation just because it supports spoiler tags always sounded like a silly decision to me!
RunAwayFrog@sh.itjust.worksto
Asklemmy@lemmy.ml•Are you replacing Reddit with Lenny?English
1·3 years agoI won’t be able to fully replace it, I’m afraid. Not before communities gain the ability for their posts to not show up in high traffic feeds.
Some subreddits I follow have this set, but this is not yet implemented in Lemmy if I’m not mistaken. So a workable move to Lemmy for them is not possible at this moment.
Here is an originally random list (using
cargo tree --prefix=depth) with some very loose logical grouping. Wide-scoped and well-known crates removed (some remaining are probably still known by most).mime data-encoding percent-encoding textwrap unescape unicode-width scraper arrayvec bimap bstr enum-iterator os_str_bytes pretty_assertions paste clap_complete console indicatif shlex lz4_flex mpeg2ts roxmltree speedy aes base64 hex cbc sha1 sha2 rsa reverse_geocoder trust-dns-resolver signal-hook signal-hook-tokio blocking fs2 semver snmalloc-rs