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
3b4098ea5d388889edb494a8954cfe0fee1c3d09
Rust
Girish21/rust-sandbox
/simple_io/src/main.rs
UTF-8
727
3.46875
3
[]
no_license
use std::io::{self, Write}; fn main() { let quit: &str = "f"; let mut sum = 0; let sum = loop { let mut input = String::new(); print!("enter a number ('f' to quit): "); io::stdout().flush().unwrap(); match io::stdin().read_line(&mut input) { Ok(_) => {} ...
true
d37776161e055024281856ae96d33edb5a007a64
Rust
jnix85/surface-control
/src/sys/perf.rs
UTF-8
3,173
3.109375
3
[ "MIT" ]
permissive
use std::fs::OpenOptions; use std::path::{Path, PathBuf}; use std::io::{Read, Write}; use crate::error::{Error, ErrorKind, Result, ResultExt}; #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum Mode { Normal, Battery, Perf1, Perf2, } impl Mode { pub fn from_str(s: &str) -> Option<Self> { ...
true
8c18511a11648b171303408c6446de724abe3e45
Rust
shooontan/pocketcache
/examples/with-actix-web/src/handlers/bye.rs
UTF-8
429
2.5625
3
[ "MIT" ]
permissive
use actix_web::{web, HttpRequest, Responder}; use pocketcache::cache::Cache; use std::sync::{Arc, Mutex}; use crate::models::user::User; pub async fn get(req: HttpRequest, cache: web::Data<Arc<Mutex<Cache<User>>>>) -> impl Responder { let name = req.match_info().get("name").unwrap_or("World"); // delete in c...
true
c8b1a86e7166d5fd68548e468594e3aefedcec2b
Rust
drupalio/headlines
/headlines/src/headlines.rs
UTF-8
6,348
2.71875
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use std::{ borrow::Cow, iter::FromIterator, sync::mpsc::{Receiver, SyncSender}, }; use eframe::egui::{ self, epaint::text, Button, Color32, CtxRef, FontDefinitions, FontFamily, Hyperlink, Label, Layout, Separator, TopBottomPanel, Window, }; pub const PADDING: f...
true
65a144acec2e7bbf7cfdd0d54c72110a7e370dab
Rust
Mokosha/pbrt_rust
/src/diff_geom.rs
UTF-8
4,676
2.5625
3
[]
no_license
use geometry::normal::Normal; use geometry::normal::Normalize; use geometry::point::Point; use geometry::vector::Cross; use geometry::vector::Dot; use geometry::vector::Vector; use shape::ShapeBase; use ray::RayDifferential; use utils::solve_linear_system_2x2; #[derive(Debug, PartialEq, PartialOrd, Clone)] pub struct...
true
daae6f92f5a78b6667f160d8365b1de777368424
Rust
Tembocs/rome
/crates/rome_cli/tests/main.rs
UTF-8
10,997
2.796875
3
[ "MIT" ]
permissive
use std::{ffi::OsString, path::Path}; use pico_args::Arguments; use rome_cli::{run_cli, CliSession, Termination}; use rome_console::BufferConsole; use rome_core::{App, DynRef}; use rome_fs::{FileSystem, MemoryFileSystem}; const UNFORMATTED: &str = " statement( ) "; const FORMATTED: &str = "statement();\n"; #[test...
true
36d01a787bd5efca67561738696017101d50b4bb
Rust
myuon/atcoder
/dp/src/bin/j.rs
UTF-8
2,362
3
3
[]
no_license
#[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mu...
true
9da6bb79815a5031a4338720d40e29fd1f2fea62
Rust
sshyran/diesel
/diesel/src/pg/value.rs
UTF-8
1,165
2.75
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::Pg; use crate::backend::BinaryRawValue; use std::num::NonZeroU32; use std::ops::Range; /// Raw postgres value as received from the database #[derive(Clone, Copy)] #[allow(missing_debug_implementations)] pub struct PgValue<'a> { raw_value: &'a [u8], type_oid: NonZeroU32, } impl<'a> BinaryRawValue<'a...
true
e9f1cdeaef2c7e98a4be6088318f5877a83e739f
Rust
hooops/crypto-crawler-rs
/crypto-msg-parser/src/exchanges/binance/mod.rs
UTF-8
1,316
2.65625
3
[ "Apache-2.0" ]
permissive
mod binance_all; mod binance_option; use std::collections::HashMap; use crypto_market_type::MarketType; use crate::{FundingRateMsg, OrderBookMsg, TradeMsg}; use serde_json::{Result, Value}; pub(crate) fn extract_symbol(_market_type: MarketType, msg: &str) -> Option<String> { let obj = serde_json::from_str::<Ha...
true
ad95a7823bec266362f77c3c009a21e4b9ad7f93
Rust
Geigerkind/decision-tree-based-hand-gesture-recognition
/lib_evaluation/src/entities/evaluation_entry.rs
UTF-8
1,156
3.40625
3
[]
no_license
use crate::value_objects::EvaluationEntryKey; /// The structure holding for each evaluation entry the necessary information. #[derive(Debug, Getters)] pub struct EvaluationEntry { key: EvaluationEntryKey, true_positive: u32, false_negative: u32 } impl EvaluationEntry { /// Creates a new instance. ...
true
20d572b808ae8a8a81cb6fce07185822cbd9ef13
Rust
dvc94ch/redpitaya-mercury
/src/la_rle.rs
UTF-8
1,226
2.8125
3
[ "ISC" ]
permissive
use uio::*; use volatile_register::{RO, RW}; #[repr(C)] pub struct LaRleRegs { /// RLE mode cfg_rle: RW<u32>, /// Current counter status_current: RO<u32>, /// Last counter status_last: RO<u32>, } impl Default for LaRleRegs { fn default(&mut self) { unsafe { self.cfg_rle.write(0); }...
true
de61a335efb3254a5a2411c2ea2dc90a8220c177
Rust
irevoire/bug
/src/main.rs
UTF-8
833
2.5625
3
[]
no_license
mod commands; use commands::bug::*; use serenity::{ framework::{standard::macros::group, StandardFramework}, model::gateway::Ready, prelude::*, }; use std::env; struct Handler; impl EventHandler for Handler { fn ready(&self, _: Context, ready: Ready) { println!("{} is connected!", ready.user....
true
d5147eeb9a76000b65b8c4d98f87983cc75e1120
Rust
hsmtkk/stunning-couscous
/src/adapter/square_peg.rs
UTF-8
232
3.359375
3
[]
no_license
pub struct SquarePeg { width :f64, } impl SquarePeg { #[allow(dead_code)] pub fn new(width:f64) -> SquarePeg { SquarePeg{width} } pub fn get_width(&self) -> f64 { self.width } }
true
a111c11371f97107ec99f430aa119df0e76eee16
Rust
lulugo19/advent-of-code-2020
/src/day18.rs
UTF-8
2,817
3.546875
4
[]
no_license
use std::iter::Peekable; #[derive(Debug, PartialEq, Eq)] pub enum Operator { Plus, Times, } #[derive(Debug, PartialEq, Eq)] pub enum Token { Number(u64), LeftParen, RightParen, Operator(Operator), } #[aoc_generator(day18)] pub fn input_generator(input: &str) -> Vec<Vec<Token>> { input .lines() ...
true
008244485c68f08d0f16f1b8b551a8651d108125
Rust
smb374/my_dots
/rust_tools/mpd_cover2/src/main.rs
UTF-8
3,027
3.015625
3
[]
no_license
extern crate image; extern crate mpd; extern crate pcre2; use std::fs::{ self, File, OpenOptions }; use std::path::Path; use std::str; use mpd::{ Client, Song }; use pcre2::bytes::Regex; use image::imageops::FilterType; fn convert(cp: &Path, op: &Path) -> Result<(), ()> { let im = image::open(cp).unwrap(); l...
true
e55671bed3889cecee53818cb313a317ff8f7a82
Rust
cristicismas/rscalc
/src/calculator.rs
UTF-8
1,618
3.5
4
[]
no_license
use super::SYMBOLS; use std::num::ParseFloatError; pub fn calculate(elements: Vec<String>) -> Result<String, ParseFloatError> { let mut result: f64 = elements[0].parse::<f64>()?; for i in 0..elements.len() { let current_element = &elements[i][..]; if SYMBOLS.contains(&current_element) { let next_el...
true
d8ab81d1fb7f9e97e967d38806f6cd4481379a3e
Rust
rodoufu/challenges
/leetCode/string/count-pairs-of-similar-strings.rs
UTF-8
1,511
3.71875
4
[]
no_license
// https://leetcode.com/problems/count-pairs-of-similar-strings/ use std::{ collections::{ HashMap, HashSet, }, iter::FromIterator, }; #[derive(Debug)] struct Word { //letter_count: HashMap<char, usize>, letters: HashSet<char>, } impl From<String> for Word { fn from(word: Strin...
true
5a88a904d6d331cbbb8ac32d5591c0b3c3e571a9
Rust
technodeguy/rest-api-rust
/src/routes/book.rs
UTF-8
2,538
2.640625
3
[]
no_license
use diesel::mysql::MysqlConnection; use hyper::{Body, Request, StatusCode, Chunk}; use futures::{future, Future, Stream}; use crate::types::response::*; use crate::utils::{response::{create_response, create_error_message}, validator::parse_form}; use crate::consts::ErrorCode; use crate::models::book::{Book, NewBook}; ...
true
9be96666b9840bf3b5806acc9f9fd57d65210296
Rust
suharev7/clickhouse-rs
/src/lib.rs
UTF-8
19,611
3
3
[ "MIT" ]
permissive
//! ## clickhouse-rs //! Asynchronous [Yandex ClickHouse](https://clickhouse.yandex/) client library for rust programming language. //! //! ### Installation //! Library hosted on [crates.io](https://crates.io/crates/clickhouse-rs/). //! //! ```toml //! [dependencies] //! clickhouse-rs = "*" //! ``` //! //! ### Supporte...
true
c56a7929abf9ee7db54c34465e744b249f31acde
Rust
sgbasaraner/aoc-rust
/d06/src/main.rs
UTF-8
4,031
3.140625
3
[]
no_license
use std::fs; use std::collections::HashMap; use std::collections::HashSet; type Coords = (i32, i32); #[derive(Debug, Clone)] struct Point { coords: Coords, closest_beacon_id: Option<String>, distance_to_beacon: i32, total_distance_to_all: i32 } impl Point { fn update_with_beacon(&mut self, beacon...
true
de4277558d5206a703994f0d7664d0cdae49d1fb
Rust
95th/torrent-rs
/common/src/types.rs
UTF-8
893
2.640625
3
[ "MIT" ]
permissive
use std::fmt; macro_rules! new_ty { ($ty: ident; $size: expr) => { #[derive(Clone)] pub struct $ty([u8; $size]); impl Default for $ty { fn default() -> Self { Self([0; $size]) } } impl fmt::Debug for $ty { fn fmt(&self, f...
true
235074ad5dbb85f3b22b509b108bf03a5c5a6b44
Rust
gchers/random-world
/src/bin/cp-predict.rs
UTF-8
5,012
2.8125
3
[ "MIT" ]
permissive
#[macro_use] extern crate ndarray; #[macro_use] extern crate serde_derive; extern crate docopt; extern crate random_world; extern crate itertools; use random_world::cp::*; use random_world::ncm::*; use random_world::utils::{load_data, store_predictions}; use itertools::Itertools; use docopt::Docopt; use ndarray::*; c...
true
a1ed5add5b967e44f08de3a77a9073d030083cf7
Rust
xleyba/kvsold
/src/bin/kvs.rs
UTF-8
3,194
3.015625
3
[]
no_license
#[macro_use] extern crate clap; use clap::{App, Arg, SubCommand}; use structopt::StructOpt; use std::env; use kvs::{Result, KvStore}; #[derive(StructOpt, Debug)] #[structopt(name = "git", about = "the stupid content tracker")] enum Opt { #[structopt(name = "set")] Set { #[structopt(value_name = "KEY...
true
d9552e2be60c26ff2481c5cb6b9b00ce280854fe
Rust
matthieu-m/stysh
/stysh-compile/src/model/hir/common.rs
UTF-8
16,135
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Common types. use std::{convert, fmt}; use crate::basic::{com, mem}; use crate::basic::sea::TableIndex; use crate::model::ast; use crate::model::hir::ItemId; // // Public Types (IDs) // pub use self::com::Id; /// Identifier (name) of an item or value. pub type Identifier = mem::InternId; /// Index of an Expr...
true
63448f41f84bbf1dfaa94db9f2bf98d9a26ebe23
Rust
oulamineYou/pt2itp
/native/src/text/mod.rs
UTF-8
27,768
3.21875
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
mod diacritics; mod tokens; mod replace; // // A note on fn names: // - Functions that determine the type of a string should be prefixed with `is_` // - Functions that operate on Strings should be prefixed with `str_` // - Functions that generate Name synonyms should be prefixed with `syn_` // pub use self::diacritic...
true
357ae406a642c6bd2118539f1c5a1640460e8693
Rust
Bietola/alba
/src/main.rs
UTF-8
496
2.921875
3
[]
no_license
use std::io; use std::error::Error; fn main() -> std::result::Result<(), Box<dyn Error>> { // Loop. loop { // Read. let mut rl = rustyline::Editor::<()>::with_config( rustyline::Config::builder() .build() ); let line = rl.readline(">> ")?; rl....
true
c8446ad7a9dfbc5cb0ffff76b25344a2a8925ffc
Rust
adamnemecek/tuix
/src/state/style/flexbox.rs
UTF-8
1,490
2.828125
3
[ "MIT" ]
permissive
use crate::entity::Entity; #[derive(Copy, Clone, PartialEq, Debug)] pub enum FlexDirection { Row, //RowReverse, //TODO Column, //ColumnReverse, //TODO } impl Default for FlexDirection { fn default() -> Self { FlexDirection::Column } } #[derive(Copy, Clone, PartialEq, Debug)] pub ...
true
4b591fa9a1bc926fbc517dff72d576b1aa4f2ad4
Rust
sile/atomic_immut
/benches/std_atomic_immut.rs
UTF-8
1,285
3.078125
3
[ "MIT" ]
permissive
use std::mem; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use std::sync::{Arc, RwLock}; #[derive(Debug)] pub struct StdAtomicImmut<T> { rwlock: RwLock<AtomicPtr<T>>, } impl<T> StdAtomicImmut<T> { pub fn new(value: T) -> Self { let ptr = AtomicPtr::new(to_arc_ptr(value)); let rwl...
true
57a64315687f73aab6245a6dbf6ad7530b717b8a
Rust
IgorPerikov/tg-chat-stats-rs
/src/main.rs
UTF-8
952
2.734375
3
[]
no_license
use itertools::Itertools; use std::fs; use tg_chat_stats::{History, Chat}; use crate::util::count_letters_by_actor; mod util; // TODO: print all chat names in a separate cli command // TODO: support chats exclusion/inclusion fn main() { let stats_file_path = "result.json"; // TODO: cli argument let example_js...
true
bb0b3dd95fbb17c982f7c711a4c0e0f213d6804d
Rust
rrybarczyk/intermodal
/src/metainfo.rs
UTF-8
11,087
2.609375
3
[ "CC0-1.0" ]
permissive
use crate::common::*; #[derive(Deserialize, Serialize, Debug, PartialEq, Clone)] pub(crate) struct Metainfo { pub(crate) announce: String, #[serde( rename = "announce-list", skip_serializing_if = "Option::is_none", default, with = "unwrap_or_skip" )] pub(crate) announce_list: Option<Vec<Vec<Str...
true
b70ec53c5fc8a4cb7670770694295ee46fcec5b1
Rust
Michael-F-Bryan/dxf-rs
/src/dxf_error.rs
UTF-8
4,316
2.59375
3
[ "Apache-2.0" ]
permissive
// Copyright (c) IxMilia. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. use std::error; use std::fmt; use std::io; use std::num; use ::image; use CodePair; #[derive(Debug)] pub enum DxfError { IoError(io::Error), ImageErr...
true
b5fced8d97ad79a18d21dee679fbb06d6378e5c9
Rust
mgenova16/nand2tetris
/projects/08/vm_translator/src/parser.rs
UTF-8
1,570
3.125
3
[]
no_license
use std::io::{self, Read, BufRead, BufReader}; use std::fs::{File, OpenOptions}; use std::path::PathBuf; use crate::command::{Command, CommandType}; pub struct Parser<'a, R: Read> { reader: BufReader<R>, command: Option<Command<'a>>, } impl<'a> Parser<'a, File> { pub fn new(p: &PathBuf) -> io::Resul...
true
a89cda21e6a5272294c0bdcf97b648ad799f395e
Rust
Aurenos/rustache
/src/buf_tcpstream.rs
UTF-8
712
3
3
[]
no_license
use std::io::prelude::*; use std::io::{self, BufReader, BufWriter}; use std::net::TcpStream; pub struct BufTcpStream { input: BufReader<TcpStream>, output: BufWriter<TcpStream>, } impl BufTcpStream { pub fn new(stream: TcpStream) -> io::Result<Self> { let input = BufReader::new(stream.try_clone()?...
true
bbf1df6e3464d98a1d2fc71d20dc169670c9c35d
Rust
anonpublic/votesmart
/contract/src/lib.rs
UTF-8
7,512
2.6875
3
[]
no_license
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::collections::{LookupMap, UnorderedMap}; use near_sdk::json_types::ValidAccountId; use near_sdk::serde::{Deserialize, Serialize}; use near_sdk::{env, near_bindgen, setup_alloc, AccountId, BorshStorageKey, PanicOnDefault}; setup_alloc!(); #[ne...
true
01d79b53dcd0632eaa5c9ffe4e071815e204de73
Rust
jamuraa/advent2018
/day19/src/main.rs
UTF-8
5,443
3.234375
3
[ "BSD-3-Clause" ]
permissive
use std::fmt; #[derive(Clone, Debug, PartialEq, Eq, Hash)] #[allow(non_camel_case_types)] enum Opcode { addr, addi, mulr, muli, banr, bani, borr, bori, setr, seti, gtir, gtri, gtrr, eqir, eqri, eqrr, } fn one_if_true(x: bool) -> u64 { if x { 1 } else { 0 } } impl Opcode { fn execu...
true
02002c9821b1178d30a85cbac76853affe515ab0
Rust
TakiKazuya/rust-opencv-sample
/src/colors.rs
UTF-8
227
2.53125
3
[]
no_license
use opencv::core::Scalar; pub fn red() -> Scalar { Scalar::new(0.0, 0.0, 255.0, 1.0) } pub fn green() -> Scalar { Scalar::new(0.0, 255.0, 0.0, 1.0) } pub fn blue() -> Scalar { Scalar::new(255.0, 0.0, 0.0, 1.0) }
true
8995751c9249b7934ac022017584af4e8a3a3343
Rust
andyherbert/raytracer
/src/renderer/camera_compute.rs
UTF-8
1,520
2.953125
3
[]
no_license
use crate::{Camera, Matrix, Ray, Vert}; pub struct CameraCompute { half_width: f64, half_height: f64, pixel_size: f64, transform: Matrix, } impl CameraCompute { pub fn new(camera: &Camera) -> CameraCompute { let half_view = (camera.fov / 2.0).tan(); let (width, height) = camera.dim...
true
dfe2987836e9b38811cab5f693cd74c5d13444b6
Rust
arkhe634/markab
/markab_parser/src/character_class_parser/error.rs
UTF-8
1,115
2.890625
3
[]
no_license
use crate::{ character_class_parser::CharacterClassParserRequirement, Error, }; use std::fmt::{ Display, Formatter, Result as FmtResult, }; #[derive(Debug)] pub struct CharacterClassParserError<'a> { from: usize, requirement: CharacterClassParserRequirement<'a>, found: Option<char>, } impl<'a> CharacterClassP...
true
cb107468725657526b74b0571c9775e6ba79f8a1
Rust
BruceBrown/d3
/src/lib.rs
UTF-8
3,986
3.15625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! A Framework for Server Development //! This crate provides a set of tools, for implementing a server. It is especially //! well suited for those cases where the server employs a pipeline architecture. //! There are two core concepts, the machine, and the instruction set. Combined //! with a channel sender and recei...
true
724f4b7cb7ea0b495a3e0467d98eaa45815e6e82
Rust
asvedr/oolang
/src/bytecode/registers.rs
UTF-8
1,678
3.34375
3
[]
no_license
#[derive(Debug,PartialEq,Clone)] pub enum Reg { IVar(u8), // index of 'int' var RVar(u8), // index of 'double' var Var(u8), // index of 'Var' var IStack(u8), // stack of int RStack(u8), // stack of real VStack(u8), // stack of Var RSelf, // var 'self' Arg(u8), // fun args ...
true
4ee406f241d0bc27bbe59d5069df333b6ff22391
Rust
d3zd3z/rdump
/filer/tests/data.rs
UTF-8
3,675
2.953125
3
[]
no_license
// Test data. use std::io; use cas::Oid; use cas::pool::RamPool; use cas::pool::ChunkSource; use filer::data::DataWrite; use rand::isaac::IsaacRng; use rand::Rng; use std::cell::RefCell; extern crate cas; extern crate filer; extern crate rand; #[macro_use] extern crate log; #[test] fn indirection() { let limit...
true
b451366f23b898e5b6720dca9ca6c09fb0a389c2
Rust
Denaun/aoc_2020
/src/ticket_translation.rs
UTF-8
8,282
3.015625
3
[ "MIT" ]
permissive
//! Day 16 use std::{cmp::PartialOrd, collections::HashSet}; use itertools::Itertools; trait Solution { fn part_1(&self) -> usize; fn part_2(&self) -> usize; } impl Solution for str { fn part_1(&self) -> usize { let (rules, _, tickets) = parsers::input(self).expect("Failed to parse the input"); ...
true
38aa06123339b47059270f6a01acb2aa1ef81e4b
Rust
mich101mich/aoc-2018
/src/days/day_18.rs
UTF-8
2,319
2.671875
3
[]
no_license
use crate::utils::*; #[allow(unused)] pub fn run() { #[allow(unused_variables)] let input = include_str!("../input/18.txt"); let mut grid = char_grid(input); let mut next_grid = grid.clone(); let neighborhood = grid.moore(); let final_grid = detect_loop(1000000000, || { next_grid.grid...
true
7b73dc9cb6e2074cb8023ddd9b8e35c03f279d21
Rust
NattapongSiri/tokenizer_rs
/src/tokenizer/en/mod.rs
UTF-8
723
3.46875
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A whitespace based word tokenizer. //! //! It split each word by using white space, nothing else is done. /// White space based tokenizer. It split word based on white space. pub struct Tokenizer; // /// Common acronym. This should be useful for sentence tokenizer. // const acronym: &'static [&'static str] = &[ ...
true
9bd90d7dcdcb697570f1164324d1497be6b02f55
Rust
Noah2610/hello-specs-physics
/src/music.rs
UTF-8
1,015
2.625
3
[ "Unlicense" ]
permissive
use std::iter::Cycle; use std::vec::IntoIter; use amethyst::assets::Loader; use amethyst::audio::{AudioSink, OggFormat, SourceHandle}; use amethyst::ecs::{World, WorldExt}; use crate::helpers::*; const MUSIC: &[&str] = &["audio/song.ogg"]; pub struct Music { pub music: Cycle<IntoIter<SourceHandle>>, } pub fn i...
true
a9d294193d26a4b24e3f31c30da720e11de8da46
Rust
raymundovr/exercism-rust
/triangle/src/lib_u64.rs
UTF-8
718
3.640625
4
[]
no_license
pub struct Triangle { a: u64, b: u64, c: u64, } impl Triangle { pub fn build(sides: [u64; 3]) -> Option<Triangle> { let (a, b, c) = (sides[0], sides[1], sides[2]); if a == 0 || b == 0 || c == 0 { return None; } if !(a + b >= c && a + c >= b && b + c >= a) { ...
true
936ac09b41b81d34b8bfc815baba04352ec8b1a4
Rust
dogamak/transmission_rpc
/src/requests/torrent_action.rs
UTF-8
1,819
2.828125
3
[]
no_license
use serde_json::Value; use super::{Request, RequestArguments}; use std::collections::BTreeMap; pub enum ActionType { Start, Stop, Verify, Reannounce } pub enum ActionTarget { Single { id: u64 }, All, List { ids: Vec<u64>, hashes: Vec<String> }, RecentlyActive } pub struct TorrentActio...
true
118444d161333e6cce7018c5c7a52fc9300770d1
Rust
TheGhostHuCodes/programming-rust
/hello/src/main.rs
UTF-8
1,363
3.78125
4
[]
no_license
use std::io::Write; use std::num::NonZeroU64; use std::str::FromStr; fn gcd(n: NonZeroU64, m: NonZeroU64) -> NonZeroU64 { let mut n_ = n.get(); let mut m_ = m.get(); while m_ != 0 { if m_ < n_ { let temp = m_; m_ = n_; n_ = temp } m_ = m_ % n_; ...
true
42ce604ff439599698c64728cdc275a99f9bd30a
Rust
mast22/rust-snake-game
/src/main.rs
UTF-8
6,987
2.890625
3
[]
no_license
use kiss3d::camera::{Camera, FirstPerson}; use kiss3d::event::{Key, WindowEvent}; use kiss3d::light::Light; use kiss3d::nalgebra::{geometry::Point, UnitQuaternion, Vector3}; use kiss3d::nalgebra::{Point3, Transform3, Translation3}; use kiss3d::window::Window; use std::time::Duration; use std::{thread, time}; use core:...
true
38f9049e740525a6bad966780654189aeb49d0a9
Rust
dennisss/dacha
/pkg/http/src/client/client_interface.rs
UTF-8
1,380
2.921875
3
[ "Apache-2.0" ]
permissive
use common::errors::*; use crate::request::Request; use crate::response::Response; #[derive(Default, Clone)] pub struct ClientRequestContext { pub wait_for_ready: bool, } #[async_trait] pub trait ClientInterface { async fn request( &self, request: Request, request_context: ClientReque...
true
349354750efacdb2b79f8daeea5182b89f855e5a
Rust
Atixx/BOFE-Rust
/src/boletin/mod.rs
UTF-8
5,868
2.75
3
[]
no_license
use crate::articles::Article; use chrono::naive::NaiveDate; use reqwest::header::{ HeaderMap, HeaderValue, ACCEPT, ACCEPT_ENCODING, CONNECTION, CONTENT_TYPE, USER_AGENT, }; use serde::Deserialize; use soup::prelude::*; use std::collections::HashMap; mod query; const POST_URL: &str = "https://www.boletinoficial.go...
true
da31c1385d6264ca8c4046d37a65b29d508f7a2c
Rust
mhmoudr/ml-lessons
/l01-linear-regression-one-dimension/rust/src/main.rs
UTF-8
1,690
3.421875
3
[ "Apache-2.0" ]
permissive
type Float = f64; struct Point {x: Float,y: Float } type Data = Vec<Point>; use std::time::Instant; fn main() { let data:Data = vec!( Point{x:1.,y:4.} , Point{x:2.,y:5.5} , Point{x:2.,y:6.} , Point{x:3.,y:9.} , Point{x:3.,y:10.} ); let start = Instant::now(); le...
true
03856d5ea17f0dc6894ad7fd09f22da6195ebfbe
Rust
fbaiesec/rust-libp2p
/protocols/ping/src/handler.rs
UTF-8
13,016
2.6875
3
[ "MIT" ]
permissive
// Copyright 2019 Parity Technologies (UK) Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, mer...
true
990b516941c9be36ec39f655c2cf33fa885d59ab
Rust
archetect/archetect
/archetect-core/src/rules.rs
UTF-8
3,133
2.890625
3
[ "MIT" ]
permissive
use std::path::Path; use linked_hash_map::LinkedHashMap; use log::trace; use crate::config::{Pattern, RuleAction, RuleConfig}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct RulesContext { overwrite: bool, #[serde(skip_serializing_if = "Option::is_none")] path_rules: Option<LinkedHashMap<Stri...
true
ee7db35f07c6820ba1b6beb0691f7c4efa7573d0
Rust
romatthe/remoc
/remoc/tests/rfn/rfn_once.rs
UTF-8
747
2.625
3
[ "Apache-2.0" ]
permissive
use remoc::rfn::{CallError, RFnOnce}; use crate::loop_channel; #[tokio::test] async fn simple() { crate::init(); let ((mut a_tx, _), (_, mut b_rx)) = loop_channel::<RFnOnce<_, Result<String, CallError>>>().await; let reply_value = "reply".to_string(); let fn_value = reply_value.clone(); let rfn =...
true
573264761763569e5e997630532a46e5cc9cded2
Rust
eldruin/tm4c-hal
/tm4c-hal/src/i2c.rs
UTF-8
12,070
2.65625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Common I2C code for TM4C123 and TM4C129 /// I2C error #[derive(Debug)] #[non_exhaustive] pub enum Error { /// Bus Busy BusBusy, /// Arbitration loss Arbitration, /// Missing Data ACK DataAck, /// Missing Address ACK AdrAck, /// I2C Timeout Timeout, } #[macro_export] ///...
true
2f71c36126e75e164a05a7650b7e4a64d60bda39
Rust
maniankara/rustbyexample
/tutorial/21ownership_borrowing.rs
UTF-8
785
3.6875
4
[ "Apache-2.0" ]
permissive
fn eat_box_i32(i: Box<i32>) { println!("box eaten: {}",i); } fn borrow_box_i32(i: &Box<i32>) { println!("borrowed: {}",i); } fn eat_i32(j: i32) { println!("eaten i32: {}", j); } fn borrow_i32(j: &i32) { println!("borrow: {}",j); } fn main() { let stack_i32 = 5i32; borrow_i32(&stack_i32); ...
true
817040532c83dd6255c74a6ddacdd38ba6b9cadc
Rust
svenschmidt75/Rust
/DSandAlg/Queue/src/lib.rs
UTF-8
6,726
3.328125
3
[]
no_license
use std::ops::{Deref, DerefMut}; use std::rc::Rc; use std::cell::RefCell; use std::borrow::{BorrowMut, Borrow}; struct Node { value: u64, next: Option<Rc<RefCell<Node>>>, } impl Node { fn new(value: u64) -> Node { Node { value, next: None } } fn find_leaf_mut(&mut self) -> &mut Node { ...
true
614a6bb8d8fb0493738fb08f135e7885bef1487a
Rust
sneakstarberry/rustlang
/projects/algorithm/q2941/src/main.rs
UTF-8
386
2.953125
3
[]
no_license
use std::io::BufReader; use std::io::BufRead; fn main() { let array = ["c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="]; let mut alphabat = String::new(); let mut rd = BufReader::new(std::io::stdin()); rd.read_line(&mut alphabat).unwrap(); for i in array.iter() { alphabat = alphabat.rep...
true
fb68621138e9c980a90017d2a4e35d2ce95e37e1
Rust
JochemKlingeler/AdventOfCode2020
/src/solutions/day_07.rs
UTF-8
1,117
3.328125
3
[]
no_license
use std::fs; pub fn part1() -> usize { do_part1(&get_day_07_input()) } fn do_part1(_input: &str) -> usize { 0 } pub fn part2() -> usize { do_part2(&get_day_07_input()) } fn do_part2(_input: &str) -> usize { 0 } fn get_day_07_input() -> String { fs::read_to_string("./input/day_07.txt").expect("S...
true
019070aa09d3d61de05290530fdbfd1c1daf2c6f
Rust
trishume/syntect
/tests/error_handling.rs
UTF-8
2,341
2.921875
3
[ "MIT" ]
permissive
use std::{ error::Error, fmt::Display, io::{Error as IoError, ErrorKind}, }; use syntect::{ parsing::{ParseScopeError, ParseSyntaxError}, LoadingError, }; #[test] fn loading_error_bad_path_display() { assert_display(LoadingError::BadPath, "Invalid path"); } #[test] fn loading_error_parse_synt...
true
0b05186580f5a71d9e5f372ce88718852b402646
Rust
zxk7516/exercise
/rust/nth-prime/src/lib.rs
UTF-8
863
3.03125
3
[]
no_license
pub fn nth(n: u32) -> Option<u32> { if n<=0 { None }else{ let mut prime:Vec<u32> = Vec::with_capacity(128); prime.push(2);prime.push(3);prime.push(5); // prime[0]=2;prime[1]=3;prime[2]=5; if n <= 3{ return Some(prime[(n-1) as usize]); }else{ ...
true
5e07b7aa88c0b2820fe18a572ab708b5d1375eb9
Rust
togglebyte/mixel2
/src/plugins.rs
UTF-8
4,631
2.75
3
[]
no_license
use std::cell::RefCell; use std::env::{set_current_dir, current_dir}; use std::fs::{read, read_dir, DirEntry}; use std::path::{Component, Path}; use mlua::prelude::*; use mlua::{Lua, Result, Function, Variadic}; use nightmare::Position; use nightmare::pixels::Pixel; use crate::canvas::Containers; #[derive(Debug)] pu...
true
7c0951071458cceabe06399ae384e10701a2d4d9
Rust
mahkoh/elang
/src/funcs.rs
UTF-8
4,927
2.5625
3
[]
no_license
#![allow(unused)] use crate::{ types::{ span::Span, store::Store, tree::{Expr, ExprType, FnType, NativeFn}, }, Elang, Error, ErrorType, ExprKind, }; use std::rc::Rc; macro_rules! bi { ($f:expr) => { ExprType::Fn { func: FnType::Native { func: Rc::new($f) }, ...
true
204f52d6c0edb2047b4195a662d702c368c586d0
Rust
fabura/icu4x
/experimental/list_formatter/src/list_formatter.rs
UTF-8
7,466
3.125
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use crate::patterns::get_patterns; use displaydoc::Display; use formatted_string_builder::FormattedStringBuilder; #[...
true
c3fdd35043bbdb0fc857baae1da794650351afc0
Rust
siku2/aoc_2019
/src/puzzles/day_02.rs
UTF-8
2,379
3.53125
4
[ "MIT" ]
permissive
use crate::input::Input; use std::error::Error; type OpCode = usize; type Program = Vec<OpCode>; const OP_ADD: OpCode = 1; const OP_MUL: OpCode = 2; const OP_HALT: OpCode = 99; fn add(p: &mut Program, a: OpCode, b: OpCode, s: OpCode) { let index = p[s]; p[index] = p[p[a]] + p[p[b]]; } fn mul(p: &mut Program,...
true
c00bd5cad44beaa23dfc2be956ff91c0ede47266
Rust
srwalter/ipp.rs
/src/request.rs
UTF-8
3,926
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
//! //! IPP request //! use std::io::{self, Read, Write}; use attribute::{IppAttribute, IppAttributeList}; use ::{Result, IPP_VERSION, IppHeader}; use consts::tag::DelimiterTag; use consts::operation::Operation; use consts::attribute::{PRINTER_URI, ATTRIBUTES_CHARSET, ATTRIBUTES_NATURAL_LANGUAGE}; use value::IppValue;...
true
12e9cd99e15eab8b07df2b8bf4ffde3a6e10ce9d
Rust
Airtnp/collection_traits
/src/allocator.rs
UTF-8
2,254
3.171875
3
[ "MIT" ]
permissive
use crate::capacity::CapacityAware; /// Types that have allocator. pub trait AllocatorAware { /// Allocator type type Allocator: std::alloc::Allocator; /// Returns the allocator associated with `Self` fn allocator(&self) -> &Self::Allocator; } pub trait AllocatorConstructible: AllocatorAware { //...
true
8d2c7a354f4bf559f54762d770d15578eff4985d
Rust
Nekrolm/reversi
/src/game/board.rs
UTF-8
5,264
3.328125
3
[]
no_license
use std::ops::{Index, IndexMut, Range}; use std::error::Error; pub const BOARD_SIZE: usize = 8; #[derive(Copy, Clone)] #[derive(PartialEq)] pub enum PlayerId { Black, White, } #[derive(Copy, Clone)] #[derive(PartialEq)] pub enum MoveError { CellNotEmpty, MoveHasNoEffect, InvalidCell } fn flip(...
true
a61fedec64e6b4d43f2d0f06e6ede5b20151bfb6
Rust
mas-yo/ragtime-old
/src/sample1/sub_component/position.rs
UTF-8
325
2.578125
3
[]
no_license
pub struct Position { pos: (f32, f32), move_per_frame: (f32, f32), } impl Position { pub fn start(&mut self) {} pub fn update(&mut self) { self.pos.0 += self.move_per_frame.0; self.pos.1 += self.move_per_frame.1; } pub fn move_to(&mut self, tgt_pos: (f32, f32), after_msec: i32) ...
true
3e5f1ff48f49a253130dae3de8a420c574067015
Rust
jasonwhite/button-rs
/src/button/events/mod.rs
UTF-8
18,933
2.65625
3
[ "MIT" ]
permissive
// Copyright (c) 2019 Jason White // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, d...
true
c13f7507882c9b0314dc27079fe92090458d7b0f
Rust
Bassel-Bakr/Data_Structures
/Rust/splay.rs
UTF-8
8,584
2.953125
3
[]
no_license
#![allow(dead_code)] #![allow(unused_variables, unused_imports)] use std::cell::RefCell; use std::cmp; use std::io::*; use std::rc::{Rc, Weak}; use std::{mem, mem::ManuallyDrop}; fn main() { // let input = &mut Input::new(); // let output = &mut BufWriter::new(stdout()); let mut t = Tree::new(); for i...
true
4576721c2a8ce842b39829df992e68a6f2d31bb7
Rust
fzuellich/chtbtr
/src/types/patch_status.rs
UTF-8
4,895
3.125
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use crate::types::{CodeReviewStatus, VerifiedStatus}; #[derive(PartialEq, Debug, Serialize, Deserialize)] pub enum PatchStatus { Both(CodeReviewStatus, VerifiedStatus), CodeReview(CodeReviewStatus), Verified(VerifiedStatus), ReadyForSubmit, None, } pub fn patc...
true
168c7039afa0aa90d285faa708feb110f4d6f3f8
Rust
gitcare-io/anton
/src/infrastructure/api/helpers/mod.rs
UTF-8
2,330
2.984375
3
[]
no_license
use rocket::http::{ContentType, Status}; use rocket::request::Request; use rocket::response; use rocket::response::{Responder, Response}; use rocket_contrib::json::JsonValue; #[derive(Debug)] pub struct ApiResponse { pub json: JsonValue, pub status: Status, } impl<'r> Responder<'r> for ApiResponse { fn re...
true
81b5314b48a7682d7a6f29205686971738e30b0d
Rust
mvidigueira/MasterProject
/rules_playtest/common/src/records.rs
UTF-8
943
2.578125
3
[]
no_license
extern crate bincode; extern crate base64; use std::collections::HashMap; pub trait WasiSerializable { fn serialize_wasi(&self) -> String; } pub trait WasiDeserializable { fn deserialize_wasi(enc: &str) -> Self; } pub type Ledger = HashMap<String, Vec<u8>>; impl WasiSerializable for Ledger { fn seriali...
true
fcd6f1135d6b369a0ae23b065a278e312577e12b
Rust
rust-itertools/itertools
/src/unziptuple.rs
UTF-8
3,547
3.40625
3
[ "MIT", "Apache-2.0" ]
permissive
/// Converts an iterator of tuples into a tuple of containers. /// /// `multiunzip()` consumes an entire iterator of n-ary tuples, producing `n` collections, one for each /// column. /// /// This function is, in some sense, the opposite of [`multizip`]. /// /// ``` /// use itertools::multiunzip; /// /// let inputs = ve...
true
d96f2b7fa4e0e34a511968a33813035a940fcb36
Rust
mactsouk/introRustLC
/day2/L4/using_channel.rs
UTF-8
974
3.6875
4
[]
no_license
use std::env; use std::thread; use std::sync::mpsc::{channel, Sender, Receiver}; fn fibonacci(n: i32) -> i32 { if n == 0 { return 0; } if n <= 1 { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } } fn main() { let args: Vec<_> = env::args().collect(); if args.len() != 2 { println!("U...
true
38c3232a30f96db59bfa26dc0dbbee4d912070f8
Rust
10allday-kai/api-daemon
/third-party/actix/src/fut/stream_fold.rs
UTF-8
3,000
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::mem; use std::pin::Pin; use std::task::{Context, Poll}; use pin_project::pin_project; use crate::actor::Actor; use crate::fut::{ActorFuture, ActorStream, IntoActorFuture}; /// A future used to collect all the results of a stream into one generic type. /// /// This future is returned by the `ActorStream::fol...
true
0b2edd9fc1334d8a368423c05434f38a94bd100a
Rust
deontologician/parry
/src/transformation/convex_hull2.rs
UTF-8
6,183
2.84375
3
[ "Apache-2.0" ]
permissive
use std::marker::PhantomData; use crate::math::Real; use crate::transformation::convex_hull_utils::{indexed_support_point_id, support_point_id}; use na::{self, Point2, Vector2}; use num_traits::Zero; /// Computes the convex hull of a set of 2d points. /// /// The computed convex-hull have its points given in counter-...
true
0c05ff170290032b527c047f885a033b2c587b7b
Rust
JohnBSmith/peat
/peatc/src/lib.rs
UTF-8
455
2.875
3
[ "CC0-1.0" ]
permissive
use std::fs::File; use std::io; use std::io::Read; mod parser; pub fn read_file(path: &str) -> Result<String,io::Error> { let mut file = File::open(path)?; let mut input = String::new(); file.read_to_string(&mut input)?; return Ok(input); } pub fn compile(input: &str) { let _t = match parser::pa...
true
74ef6387bf0a5beae6054435c97c09a604d80973
Rust
95th/pyret
/src/symbol.rs
UTF-8
2,356
3.109375
3
[]
no_license
use std::cell::RefCell; use std::{collections::HashMap, fmt, mem, str::FromStr}; #[derive(Copy, Clone, Eq, PartialEq, Hash)] pub struct Symbol(u32); impl Symbol { pub fn dummy() -> Self { Self::intern("") } pub fn intern(s: &str) -> Self { with_interner(|interner| interner.intern(s)) ...
true
3dcc2e5b0ce2ddde6a5f73b3d7f58fc33e64ea3b
Rust
shakyShane/wf2
/wf2_core/src/recipes/wp/pass_thru.rs
UTF-8
2,606
3.140625
3
[]
no_license
use crate::context::Context; use crate::dc_tasks::DcTasks; use crate::recipes::m2::subcommands::composer::composer; use crate::subcommands::dc::dc_passthru; use crate::task::Task; use std::cmp; /// /// Enum to represent all of the possible pass-thru commands available /// #[derive(Debug, Clone)] pub enum WpPassThru {...
true
0b8239ab4e8c5c4fc3e2d91dcf52c6b4afe49803
Rust
isgasho/shine
/crates/shine-graph/src/svec/hashstore.rs
UTF-8
1,183
3.25
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::svec::{Store, StoreMut}; use std::collections::HashMap; pub struct HashStore<T> { values: HashMap<usize, T>, } impl<T> HashStore<T> { pub fn new() -> Self { HashStore { values: HashMap::new() } } pub fn new_with_capacity(capacity: usize) -> Self { HashStore { va...
true
a1101e1deb84f164fb9da5b219c4da45b0879585
Rust
Tuxinet/rust-path-tracer
/src/camera.rs
UTF-8
1,659
2.984375
3
[]
no_license
extern crate nalgebra as na; use na::{Vector3, Rotation3}; use crate::ray::Ray; use crate::vecutil::VecUtil; use rand::prelude::SmallRng; use crate::lehmer::Lehmer; #[derive(Clone, Debug)] pub struct Camera { lower_left_corner: Vector3<f64>, horizontal: Vector3<f64>, vertical: Vector3<f64>, origin: Vec...
true
3a71a9b47413b921366593623eb3b03e9f6280a4
Rust
eupn/actix-erlay-sim
/src/recset.rs
UTF-8
9,054
3.15625
3
[]
no_license
//! Defines set that can be reconciled. use minisketch_rs; use minisketch_rs::Minisketch; use std::collections::HashSet; use std::fmt::Debug; use std::hash::Hash; /// Types that can produce short ID (short hash) can implement this trait. pub trait ShortId<I> { fn short_id(&self) -> I; } /// A set that supports r...
true
c96df48dfc2517deca337e304d710bd4fa0e834d
Rust
brundonsmith/strainer
/src/counting.rs
UTF-8
6,144
3.3125
3
[]
no_license
use std::{collections::{HashMap, HashSet}, fmt::Display, path::{Path, PathBuf}}; use crate::{options::Options, pattern::matches}; pub type Occurrences = HashMap<String, Vec<FileLocation>>; /// Return a record of all occurrences of every line in `text` pub fn count_lines( file_path: &Path, text: &str, opt...
true
eda64373a05198682648eca8615bca12b7c58fd7
Rust
8pockets/exercism-rust
/difference-of-squares/src/lib.rs
UTF-8
334
3.4375
3
[]
no_license
pub fn square_of_sum(n: usize) -> usize { let sum: usize = (1..).take(n).fold(0, |a, n| a + n); return sum * sum; } pub fn sum_of_squares(n: usize) -> usize { let sum: usize = (1..).take(n).map(|a| a * a).sum(); return sum; } pub fn difference(n: usize) -> usize { return square_of_sum(n) - sum_of_...
true
2bffe73de8b00829d5a4261c77b67738d02f2a88
Rust
ondich/euler100
/pe001/src/main.rs
UTF-8
223
3.390625
3
[]
no_license
// Project Euler, Problem 1 // Multiples of 3 and 5 fn main() { let mut sum = 0; for k in 1..1000 { if k % 3 == 0 || k % 5 == 0 { sum = sum + k } } println!("Answer: {}", sum) }
true
526eaef9483552b66fc0aa194bf53ed1b15283b7
Rust
madhav-madhusoodanan/actix-web
/src/functions/AuthenticateUser.rs
UTF-8
362
2.609375
3
[]
no_license
use hmac:: Hmac; use jwt::VerifyWithKey; use sha2::Sha265; use std::collections::BTreeMap; use crate::config::key; pub fn AuthenticateUser(bearer: String) -> Result<String, String> { // extract the user from the token, given the secret key // and check if the user is available let claim: BTreeMap<String,...
true
7e89bc8732218abe3d860d96eb260e30ac4fd79d
Rust
nickolay/git-interactive-rebase-tool
/src/todo_file/src/history/operation.rs
UTF-8
106
2.546875
3
[ "BSD-3-Clause", "GPL-3.0-only", "Apache-2.0", "BSD-2-Clause", "GPL-3.0-or-later", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later" ]
permissive
#[derive(Debug, PartialEq, Eq)] pub(crate) enum Operation { Modify, SwapUp, SwapDown, Add, Remove, }
true
1848e58515ff2d7eb89a21cfb385008545518c53
Rust
chrisemerson/adventOfCode
/2020-Rust/Day16/main.rs
UTF-8
5,646
3.140625
3
[]
no_license
use std::collections::HashMap; use std::fs; #[derive(Debug)] struct Range { low: i32, high: i32, } #[derive(Debug)] struct Requirement { name: String, ranges: Vec<Range>, } fn main() { let input = fs::read_to_string("input.txt") .expect("Something went wrong reading the file"); let (...
true
7ce885908c1e48e5fc27f0ff51341afbd9ce1729
Rust
ganga1980/rust-workshop
/part-1/solution/src/lib.rs
UTF-8
3,902
3.375
3
[]
no_license
use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; // How many buckets the hashmap begins with const INITIAL_BUCKET_COUNT: usize = 16; // The max load factor as computed by the average number of items per slot const MAX_LOAD_FACTOR: f64 = 0.9; type Slot<K, V> = Option<((K, V), usize)>; pub ...
true
3b5362c152b251df0997625bfe9c64517d2b853e
Rust
jroweboy/marauder
/visualizer/gl_helpers.rs
UTF-8
3,879
2.546875
3
[ "MIT" ]
permissive
// See LICENSE file for copyright and license details. use std; use gl; use gl::types::{GLuint, GLsizeiptr}; use cgmath::matrix::{Matrix, Mat4, Mat3, ToMat4}; use cgmath::vector::{Vec2, Vec3}; use cgmath::angle; use core::misc::deg_to_rad; use core::types::{Size2, MInt}; use visualizer::types::{MFloat}; pub use load_...
true
a004c9f9579967a293daff057df6836e8d43b2c1
Rust
gadomski/velodyne
/src/source.rs
UTF-8
485
3.515625
4
[]
no_license
//! Sources of Velodyne data. use Point; /// A source of Velodyne data. #[derive(Clone, Copy, Debug)] pub struct Source; impl Source { /// Returns an interator over this source's points. pub fn points(&mut self) -> Points { unimplemented!() } } /// An iterator over a source's points. #[derive(Cl...
true
9a16d9ad0070ea087b830e566e40571dd44e9a76
Rust
bertptrs/adventofcode
/2022/src/day25.rs
UTF-8
1,557
3.5625
4
[ "MIT" ]
permissive
use anyhow::Result; fn parse_num(num: &[u8]) -> Result<i64> { let mut total = 0; let mut factor = 1; for &b in num.iter().rev() { match b { b'0' => (), b'1' => total += factor, b'2' => total += 2 * factor, b'-' => total -= factor, b'=' =>...
true
852b778797a7ed8381c1e87db8037d93dc945697
Rust
Lol3rrr/rizm
/compiler/src/pretty_print.rs
UTF-8
1,122
3.640625
4
[]
no_license
pub trait PrettyPrint { fn print(&self, formatter: &mut PrettyFormatter); } fn gen_padding(indentation: usize) -> String { if indentation == 0 { return "".to_owned(); } let mut result = String::new(); if indentation > 2 { for _ in 0..(indentation - 2) { result.push(' '...
true
ae9244b8d582ebfe8fae09cce5ad13b42bc2f53e
Rust
H2CO3/database_dsl_complexity
/ExampleData/complexity_metrics/src/main.rs
UTF-8
8,164
2.734375
3
[]
no_license
use std::io::{ stdin, Read, Result as IoResult }; use structopt::StructOpt; use serde::Serialize; use serde_json::{ json, Value }; use sqlparser::{ tokenizer::{ Tokenizer, Token, TokenizerError }, parser::{ Parser, ParserError }, ast::Statement, }; use error::SqlError; use dialect::SqlDialect; mod error; m...
true
5110314cc41fa9e94a1aea67965c7e781b12d6dd
Rust
2color/prisma-engines
/query-engine/core/src/schema/enum_type.rs
UTF-8
3,544
2.984375
3
[ "Apache-2.0" ]
permissive
use super::*; use prisma_models::{InternalEnumRef, PrismaValue, ScalarFieldRef}; #[derive(Debug, Clone, PartialEq)] pub enum EnumType { /// Generic, prisma-application specific string enum. /// Semantics are defined by the component interpreting the contents. String(StringEnumType), /// Enum from the ...
true
0fb01d7d8202cf931d2ce6548d3ce6d511ef1d8c
Rust
Nasupl/embedded-rust-devcontainer
/wio-examples/examples/6-3-uart.rs
UTF-8
807
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
//! 6-3 シリアル入出力/UARTのサンプルコードです。 //! ホストPCのシリアルターミナルに //! ```text //! hello world //! this is UART example! //! ``` //! と出力します。 //! //! ### 実行方法 //! ```sh //! $ cargo hf2 --example 6-3-uart //! ``` #![no_std] #![no_main] use panic_halt as _; use wio_terminal as wio; use core::fmt::Write; use wio::hal::clock::GenericC...
true
d0eaaefa12cb5db7645541cb211cdb62c14270d0
Rust
yukihir0/rust_sandbox
/fizzbuzz_iterator/src/main.rs
UTF-8
1,487
3.515625
4
[]
no_license
use std::fmt; enum Result { Number(u64), Fizz, Buzz, FizzBuzz, } impl fmt::Display for Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Result::Number(n) => write!(f, "{}", n), Result::Fizz => write!(f, "Fizz"), Result:...
true