Ergonomic, static, contextual errors in Rust.
In a (typically larger) Rust program which is handling errors correctly, by default Rust does not
capture the location (filename, line number and column number) where an Error
was first emitted.
Note: `mos-rust` is available via https://hub.docker.com. But if you're not on `amd64` and don't mind potentially stale builds | |
(the docker image is 8 months old and 19,980 commits behind `llvm-mos` as of the time of this writing). | |
# Installation | |
## 1. Build & install `llvm-mos` to `/opt/llvm-mos` | |
### macOS | |
```fish | |
sudo mkdir /opt/llvm-mos | |
sudo chwown "$(whoami)" /opt/llvm-mos | |
git clone https://github.com/llvm-mos/llvm-mos |
This guide intends to summarize the essencial steps performed to build a Raspberry Pi minmal image using Yocto.
To build the image we are going to use the Poky and the layers meta-openembedded , meta-raspberrypi .
The list of all meta-raspberrypi dependencies are contained in the Readme.md the provided MACHINE's are listed on the layer-contentens.md
// This is a technique to emulate lifetime GATs (generic associated types) on stable rust starting | |
// with rustc 1.33. | |
// | |
// I haven't seen this exact technique before, but I would be surprised if no one else came up with | |
// it. I think this avoids most downsides of other lifetime GAT workarounds I've seen. | |
// | |
// In particular, neither implementing nor using traits with emulated lifetime GATs requires adding | |
// any helper items. Only defining the trait requires a single helper trait (+ a single helper impl | |
// for the 2nd variant) per GAT. This also makes the technique viable without any boilerplate | |
// reducing macros. |
adapter speed 10000 | |
adapter driver ftdi | |
ftdi_device_desc "Dual RS232-HS" | |
ftdi_vid_pid 0x0403 0x6010 | |
ftdi_layout_init 0x0008 0x001b | |
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020 | |
set _CHIPNAME riscv | |
transport select jtag |
fn iterative_save<W: Write>(&self, mut wtr: W) -> Result<&Self> { | |
for row in self { | |
for (i, col) in row.iter().enumerate() { | |
match i { | |
0 => wtr.write_all(col.as_bytes())?, | |
_ => { | |
wtr.write_all(b",")?; | |
wtr.write_all(col.as_bytes())? | |
} | |
} |
fn main() { | |
let game = "X 7/ 9- X F8 ⑧/ F6 X X X8/" | |
.chars() | |
.filter(|c| !c.is_whitespace()) | |
.fold(Vec::new(), |mut rolls, roll| { | |
match roll { | |
'X' => rolls.push(10_u8), | |
'/' => rolls.push(10 - rolls.last().expect("invalid game score")), | |
c if c >= '0' && c <= '9' => rolls.push((u32::from(c) - 0x30) as u8), | |
c if c >= '⑤' && c <= '⑧' => rolls.push((u32::from(c) - 0x245f) as u8), |
#![feature(existential_type)] | |
use chrono::Local; | |
use std::io::{self, Write}; | |
type Result<T> = std::result::Result<T, failure::Error>; | |
trait IOutput { | |
fn write(&self, content: &String) -> Result<()>; | |
} | |
struct ConsoleOutput {} |
using System; | |
using Autofac; | |
namespace DemoApp | |
{ | |
// This interface helps decouple the concept of | |
// "writing output" from the Console class. We | |
// don't really "care" how the Write operation | |
// happens, just that we can write. | |
public interface IOutput |
#![feature(existential_type)] | |
type Result<T> = std::result::Result<T, failure::Error>; | |
trait MyTrait { | |
fn greet(&self) -> String; | |
} | |
struct MyType {} |