Skip to content

Instantly share code, notes, and snippets.

View tsauvajon's full-sized avatar

Thomas Sauvajon tsauvajon

View GitHub Profile

Rust Error Handling Cheatsheet - Result handling functions

Introduction to Rust error handling

Rust error handling is nice but obligatory. Which makes it sometimes plenty of code.

Functions return values of type Result that is "enumeration". In Rust enumeration means complex value that has alternatives and that alternative is shown with a tag.

Result is defined as Ok or Err. The definition is generic, and both alternatives have

#!/usr/bin/env bash
function for_all_test_files { find $(go list -f '{{ .Dir }}' ./...) -name '*_test.go' ; }
function first_line_of_test { xargs -n1 awk '/^func Test/{getline; print FILENAME ":" NR-1 " " $0}' ; }
function not_parallel { grep -v 't.Parallel()' ; }
if for_all_test_files | first_line_of_test | not_parallel
then
echo FAIL: not all tests call t.Parallel
exit 1
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFx2PwgBEACurx565A50ByyE2u6WEJneCzdT5hmWIYCFkMBiOafxHzYgmDX2
iexDek6+Ms01CWhmA3wdR21S2rQAt3pw23UU9L48LrgCnZbh9WSQWC391IctzUZe
BclMJ03cow5RMyacNd/FaLrJBH4/vkg5Ive6QsgD/zxBFQJU5qvBLdedN/LhpOJV
dg7BM4fvwLGqITloLOraSSGQynIEDz34YJXzII3XWxG0r7j6+CqDVbWK8fk6AkPN
UQDEaRWBrJ/H9iYzx288Gd8InlLwlaXvJaUokX8YCnkyQQrLrek/spWvlnKYqszY
BC7A2PzhBZdtvDloZp184lBhX6KtCSOIie+XtzomxAA2MwyNKR6Q7xWkifAAK39M
6czdqjfHX6sV6l6iDhhVpJBfhKRv7ntGfHci8z7q7+zAbEXEy2am/fuBjXdyvg1o
ep+arp05trz4A3Y1QOaBzLRlrahalCwWFbYtmmzP4n8CkxQaQ/nqwPZSQ5ez7Xni
@tsauvajon
tsauvajon / tsauvajon.pub
Created October 31, 2019 23:58
Public SSH Key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDhi5kXGJWbF3ZZ/HA/+VJXd+1jRUNH1IydF4dJFlgT+Ag9XHbSh4WqFReQfYjTVJRE4LQJznvl0RmmUUB1+5CH37HUvN5zw0GUucfMNmtjSPYli6Vgvn0vhzKOwZsLB+nurS9AztuD0PlC3l/FYvBTix4rswyEgb1p1BQVUcSsRpSnyu30Ft1RE9PAtw8sMFk7CrPQpLN1KF1WOToTon7Refv6+OtKfZFOAwO+Po8R4K7QeQlbcXs0GbDlxn3jaG8oTATn27kBVs8/3lUdgxUBoxm1sdxgrfhAEGJFXsb62evSPIjS5fLNLAxwbEH50pT0xOA4MvGLjRkyWf8f1bwp tsauvajon
@tsauvajon
tsauvajon / search_kibana_console.txt
Created October 2, 2018 17:59 — forked from dadoonet/search_kibana_console.txt
Demo script for "A NoSQL search engine to find..." talk
### REINIT
DELETE user
PUT user
{
"settings": {
"number_of_shards": 1
},
"mappings": {
"_doc": {
"properties": {
@tsauvajon
tsauvajon / gerflor-animated-loading-logo.markdown
Created October 3, 2017 12:43
Gerflor Animated loading logo
@tsauvajon
tsauvajon / SpeedDial.css
Created May 3, 2017 11:51 — forked from antoinerousseau/SpeedDial.css
SpeedDial with material-ui
.cover {
position: fixed;
width: 100%;
top: 0;
left: 0;
z-index: 1100; /* just above title bar */
transition: opacity 0.2s ease-in-out;
opacity: 1;
/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#5dc1b2+0,1fbcd2+100 */