Skip to content

Instantly share code, notes, and snippets.

View jonhoo's full-sized avatar
🤦‍♂️
Permanent 418 status code.

Jon Gjengset jonhoo

🤦‍♂️
Permanent 418 status code.
View GitHub Profile
@jonhoo
jonhoo / abstract.md
Created January 10, 2023 02:45
Living with Rust Long-Term abstract

Living with Rust Long-Term

Rust and its ecosystem are, seemingly, in constant flux. And this appearance of perpetual motion can be scary, especially when you're building an application with stability and long-term project sustainability in mind. New Rust versions bring ever-higher editions, must-have new features, and lint and tool changes to keep on top of. And as new features get adopted, new crates and major versions emerge, leaving once-vibrant ecosystems to fade into oblivion. All this happens while the software ecosystem surrounding and underpinning Rust continues its relentless march forward.

In this talk, we'll take a look at the kinds of changes that may happen under you when working with Rust and how to live with them. We'll talk about Rust and crate versioning, but also backwards compatibility, unstable features, minimum supported Rust versions, and 1.0 releases. This talk is geared towards those using Rust to build applications and services, not those building Rust libraries. It won't tell you

[START][2022-12-02 20:14:20] LSP logging initiated
[INFO][2022-12-02 20:14:20] .../vim/lsp/rpc.lua:261 "Starting RPC client" {
args = {},
cmd = "rust-analyzer",
extra = {
cwd = "/local/home/jongje/dev/tmp/consumer-of-needs-nightly"
}
}
[TRACE][2022-12-02 20:14:20] .../lua/vim/lsp.lua:953 "LSP[rust_analyzer]" "initialize_params" {
capabilities = {
#!/bin/bash
dry=0
if [[ $# -gt 0 && $1 == "-n" ]]; then
dry=1
shift
fi
prefix="v"
if [[ $# -gt 0 ]]; then
if [[ $1 = -* || $# -gt 1 ]]; then
use std::collections::VecDeque;
use std::sync::{Arc, Condvar, Mutex};
// Flavors:
// - Synchronous channels: Channel where send() can block. Limited capacity.
// - Mutex + Condvar + VecDeque
// - Atomic VecDeque (atomic queue) + thread::park + thread::Thread::notify
// - Asynchronous channels: Channel where send() cannot block. Unbounded.
// - Mutex + Condvar + VecDeque
// - Mutex + Condvar + LinkedList
@jonhoo
jonhoo / cell-tests.rs
Last active October 10, 2024 23:52
cell-refcell-rc
// these aren't _quite_ functional tests,
// and should all be compile_fail,
// but may be illustrative
#[test]
fn concurrent_set() {
use std::sync::Arc;
let x = Arc::new(Cell::new(42));
let x1 = Arc::clone(&x);
std::thread::spawn(move || {

Hi there!

I'm looking for a mascot to use with my [YouTube] and [Twitch] channels. Unlike seemingly many of the channels out there, mine is not gaming related, but is instead a place where I do live programming videos with an educational focus on the [Rust programming language].

My want for a mascot is particularly tied to a new series of streams I've started doing called "Crust of Rust". I think the name is cute, and warrants a mascot, though I'd like to also use the mascot for the rest of my channel.

pub trait IteratorExt: Iterator + Sized {
fn our_flatten(self) -> Flatten<Self>
where
Self::Item: IntoIterator;
}
impl<T> IteratorExt for T
where
T: Iterator,
{
fn our_flatten(self) -> Flatten<Self>
#[macro_export]
macro_rules! avec {
($($element:expr),*) => {{
// check that count is const
const C: usize = $crate::count![@COUNT; $($element),*];
#[allow(unused_mut)]
let mut vs = Vec::with_capacity(C);
$(vs.push($element);)*
vs
#![warn(rust_2018_idioms)]
#[derive(Debug)]
pub struct StrSplit<'haystack, D> {
remainder: Option<&'haystack str>,
delimiter: D,
}
impl<'haystack, D> StrSplit<'haystack, D> {
pub fn new(haystack: &'haystack str, delimiter: D) -> Self {
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
>
<channel>
<atom:link href="{{ site.url }}{{ page.url }}" rel="self" type="application/rss+xml" />
<link>{{ site.url }}</link>