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
bd0d4a9ce4a6728ece0dc3596c39ade69d2439c8
Rust
fairjm/feel_boring
/hello/src/main.rs
UTF-8
1,416
2.984375
3
[]
no_license
use std::net::TcpListener; use std::io::prelude::*; use std::fs; use std::thread; use std::time::Duration; use hello::ThreadPool; fn main() { let listener = TcpListener::bind("localhost:7878").unwrap(); let args:Vec<String> = std::env::args().collect(); let thread_num = if args.len() < 2 { 4 } ...
true
0175f8039f60991c5519488e7b49d41fb3ea503c
Rust
sgreenlay/aoc-2019
/src/day14.rs
UTF-8
6,630
3.015625
3
[]
no_license
use std::io; use std::io::BufRead; use std::cmp; use std::fmt; use std::fs; use regex::Regex; use lazy_static; use std::collections::HashMap; #[derive(Clone)] struct Ingredient { chemical: String, quantity: i128, } impl Ingredient { fn from_string(s: String) -> Ingredient { lazy_static! { ...
true
ecd170292e95e7d4fcbea502af7e90ca532cc0d6
Rust
pismute/exercism
/rust/dot-dsl/src/lib.rs
UTF-8
2,284
3.1875
3
[]
no_license
use std::collections::HashMap; #[derive(Clone, PartialEq, Debug)] pub struct Edge { from: String, to: String, attrs: HashMap<String, String>, } impl Edge { pub fn new(from: &str, to: &str) -> Edge { Edge { from: from.to_string(), to: to.to_string(), attrs: H...
true
143a54dd772b740c2cbe502496f0109f92c24a29
Rust
williewillus/advent_of_code_2015
/src/day15.rs
UTF-8
1,860
3.203125
3
[]
no_license
use regex::Regex; use itertools::Itertools; #[derive(Debug)] struct Attributes { name: String, capacity: i32, durability: i32, flavor: i32, texture: i32, calories: i32, } fn read_input() -> Vec<Attributes> { let pat = Regex::new(r"(\w+): capacity (-?\d+), durability (-?\d+), flavor (-?\d+)...
true
7d91f10d3207d0a6d6d5d87577e86d511aff66ba
Rust
Alan19922015/glacio
/glacio-http/src/atlas/handlers.rs
UTF-8
3,483
2.875
3
[]
no_license
//! Handle ATLAS requests. use atlas::{Config, Status}; use iron::{IronResult, Request, Response}; use json; /// Handler for ATLAS requests. /// /// Just like the `Cameras` multi-route handler, this structure does not implement `Handler` /// itself. Rather, its method(s) are passed via closures into the router. #[der...
true
6225ad4cdb727d71c054de98b3fa262b3165c5fc
Rust
sajid-munawar/Rust-learning
/loops/src/main.rs
UTF-8
362
3.65625
4
[]
no_license
fn main() { let mut counter=2; let mut val_count=0; loop { val_count=val_count+1; counter=counter+1; println!("Hello world!"); if (counter==5){ break } }; println!("{}",val_count); /* in this program we are checking how to create and break...
true
c174acea35043424603e543fa1fa7fcaded48550
Rust
wjlroe/ray-tracer-challenge
/src/tuples.rs
UTF-8
8,819
3.546875
4
[]
no_license
use super::float_eq; use std::fmt; use std::ops; #[derive(Copy, Clone, Default)] pub struct Tuple { pub x: f32, pub y: f32, pub z: f32, pub w: f32, } impl Tuple { pub fn new(x: f32, y: f32, z: f32, w: f32) -> Self { Tuple { x, y, z, w } } pub fn point(x: f32, y: f32, z: f32) -> Se...
true
334f3103fff581d5f23b472375a6372bebb5c82f
Rust
fundon/actix-net
/actix-service/src/transform.rs
UTF-8
4,415
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
use std::rc::Rc; use std::sync::Arc; use futures::{Async, Future, IntoFuture, Poll}; use crate::transform_map_init_err::TransformMapInitErr; use crate::{NewService, Service}; /// `Transform` service factory. /// /// Transform factory creates service that wraps other services. /// /// * `S` is a wrapped service. /// ...
true
143f3bd922de02dc1a1203fb21b413f67ae98a31
Rust
pabloariasal/sapo
/src/ast_printer.rs
UTF-8
1,285
3.3125
3
[ "MIT" ]
permissive
use super::ast::Expression; pub fn print_ast(ast: Box<Expression>) -> String { let mut buf = String::new(); print_expression(&*ast, &mut buf); buf } fn print_expression(ast: &Expression, buf: &mut String) { match &*ast { Expression::IntegerLiteral { token: _, value } => { buf.push_...
true
3c20935e06a7a064f9db99484deae1db98b94ec3
Rust
mathw/adventofcode
/aoc2021/src/day18.rs
UTF-8
10,460
3.203125
3
[]
no_license
use crate::day::{DayResult, PartResult}; use chumsky::prelude::*; use itertools::Itertools; use std::{collections::LinkedList, ops::Add, str::FromStr}; pub fn run() -> Result<DayResult, Box<dyn std::error::Error>> { let part1 = part1(include_str!("inputs/day18.txt"))?; let part2 = part2(include_str!("inputs/da...
true
0765c20daf869dee08b515dda79d4d22d19f9ad6
Rust
EFanZh/LeetCode
/src/problem_0659_split_array_into_consecutive_subsequences/two_optimized_binary_heaps.rs
UTF-8
2,652
3.375
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // use std::mem; #[derive(Default)] struct OptimizedBinaryHeap { one: u16, two: u16, three: u16, } impl OptimizedBinaryHeap { fn push(&mut self, length: u16) { ...
true
1b62f6974155804206a3cf7535be8c5612a3299b
Rust
paprikaLang/rust-parsole
/src/main.rs
UTF-8
2,133
2.984375
3
[]
no_license
extern crate clap; use clap::{Arg}; extern crate reqwest; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; #[macro_use] extern crate prettytable; pub static URL: &str = "https://newsapi.org/v2/sources?language=en&apiKey=c16fc7641ca44e0f85995fbbe7a5ae09"; use clap::App; #[derive(Deb...
true
75540efec55866ec491c6e1b9de2246443d4994a
Rust
salsa-rs/salsa
/tests/storage_varieties/tests.rs
UTF-8
1,305
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
#![cfg(test)] use crate::implementation::DatabaseImpl; use crate::queries::Database; use salsa::Database as _Database; use salsa::Durability; #[test] fn memoized_twice() { let db = DatabaseImpl::default(); let v1 = db.memoized(); let v2 = db.memoized(); assert_eq!(v1, v2); } #[test] fn volatile_twice...
true
192d9a16353750bc6102ee28189f3a4c1799de8b
Rust
skalpell/rust-fsnotify
/src/win/mod.rs
UTF-8
2,379
2.546875
3
[ "Apache-2.0" ]
permissive
extern crate winapi; extern crate "kernel32-sys" as win; /** * Compulsory readup: * 1. http://qualapps.blogspot.se/2010/05/understanding-readdirectorychangesw.html * 2. http://stackoverflow.com/questions/339776/asynchronous-readdirectorychangesw * 3. https://msdn.microsoft.com/en-us/library/windows/desktop/aa36386...
true
e2939f33848b12fe38c840ef59a2de13750dc835
Rust
SFD-411/learning
/Rust/bevy-snake/src/main.rs
UTF-8
8,694
2.71875
3
[]
no_license
use rand::prelude::random; use bevy::{ core::FixedTimestep, app::App, prelude::*, //ecs::schedule::RunOnce, }; // dimensions const AWIDTH: u32 = 24; const AHEIGHT: u32 = 24; const SQSIZE: f32 = 0.8; static mut speed: f64 = 0.5; static mut level: i32 = 1; // snake status #[derive(SystemLabel, Debug, Ha...
true
316598f51dc5f0210178eb9b8d2cc5515237b850
Rust
UTMIST/oneshot-rs
/src/data/mod.rs
UTF-8
1,148
2.78125
3
[ "MIT" ]
permissive
use ndarray_image::open_gray_image; use std::path::PathBuf; use std::vec::Vec; /// ND-Array for bilevel (black/white) image pixels. pub type NDArr = ndarray::Array<f32, ndarray::IxDyn>; macro_rules! push_pixels { ($p:expr, $v:expr) => { let img = open_gray_image($p).expect("unable to open image"); ...
true
dafe18cc345f0e97a0441396e01f1ac19870ef23
Rust
nwymyczak/roguelikedev-does-the-complete-roguelike-tutorial
/src/game/map.rs
UTF-8
10,289
3
3
[]
no_license
#![allow(dead_code)] extern crate rand; use rand::Rng; use std::cmp; use game::rect::*; use game::tile::*; use game::object::*; use game::draw_info::*; use game::is_blocked; pub struct Map { tiles: Vec<Tile>, width:i32, height:i32, out_of_bounds_tile: Tile, } //TODO Maybe one day we can implemen...
true
00cd2b88e7838be02042a7a21902f764bcdfc697
Rust
happydpc/fission
/src/texture/bitmap.rs
UTF-8
1,388
2.609375
3
[]
no_license
use std::convert::TryFrom; use std::iter::Sum; use std::ops::Mul; #[allow(clippy::wildcard_imports)] use graphite::*; use image::{GenericImageView, Rgba, io::Reader}; use serde::Deserialize; use crate::image::bitmap::Bitmap; use crate::util::config; impl<A: Copy> Bitmap<A> { #[inline] pub fn eval(&self, s: F2) -...
true
1f199a7994487fd9b58db937719e363580a27128
Rust
BlueGreenMagick/quick-xml
/src/de/escape.rs
UTF-8
5,896
3.28125
3
[ "MIT" ]
permissive
//! Serde `Deserializer` module use crate::de::deserialize_bool; use crate::{errors::serialize::DeError, errors::Error, escape::unescape, reader::Decoder}; use serde::de::{DeserializeSeed, EnumAccess, VariantAccess, Visitor}; use serde::{self, forward_to_deserialize_any}; use std::borrow::Cow; /// A deserializer for ...
true
a425cd42e92cf71213962825f2967ec04f157bf6
Rust
ramsayleung/rspotify
/rspotify-model/src/error.rs
UTF-8
1,078
2.90625
3
[ "MIT" ]
permissive
use serde::Deserialize; use thiserror::Error; pub type ApiResult<T> = Result<T, ApiError>; pub type ModelResult<T> = Result<T, ModelError>; /// Matches errors that are returned from the Spotfiy /// API as part of the JSON response object. #[derive(Debug, Error, Deserialize)] pub enum ApiError { /// See [Error Obj...
true
f82b3b0b88f081c8c21d99d08ae2c96e2417f9a9
Rust
winksaville/fuchsia
/third_party/rust_crates/vendor/futures/src/poll.rs
UTF-8
3,202
3.5
4
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
/// A macro for extracting the successful type of a `Poll<T, E>`. /// /// This macro bakes propagation of both errors and `NotReady` signals by /// returning early. #[macro_export] macro_rules! try_ready { ($e:expr) => (match $e { Ok($crate::Async::Ready(t)) => t, Ok($crate::Async::NotReady) => retu...
true
e0a290ae2a49656e16f1612d07fe160a68ebe567
Rust
hamish-miller/gmock-sed
/tests/cook_book.rs
UTF-8
1,822
2.625
3
[]
no_license
/// Examples specified in the gMock cookbook. /// /// https://github.com/google/googletest/blob/master/googlemock/docs/cook_book.md#old-style-mock_methodn-macros mod common; use common::*; mod cookbook { use super::*; macro_rules! cookbook_test { ($name:tt $old:tt -> $new:tt) => { #[test] fn $nam...
true
404487e459f43d5805f1be2225833fb80f59fc57
Rust
alexthemitchell/blott
/src/render/mod.rs
UTF-8
884
2.765625
3
[]
no_license
extern crate regex; use std; use self::templates::Template; mod hash; mod markdown; mod templates; pub type Result<T> = std::result::Result<T, RenderError>; pub type HTML = String; pub type Hashtag = String; #[derive(Debug)] pub enum RenderError { Markdown(markdown::MarkdownRenderError), } pub fn render_post(...
true
63afd5b47b11a95c5e05ec71f8e28d5b80f53109
Rust
warp-tech/warpgate
/warpgate-common/src/try_macro.rs
UTF-8
1,308
2.8125
3
[ "Apache-2.0" ]
permissive
#[macro_export] macro_rules! try_block { ($try:block catch ($err:ident : $errtype:ty) $catch:block) => {{ #[allow(unreachable_code)] let result: anyhow::Result<_, $errtype> = (|| Ok::<_, $errtype>($try))(); match result { Ok(_) => (), Err($err) => { { ...
true
a0c4b5b07c56539dbca413ca6a604d53b2017b51
Rust
prisma/prisma-engines
/query-engine/schema/src/build/input_types/objects/order_by_objects.rs
UTF-8
9,463
2.625
3
[ "Apache-2.0" ]
permissive
use std::borrow::Cow; use super::*; use constants::{aggregations, ordering}; use output_types::aggregation; use prisma_models::prelude::ParentContainer; #[derive(Debug, Default, Clone, Copy)] pub(crate) struct OrderByOptions { pub(crate) include_relations: bool, pub(crate) include_scalar_aggregations: bool, ...
true
d77d441f7065e225bc6727bc825155bba179c1f2
Rust
architus/architus
/logs/submission/src/config.rs
UTF-8
3,847
2.921875
3
[ "MIT" ]
permissive
//! Contains configuration options for the service that control its network topology //! and internal behaviors use anyhow::Context; use architus_config_backoff::Backoff; use serde::Deserialize; use sloggers::terminal::TerminalLoggerConfig; use std::path::PathBuf; use std::time::Duration; /// Configuration object loa...
true
42ff8e31a77a1453c86fb6e6ba2b3de04b462be6
Rust
LeafChage/s
/parser/src/parser.rs
UTF-8
851
2.765625
3
[]
no_license
use super::error::{ParseError, Result}; use lexer::s::Edge; use lexer::token::Token; pub fn parse(e: &Edge) -> Result<Token> { match e { &Edge::S(ref s) => { let head = s.head(); match head { &Edge::S(_) => parse(head), &Edge::Token(Token::Symbol(ref ...
true
bfc621cc7f5bb46ba4936b574f81abe78781fc92
Rust
thoov/volta
/crates/volta-core/src/inventory.rs
UTF-8
3,689
2.875
3
[ "BSD-2-Clause-Views", "BSD-2-Clause" ]
permissive
//! Provides types for working with Volta's _inventory_, the local repository //! of available tool versions. use std::collections::BTreeSet; use std::ffi::OsStr; use std::path::Path; use crate::error::{Context, ErrorKind, Fallible}; use crate::fs::read_dir_eager; use crate::layout::volta_home; use crate::tool::Packa...
true
c417016078beb0a55ded62ec977226de728a8fe2
Rust
NicolasLagaillardie/mpst_rust_github
/tests/cancel_mod/cancel_02.rs
UTF-8
2,326
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
use mpstthree::binary::cancel::cancel; use mpstthree::binary::struct_trait::{end::End, recv::Recv, send::Send}; use mpstthree::role::end::RoleEnd; use mpstthree::{ bundle_struct_fork_close_multi_cancel, create_multiple_normal_role, create_recv_mpst_session_bundle, create_send_mpst_cancel, create_send_mpst_sessi...
true
027b8d0639b5167965bfe6505199dedfc127d45e
Rust
niladic/egui
/egui_demo_lib/src/apps/demo/font_contents_emoji.rs
UTF-8
112,269
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
/// A list of ~all~ most emojis available in `emoji-icon-font.ttf` /// /// Also viewable at <http://jslegers.github.io/emoji-icon-font/> /// Source: <https://github.com/jslegers/emoji-icon-font> #[allow(unused)] #[rustfmt::skip] pub const EMOJI_ICON_FONT_LIST: &[(u32, char, &str)] = &[ (0xA9, '©', "copyright"), ...
true
f6214d86277becdfbd6c3c6c73e17ef9a7412121
Rust
pizzamig/ucl-rs
/src/error.rs
UTF-8
917
2.8125
3
[ "MIT" ]
permissive
use libucl_sys::ucl_error_t; #[derive(Clone, Debug)] pub enum Error { Ok, Syntax(String), Io, State, Nested, Macro, Internal, SSL, Other } impl Error { pub fn from_code(num: i32, desc: String) -> Self { match num { _ if num == ucl_error_t::UCL_EOK as i...
true
d7db54321631322b082cf3bfcca831f7acd68e7a
Rust
lemonxah/csloc
/src/main.rs
UTF-8
2,445
2.796875
3
[]
no_license
#[macro_use] extern crate clap; use walkdir::WalkDir; use clap::App; use funlib::Foldable::*; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() -> std::io::Result<()> { let yaml = load_yaml!("cli.yaml"); let matches = App::from_yaml(yaml).get_matches(); let path = matches.va...
true
01cf41405b00a537dac0760b935488d24a02c46d
Rust
satylogin/leetcode
/medium/1631. Path With Minimum Effort.rs
UTF-8
1,309
2.828125
3
[]
no_license
use std::collections::BinaryHeap; use std::cmp::max; impl Solution { pub fn minimum_effort_path(heights: Vec<Vec<i32>>) -> i32 { let (n, m) = (heights.len() as i32, heights[0].len() as i32); let mut cost: Vec<Vec<i32>> = vec![vec![std::i32::MAX; m as usize]; n as usize]; let mut visited: Ve...
true
9a30a4775c7513db563c9331489913ba0d1e4757
Rust
sapunm/AoC-Solutions
/2020 - Rust/day-08/src/bin/puzzle-a.rs
UTF-8
753
2.6875
3
[]
no_license
use day_08::input::*; fn boot(data: &DataType) -> (ResultType, ResultType) { let mut visited = vec![false; data.len()]; let mut ip: ResultType = 0; let mut acc: ResultType = 0; loop { visited[ip as usize] = true; let (op_code, param) = &data[ip as usize]; match op_code { ...
true
90509c6dc12dfa92d4caa0673a6b533c47e66925
Rust
kevaundray/plookup
/src/lookup/lookup.rs
UTF-8
2,968
2.671875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "MIT" ]
permissive
use ark_bls12_381::{Bls12_381, Fr}; use ark_poly_commit::kzg10::Powers; use super::{ proof::LookUpProof, table::{LookUpTable, PreProcessedTable}, }; use crate::{multiset::MultiSet, transcript::TranscriptProtocol}; pub struct LookUp<T: LookUpTable> { table: T, // This is the set of values which we want...
true
c253718b0bb97cc750a75c92502eb6875749669f
Rust
csnover/earthquake-rust
/libcommon/tests/io/mod.rs
UTF-8
1,904
2.671875
3
[ "Apache-2.0" ]
permissive
mod shared_stream; #[test] fn take_seek() { use binrw::io::{Cursor, Read, Seek, SeekFrom}; use libcommon::TakeSeekExt; let mut cursor = Cursor::new(b"hello world"); { let mut buf = [0; 5]; let mut take = cursor.by_ref().take_seek(5); take.read_exact(&mut buf).unwrap(); a...
true
59a161838e638d7fde5a682eeef93806eabb5452
Rust
magiclen/rocket-accept-language
/src/macros.rs
UTF-8
706
3.109375
3
[ "MIT" ]
permissive
/// This macro can be used to create a `Vec<LanguageIdentifier>` instance quickly by providing multiple `<language>[-<region>]` or `<language>[_<region>]` strings separated by commas. #[macro_export] macro_rules! language_region_pairs { ($($id:expr),* $(,)*) => { vec![$($crate::unic_langid::langid!($id),)*]...
true
a82c096aaae09c1f3e4c4270694150d1ad8c36ea
Rust
LiquidLemon/advent-of-code
/2015/7/7.rs
UTF-8
2,589
3.46875
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::collections::HashMap; #[derive(Debug)] enum Rule { Value(u16), Alias(String), Operation { op: String, args: Vec<Rule>, }, } impl Rule { fn parse(input: &str) -> Rule { let tokens: Vec<_> = input.trim().split(' ').collect(...
true
ad9f94ac644129b0cc8c1691f73b169767a3b2a5
Rust
wisest30/AlgoStudy
/source/leetcode/2125/hyo.rs
UTF-8
371
2.71875
3
[]
no_license
impl Solution { pub fn number_of_beams(bank: Vec<String>) -> i32 { let mut prev = 0; bank.iter() .filter(|s| s.contains("1")) .map(|s| s.chars().filter(|&c| c == '1').count()) .fold(0, |acc, x| { let ret = acc + x * prev; prev = x;...
true
5af1adbfe9756a0eb82e12f412807d5843f45768
Rust
placrosse/RobotS
/src/actors/actor_cell.rs
UTF-8
8,697
3.4375
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use std::sync::{Arc, Mutex, RwLock}; use actors::{Actor, ActorRef, ActorSystem, CanReceive, Message, Props}; /// Special messages issued by the actor system. #[derive(Clone)] pub enum SystemMessage { /// Restarts the actor by repa=lacing it with a new version created with its Props...
true
fd4db16d7a68538680f429bd6529d13312c14946
Rust
oliverlee/dominion
/scraper/src/lib.rs
UTF-8
609
2.75
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] pub struct Scrape { pub sets: Vec<Set>, pub types: Vec<String>, pub cards: Vec<Card>, } #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Set { pub name: String, pub card_indices: Vec<usize>, } #[derive(Seriali...
true
6c941f0ca3f898212210f167c114e76f7893af66
Rust
NeoLegends/sutp
/implementation/sutp/tests/smoke.rs
UTF-8
3,951
2.953125
3
[]
no_license
mod common; use crate::common::run_timed; use env_logger; use futures::prelude::*; use log::info; use std::{ io::{Error, ErrorKind}, thread, time::Duration, }; use sutp::{SutpListener, SutpStream}; use tokio::{ self, io::{read_to_end, shutdown, write_all}, }; const TEST_STRING: &str = "Hello World...
true
b3a4e3728bcf413dfc07eb308aec60f807f0fd82
Rust
adamransom/id3
/src/tag/mod.rs
UTF-8
1,024
3.375
3
[]
no_license
//! Types, structs and functions related to reading an ID3v2 tag. use std::io::Read; use std::result; use header::Header; use frame::Frame; pub use self::error::Error; mod error; /// A specialised `Result` type for tag reading operations. pub type Result<T> = result::Result<T, Error>; /// A type representing an I...
true
19771c89ee4d1caa9270b12f8baed641993f70e5
Rust
FrozenDroid/nrf91-rs
/src/dppic_ns/chenclr.rs
UTF-8
47,775
2.90625
3
[ "0BSD" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CHENCLR { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
true
8fdddb2cbbd97977caf74b0f20e6cfd7607f4073
Rust
m-ou-se/whichever-compiles
/src/lib.rs
UTF-8
1,320
2.796875
3
[ "BSD-2-Clause" ]
permissive
use proc_macro::{Delimiter::Brace, TokenStream, TokenTree::Group}; use std::{fs::File, io::Read, os::unix::io::FromRawFd}; #[proc_macro] pub fn whichever_compiles(input: TokenStream) -> TokenStream { let mut input = input.into_iter(); let mut alternatives = Vec::new(); while let Some(t) = input.next() { ...
true
86e156741e1220c6d2f7f2e03d49c12c1bac7805
Rust
lar-rs/can
/src/can4linux/mod.rs
UTF-8
2,287
2.78125
3
[]
no_license
mod analog; mod aouts; mod motor; mod digital; pub mod bindings; pub use self::bindings as can; pub use self::analog::*; pub use self::aouts::*; pub use self::motor::*; pub use self::digital::*; pub use super::rpc; use jsonrpc_core::{Result}; use super::rpc::Node; fn read_value(node:i32,index:i32,sub: u8) -> Result...
true
c256e5f7c9a7e9b36142bab41e888dfea8a88f89
Rust
mrkgnao/afterburner
/src/last.rs
UTF-8
280
2.9375
3
[]
no_license
use crate::absorb::*; pub struct Last<T>(pub Option<T>); impl<T> Last<T> {} impl<T> Absorb for Last<T> { fn nil() -> Last<T> { Last(None) } fn absorb(&mut self, other: &mut Last<T>) { if let Some(value) = other.0.take() { self.0 = Some(value); } } }
true
22cfd9b755c372fd37314ed83570494e254f9419
Rust
antonblanchard/bar
/src/bar/bar.rs
UTF-8
7,114
3.109375
3
[ "MIT" ]
permissive
use std::char; use std::str; use std::fmt; use std::cmp::Ordering; use std::collections::BTreeMap; use std::collections::Bound; use std::process::{ Command, Stdio, ChildStdin, }; use std::io::prelude::*; use std::io::{ BufWriter, }; use pipe::PipeWriter; use util::{ Result, Error, }; pub struc...
true
c0dc07ea0810e3d7a3385d17767f68c3143c0fd6
Rust
matthunz/async-native-timer
/src/unix.rs
UTF-8
1,749
2.578125
3
[ "MIT" ]
permissive
use crate::RawTimer; use libc::{timerfd_create, CLOCK_MONOTONIC, TFD_NONBLOCK}; use mio::unix::EventedFd; use mio::{Evented, Poll, PollOpt, Ready, Token}; use std::io; use std::os::unix::io::RawFd; use std::time::Duration; /// Unix implementation of a `RawTimer` based on file descriptors pub struct NativeTimer { ...
true
29421fbe836d655a0416e42557ff94d325238ea8
Rust
starcoinorg/starcoin
/vm/gas-algebra-ext/src/transaction.rs
UTF-8
4,809
2.546875
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 //! This module defines all the gas parameters for transactions, along with their initial values //! in the genesis and a mapping between the Rust representation and the on-chain gas schedule. use crate::algebra::{FeePerGasUnit, Ga...
true
b9a78753d92738019f1a7835665209d654f3206c
Rust
jdm/diesel
/diesel/src/insertable.rs
UTF-8
5,395
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::marker::PhantomData; use backend::{Backend, SupportsDefaultKeyword}; use expression::{AppearsOnTable, Expression}; use result::QueryResult; use query_builder::{AstPass, QueryFragment, UndecoratedInsertRecord, ValuesClause}; use query_source::{Column, Table}; #[cfg(feature = "sqlite")] use sqlite::Sqlite; ///...
true
504dbc81468058f7c1cb698607e94ff4cb64a0b6
Rust
kroeckx/ruma
/crates/ruma-events/src/room_key_request.rs
UTF-8
2,776
3.0625
3
[ "MIT" ]
permissive
//! Types for the *m.room_key_request* event. use ruma_events_macros::EventContent; use ruma_identifiers::{DeviceIdBox, EventEncryptionAlgorithm, RoomId}; use ruma_serde::StringEnum; use serde::{Deserialize, Serialize}; /// The payload for `RoomKeyRequestEvent`. #[derive(Clone, Debug, Deserialize, Serialize, EventCon...
true
3684e3d16c961a076e7836344561284ef8a30b15
Rust
ValorZard/Resphys-Fixed
/src/object/builder.rs
UTF-8
2,723
2.96875
3
[ "Apache-2.0" ]
permissive
pub use super::super::collision::AABB; pub use super::{Body, BodyHandle, BodyStatus, Collider, ColliderState}; use crate::Vec2; /// Builder for the `Body`. Start with `new`, finish with `build`. #[derive(Debug, Clone)] pub struct BodyDesc { pub position: Vec2, pub velocity: Vec2, pub status: BodyStatus, ...
true
f7f587661465dbf291f21bba559ea0768009d84a
Rust
katharostech/async_graphql_extras
/examples/with_macro.rs
UTF-8
1,110
2.609375
3
[]
no_license
use std::convert::Infallible; use async_graphql::*; use async_graphql_extras::graphql_object; use warp::Filter; type MySchema = Schema<Query, EmptyMutation, EmptySubscription>; struct Query; /// Information about the user #[graphql_object] pub struct UserData { username: String, display_name: String, } #[O...
true
4460805c4b0af3341a8125300bd054f58812b011
Rust
dejanos-pocket/enutt
/src/client.rs
UTF-8
3,506
2.625
3
[]
no_license
use std::convert::TryFrom; use std::net::SocketAddr; use quinn::{Endpoint, RecvStream, SendStream}; use tracing::{error, info}; use crate::config::{new_transport_cfg, Quic}; use crate::connection::{ConnectionHolder, ConnectionPool}; use crate::message::Message; use crate::node::Address; use crate::Error; pub struct ...
true
d81ccae3b6bfd24e0bc622449fd10a4860e89bb0
Rust
marcusradell/monadium
/api/lib/src/kits/status/mod.rs
UTF-8
1,093
2.78125
3
[]
no_license
use crate::io::{Error, Result}; use axum::{routing::get, Json, Router}; use serde::Serialize; use std::sync::{Arc, Mutex}; use super::KitRouter; #[derive(Clone, Serialize, Default)] pub enum StatusValue { #[default] Booting, Ready, Unhealthy, _ShuttingDown, } #[derive(Clone, Serialize, Default)] ...
true
3aee2d49f615f47ecf8fdfc1fcb7572b7e6dd32e
Rust
iCodeIN/rust-dangerous
/examples/json.rs
UTF-8
5,176
3.09375
3
[ "MIT" ]
permissive
//! This example demonstrates a simple JSON parser (doesn't support escaping //! fully). //! //! ``` //! echo '{ "hello": "bob" }' | cargo run --example json //! ``` use std::io::{self, Read}; use dangerous::{BytesReader, Error, Expected, Input, Invalid}; fn main() { let mut input_data = Vec::new(); io::stdin...
true
8db0ca14dca4ee5dec1d3c0c586746a4dc983d81
Rust
Alonely0/tinytest
/src/lib.rs
UTF-8
1,859
3.546875
4
[ "MIT" ]
permissive
#![no_std] //! Write more compact unit tests with a small macro. /// This macro takes a test name, a closure and its expected value, and translates them into a unit test. /// # Examples /// ``` /// unit_test!(test1, || some_function_in_scope("test").unwrap(), "expected output") /// ``` /// automatically gets translat...
true
cdbdaadfb6724870d4bdf2dae215bc9e52612ec4
Rust
ysoftman/test_code
/rust/iterator_vs_for/iterator_vs_for.rs
UTF-8
770
3.109375
3
[ "MIT" ]
permissive
// ysoftman // iterator vs for // iterator(반복자)는 컴파일되서 어셈블리코드가 생성되면 loop unrolling 되어 for 이상으로 빠르다. // loop unrolling - 반복문을 쓰지 않고 반복만큼 코드를 반복(풀어)시킨다. // for i<10; i++ { // dosomething; // } // 을 loop unrolling 하면 // dosomething; ... 10 번 명시하게 된다. // 루프 마다 조건을 검사하는 오버헤드를 줄여 속도를 빠르게 할 수 있는 장점이 있지만 // 코드 사이즈가 커지고 unr...
true
a7141df6ad640b90165f782f3031eb2e1900722b
Rust
i-poper/bluez-dbus
/src/blocking/session.rs
UTF-8
4,019
2.75
3
[]
no_license
use crate::*; use dbus::arg::{Append, AppendAll, Arg, Get, ReadAll, Variant}; use dbus::blocking::Connection; use std::fmt; use std::fmt::Debug; use std::sync::{Arc, Mutex}; use std::time::Duration; static MANAGED_OBJECT_INTERFACE: &str = "org.freedesktop.DBus.ObjectManager"; static MANAGED_OBJECT_METHOD: &str = "GetM...
true
9dfb0956fef9b92cf07dcb601fcbc0f32211f85f
Rust
dermesser/localmr
/src/formats/lines.rs
UTF-8
5,740
3.25
3
[ "MIT" ]
permissive
//! Module that uses text files as input to the mapper phase. //! This module implements only an iterator yielding single lines; //! using the RecordIterator from formats::util, the necessary key/value //! iterator can be implemented. use phases::output::SinkGenerator; use std::fs; use std::io; use std::io::{Read, Buf...
true
7da9f75bc24f434a1bc1025ad4f09accbb29cbc6
Rust
2xsaiko/mcrestool
/binserde/src/util.rs
UTF-8
1,587
2.84375
3
[ "MIT" ]
permissive
use std::marker::PhantomData; use crate::{BinDeserialize, BinDeserializer, BinSerialize, BinSerializer, Result}; pub struct VecLikeIter<D, T> { deserializer: D, remaining: usize, marker: PhantomData<T>, } impl<'de, D, T> VecLikeIter<D, T> where D: BinDeserializer<'de>, T: BinDeserialize<'de>, { ...
true
b258624ac6380eb1314e4ab746a634e62d314807
Rust
Practical-Formal-Methods/blossom
/wholeProgramAnalyzer/blossom/benchmarks/rust/arclength/arclength.rs
UTF-8
560
2.90625
3
[ "MIT", "NCSA", "BSD-2-Clause" ]
permissive
pub fn numerical_kernel(x : f64) -> f64 { let n : i32 = 5; let mut t1 : f64; let mut d1 : f64 = 1.0; t1 = x; for k in 1 .. (n+1) { d1 = 2.0 * d1; t1 = t1 + (d1 * x).sin() / d1; } return t1; } pub fn original_program_main(n : i32) { let h : f64; let mut t2 : f64; let dppi : f64; let mut ...
true
13e3524adccda3de068cb0672e9b44dca216d83b
Rust
tommyshem/learn-to-code
/learn-rustlang/coding-exercises/website-exercises/src/strings/codewars/two_to_one.rs
UTF-8
1,525
3.65625
4
[]
no_license
// code wars - two to one use colored::*; pub fn solution(){ println!("{} Run test suit {}","Two to one".green(),"cargo test two_to_one_basic_tests".yellow()); let _solution = longest("testing","te"); } // solution to the problem fn longest(a1: &str, a2: &str) -> String { // Copy chars into a vector, sort...
true
23dcd1db12508fbb798dec1dfb49e0fa6cd7b7cd
Rust
svip/adventofcode
/2018/day19/day19-2.rs
UTF-8
7,145
3.109375
3
[ "MIT" ]
permissive
use std::io; use std::io::prelude::*; #[derive(Copy,PartialEq,Debug)] enum Op { Ip, // Set instruction pointer Addr, //(add register) stores into register C the result of adding register A and register B. Addi, //(add immediate) stores into register C the result of adding register A and value B. Mulr, // (multi...
true
2c5cae697ab068f8451028974f5ebca6b371b238
Rust
syberant/evolvim
/evolvim-lib/src/lib/neat/output.rs
UTF-8
1,058
2.8125
3
[ "MIT" ]
permissive
#[derive(Clone, Debug, Serialize, Deserialize)] pub enum OutputType { MouthHue, Eating, Turning, Accelerating, Fight, } impl OutputType { pub fn use_output<B>( &self, value: f64, env: &mut crate::brain::EnvironmentMut<B>, time_step: f64, ) { use Outpu...
true
96ea021a30d3970b3d285a8ab5a036ef05627f23
Rust
sgravrock/adventofcode
/2019/rust/day15p2/src/pathfinder.rs
UTF-8
3,509
3.21875
3
[ "MIT" ]
permissive
use crate::bot::{Bot, Cell, Coord, Direction}; #[cfg(test)] use crate::testing_bot::TestingBot; use std::collections::{VecDeque, HashSet}; struct Path { moves: Vec<Direction>, pos: Coord } impl Path { fn append(&self, dir: Direction) -> Path { let next_pos = match dir { Direction::N => (self.pos.0, self.pos.1...
true
aa2f25be624c394e28079dbef7547b64ad7fe1ab
Rust
hhandika/spades-runner
/src/parser.rs
UTF-8
2,969
3.390625
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::BufReader; use std::io::prelude::*; use crate::utils; pub fn parse_seqdir(input: &str) -> Vec<SeqDirs> { let file = File::open(input).unwrap(); let buff = BufReader::new(file); let mut seqdir = Vec::new(); buff.lines() .filter_map(|ok| ok.ok()) .skip(1)...
true
3d1b68c1d8f288c5a91fd6cb2370ebe3af9f0335
Rust
villor/rustia
/crates/protocol/src/codec.rs
UTF-8
5,836
2.734375
3
[]
no_license
use bytes::{Buf, BufMut, Bytes, BytesMut}; use std::io; use adler32::adler32; use tokio_util::codec::{Encoder, Decoder}; use super::util::xtea; const HEADER_SIZE: usize = 2; const CHECKSUM_SIZE: usize = 4; const MAX_FRAME_SIZE: usize = 24590; const MAX_DATA_SIZE: usize = MAX_FRAME_SIZE - HEADER_SIZE; #[derive(Debug)...
true
41d20156e76f64ac71378ccb46187fc010cce512
Rust
dougtq/rust-lang
/playground/throw-fun/src/main.rs
UTF-8
559
2.734375
3
[ "MIT" ]
permissive
#[macro_use] extern crate throw; use std::io::prelude::*; use std::io; use std::fs::File; fn read_log() -> Result<String, throw::Error<io::Error>> { let mut file = throw!(File::open("some_file.log")); let mut buf = String::new(); throw!(file.read_to_string(&mut buf)); Ok(buf) } fn do_things() -> Resu...
true
fac9a20673ca8968ccfdaee184b230c55de22cc8
Rust
brunoczim/thedes
/src/math/rand/weighted.rs
UTF-8
9,446
3.125
3
[ "MIT" ]
permissive
use crate::{ error::Result, math::{ rand::noise::{NoiseGen, NoiseInput, NoiseProcessor}, NumRange, }, }; use num::{ integer::Integer, rational::Ratio, traits::{ cast::{FromPrimitive, ToPrimitive}, ops::checked::{ CheckedAdd, CheckedDiv, ...
true
7e620e2f92ac0732966236dbfe7891760cdefa02
Rust
KevinWMatthews/rust-ownership
/src/lifetimes_for_references.rs
UTF-8
1,435
4.0625
4
[]
no_license
fn main() { example1(); example2(); example3(); example4(); } fn example1() { let x = 5; let y = &x; // <-- Lifetime of reference 'y' starts // Use the reference let _val = *y; // <-- Lifetime of reference 'y' ends // Do other stuff // ... } fn example2() { let x = 5; ...
true
a1afda575c2ac0e996927c584f6497e9d47ffb1b
Rust
pandoraboxchain/rustheus
/src/chain_builder/src/chain_builder.rs
UTF-8
4,372
2.703125
3
[]
no_license
use primitives::hash::H256; use ser::Serializable; use primitives::bytes::Bytes; use chain::{Transaction, IndexedTransaction, TransactionInput, TransactionOutput, OutPoint}; #[derive(Debug, Default, Clone)] pub struct ChainBuilder { pub transactions: Vec<Transaction>, } #[derive(Debug, Default, Clone)] pub struct Tr...
true
353d3d39b6c3ed6ed93fd8b0924dd5be4d715a3b
Rust
borismueller/rust
/add_calc/src/main.rs
UTF-8
1,991
3.59375
4
[]
no_license
use std::env; fn main() { let args: Vec<_> = env::args().collect(); if args.len() < 4 { println!("not enough args :/"); } else { if args[1].parse::<f64>().is_ok() && args[3].parse::<f64>().is_ok() { match args[2].as_ref() { "+" => println!("result {}", add(args[1...
true
d39fa8ddf02b1447cc508b4269f885050a9333e1
Rust
rachlmac/sos-kernel
/params/src/mem.rs
UTF-8
454
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Memory parameters use memory::PAddr; use core::ops::Range; use core::slice::Iter; /// A memory map is an iterator over memory areas pub type Map<'a> = Iter<'a, Area>; /// A memory area #[derive(Debug, Copy, Clone)] pub struct Area { /// The start address of this memory area pub start_addr: PAddr , /// T...
true
9d3d5ec6e1d96e51bef468e22e63540ee0230ece
Rust
mardiros/cabot
/src/client.rs
UTF-8
12,314
2.578125
3
[ "BSD-3-Clause" ]
permissive
//! The HTTP Client that perform query use std::collections::HashMap; use std::mem; use std::net::SocketAddr; use std::pin::Pin; use async_std::io::{self, Write}; use async_std::task::Context; use async_std::task::Poll; use futures::future::{BoxFuture, Future}; use log::Level::Debug; use super::constants; use super::...
true
1453d5ea9416c877f88cf06faa9cba6d93bbdf34
Rust
input-output-hk/jormungandr
/modules/blockchain/src/lib.rs
UTF-8
2,699
3.234375
3
[ "MIT", "Apache-2.0" ]
permissive
/*! # Blockchain management module this module provides a high level API to manage the blockchain and the different state it may be. Allowing tracking different branches and to be able to make simple informed decisions as to what is the tip of the blockchain or what is a valid block. ## Reference the `Reference` hol...
true
33c8008ee189e24d218cb75daf85fac1700a4ad2
Rust
smallswan/rust-by-example
/src/validators.rs
UTF-8
6,072
2.828125
3
[]
no_license
use regex::Regex; use std::collections::HashMap; lazy_static! { static ref IDENTIFIER_REGEX: Regex = Regex::new("^([0-9ABCDEFGY]{1})([1239]{1})([0-9ABCDEFGHJKLMNPQRTUWXY]{6})([0-9ABCDEFGHJKLMNPQRTUWXY]{9})([0-9ABCDEFGHJKLMNPQRTUWXY])$").unwrap(); static ref REGEX_18_ID_CARD_NO: Regex = Regex::new(r"^\d{17}[\dX...
true
22edc75a9661b969608453d7b14648c9d9c9ae1a
Rust
yrong/rust-examples
/rpl/_01_hello/main.rs
UTF-8
1,788
3.921875
4
[ "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
/* #1: defines a function named: `main`. main function: + this is a special function. + it runs as the first code in an executable rust program. */ fn main() { /* ^ | between `{` and `}` this is where this function's body starts. ============================================...
true
3182584a8c13212abf945d9111e88d3ea90c00f4
Rust
Simteract/obj-exporter-rs
/examples/export_obj_single.rs
UTF-8
1,371
2.578125
3
[ "MIT" ]
permissive
extern crate obj_exporter as obj; use obj::{Geometry, ObjSet, Object, Primitive, Shape, TVertex, Vertex}; pub fn main() { let set = ObjSet { material_library: None, objects: vec![ Object { name: "Square".to_owned(), vertices: vec![ (-1.0, -1.0, 0.0), (1.0, -1.0, 0.0...
true
8187820b559a9f0a6d153401bc4fa4dfce018496
Rust
thomas9911/timeseries
/src/postgresql_structs.rs
UTF-8
8,273
2.71875
3
[]
no_license
#![cfg(feature = "postgresql_db")] use crate::{BtreeMapTrait, DbObject, DbTableError, Table, TableMetaTrait}; use postgres::types::ToSql; use std::collections::{BTreeMap, HashMap}; #[derive(Debug)] pub enum PostgresqlError { Bincode(std::boxed::Box<bincode::ErrorKind>), DbTableError(DbTableError), Postgres...
true
123243c8297fb1f31557eccf891745950e79b2fa
Rust
pete21/tickgrinder
/private/src/trading_conditions/sma_cross.rs
UTF-8
526
3.21875
3
[ "MIT" ]
permissive
//! Basic trading condition that checks whether the price crosses a SMA upwards or downwards //! and creates orders when it does. use tickgrinder_util::trading::tick::*; use tickgrinder_util::trading::trading_condition::*; pub struct SmaCross { period: usize, } impl TradingCondition for SmaCross { fn eval(&m...
true
5db55cb8d6b840488b17959f8e22b1f504f70f58
Rust
Cloudxtreme/astro-rust
/src/interpol.rs
UTF-8
1,461
3.421875
3
[ "MIT" ]
permissive
//! Interpolation of intermediate values of functions /** Interpolates an intermediate value of a function from three of it's given values # Returns * `interpol_val`: Intermediate value of the function # Arguments * `y1`: Value 1 of the function * `y2`: Value 2 of the function * `y3`: Value 3 of the function * `n`...
true
1be6a60225e4ec9987a14d4d1a43322c7388c2f2
Rust
ilaborie/grass
/src/args.rs
UTF-8
6,397
2.9375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use codemap::{Span, Spanned}; use crate::{ common::Identifier, error::SassResult, value::Value, {Cow, Token}, }; #[derive(Debug, Clone)] pub(crate) struct FuncArgs(pub Vec<FuncArg>); #[derive(Debug, Clone)] pub(crate) struct FuncArg { pub name: Identifier, pub ...
true
7e5a4ad1d73fce83c102ba79a9d8bd80b4497ae4
Rust
Al-Kindi-0/tfhe
/src/circuits/utils.rs
UTF-8
1,111
3.625
4
[ "Apache-2.0" ]
permissive
//! A small module containing useful utility functions. /// A helper function for converting a byte to an array of bits. pub const fn to_bits(byte: u8) -> [bool; 8] { let bit7: bool = ((byte >> 7) & 0b1) == 1; let bit6: bool = ((byte >> 6) & 0b1) == 1; let bit5: bool = ((byte >> 5) & 0b1) == 1; let bit4: bool ...
true
f25ca9d38892834c0751f9356bbfaededf27160d
Rust
infinyon/fluvio
/crates/fluvio-cli/src/client/tableformat/mod.rs
UTF-8
3,221
2.84375
3
[ "Apache-2.0" ]
permissive
mod create; mod delete; mod list; pub use cmd::{TableFormatConfig, TableFormatCmd}; mod cmd { use std::sync::Arc; use std::path::PathBuf; use std::fs::File; use std::io::Read; use std::fmt::Debug; use async_trait::async_trait; use serde::Deserialize; use clap::Parser; use anyhow:...
true
f42763487a0f96989b07e7f9f02e884c63dc6906
Rust
gemarcano/libtock-rs
/src/buttons.rs
UTF-8
4,149
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use crate::callback::CallbackSubscription; use crate::callback::Consumer; use crate::result::OtherError; use crate::result::OutOfRangeError; use crate::result::TockResult; use crate::syscalls; use core::marker::PhantomData; const DRIVER_NUMBER: usize = 0x00003; mod command_nr { pub const COUNT: usize = 0; pub...
true
e29529d9b66268f3874a06b8b653e0ce9f4f2989
Rust
RevelationOfTuring/Rust-exercise
/src/lifetimes/mod.rs
UTF-8
1,554
3.5625
4
[ "Apache-2.0" ]
permissive
/* 生命周期 编译器中的`借用检查器`用生命周期来保证所有的借用都是有效的。 确切地说,一个变量的生命周期在它创建的时候开始,在它销毁的时候结束。 虽然生命周期和作用域经常被一起提到,但它们并不相同。 考虑这种情况,我们通过 & 来借用一个变量。 该借用拥有一个生命周期,此生命周期由它声明的位置决定。 于是,只要该借用在出借者(lender)被销毁前结束,借用就是有效的。 然而,借用的作用域则是由使用引用的位置决定的。 */ mod explicit_annotation; mod functions; mod methods; mod structs; mod ...
true
7eb776c7eff21c75808c534e2661350ddaf2410c
Rust
keydunov/lisp-in-rust
/src/evaluator.rs
UTF-8
2,470
3.421875
3
[]
no_license
use parser::Sexpr; use std::fmt; pub enum LispValue { Nil, Symbol(String), Int(i32) } pub struct Evaluator; pub type EvalResult = Result<LispValue, String>; impl LispValue { fn pretty_print(&self) -> String { match *self { LispValue::Nil => "nil".to_string(), LispValue::Int(x) => x.to_string...
true
b4c9c5105d2fa933800eb9c09f6cc0f0adab7a10
Rust
mdraeger/networks
/src/parse_text.rs
UTF-8
3,555
3.109375
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use regex::Regex; use std::fs::File; use std::io::{BufReader, BufRead}; use std::path::Path; use network::{Capacity, Cost, NodeId}; /// Describes one edge (arc) in a network, regardless of actual network /// implementation. pub type Edge = (NodeId, NodeId, Cost, Capacity); fn parse_pat...
true
8f2c58bff1f92675e989119b1116b103b3a8ea37
Rust
gimli-rs/gimli
/src/read/reader.rs
UTF-8
15,124
3.125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[cfg(feature = "read")] use alloc::borrow::Cow; use core::convert::TryInto; use core::fmt::Debug; use core::hash::Hash; use core::ops::{Add, AddAssign, Sub}; use crate::common::Format; use crate::endianity::Endianity; use crate::leb128; use crate::read::{Error, Result}; /// An identifier for an offset within a secti...
true
0e609a2221b996e0a2cc8e545f1bb5b3121a5a26
Rust
archer884/rust-sfv
/src/creation.rs
UTF-8
839
2.890625
3
[]
no_license
use record::SfvRecord; use std::io; use std::path::Path; /// A collection of filenames and their attendant checksums. #[derive(Debug, Default)] pub struct SfvCreator { records: Vec<SfvRecord> } impl SfvCreator { /// Creates a new blank `SfvCreator`. pub fn new() -> SfvCreator { SfvCreator::default...
true
7c50dc10485467cdc8f656b3ddf4d32497a9be1a
Rust
EFanZh/LeetCode
/src/problem_0053_maximum_subarray/dynamic_programming.rs
UTF-8
849
2.8125
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn max_sub_array(nums: Vec<i32>) -> i32 { let mut max_sum = i32::MIN; let mut prev_max_sum = 0; for num in nums { p...
true
a123d32d5762591ed5390421fd9c723da7d77b35
Rust
ruma/ruma
/crates/ruma-common/src/serde/base64.rs
UTF-8
4,810
3.1875
3
[ "MIT" ]
permissive
//! Transparent base64 encoding / decoding as part of (de)serialization. use std::{fmt, marker::PhantomData}; use base64::{ engine::{general_purpose, GeneralPurpose, GeneralPurposeConfig}, Engine, }; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; /// A wrapper around `B` (usually `Vec<u8>...
true
f46a61bf4de669ac0c740dbe85c42237e37c449a
Rust
PetarV-/advent-of-rust
/src/bin/aor-22.rs
UTF-8
7,178
2.921875
3
[ "MIT" ]
permissive
use std::io::prelude::*; use std::fs::File; use std::path::Path; use std::collections::HashMap; const INFTY: i32 = 1 << 30; #[derive(Clone, Hash, PartialEq, Eq)] struct Wizard { hp : i32, arm : i32, mana: i32 } #[derive(Clone, Hash, PartialEq, Eq)] struct Warrior { hp : i32, dmg: i32 } #[derive...
true
7fcc237027cd62ebe4da97db8613f3a97a961f3a
Rust
nervosnetwork/muta-utils
/muta-codec-derive/src/decode.rs
UTF-8
5,278
2.671875
3
[ "MIT" ]
permissive
use proc_macro2::TokenStream; use quote::quote; pub struct ParseQuotes { single: TokenStream, list: TokenStream, } pub fn decode_parse_quotes() -> ParseQuotes { ParseQuotes { single: quote! { rlp.val_at }, list: quote! { rlp.list_at }, } } pub fn decode_unnamed_field(index: usize,...
true
0c716a01caf04a8bb3eb9783cc646ea87daafe25
Rust
chin0/everydayalgo
/baekjoon/graph/dfs_bfs/bfs_1012/src/main.rs
UTF-8
1,974
3.28125
3
[]
no_license
use std::io::{stdin, Read}; use std::str::{FromStr, SplitWhitespace}; use std::collections::VecDeque; #[derive(Default)] struct Scanner { buffer: Vec<String> } impl Scanner { fn next<T: std::str::FromStr>(&mut self) -> T { loop { if let Some(token) = self.buffer.pop() { ret...
true
438a0ba56d43cda969862e7d28ec60e7bcec0bf8
Rust
jimblandy/swgl-replay
/gl-replay/src/bin/dump-commands.rs
UTF-8
868
2.59375
3
[]
no_license
use docopt::Docopt; use serde::Deserialize; use std::io; use gl_replay::Call; use gl_replay::FileRecording; type Recording = FileRecording<Call>; const USAGE: &'static str = " Dump gl-replay command log. Usage: gl-replay <dir>... "; #[derive(Debug, Deserialize)] struct Args { arg_dir: Vec<String>, } fn main...
true
fbec594bb0a7885c664fa98e42ccd4bc9e9c3228
Rust
icyJoseph/codejam-js
/src/broken_clock/src/broken_clock.rs
UTF-8
3,446
3.0625
3
[]
no_license
use std::io; type Res<T> = Result<T, Box<dyn std::error::Error>>; fn nxt() -> String { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(_) => input, _ => panic!("Error reading line"), } } fn parse_num<T: std::str::FromStr>() -> T { match nxt().trim().parse::...
true
b3e170fbb363b7436165d7a1b2865bcd9dfac41d
Rust
KevinGrandon/learning-rust
/examples/18-generics/18-generics.rs
UTF-8
993
3.84375
4
[]
no_license
// A generic struct struct Pair<XFOO> { first: XFOO, second: XFOO, } // A generic function fn swap<XFOO>(pair: Pair<XFOO>) -> Pair<XFOO> { let Pair { first: first, second: second } = pair; Pair { first: second, second: first } } // Reimplementing a 2-element tuple as a tuple struct struct Tuple2<XFOO...
true