blob_id
stringlengths
40
40
language
stringclasses
1 value
repo_name
stringlengths
5
140
path
stringlengths
5
183
src_encoding
stringclasses
6 values
length_bytes
int64
12
5.32M
score
float64
2.52
4.94
int_score
int64
3
5
detected_licenses
listlengths
0
47
license_type
stringclasses
2 values
text
stringlengths
12
5.32M
download_success
bool
1 class
03a161a6c9932e8436d9155d317d63930f74d964
Rust
Arnavion/k8s-openapi
/src/v1_23/api/core/v1/container_image.rs
UTF-8
7,291
2.78125
3
[ "Apache-2.0" ]
permissive
// Generated from definition io.k8s.api.core.v1.ContainerImage /// Describe a container image #[derive(Clone, Debug, Default, PartialEq)] pub struct ContainerImage { /// Names by which this image is known. e.g. \["k8s.gcr.io/hyperkube:v1.0.7", "dockerhub.io/google_containers/hyperkube:v1.0.7"\] pub names: Opti...
true
6aba3f4c603887a3ee6fda6d6063c35d3613111f
Rust
isgasho/dialectic
/dialectic/src/error.rs
UTF-8
6,098
3.25
3
[ "MIT" ]
permissive
#[allow(unused_imports)] // To link with documentation use crate::prelude::*; /// A placeholder for a missing [`Transmit`] or [`Receive`] end of a connection. /// /// When using [`split`](Chan::split), the resultant two channels can only send or only receive, /// respectively. This is reflected at the type level by th...
true
c92d4b99a09ecf798b6b6c66116a6ee26f8a9cc4
Rust
ColinIanKing/riscv-rust
/src/virtio_block_disk.rs
UTF-8
5,260
2.765625
3
[ "MIT" ]
permissive
pub struct VirtioBlockDisk { id: u8, clock: u64, driver_features: u32, guest_page_size: u32, queue_select: u32, queue_num: u32, queue_pfn: u32, queue_notify: u32, status: u32, notify_clock: u64, interrupting: bool, contents: Vec<u8> } impl VirtioBlockDisk { pub fn new() -> Self { VirtioBlockDisk { id...
true
6a0837e622a0528ddfdfc61e01d8c4b5b89fe398
Rust
lmigueldf/awsm
/lib/src/webgl/uniforms.rs
UTF-8
13,982
2.953125
3
[ "MIT" ]
permissive
use web_sys::{WebGlProgram, WebGlUniformLocation}; use super::context::{WebGlContext}; use crate::errors::{Error, NativeError}; use super::enums::{DataType}; use log::{info}; pub fn get_uniform_location(gl:&WebGlContext, program:&WebGlProgram, name:&str) -> Result<WebGlUniformLocation, Error> { gl.get_uniform_loca...
true
d750d38e316e4b49a4c10a5069c3bd24902b5a7f
Rust
candersonmiller/aws-rs
/src/mod1.rs
UTF-8
1,743
3.15625
3
[ "Apache-2.0" ]
permissive
use std::fmt; use std::num; use std::str; use std::collections::HashMap; use url; use curl; use std::fmt::Error; use status; pub enum Method { Head, Get, Post, Put, Delete } impl fmt::Show for Method { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), Error> { match *self { Head => write!(f, ...
true
93b1d33dadade794219c729ae277389e2dc4f74d
Rust
vgene/bencher_scrape
/crates/crates/sliding_puzzle_rust/src/base/mod.rs
UTF-8
8,894
3.296875
3
[]
no_license
use std::collections::HashSet; use std::iter::FromIterator; use lehmer::Lehmer; use rand::{thread_rng,seq}; use direction::Direction; use error::SlidingPuzzleError; use result::Result; #[derive(Debug, Clone, PartialEq)] pub struct SlidingPuzzle<T> { tiles: Vec<T>, columns: usize, blank: usize, } impl<T:...
true
2ba3fd35fee2b8cbcafcbc5286f8e3c327703b92
Rust
k0pernicus/aoc2020
/ex10/src/lib/compute.rs
UTF-8
1,966
3.046875
3
[]
no_license
use std::collections::HashMap; // get_jolts_difference_per_adapter needs a SORTED adapter vector! // returns the differences of 1-jolts, 2-jolts, and 3-jolts - in this specific order pub fn get_jolts_difference_per_adapter(adapters: &Vec<usize>) -> HashMap<usize, usize> { let adapters_len = adapters.len(); let...
true
e2c5716e356be76d3eeeee8ab988a68c9bd421dc
Rust
dollarkillerx/Re-learning-RUST
/demo16/src/main.rs
UTF-8
338
3.3125
3
[ "MIT" ]
permissive
fn main() { println!("High Order Function !"); let mut fname:IOE = inc_by_one; let x = 3; println!("opt {} = {}",x ,fname(x)); fname = dec_by_one; println!("opt {} = {}",x ,fname(x)); } // define HOF type IOE = fn(i32) -> i32; fn inc_by_one(x: i32) -> i32 { x + 1 } fn dec_by_one(x: i32) ->...
true
2897472ed85d88f7d13e970639142a9ad190cfa0
Rust
LDiazN/buddy_system_sample
/buddy_system/src/utils/mod.rs
UTF-8
769
3.328125
3
[]
no_license
/** * Some utility functions */ /// Return the lowest 2-power number less than or equal n /// ## Parameters /// * `n` - number whose lower 2-power bound we want to compute /// ## Return /// highghest 2-power number lower or equal than n pub fn nearest_lower_2_power(n : usize) -> usize { (2 as usize).pow((n as f3...
true
a578400ee51b0afc969876ded119fb2bd0c7fa30
Rust
SingingTree/CodeKata
/Kata06/anagrams/src/lib.rs
UTF-8
1,118
3.734375
4
[ "MIT" ]
permissive
use std::collections::HashMap; pub fn get_sorted_chars(string : &str) -> String { let mut chars : Vec<char> = string.chars().collect(); chars.sort(); let mut sorted_string = String::new(); for c in chars { sorted_string.push(c); } sorted_string } pub fn get_anagrams<'a>(strings : &[&'a...
true
bcf67689172d6492ec8091df5dc406c419e70c73
Rust
matter-labs/eip1962
/src/extension_towers/fp4_as_2_over_2.rs
UTF-8
10,801
2.75
3
[ "Apache-2.0" ]
permissive
use crate::fp::Fp; use crate::field::{SizedPrimeField}; use crate::representation::ElementRepr; use crate::traits::{FieldElement, BitIterator, FieldExtension, ZeroAndOne}; use super::fp2::{Fp2, Extension2}; use super::Fp2Fp4FrobeniusBaseElements; pub struct Fp4<'a, E: ElementRepr, F: SizedPrimeField<Repr = E> >{ p...
true
e7dccb849072425659ac6e350c67fd9dccc7cd2a
Rust
eric7237cire/rust-algorithm-problems
/codejam/src/y2017round2/d.rs
UTF-8
16,060
2.671875
3
[]
no_license
// maybe like Problem D. Descending in the Dark round 2 2012 /* Bipartite matching Grid BFS Cycles Hard */ use crate::algo::graph::flow::*; use crate::algo::graph::*; use crate::util::grid::constants::*; use crate::util::grid::{Grid, GridCoord, GridRowColVec}; use crate::util::input::*; //use std::thread; use bimap::B...
true
cd662f68b0ba1da0e984709924d27d821f6541d8
Rust
seb-odessa/crypto-demo
/src/main.rs
UTF-8
1,329
2.921875
3
[]
no_license
extern crate crypto; extern crate time; use crypto::digest::Digest; use time::PreciseTime; pub fn print(raw : &[u8]){ for idx in 0..raw.len() { print!("{0:02x}", raw[idx]); } println!(""); } pub fn cycle(dig : &mut Digest, mut buffer : &mut [u8]) { dig.reset(); dig.input(&buffer); dig...
true
0321e2dbb82d34aa37a0cc1ccc78e048f97de380
Rust
karimElmougi/epi-rust
/src/array/enumerate_primes.rs
UTF-8
680
3.78125
4
[]
no_license
pub fn enumerate_primes(n: i32) -> Vec<i32> { let mut integers = (0..=n).map(|_| true).collect::<Vec<_>>(); for i in 2..=n { if !integers[i as usize] { continue; } let mut multiples = i + i; while multiples <= n { integers[multiples as usize] = false; ...
true
16a4cf3d6e0358d3d040e62478717121b9c6f1d1
Rust
drahnr/messagebird-async
/src/sms/typedetails.rs
UTF-8
4,577
3.03125
3
[ "MIT", "Apache-2.0" ]
permissive
use super::*; use std::collections::{hash_set::Iter, HashSet}; use std::fmt; use serde::de::{Deserialize, Deserializer, MapAccess, Visitor}; use serde::ser::{Serialize, SerializeMap, Serializer}; /// Type Details /// /// Additional message details for the SMS message when passing and querying the MessageBird system. ...
true
8c0a07e0d01cfc3d825a0caa8e5820b03186a613
Rust
hitoyozake/competitive_programming
/yukicoder/804/p804/src/main.rs
UTF-8
721
3.25
3
[]
no_license
fn get_line()->String{ let mut x = String::new(); let r = std::io::stdin().read_line(&mut x); x } fn main() { let nlines = String::from(get_line().trim()); let nums: Vec<&str> = nlines.split(' ').collect(); let y: u32 = nums[0].parse::<u32>().unwrap(); let niku: u32 = nums[1].p...
true
8aee6055cfa23014b2834e62d29dabbf628d5be1
Rust
gcfbn/learning_rust
/graphs/graph/src/lib.rs
UTF-8
1,051
2.859375
3
[]
no_license
//! Implementation of directed graph structure //! //! Result type for functions in this crate is [`crate::errors::BuildGraphResult`] //! //! # Example //! ``` //! use graph::Graph; //! //! let graph: Graph = "4 3 //! 1 2 150 //! 1 3 220 //! 4 2 140" //! .parse() //! .unwrap(); //! //! assert_eq!(gr...
true
fe470f8512113467d8847423e0160585dca15f2d
Rust
nicolas-cherel/rumblebars
/tests/parse/mod.rs
UTF-8
1,696
2.765625
3
[]
no_license
extern crate rumblebars; use rumblebars::Template; use rumblebars::ParseError; use rumblebars::parse; static BIG: &'static str = r##" conten content {{pouet.so1}} {{#pouet2}} do do do {{/pouet2}} {{#pouet3}} do do do {{/pouet3 }} {{#deep}} zero {{#deep1}} one {{#deep2}}...
true
bce9c9c7215f12b651144dd95dab937b35570d9d
Rust
ackintosh/sandbox
/rust/leetcode/src/insert_into_a_binary_search_tree.rs
UTF-8
2,800
3.828125
4
[]
no_license
// https://leetcode.com/problems/insert-into-a-binary-search-tree/ // Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val...
true
3e2d16df23a85874846985767194160e4b4736bf
Rust
pnakun/rmessenger
/src/bot/mod.rs
UTF-8
3,542
3.109375
3
[ "MIT" ]
permissive
mod utils; pub struct Bot { access_token: String, app_secret: String, graph_url: String, } impl Bot { pub fn new(access_token: &str, app_secret: &str) -> Bot { Bot { access_token: access_token.to_string(), app_secret: app_secret.to_string(), graph_url: "http...
true
9d03af64d7ced43b89f0bc3d1cc9a57565d1775d
Rust
crisidev/holysee
/holysee/src/ircclient.rs
UTF-8
9,466
2.6875
3
[ "MIT" ]
permissive
pub mod client { extern crate irc; extern crate chan; use std::{thread, time, process}; use std::default::Default; use chan::{Sender, Receiver}; use self::irc::client::prelude::*; use settings::Settings; use message::{Message, TransportType, DestinationType}; fn main_to_irc_loop(...
true
190f86c5487e1666fde68dc99bf1c5b255f3c9e1
Rust
ebsnet/blockchain
/bin/tx_generator/src/main.rs
UTF-8
3,867
2.8125
3
[]
no_license
#![deny(warnings, missing_docs)] //! This crate provides functionality to generate new usage transactions and append them to the //! blockchain. #[macro_use] extern crate clap; extern crate env_logger; #[macro_use] extern crate log; extern crate client; extern crate cryptography; extern crate data; mod cli; use st...
true
0ba514d81d1fc5d34d1b72dd8eac4ac2f006f425
Rust
Serbis/sealrs
/src/testkit/actors/macrodef.rs
UTF-8
4,337
3.5
4
[]
no_license
//! Macros used with tests /// Creates TestProbe matcher function from the user specified block of code /// /// # Examples /// /// ``` /// matcher!(v => { /// if let Some(m) = v.downcast_ref::<some_actor::SomeMsg>() { /// if m.data > 100 { /// true /// } else { /// false ///...
true
ce637ba23f880b98007528e1ecea5299ddc93aba
Rust
xadic/hello-rocket
/src/main.rs
UTF-8
2,800
2.96875
3
[]
no_license
#[macro_use] extern crate diesel; use std::collections::HashMap; use rocket::{ delete, get, post, put, routes, serde::{ json::{serde_json::json, Json, Value}, Deserialize, Serialize, }, tokio::sync::Mutex, State, }; use rocket_sync_db_pools::database; // map -> mutex -> state type ...
true
fc0669b8da80788a01d000ca9fc4e90a5a9f338b
Rust
minijackson/INF-4301A
/src/builtins.rs
UTF-8
2,799
3.65625
4
[ "MIT" ]
permissive
//! Where all the builtins are defined (Rust code-wise) //! //! This includes print / println functions, binary / unary operators... use type_sys::Value; use type_sys::Value::*; macro_rules! define_arit_operator { ( $symbol:tt, $func_name:ident) => { pub fn $func_name(args: &[Value]) -> Value { ...
true
a19feec8785aafc1e599c1f0c1addb8328208327
Rust
HevanHull/Rust
/chapter3/sub3.5/while_loop/src/main.rs
UTF-8
342
3.765625
4
[]
no_license
fn main() { let mut number = 5; while number != 0{ println!("T-MINUS {} !!!", number); number -= 1; } println!("ZERO!!"); println!("LIFT OFF!!!"); } // The "FOR" Alt is: //fn main() { //for number in (1..4).rev() { //println!("{}!", number); //} //print...
true
e672874ee4cc78562a182e812e319c5cc5c2bf4a
Rust
jawwadturabi/AXIOM-IOT-Batch-04
/floating_point/src/main.rs
UTF-8
451
4.125
4
[]
no_license
fn main() { //floating point // let a = 5.60; // let b = 3.10; // println!("{}", a - b); //boolean type // let present = false; //true // println!("{}", present); //character type // let ch = '$'; // println!("{}", ch) //class task //make a calculator which prints addi...
true
73bfb5b1dc7e4c9281c0de35b9fb88cea8da6be3
Rust
crhino/IronSwarm
/src/swarm/mod.rs
UTF-8
7,871
2.765625
3
[ "MIT" ]
permissive
// Swarm Peer-to-Peer Networking // // Agent's should have knowledge of their neighbors/connections, this module is // to ensure knowledge transfer through the entire swarm. This module will also // be used to ensure the self-healing nature of the swarm's network and make sure // that a partition does not take place. A...
true
8a26cfdc7b3b5b3e9a78f5fcdfcee2da8e27857c
Rust
OUCompilers/cs4100-sp21
/in-class/foo/src/main.rs
UTF-8
464
3.4375
3
[]
no_license
trait HasFoo { fn foo(&self); fn foofoo(&self) { self.foo(); self.foo() } } impl HasFoo for i32 { fn foo(&self) { println!("i32 {}", self) } } impl HasFoo for bool { fn foo(&self) { println!("bool {}", self) } } impl<T: HasFoo> HasFoo for Vec<T> { fn foo(&self) { for x in self { ...
true
ae5b599b48dba84d2f996d65a7c1c3d7ce13f1ac
Rust
FaultyPine/ParseTxtForMods
/src/parse.rs
UTF-8
3,446
3.390625
3
[]
no_license
use hash40::{Hash40, hash40}; use std::collections::HashMap; use std::io::prelude::*; use prc::param::*; /* becuase prc-rs doesn't support changing what's already in a ParamKind, make the vector and fill in values first, and then make the ParamKind::Struct once that "struct" in the text file is finished now it does...
true
8fd8a8d33564a23a8b0dca343e08a2f8e8d3f983
Rust
techtronics/MantaRay
/src/light.rs
UTF-8
1,354
3.203125
3
[]
no_license
use cgmath::point::{Point, Point3}; use cgmath::vector::EuclideanVector; pub struct LightSource { origin: Point3<f32>, light: Light } impl LightSource { pub fn new(o: Point3<f32>, l: Light) -> LightSource { LightSource {origin: o, light: l} } pub fn intensity(&self, point: Point3<f32>) -> ...
true
b9910cc357aa3728e5a279ab255de8ff777a7934
Rust
ReggieMarr/audio-oxide
/src/signal_processing/mod.rs
UTF-8
3,565
3.0625
3
[]
no_license
/* This module contains components which are used for processing data. It contains two main structs, Sample and Scope. It also republishes the module audiovisual. Used to project audio data, visually. */ pub mod audiovisual; const FFT_SIZE : usize = 1024; const NUM_TRANSFORM_OPTIONS : usize = 3; //What ...
true
051a5436a85b47d60b7c152aa65d2a801a1e86a8
Rust
michael-suggs/bevy-snake
/src/snake.rs
UTF-8
1,173
2.734375
3
[]
no_license
use bevy::prelude::*; use std::time::Duration; use super::*; pub struct SnakeHead { pub direction: Direction, } pub struct Materials { pub head_material: Handle<ColorMaterial>, pub food_material: Handle<ColorMaterial>, pub segment_material: Handle<ColorMaterial>, } pub struct SnakeSegment; #[derive(...
true
de2b07c18d068b77150195f77d5a2dbda3589cde
Rust
polachok/rust-psutil
/examples/kill.rs
UTF-8
420
2.9375
3
[ "MIT" ]
permissive
//! Kill a process, reading it's PID from a file extern crate psutil; use std::path::Path; use psutil::process::Process; #[cfg(not(test))] fn main() { let args: Vec<String> = std::env::args().collect(); let pidfile = Path::new(&args[1][..]); let process = Process::from_pidfile(&pidfile).unwrap(); if...
true
9ea16d70feda653cf8e3128c9595a49edb97a6fd
Rust
Pop-tg/cli
/src/error.rs
UTF-8
954
2.703125
3
[]
no_license
use reqwest::StatusCode; use thiserror::Error; use crate::ErrorCode; #[derive(Error, Debug)] pub enum Error { #[error("Bad key format, should be 3 - 12 chars long, using [a-zA-Z0-9_-]")] BadKey, #[error("API returns an error: [{0:?}] {1}")] ApiError(ErrorCode, String), #[error("Bad request")] ...
true
2cd5adfe8de3af7329f8507162fd62284d6d5a41
Rust
huonw/nickel.rs
/src/query_string.rs
UTF-8
2,544
3.265625
3
[ "MIT" ]
permissive
use std::borrow::Cow; use std::collections::HashMap; use request::Request; use urlencoded; use hyper::uri::RequestUri; use hyper::uri::RequestUri::{Star, AbsoluteUri, AbsolutePath, Authority}; use url::UrlParser; use plugin::{Plugin, Pluggable}; use typemap::Key; type QueryStore = HashMap<String, Vec<String>>; // Plu...
true
2ac57c10875f8b04adf35c78b886651443335d0e
Rust
beevans/integrated-manager-for-lustre
/tokio-runtime-shutdown/src/lib.rs
UTF-8
2,245
2.6875
3
[ "GPL-1.0-or-later", "MIT", "BSD-3-Clause" ]
permissive
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use futures::{future, lock::Mutex, stream, Future, Stream, StreamExt, TryFutureExt, TryStreamExt}; use std::sync::Arc; use stream_cancel::{Trigger, Valve}; /// Wraps ...
true
14e912220666dd853b74e7019795946d3e5ac5fe
Rust
fs-gust-club/fs-gust
/solutions/rust/06_text_adventure/kirk_jamie/src/room.rs
UTF-8
496
3.1875
3
[ "MIT" ]
permissive
pub struct Room<'a>{ pub name: String, pub doors: Vec<Door<'a>>, } impl<'a> Room<'a>{ pub fn new(name: String, doors: Vec<Door<'a>>) -> Room <'a>{ Room { name: name, doors: doors, } } } pub struct Door<'a>{ pub name: &'a str, pub direction: &'a str }...
true
cd6bae7df799d94652c0a9ee3b2e3e397c6ef688
Rust
seija-engine/seija-old
/src/render/components/mod.rs
UTF-8
10,785
2.609375
3
[ "MIT" ]
permissive
mod image; mod sprite; mod sprite_sheet; mod text; mod mesh2d; pub use image::{ImageRender}; pub use sprite::{SpriteRender}; pub use sprite_sheet::{SpriteSheet,Sprite,TextureCoordinate}; pub use text::{TextRender,LineMode}; pub use crate::render::SpriteMesh; pub use mesh2d::{Mesh2D}; use crate::common::rect::{Rect}; us...
true
bc55eb76152bc671dea8e8dd4562dca36b0775a5
Rust
olsonjeffery/rust-http-client
/request.rs
UTF-8
588
3.078125
3
[]
no_license
export build_request; import std::net::url; import std::net::url::url; fn build_request(url: url) -> ~str { let host = url.host; let path = if url.path.is_not_empty() { url.path } else { ~"/" }; let request_header = #fmt("GET %s HTTP/1.0\u000D\u000AHost: %s\u000D\u000A\u000D\u000A", ...
true
5ebe4084199ee0630bf085113b67d9c0ecd44543
Rust
Ruddickmg/byThePeoples
/services/auth/src/configuration/connection.rs
UTF-8
317
2.578125
3
[]
no_license
const PORT: &str = "PORT"; const ADDRESS: &str = "IP"; const DEFAULT_PORT: &str = "8080"; const ALL_ADDRESSES: &str = "0.0.0.0"; pub fn uri() -> String { let ip = environment::env_or_default(ADDRESS, ALL_ADDRESSES); let port = environment::env_or_default(PORT, DEFAULT_PORT); format!("{}:{}", ip, port) }
true
3059a96707bed2ff9dcbee4c7bb27610a673128b
Rust
pirtwo/rust-coding-challenge
/problem-010/src/main.rs
UTF-8
1,058
3.765625
4
[]
no_license
fn main() { let primes = eratosthenes_sieve(2000000); let sum: u64 = primes.iter().map(|x| x.value).sum(); println!("sum of primes below 2 million is = {}", sum); } fn eratosthenes_sieve(up_to: u64) -> Vec<Number> { let mut numbers = vec![]; let upper_bound = ((up_to - 2) as f64).sqrt().floor() as ...
true
2d210bc7225be22ea0297ea8726a10e3c8ab95c0
Rust
C-Saunders/advent-of-code-2019
/src/day4.rs
UTF-8
3,443
3.25
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; use itertools::Itertools; use std::collections::HashMap; #[derive(Debug)] pub struct IntRange { bottom: u32, top: u32, } #[aoc_generator(day4)] pub fn parse_data(input: &str) -> IntRange { let split: Vec<u32> = input .split('-') .map(|item| item...
true
b4802af1af9a892ea2c21819a64c11a5848e2f9a
Rust
Baidicoot/8-bit-risc-machine
/src/compile.rs
UTF-8
16,285
2.84375
3
[]
no_license
extern crate regex; extern crate risc_vm; use risc_vm::{DISCS, REGISTERS}; use regex::{RegexBuilder, Regex}; fn reg(s: &str) -> Regex { RegexBuilder::new(s) .multi_line(true) .build() .unwrap() } lazy_static!{ static ref INS: Regex = reg(r"^\s*([A-Z]+) ([\w:@ ]+)"); static ref COM...
true
82afec5d23e3657d9d6b162690408c5550b2b474
Rust
IThawk/rust-project
/rust-master/src/test/ui/swap-2.rs
UTF-8
272
2.96875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass use std::mem::swap; pub fn main() { let mut a: Vec<isize> = vec![0, 1, 2, 3, 4, 5, 6]; a.swap(2, 4); assert_eq!(a[2], 4); assert_eq!(a[4], 2); let mut n = 42; swap(&mut n, &mut a[0]); assert_eq!(a[0], 42); assert_eq!(n, 0); }
true
132f5d26d1fb3fef68469e8649436a17c88637e7
Rust
magiclen/rc-u8-reader
/tests/rc_u8_reader.rs
UTF-8
320
3
3
[ "MIT" ]
permissive
use std::{io::Read, rc::Rc}; use rc_u8_reader::RcU8Reader; #[test] fn to_string() { let data: Rc<str> = "Hello world!".into(); let mut reader = RcU8Reader::new(data); let mut result = String::new(); reader.read_to_string(&mut result).unwrap(); assert_eq!("Hello world!".to_string(), result); }
true
52b6bea58569baaf9ba5ea39e212c8172ed453bc
Rust
neosam/ruma-api-macros
/src/parse.rs
UTF-8
3,343
2.78125
3
[]
no_license
//! Implementation details of parsing proc macro input. use syn::{ Attribute, AttrStyle, Expr, Field, Ident, MetaItem, NestedMetaItem, Visibility, }; use syn::parse::{expr, ident, lit, ty}; use synom::space::{block_comment, whitespace}; #[derive(Debug)] pub enum Entry { Metadata(Ve...
true
1375b2cee527fa7487967c62af8739914e8818a2
Rust
stm32-rs/stm32-rs-nightlies
/stm32g0/src/stm32g0b1/exti/swier2.rs
UTF-8
2,974
2.703125
3
[]
no_license
#[doc = "Register `SWIER2` reader"] pub type R = crate::R<SWIER2_SPEC>; #[doc = "Register `SWIER2` writer"] pub type W = crate::W<SWIER2_SPEC>; #[doc = "Field `SWI2` reader - Software rising edge event trigger on line 34"] pub type SWI2_R = crate::BitReader<SWI2W_A>; #[doc = "Software rising edge event trigger on line ...
true
38a113d8dc7cbbc345bde583575413648323a86d
Rust
hrlmartins/advent-of-code-2019
/day_9/p2/src/main.rs
UTF-8
9,026
3.234375
3
[]
no_license
use std::io::{self, BufReader, Read, BufRead}; use std::collections::{HashMap, VecDeque}; use std::iter::FromIterator; #[derive(PartialEq, Debug)] enum OpCode { Add = 1, Multiply, ReadInput, PrintAddress, JIfTrue, JIfFalse, Lt, Eq, SetRelOffset, Halt = 99 } #[derive(PartialEq, ...
true
118c5f544fceca1cf27dbb5c25f173d0ce413d81
Rust
t-shin-komae/rust-msh-v2-parser
/src/main.rs
UTF-8
844
2.609375
3
[ "WTFPL" ]
permissive
use gmsh_v2_parser::*; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; use std::error::Error; fn main() -> Result<(),Box<dyn Error>>{ let file = File::open("mesh.msh")?; let mut buf_reader = BufReader::new(file); let mut contents = String::new(); buf_reader.read_to_string(&mut conten...
true
05d2f15591ab6b2ea2c1fa2fd73c55b0f7de84fd
Rust
standardgalactic/configure_me
/configure_me_codegen/src/config.rs
UTF-8
12,708
3.21875
3
[ "MITNFA" ]
permissive
use std::fmt; #[derive(Debug)] pub enum ValidationErrorKind { MandatoryWithDefault, InvertedWithAbbr, InvertedWithCount, InvalidAbbr, } #[derive(Debug)] pub struct ValidationError { name: String, kind: ValidationErrorKind, } impl fmt::Display for ValidationError { fn fmt(&self, f: &mut fm...
true
3a0bdafc02ac16d0b1dfcbab2ba2381c582f0431
Rust
Project-StarDust/old-spatial-sdk-rs
/spatial_codegen/src/parser/utils.rs
UTF-8
1,548
2.828125
3
[]
no_license
use nom::character::is_digit; use nom::fold_many1; use nom::many0; use nom::map; use nom::map_opt; use nom::map_res; use nom::named; use nom::one_of; use nom::pair; use nom::separated_list; use nom::tag; use nom::take_while1; named!( pub uppercase<char>, one_of!("ABCDEFGHIJKLMNOPQRSTUVWXYZ") ); named!( pu...
true
cccf3de1051d91428bbd7183454871c134c50572
Rust
tylerreisinger/rust-fractal-generator
/src/render/grayscale.rs
UTF-8
1,550
2.671875
3
[]
no_license
use grid; use image; use fractal::{FractalOrbit}; use render::{RenderError, FractalRenderer, RenderResult}; use super::map::{OrbitMapper, MappedCellIntensity}; pub struct GrayscaleFractalRenderer<T> { mapper: T, } impl<T: OrbitMapper> GrayscaleFractalRenderer<T> { pub fn new(mapper: T) -> Self { Gray...
true
0df479f41a2e4c7183070e592800ada2984e45c7
Rust
RoxasShadow/rust-cleverbot
/src/cleverbot.rs
UTF-8
2,510
2.65625
3
[]
no_license
use std::io::Read; use std::collections::HashMap; use hyper::{Client, Url}; use ::Params; use ::Utils; pub struct Cleverbot { pub backlog: Vec<Response>, params: Params } #[derive(Clone, Debug)] pub struct Response { pub question: String, pub answer: String } impl Cleverbot { pub fn new() -> Cleve...
true
ee8c031aae5e1e2c0685c1e7ae2418597c1cfff7
Rust
wontfix-org/tues-rs
/src/main.rs
UTF-8
6,532
2.625
3
[]
no_license
use std::io; use std::vec::*; use std::boxed::*; use std::net::TcpStream; use std::io::prelude::*; use std::os::unix::io::{AsRawFd}; extern crate ssh2; extern crate rustop; extern crate whoami; extern crate subprocess; extern crate rpassword; extern crate filedescriptor; extern crate task_queue; fn auth(host: &str,...
true
9968bdf52d4965f992a7d7051c4830a5792d55c2
Rust
Kurble/Tutris9
/client/src/controls.rs
UTF-8
7,070
3.140625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::fmt::Display; use std::fmt::Formatter; use std::ops::Index; use serde::*; use quicksilver::lifecycle::Window; use quicksilver::lifecycle::Event; use quicksilver::input::Key; use quicksilver::input::GamepadButton; use quicksilver::input::GamepadAxis; #[derive(Clone, Copy, Eq, Pa...
true
650e5b61ebda25f16e4f285a066032fd2418ed2d
Rust
sagebind/riptide
/syntax/src/ast.rs
UTF-8
5,069
3.203125
3
[ "MIT" ]
permissive
//! Abstract syntax tree definitions for the language syntax. use crate::source::Span; use std::fmt; macro_rules! derive_debug_enum_transparent { ( $(#[$meta:meta])* $vis:vis enum $name:ident { $( $variant:ident($inner:ty) $(,)* )* } ...
true
1d014fe290adda500c8c97ca0d28e0ca02c80230
Rust
visigoth/fruity
/src/dispatch/object.rs
UTF-8
4,344
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
use super::DispatchQueue; use crate::core::{Arc, ObjectType}; use std::{cell::UnsafeCell, ffi::c_void, panic::RefUnwindSafe, ptr::NonNull}; /// The base type for dispatch objects. /// /// Documentation: /// [Swift](https://developer.apple.com/documentation/dispatch/dispatchobject) | /// [Objective-C](https://developer...
true
4497ad81ad41b9af530156a18b2580135ad01353
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-15155.rs
UTF-8
643
2.78125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass trait TraitWithSend: Send {} trait IndirectTraitWithSend: TraitWithSend {} // Check struct instantiation (Box<TraitWithSend> will only have Send if TraitWithSend has Send) #[allow(dead_code)] struct Blah { x: Box<dyn TraitWithSend> } impl TraitWithSend for Blah {} // Struct instantiation 2-levels deep #[a...
true
4d02fe882d02fc0bc827a5e2b3d17652845fb28f
Rust
gushernobindsme/rust-typical90
/q-061/src/main.rs
UTF-8
915
2.9375
3
[]
no_license
// -*- coding:utf-8-unix -*- use proconio::input; use std::collections::VecDeque; fn main() { input! { q: usize, tx: [(usize, usize); q], } let mut deck = VecDeque::new(); let mut answers = Vec::new(); for i in 0..q { let (t, q) = tx[i]; if t == 1 { // ...
true
b9d5754b940c582a512ad081cd60e92919ac1be6
Rust
FilippoRanza/fsa-net
/fsa-net-parser/item-location-derive/src/lib.rs
UTF-8
4,232
2.6875
3
[ "MIT" ]
permissive
extern crate proc_macro; use proc_macro::TokenStream; use quote; use syn; use syn::parse::Parser; use syn::parse_macro_input; #[proc_macro_attribute] pub fn add_location(_: TokenStream, input: TokenStream) -> TokenStream { let ast = parse_macro_input!(input); let ast = add_location_fields(ast); add_locati...
true
726fc7bee93fb85aff589326c9cf75e1d682a4f8
Rust
nyirit/differential_ldbc_snb
/src/lib/loader.rs
UTF-8
7,513
2.953125
3
[]
no_license
use super::types::*; use unwrap::unwrap; pub fn load_data(filename: &str, index: usize, peers: usize) -> Vec<Vec<String>> { use std::io::{BufRead, BufReader}; use std::fs::File; let mut data = Vec::new(); let file = BufReader::new(File::open(filename).expect(&format!("Could open file {}", filename)))...
true
d1a7fda5c2329cb4a4635ff7f0cd37d0848c014b
Rust
a1967629423/vue-compiler
/crates/compiler/src/lib.rs
UTF-8
4,791
2.625
3
[ "MIT" ]
permissive
#![allow(dead_code)] #![feature(generic_associated_types, once_cell)] //! See README.md // TODO: reorg pub #[macro_use] pub mod util; pub mod codegen; pub mod compiler; pub mod converter; pub mod error; pub mod flags; pub mod ir; pub mod parser; pub mod scanner; pub mod transformer; use flags::StaticLevel; use ir::Js...
true
ead0639719aee64cc3f83c72c7de88ce294b5798
Rust
ErikDeSmedt/example-data
/src/lib.rs
UTF-8
6,667
3.390625
3
[ "MIT" ]
permissive
//! example-data is created to easily load common datasets. //! //! We use the [Apache Arrow](https://docs.rs/arrow/3.0.0/arrow/index.html) memory format //! which allows for simple conversion to multiple dataframe implementations. //! //! ```rust //! use example_data::{Repo}; //! use arrow::record_batch::RecordBatch; ...
true
5bf39bd1f7b170b52e4d5ef61afe3d42e28a1dcb
Rust
hawkw/seax_scheme
/ast/src/lib.rs
UTF-8
24,798
2.609375
3
[ "MIT" ]
permissive
#![crate_name = "ast"] #![unstable(feature="scheme")] #![crate_type = "lib"] #![feature(convert)] #![feature(box_syntax,box_patterns)] #![feature(vec_push_all)] #![feature(slice_patterns)] #![feature(staged_api)] #![staged_api] #[macro_use] extern crate seax_util as seax; use seax::cell::SVMCell; use seax::cell::Atom...
true
d402404dfaa10b1e07fd887c25a2d4224a218bc2
Rust
PayasR/rust_road_router
/engine/src/datastr/graph/floating_time_dependent/piecewise_linear_function.rs
UTF-8
66,701
2.90625
3
[ "BSD-3-Clause" ]
permissive
//! Actual algorithms for linking, merging and copying around `PiecewiseLinearFunctions`. //! //! Code tuned for maximum performance, not for readability or maintainability. //! Whatever happens in here should stay in here, theres quite a bit of Type abuse, //! a lot of code with subtle implications and many ugly float...
true
59072287c10f15605fb62938524b8326b3ea86fa
Rust
bdalrhm/rmc
/src/test/ui/type-alias-impl-trait/issue-85113.rs
UTF-8
664
2.921875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
#![feature(min_type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] #![allow(incomplete_features)] type OpaqueOutputImpl<'a> = impl Output<'a> + 'a; //~^ ERROR: hidden type for `impl Trait` captures lifetime that does not appear in bounds //~| ERROR: the type `&'<empty> str` does not fulfill the required lifeti...
true
d8a5fdd794a1ccc430028d62300938a40ec4f724
Rust
leontoeides/google_maps
/src/distance_matrix/request/with_transit_route_preference.rs
UTF-8
1,674
3.40625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::directions::request::transit_route_preference::TransitRoutePreference; use crate::distance_matrix::request::Request; impl<'a> Request<'a> { /// Specifies the preference for transit routes. /// /// ## Arguments /// /// * `transit_route_preference` ‧ The preference of the transit rider; ...
true
cc0e5c2144730e954b2f38e1a367c22d02c93b92
Rust
cpjreynolds/cube
/src/errors.rs
UTF-8
3,605
3.015625
3
[]
no_license
use std::error; use std::result; use std::fmt::{ self, Display, Formatter, }; use std::io; use std::env; use image; use glium; use toml; pub type Result<T> = result::Result<T, Error>; #[derive(Debug)] pub struct Error { msg: String, detail: Option<String>, inner: Option<Box<error::Error>>, } ...
true
64a109072bcce59a1b64a9f7e2c233461bc71a5c
Rust
doraneko94/RustAntBook
/atcoder/examples/abc012d.rs
UTF-8
1,151
3.0625
3
[]
no_license
fn read1<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } pub fn readn<T: std::str::FromStr>(delimiter: &str) -> Vec<T> { let s = read1::<String>(); s.split(delimiter).map(|e| e.parse().ok().unwrap()).collect::<Vec<T...
true
aa7b0f84e2d4d010d05a3a6c1305a68c331e9d2c
Rust
melted/aoc2017
/src/bin/day1.rs
UTF-8
635
3.046875
3
[]
no_license
use std::convert::From; use std::io::*; fn load_data() -> Vec<i32> { let mut v : Vec<u8> = Vec::new(); stdin().read_to_end(&mut v); let mut out : Vec<i32> = v.into_iter().map(|x| i32::from(x) - 48).filter(|&x| x >= 0 && x <= 9).collect(); let first = out[0]; out.push(first); out } fn main() { ...
true
6323f643bd940fa7495d4dfc6aac009ccb41d3d5
Rust
lloydmeta/frunk
/examples/generic.rs
UTF-8
1,356
3.484375
3
[ "MIT" ]
permissive
use frunk::{hlist, hlist_pat, Generic}; #[derive(Generic, Debug, PartialEq)] struct Person<'a> { first_name: &'a str, last_name: &'a str, age: usize, } #[derive(Generic, Debug, PartialEq)] struct Person2<'a> { name_first: &'a str, name_last: &'a str, age_of_person: usize, } fn main() { le...
true
ed1a8a0fe281f0288dcd144cbc10a1908b2ac3dd
Rust
vtheno/kudo
/src/errors.rs
UTF-8
1,003
2.921875
3
[ "Zlib" ]
permissive
#[derive(Debug)] pub enum FetchError { ComponentAlreadyBorrowed(ComponentAlreadyBorrowed), ComponentDoesNotExist(ComponentDoesNotExist), } #[derive(Debug)] pub struct ComponentAlreadyBorrowed(&'static str); impl ComponentAlreadyBorrowed { pub fn new<T>() -> Self { Self(std::any::type_name::<T>()) ...
true
7e3a914be7e44a9eb6451df263ffcf9a773a6453
Rust
Jekshmek/unity-to-rust
/pointers/src/lib.rs
UTF-8
2,291
3.140625
3
[]
no_license
 #![allow(non_snake_case)] mod counter; use counter::PtrCounter; use std::mem::transmute; // Мы используем Rust для выделения памяти, чтобы создать наш счетчик в куче, используя Box , а затем преобразуем это поле в необработанный указатель. // Эта хитрость избавляет от необходимости вручную распределять память //...
true
f5ffd0c1a90038e61ef8820ef47b5e00e3565b78
Rust
jeroenvervaeke/redux-rs
/src/store/mod.rs
UTF-8
8,355
3.234375
3
[ "MIT" ]
permissive
use async_trait::async_trait; use std::marker::PhantomData; use tokio::task::JoinHandle; use crate::{ middleware::{MiddleWare, StoreApi, StoreWithMiddleware}, Reducer, Selector, Subscriber, }; mod worker; use worker::{Address, Dispatch, Select, StateWorker, Subscribe}; /// The store is the heart of any redux...
true
460f5e59c7b9fc4b08e77ecd5bb0f23bfd41fef8
Rust
dropbox/finderinfo-rust
/src/lib.rs
UTF-8
27,202
2.8125
3
[ "Apache-2.0" ]
permissive
#![allow(non_snake_case, non_upper_case_globals)] //! Structs and functions to manipulate MacOS/HFS+ structs, e.g. com.apple.FinderInfo. //! //! Note that HFS+ is big-endian, and so all serialization/deserialization has to be byteswapped //! appropriately. APFS isn't big-endian, but it pretends pretty hard internally ...
true
926fa948ff87001bbec5551de7bab5f7358bae94
Rust
reinterpretcat/vrp
/rosomaxa/src/utils/parallel.rs
UTF-8
4,168
2.828125
3
[ "Apache-2.0" ]
permissive
#[cfg(test)] #[path = "../../tests/unit/utils/parallel_test.rs"] mod parallel_test; pub use self::actual::map_reduce; pub use self::actual::parallel_collect; pub use self::actual::parallel_foreach_mut; pub use self::actual::parallel_into_collect; pub use self::actual::ThreadPool; #[cfg(not(target_arch = "wasm32"))] m...
true
b743892ce3356272116cb0f8af9b3a102028ee20
Rust
sogapalag/contest
/atcoder/dwacon5th-final/c.rs
UTF-8
10,000
2.84375
3
[]
no_license
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufRea...
true
6abbce3a908e72bd54f6015d3b52652c4b817c78
Rust
marcjamot/advent-of-code-2019
/src/main.rs
UTF-8
1,622
2.546875
3
[ "MIT" ]
permissive
extern crate clap; extern crate num; #[cfg(test)] extern crate quickcheck; #[cfg(test)] #[macro_use(quickcheck)] extern crate quickcheck_macros; use clap::{App, Arg}; mod computer; mod days; mod reader; mod writer; fn main() { let (day, input) = get_args(); match day { 1 => days::day_1::run(input.as_...
true
ae3b4b805c3d865ab662f365020f68aa629c629e
Rust
timokoesters/conduit
/src/database/key_value/rooms/edus/read_receipt.rs
UTF-8
5,386
2.53125
3
[ "Apache-2.0" ]
permissive
use std::mem; use ruma::{ events::receipt::ReceiptEvent, serde::Raw, CanonicalJsonObject, OwnedUserId, RoomId, UserId, }; use crate::{database::KeyValueDatabase, service, services, utils, Error, Result}; impl service::rooms::edus::read_receipt::Data for KeyValueDatabase { fn readreceipt_update( &self...
true
9ab7b9973dbc210c912067a6af302342a6123808
Rust
hhacker1999/rsblocks
/src/utils/local_ip.rs
UTF-8
937
2.578125
3
[ "MIT" ]
permissive
use crate::config::CONFIG; use crate::types::ThreadsData; pub async fn get_local_ip() -> ThreadsData { let addrs = nix::ifaddrs::getifaddrs().unwrap(); let mut ip = String::new(); for ifaddr in addrs { match ifaddr.address { Some(address) => { if ifaddr.interface_name ==...
true
8fa2e9499e65a78c0a989e2c403ae667f6920763
Rust
RustExamples/data_types
/src/main.rs
UTF-8
392
3.96875
4
[]
no_license
fn main() { // Arrays store fixed elements of same type and can't grow or shrink let array = [1, 2, 3, 4, 5]; let one = array[0]; println!("one is {}", one); let months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "...
true
9388cf50961189a8a25fafae125022370bc70be2
Rust
coffeecup-winner/icfpc2007
/src/cli_main.rs
UTF-8
5,774
2.734375
3
[]
no_license
use std::io::{self, BufRead, Write}; use crate::build::BuilderState; use crate::exec::ExecutionState; use crate::png_utils::*; enum Mode { DNA, RNA, } pub fn cli_main(prefix: &[u8], dna: &[u8]) -> io::Result<()> { let mut exec_state = ExecutionState::new(prefix, dna); let mut build_state...
true
ed929eb0ff019ac16f1bec6efb4ea8645d75e278
Rust
yjv/rust_fixed_width
/src/data_type.rs
UTF-8
3,851
3.015625
3
[]
no_license
use std::ops::Range; use record::{DataRanges, Data}; use super::BoxedErrorResult as Result; pub enum ShouldReadMore { More(usize), NoMore } pub trait DataSupport { type DataHolder; fn get_length(&self, data: &[u8]) -> Length { Length { length: data.len(), remainder: 0 } } fn get_byte_...
true
27eed6b79e5fc49506af3dcebc9cd6c2b6fbc4e0
Rust
backwaterred/coreutils
/src/uu/echo/src/echo.rs
UTF-8
5,867
2.53125
3
[ "MIT", "GPL-1.0-or-later", "GPL-3.0-or-later" ]
permissive
// This file is part of the uutils coreutils package. // // (c) Derek Chiang <derekchiang93@gmail.com> // (c) Christopher Brown <ccbrown112@gmail.com> // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. #[macro_use] extern crate uucore; use...
true
7009281b050e025b171e05417b4c95c2bdefd3db
Rust
atvaccaro/learns
/codeabbey/5/src/main.rs
UTF-8
476
3.203125
3
[ "MIT" ]
permissive
use std::io::{self, Read}; fn main() { let mut buffer = String::new(); io::stdin().read_line(&mut buffer).unwrap(); let numbers: Vec<i32> = buffer.as_str().split_whitespace().map(|s| s.parse::<i32>().unwrap()).collect(); let mut min = i32::max_value(); let mut max = i32::min_value(); for n i...
true
6a894121f1533d844423f35295b6878c72220fe6
Rust
eupp/rustacata
/examples/eval/src/main.rs
UTF-8
801
2.71875
3
[ "Apache-2.0" ]
permissive
extern crate rustacata_example_eval; use rustacata_example_eval::Expr; use rustacata_example_eval::Foldable; use rustacata_example_eval::Transformer; fn main() { // // 2 * (7 + 1) = 16 let e = Expr::Mult( Box::new(Expr::Value(2)), Box::new(Expr::Add( Box::new(Expr::Value(7)), ...
true
ee4b583c32972dc6a26ba1e99754020a98f1669c
Rust
litttley/editor.sh
/yeditor/src/room/manager.rs
UTF-8
2,848
2.859375
3
[ "MIT" ]
permissive
use super::room; use actix::prelude::*; use failure::Fallible; use std::collections::HashMap; #[derive(Clone)] pub struct RoomInfo { pub id: u32, pub addr: Addr<room::Room>, pub room_key: String, } pub struct RoomManager { rooms: HashMap<String, RoomInfo>, next_room_id: u32, } impl RoomManager {...
true
ee121dd7082d048f75453249ec9c80ffa673f323
Rust
mantou132/LeetCode-Solution
/src/p4.rs
UTF-8
2,519
3.3125
3
[]
no_license
struct Solution {} impl Solution { pub fn find_median_sorted_arrays(nums1: Vec<i32>, nums2: Vec<i32>) -> f64 { let len1 = nums1.len() as i32; let len2 = nums2.len() as i32; let mut min1_index = -1_i32; let mut max1_index = len1; let mut min2_index = -1_i32; let mut max2_index = len2; let ...
true
935bd1df804ced9b643cd7be727136ea79bcf180
Rust
markschl/seqtool
/src/lib/bytesize.rs
UTF-8
1,776
3.78125
4
[ "MIT" ]
permissive
//! Small function that parses memory sizes, accepting //! different units (K, M, G, T) pub fn parse_bytesize(size: &str) -> Result<f64, String> { let size = size.trim(); if size.is_empty() { return Err("Empty size string.".to_string()); } let number = size.parse::<f64>(); match number { ...
true
ccfee72b2cc98de703d4ace2d4e862c0bc8cbd12
Rust
kem243/Fighting-Game
/examples/02objectClient.rs
UTF-8
2,227
3.078125
3
[ "MIT" ]
permissive
use std::net::{SocketAddr, UdpSocket}; use std::{io, str}; // For input use bincode::{serialize, deserialize}; use serde_derive::{Serialize, Deserialize}; extern crate street_code_fighter as scf; use scf::networking::packet::Packet; use scf::animation; use scf::input; // use sdl2::rect::{Point, Rect}; ...
true
7dbc88e1709c3a4eee0d394e0a592d0ba75f94a2
Rust
PacktPublishing/Rust-Cookbook
/Chapter04/sample_mod.rs
UTF-8
1,428
2.71875
3
[ "MIT" ]
permissive
//-- ######################### //-- Task: To create a sample module to illustrate how to use a module in rust //-- Author: Vigneshwer.D //-- Version: 1.0.0 //-- Date: 4 March 17 //-- ######################### // Defined module named `sample_mod` mod sample_mod { // By default all the items in module have private v...
true
6dd5de09ffc336d944b7c5603fc49a9bb0df8f9b
Rust
ryancarins/resize
/src/main.rs
UTF-8
1,298
3.265625
3
[]
no_license
use argparse::{ArgumentParser, Collect, Store}; use resize::Options; use std::process; fn main() { let default_width = 1366; let default_height = 768; let mut options = Options::new(default_width, default_height, Vec::new()); //Handle command line arguments { //Using variables here because...
true
6923dcf1a2a6bfdc790a2879ae18193485d58207
Rust
jdm/nom-workshop-exercises
/ingredients-parser/src/main.rs
UTF-8
1,232
3.28125
3
[]
no_license
#[macro_use] extern crate nom; use nom::{alpha, digit, space}; use std::str::{self, FromStr}; #[derive(Debug)] enum Unit { Cups, Grams, Milligrams, Teaspoons, Tablespoons, } impl FromStr for Unit { type Err = (); fn from_str(s: &str) -> Result<Unit, ()> { match s { _ =...
true
874e9c3d7a9377771e3066ddb101aeb47e5ea0ef
Rust
scoopr/naga-include-poc
/src/main.rs
UTF-8
3,014
2.8125
3
[]
no_license
use anyhow::Context; fn do_file(filename: &str, mut module: naga::Module) -> Result<naga::Module, anyhow::Error> { let source = std::fs::read_to_string(filename)?; let ext = std::path::Path::new(filename) .extension() .map(std::ffi::OsStr::to_string_lossy) .map(std::borrow::Cow::into_o...
true
6454f5fde832e503d3c834ff5747ac502b20480e
Rust
cpichard/rustfx
/src/rfx/rfxfileformat.rs
UTF-8
20,451
3.125
3
[]
no_license
/// /// RFX file format parser /// use std::fs::File; use std::io::Read; use rfx::project::{Project, Node}; use rfx::project::NodeHandle; use std::collections::HashMap; use std::ffi::CString; /// Recognized commands #[derive(Debug, PartialEq, Clone)] enum CommandType { Name = 0, // set name Node, // create n...
true
825cdcf4aeddc949db6ced540578d44a9ab4004a
Rust
dbrgn/threema-gateway-rs
/src/connection.rs
UTF-8
7,496
3.09375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Send and receive messages. use std::{borrow::Cow, collections::HashMap, str::FromStr}; use data_encoding::HEXLOWER; use reqwest::{multipart, Client, StatusCode}; use crate::{errors::ApiError, types::BlobId}; /// Map HTTP response status code to an ApiError if it isn't "200". /// /// Optionally, you can pass in ...
true
84b6026e6acb107c460c3cdbe6d3d14975074933
Rust
iximeow/yaxpeax-x86
/test/real_mode/operand.rs
UTF-8
968
2.703125
3
[ "0BSD" ]
permissive
use yaxpeax_x86::real_mode::{InstDecoder}; #[test] fn test_implied_memory_width() { fn mem_size_of(data: &[u8]) -> Option<u8> { let decoder = InstDecoder::default(); decoder.decode_slice(data).unwrap().mem_size().unwrap().bytes_size() } // test push, pop, call, and ret assert_eq!(mem_s...
true
f23e1e4dc468b02b6f16afcecdaa162e0d268aae
Rust
tikv/client-rust
/src/lib.rs
UTF-8
5,622
2.96875
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. //! This crate provides an easy-to-use client for [TiKV](https://github.com/tikv/tikv), a //! distributed, transactional key-value database written in Rust. //! //! This crate lets you connect to a TiKV cluster and use either a transactional or raw (si...
true
645a4b56c30dec779a99d867d6beb7a3d11170dd
Rust
baconator/advent_of_code_2018
/src/challenge1/hard.rs
UTF-8
721
3.0625
3
[ "MIT" ]
permissive
use std::collections::HashSet; #[test] fn test() { let samples = vec![("+1\n-2\n+3\n+1", 2)]; for (input, expected) in samples { assert_eq!(expected, solve(input.lines().map(|l| l.to_owned()))); } } pub fn solve(input: impl Iterator<Item = String>) -> i64 { let values = input .map(|lin...
true