Skip to content

Instantly share code, notes, and snippets.

Avatar
🔁
Everything that, in happening, causes itself to happen, happens again

Ibraheem Ahmed ibraheemdev

🔁
Everything that, in happening, causes itself to happen, happens again
View GitHub Profile
View variadics_analysis.md

About variadics in Rust

This is an analysis of how variadic generics could be added to Rust. It's not a proposal so much as a summary of existing work, and a toolbox for creating an eventual proposal.

Introduction

Variadic generics (aka variadic templates, or variadic tuples), are an often-requested feature that would enable traits, functions and data structures to be generic over a variable number of types.

To give a quick example, a Rust function with variadic generics might look like this:

View # Simple Yet Powerful Struct Validations In Go Without Reflection!.md
@qolop
qolop / factors.rs
Created Jul 8, 2016
A one liner to find factors of a number in Rust.
View factors.rs
use std::io;
fn main() {
println!("Enter a number to find its factors: ");
let mut s = String::new();
io::stdin()
.read_line(&mut s)
.expect("failed to read line");
let num: u64 = s.trim().parse().expect("Enter in a positive integer only");
let factors = get_factors_functional(num);
@mjohnsullivan
mjohnsullivan / http_server.rs
Last active Oct 17, 2021
Simple HTTP server example for Rust
View http_server.rs
// Updated example from http://rosettacode.org/wiki/Hello_world/Web_server#Rust
// to work with Rust 1.0 beta
use std::net::{TcpStream, TcpListener};
use std::io::{Read, Write};
use std::thread;
fn handle_read(mut stream: &TcpStream) {
let mut buf = [0u8 ;4096];
@niyazpk
niyazpk / pQuery.js
Created Oct 25, 2014
Add or update query string parameter
View pQuery.js
// Add / Update a key-value pair in the URL query parameters
function updateUrlParameter(uri, key, value) {
// remove the hash part before operating on the uri
var i = uri.indexOf('#');
var hash = i === -1 ? '' : uri.substr(i);
uri = i === -1 ? uri : uri.substr(0, i);
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
@huonw
huonw / blackmagic.rs
Created Jan 15, 2014
do-while loops in Rust
View blackmagic.rs
while {
let x = foo();
bar(x);
x != 0
} {}
@rxaviers
rxaviers / gist:7360908
Last active Oct 18, 2021
Complete list of github markdown emoji markup
View gist:7360908

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: