Skip to content

Instantly share code, notes, and snippets.

View marioidival's full-sized avatar
😶‍🌫️

Mario Idival marioidival

😶‍🌫️
  • Self Employed ;)
  • Campina Grande, Paraíba, Brazil
  • 10:03 (UTC -03:00)
  • X @marioidival
View GitHub Profile

API elegantes de bibliotecas em Rust

A existencia de bibliotecas com amigaveis e faceis de usar é um dos fatores mais importantes quando escoher uma linguagem de programaçào. Aqui temos algumas dicas de como escrever bibliotecas com otimas APIs em Rust. (Muito dessas dicas são aplicaveis em outras linguagens)e

Conteudos

  • O que faz uma API elegante?
  • Tecnicas
    • Nomes consistente
  • Mais convensoes de nomes de metodos
extern crate rocket;
use rocket::{Request, Data, Outcome};
use rocket::data::{self, FromData};
use rocket::Outcome::*;
use std::collections::HashMap;
pub struct WhereStructResult {
sql: String, values: Vec<String>,
@marioidival
marioidival / dbz.md
Last active July 28, 2017 02:34
Go Context - IDEIAS

Criar um programa para simular os personagens de Dragon Ball aumentando o Ki...

@marioidival
marioidival / build.md
Created July 28, 2017 00:08
routes! not found in scope
error: cannot find macro `routes!` in this scope
  --> src/server/start_server.rs:13:21
   |
13 |         .mount("/", routes![hello])
   |                     ^^^^^^

error: aborting due to previous error

error: Could not compile `goga`.
@marioidival
marioidival / fact.go
Last active July 27, 2017 13:07
WATBENCHTIME
package main
import (
"fmt"
)
func fact(n int) int {
if n == 0 {
return 1
}
@marioidival
marioidival / init.el
Last active July 31, 2022 20:48
my emacs config
(require 'package)
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(package-initialize)
(require 'go-eldoc)
@marioidival
marioidival / concurrency-in-go.md
Created February 5, 2017 11:05 — forked from kachayev/concurrency-in-go.md
Channels Are Not Enough or Why Pipelining Is Not That Easy
package api
import (
"net/http"
"log"
"github.com/urfave/negroni"
)
type AccessControl struct{}
@marioidival
marioidival / carray.py
Last active October 18, 2016 18:18
Implementação de Fila e Pilha com Listas Encadeadas e Array para a disciplina de Estrutura de Dados Lineares
class CArray:
def __init__(self, size):
if not size:
raise ValueError
self._data = [None for _ in range(size)]
self._head = 0
self._tail = 0
@marioidival
marioidival / app.js
Created June 22, 2016 00:51 — forked from tobyzerner/app.js
Mithril ES6 Components
import Component from './component';
class Widget extends Component {
init(ctrl) {
var props = this.props;
ctrl.counter = props.initialValue;
ctrl.increment = function() {
ctrl.counter++;