Skip to content

Instantly share code, notes, and snippets.

KodrAus / Profile Rust on
Last active November 14, 2023 17:19
Profiling Rust Applications

Profiling performance

Using perf:

$ perf record -g binary
$ perf script | | rust-unmangle | > flame.svg

NOTE: See @GabrielMajeri's comments below about the -g option.

KodrAus /
Last active November 4, 2021 05:28
Serializing fixed-size arrays in serde


Add the following method to Serializer:

fn serialize_byte_array<const N: usize>(self, bytes: &[u8; N]) -> Result<Self::Ok, Self::Error> {
KodrAus /
Last active November 4, 2021 04:21
Sizes of bytes vs tuples in some serde binary formats
extern crate test;
use serde::{Serialize, Serializer};
pub struct Bytes([u8; 16]);
pub struct Tuple([u8; 16]);
KodrAus /
Last active June 29, 2020 19:11
Converting between `tracing` key values and `log` key values
use std::fmt;
use log::kv::{self, Source, value::{self, Fill}};
use tracing::{Value, Field, field::{self, Visit}};
pub struct LogField<'kvs>(&'kvs Field, &'kvs dyn Value);
impl fmt::Debug for LogField<'_> {
KodrAus /
Created April 11, 2020 01:30
Find `msbuild` using `vswhere`
use std::path::PathBuf;
use std::process::Command;
use std::str;
let mut msbuild = PathBuf::from("msbuild");
let check_msbuild = Command::new(msbuild)
use std::{
enum Dyn<'v, T: ?Sized, TStatic: ?Sized>
KodrAus / PureDI.cs
Last active January 20, 2020 07:02 — forked from davidfowl/PureDI.cs
DI under the hood. This is what DI containers automate for you
using System;
using System.Threading;
namespace PureDI
class Program
static void Main(string[] args)
// Create the singletons once
KodrAus /
Last active July 23, 2019 05:37
Finding my examples
KodrAus / Dump DotNet JIT
Last active February 11, 2019 00:59
Debugging .NET JIT Output

See this issue in Kestrel.

This is what I do from my OSX environment.

Build coreclr checked

$ ./ -x64 -checked -skiptests
KodrAus / Replace Concrete impl with
Created January 25, 2019 01:09
Using cargo features to replace a set of concrete impls with a blanket one

Using cargo features to replace a set of concrete trait impls with a blanket one

There's subtlety involved in doing this so I've just dumped this out from another document in case I ever need to remember what they were in the future.


The Visit trait can be treated like a lightweight subset of serde::Serialize that can interoperate with serde, without necessarily depending on it. It can't be implemented manually:

/// A type that can be converted into a borrowed value.