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
@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 / 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 */