212 results for "":
Small strings in Rust
Hey everyone!
This article is brought to you by a shameless nerd snipe, courtesy of Pascal.
In case you’ve blocked Twitter for your own good, this reads:
There should be a post explaining and comparing smolstr and smartstring (and maybe others, like smallstr)
Well, I took the bait.
But, since this is me writing, I get to set the rules:
- There will be no “maybe others” - we’ll review just the first two
A half-hour to learn Rust
In order to increase fluency in a programming language, one has to read a lot of it.
But how can you read a lot of it if you don’t know what it means?
In this article, instead of focusing on one or two concepts, I’ll try to go through as many Rust snippets as I can, and explain what the keywords and symbols they contain mean.
Ready? Go!
Variable bindings
Working with strings in Rust
There’s a question that always comes up when people pick up the
Rust programming language: why are there two
string types? Why is there String
, and &str
?
My Declarative Memory Management article answers the question partially, but there is a lot more to say about it, so let’s run a few experiments and see if we can conjure up a thorough defense of Rust’s approach over, say, C’s.
rock 0.9.8 is out
A little less than two months after the previous release, I’m happy to announce
that the ooc compiler rock 0.9.8, codename columbia
is now out.
The impatients can readily skip to the release notes, but for those who prefer a narrative, let me tell you why I’m excited about this release.
String interpolation
We’ve thrown around this idea a lot since the early versions of rock since we have a few rubyists in our ranks, but only recently Alexandros Naskos took matters into his own hands and just implemented the fuck out of it.
Finding the default network interface through WMI
Let’s set aside our sup
project for a while.
Don’t get me wrong - it’s a perfectly fine project, and, were we simply rewriting “ping” for Windows in Rust, we could (almost) stop there.
We’re currently using the operating system’s facility to speak ICMP, which is great for a bunch of reasons: we can be sure that whatever flaws there are in the implementation, all “native” Windows programs suffer from it as well.
Image decay as a service
Since I write a lot of articles about Rust, I tend to get a lot
of questions about specific crates: “Amos, what do you think of oauth2-simd
?
Is it better than openid-sse4
? I think the latter has a lot of boilerplate.”
And most of the time, I’m not sure what to responds. There’s a lot of crates out there. I could probably review one crate a day until I retire!
Implementing "Log in with GitHub"
Because I started accepting donations via GitHub Sponsors, and because donating at the “Silver” tier or above gives you advance access to articles and your name in the credits, I need to interface with the GitHub API the same way I do the Patreon API.
Because I’d rather rely on third-party identity providers than provide my own
sign up / log in / password forgotten / 2FA flow, user identifiers on my website
are simply {provider}:{provider_specific_user_id}
:
Abstracting away correctness
I’ve been banging the same drum for years: APIs must be carefully designed.
This statement doesn’t resonate the same way with everyone. In order to really understand what I mean by “careful API design”, one has to have experienced both ends of the spectrum.
But there is a silver lining - once you have experienced “good design”, it’s really hard to go back to the other kind. Even after acknowledging that “good design” inevitably comes at a cost, whether it’s cognitive load, compile times, making hiring more challenging, etc.
One funny way to bundle assets
There’s one thing that bothers me. In part 1, why are we using
hyper-staticfile
? Couldn’t we just use file:///
URLs?
Well, first off: showing off how easy it is to serve some static files, even in a “scary” language like Rust, is just not something I could pass up.
But also: think about distributing salvage
as a tool. Will we want to
distribute all those HTML/CSS/JS/font files alongside it?
Highlighted code in slides
I have obsessed about this long enough, I think it’s only fair I (and you!) get some content out of it.
When I started writing this article, I was working on my P99 CONF slides. Those slides happen to include some bits of code. And because I’m a perfectionist, I would like this code to be syntax highlighted, like this:
let addr: SocketAddr = config.address.parse()?;
let ln = TcpListener::bind(&addr).await?;
info!("🦊 {}", config.base_url);