Skip to content

Instantly share code, notes, and snippets.

View nrc's full-sized avatar
🐙
Having a rest

Nick Cameron nrc

🐙
Having a rest
View GitHub Profile
@nrc
nrc / async.rs
Created September 7, 2022 12:56
async IO traits
use std::io::Result;
use std::mem::{self, MaybeUninit};
// A simple async-ification of sync Read plus downcasting methods.
pub trait Read {
// async
fn read(&mut self, buf: &mut [u8]) -> Result<usize>;
// ...
WARNING: documentation for this crate may be rendered differently using the new Pulldown renderer.
See https://github.com/rust-lang/rust/issues/44229 for details.
WARNING: rendering difference in `Constructs a `Layout` from a given `size` and `align`,...`
--> src/liballoc/allocator.rs:79:4
/html[0]/body[1]/ul[1]/li[1]/p[0] Text differs:
expected: `must not exceed 2^31 (i.e.`
found: `must not exceed 2`
/html[0]/body[1]/ul[1]/li[1]/p[0] Tags differ: expected: `code`, found: `sup`
/html[0]/body[1]/ul[1]/li[1]/p[0] Text differs:
expected: `),`
Differences spotted in "Utilities for formatting and printing `String`s\n\nThis module contains the runtime support for the [`format!`] syntax extension.\nThis macro is implemented in the compiler to emit calls to this module in\norder to format arguments at runtime into strings.\n\n# Usage\n\nThe [`format!`] macro is intended to be familiar to those coming from C\'s\n`printf`/`fprintf` functions or Python\'s `str.format` function.\n\nSome examples of the [`format!`] extension are:\n\n```\nformat!(\"Hello\"); // => \"Hello\"\nformat!(\"Hello, {}!\", \"world\"); // => \"Hello, world!\"\nformat!(\"The number is {}\", 1); // => \"The number is 1\"\nformat!(\"{:?}\", (3, 4)); // => \"(3, 4)\"\nformat!(\"{value}\", value=4); // => \"4\"\nformat!(\"{} {}\", 1, 2); // => \"1 2\"\nformat!(\"{:04}\", 42); // => \"0042\" with leading zeros\n```\n\nFrom these, you can see that the first argument is a format string. It is\nrequired by the compiler for this to be a s
@nrc
nrc / Abstract v3
Last active July 31, 2017 06:18 — forked from Xanewok/Abstract v3
>>>>>>>>>>>>>>>>>>>>>>>
Teaching an IDE to understand Rust
>>>>>>>>>>>>>>>>>>>>>>>
Abstract
(A concise, engaging description for the public program. Limited to 600 characters.)
IDE support is one of Rust's most requested features. From the 2017 State of Rust Survey:
roughly 30% of Rust users are looking forward to IDE support more than any other feature in 2017 and for 22% of
non-users, lack of IDE support is their main reason for not using Rust. Thankfully, the Rust Language Server is here now and it gets smarter and
more capable every day.
@nrc
nrc / lists-2.rs
Created September 16, 2016 03:51
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
@nrc
nrc / lists-4.rs
Created September 16, 2016 03:43
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
time: 0.013; rss: 62MB parsing
time: 0.003; rss: 62MB configuration 1
time: 0.000; rss: 62MB recursion limit
time: 0.000; rss: 62MB crate injection
time: 0.023; rss: 96MB macro loading
time: 0.001; rss: 98MB plugin loading
time: 0.000; rss: 98MB plugin registration
time: 0.213; rss: 106MB expansion
time: 0.021; rss: 106MB configuration 2
time: 0.000; rss: 106MB gated configuration checking
@nrc
nrc / strace.txt
Created October 19, 2015 04:59
strace
execve("/usr/local/bin/cargo", ["cargo", "rustc", "--", "-Ztime-passes"], [/* 24 vars */]) = 0
brk(0) = 0x7ff9443f7000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff941c74000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/root/rust/x86_64-unknown-linux-gnu/stage2/lib/tls/x86_64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/rust/x86_64-unknown-linux-gnu/stage2/lib/tls/x86_64", 0x7fffac27ac00) = -1 ENOENT (No such file or directory)
open("/root/rust/x86_64-unknown-linux-gnu/stage2/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/rust/x86_64-unknown-linux-gnu/stage2/lib/tls", 0x7fffac27ac00) = -1 ENOENT (No such file or directory)
open("/root/rust/x86_64-unknown-linux-gnu/stage2/lib/x86_64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file
@nrc
nrc / gist:7261e80068115a3ac76c
Last active August 29, 2015 14:24
Method calls
// I think this is every possible way to call a method in Rust.
struct Foo;
impl Foo {
fn m1() {
println!("Hello! m1");
}
fn m2(&self) {
@nrc
nrc / ints.md
Created November 29, 2014 22:29
Integer fallback etc.

Integer types

This is meant to be a summary of the current status and the questions around integer fallback and type names. It's meant to be an objective overview so we can discuss at the work week and have the same starting point. (Obviously I have an opinion here, so it might not be totally objective but I'll try).

Current status