Async Rust Is A Bad Language
https://bitbashing.io/async-rust.html
Yet another programming blog. Thoughts on software and related misadventures.
I'm working on a cli for a service I've made that maintains a node edge graph (think neo4j type thing). I want to be able to display a graph in the terminal in a sort of ascii art text form kinda like git log -graph. I haven't found any third part libraries that can do that and am looking for help.
Change in Guidance on Committing Lockfiles | Rust Blog
https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html
Empowering everyone to build reliable and efficient software.
Transitioning /r/rust to the Threadiverse
https://blog.erlend.sh/transitioning-r-rust-to-the-threadiverse
Three months ago I submitted a post to the Rust sub-reddit called 'Building a better /r/rust together'. It quickly rose to the top and ga...
Release v1.0.184 · serde-rs/serde
https://github.com/serde-rs/serde/releases/tag/v1.0.184
Restore from-source serde_derive build on all platforms — eventually we'd like to use a first-class precompiled macro if such a thing becomes supported by cargo / crates.io
Precompiled binary removed from serde in v1.0.184
Release v1.0.184 · serde-rs/serde
https://github.com/serde-rs/serde/releases/tag/v1.0.184
Restore from-source serde_derive build on all platforms — eventually we'd like to use a first-class precompiled macro if such a thing becomes supported by cargo / crates.io
using serde_derive without precompiled binary · Issue #2538 · serde-rs/serde
https://github.com/serde-rs/serde/issues/2538
I'm working on packaging serde for Fedora Linux, and I noticed that recent versions of serde_derive ship a precompiled binary now. This is problematic for us, since we cannot, under no circumstance...
I recently ran into an issue where I wanted to use Any
for slices. However, it only allows 'static
types (based on what I read, this is because you get the same TypeId
regardless of lifetimes).
I came up with this workaround which I think is safe:
use std::{
any::{Any, TypeId},
marker::PhantomData,
};
#[derive(Clone, Debug)]
pub struct AnySlice<'a> {
tid: TypeId,
len: usize,
ptr: *const (),
marker: PhantomData<&'a ()>,
}
impl<'a> AnySlice<'a> {
pub fn from_slice(s: &'a [T]) -> Self {
Self {
len: s.len(),
ptr: s.as_ptr() as *const (),
tid: TypeId::of::(),
marker: PhantomData,
}
}
pub fn as_slice(&self) -> Option<&'a [T]> {
if TypeId::of::() != self.tid {
return None;
}
Some(unsafe { std::slice::from_raw_parts(self.ptr as *const T, self.len) })
}
pub fn is(&self) -> bool {
TypeId::of::() == self.tid
}
}
edit: Unfortunately it seems like Lemmy insists on mangling the code block. See the playground link below.
T: Any
ensures T
is also 'static
. The lifetime is preserved with PhantomData
. Here's a playground link with some simple tests and a mut version: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3116a404c28317c46dbba6ed6824c8a9
It seems to pass Miri, including the mut version (which requires a bit more care to ensure there can only be one mutable reference). Any problems with doing this?
New features on lib.rs
https://users.rust-lang.org/t/new-features-on-lib-rs/98560
I've implemented a few new things on lib.rs recently! New features page It lists all cargo features that a crate supports. It includes comments from Cargo.toml, neatly formatted as markdown, so you can learn what the features do. Since comments on features are rare, I also search crate's source code for uses of cfg(feature = "…") to give a hint what functions or types are affected by the feature. Cargo has this quirk that all optional dependencies implicitly create features, unless you use a ...
This Week in Rust 508 · This Week in Rust
https://this-week-in-rust.org/blog/2023/08/16/this-week-in-rust-508/