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
5971903b420b5e5243938b0bbc2d749d92a5f831
Rust
freiguy1/rust-roller
/src/control/list_select.rs
UTF-8
4,488
3.09375
3
[ "MIT" ]
permissive
#![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] use control::Control; use dice::Dice; use rustbox::keyboard::Key; use rustbox::{Color, RustBox}; use std::collections::VecDeque; pub struct ListSelect { items: VecDeque<Dice>, selected_index: usize, selected: bool, size_x: usiz...
true
a89422428c3a8a3e3b92e8293cbea86f504a891d
Rust
ugnom/programming_competition_archive
/abc/abc049/a.rs
UTF-8
589
3.453125
3
[]
no_license
use std::str::FromStr; fn get_one<T : FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); return s.trim().parse().ok().unwrap(); } fn get_vec<T : FromStr>() -> Vec<T> { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); return s.trim().split_w...
true
b46e1cdcf664fa1e225b4f03f176882a16e73510
Rust
SkylerLipthay/mini-v8
/src/error.rs
UTF-8
3,404
3.234375
3
[ "MIT" ]
permissive
use crate::*; use std::error::Error as StdError; use std::fmt; use std::result::Result as StdResult; /// `std::result::Result` specialized for this crate's `Error` type. pub type Result<T> = StdResult<T, Error>; /// An error originating from `MiniV8` usage. #[derive(Debug)] pub enum Error { /// A Rust value could...
true
fcffc8c48a0b27024f8a8e90aeb2ce91f8655dd3
Rust
kyle-mccarthy/fn-rs
/fn-api/src/lib.rs
UTF-8
4,065
2.984375
3
[]
no_license
pub mod errors; use crate::errors::Errors; use failure; use serde::{Deserialize, Serialize}; use serde_json; use std::collections::HashMap; /// Trait for handling common conversions pub trait ConvertFunction<'a>: Sized + Deserialize<'a> + Serialize { fn to_bytes(&self) -> Result<Vec<u8>, Errors> { serde_c...
true
130d0eaa7f2d919aa4b76f90285cdc867aa15f08
Rust
tuanir/fantoch
/fantoch/src/sim/runner.rs
UTF-8
30,077
2.515625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::client::{Client, Workload}; use crate::command::{Command, CommandResult, DEFAULT_SHARD_ID}; use crate::config::Config; use crate::executor::{ExecutionOrderMonitor, Executor, ExecutorMetrics}; use crate::id::{ClientId, ProcessId, ShardId}; use crate::metrics::Histogram; use crate::planet::{Planet, Region}; us...
true
150be912dfc9312a79c4f8b85d463348074c060c
Rust
IThawk/rust-project
/rust-master/src/test/ui/statics/static-recursive.rs
UTF-8
989
2.640625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; struct StaticDoubleLinked { prev: &'static StaticDoubleLinked, next: &'static StaticDoubleLinked, data: i32, head: bool } static L1: StaticDoubleLinked = StaticDoubleLinked{prev: &L3, next: &L2, data: 1, head: true};...
true
3479fd3be82c751c456ea2d96808e328bf5c45f9
Rust
chklauser/adventofcode-solutions
/2019/src/day14.rs
UTF-8
9,576
2.765625
3
[ "MIT" ]
permissive
use std::rc::Rc; use fxhash::FxHashMap; #[aoc_generator(day14)] pub fn generator(input: &str) -> Vec<Recipe> { let mut elements: FxHashMap<&str, Rc<String>> = FxHashMap::default(); fn intern<'a>(elements: &mut FxHashMap<&'a str, Rc<String>>, id: &'a str) -> Rc<String> { elements.entry(id).or_insert_wit...
true
98d72495e8cfe7900e84c6a4abe825f6e63e6f12
Rust
voxjar/elastiql
/src/search/script.rs
UTF-8
3,190
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
//! Types for searching/aggregating using [scripts] //! //! [scripts]: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html use std::default::Default; use serde::{Deserialize, Serialize}; /// Available sandboxed scripting [languages]. /// /// [languages]: https://www.elastic.co/guid...
true
e8d843a713ad8395d4d4effc5bc2afafb55c0f9e
Rust
andriy-kuz/coursera_bitcoin
/blockchain/src/txhandler.rs
UTF-8
2,503
2.859375
3
[]
no_license
use crypto::*; use std::collections::HashSet; use transaction::Transaction; use utxo::*; pub struct TxHandler<'a> { utxo_pool: &'a mut UTXOPool, } impl<'a> TxHandler<'a> { pub fn new(utxo_pool: &'a mut UTXOPool) -> Self { { TxHandler { utxo_pool } } } pub fn is_valid(&mut ...
true
e936e830b440d4c1300be463cc5d8d3b3344ddca
Rust
paulhandy/iota.rs
/sign/src/iss.rs
UTF-8
12,567
2.546875
3
[]
no_license
// This is a straight clone off https://github.com/Come-from-Beyond/ISS/blob/master/src/cfb/iss/ISS.java for testing purposes. // XXX DO NOT EXPECT THE METHODS OR CODE IN THIS MODULE TO PERSIST XXX use trytes::*; use tmath::*; use trytes::constants::RADIX; use curl::*; use core::cmp::min; const TRYTE_WIDTH: usize = 3...
true
92650ac7729d820e7107c5dc32eba91b70cc0527
Rust
beqaabu/t3rn
/circuit/pallets/execution-delivery/src/message_assembly/chain_generic_metadata.rs
UTF-8
4,559
2.765625
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
#![cfg_attr(not(feature = "std"), no_std)] use sp_std::fmt::Debug; use sp_std::vec; use frame_metadata::{DecodeDifferent, ExtrinsicMetadata, RuntimeMetadataV13}; use frame_support::ensure; use sp_std::default::Default; use sp_std::prelude::*; #[derive(Debug)] pub struct Metadata { runtime_metadata: RuntimeMetada...
true
baf3ce962d27f8f52702fe669ba5c6ac90aa1641
Rust
MrJohz/re-redis
/tests/test_sync_bit_commands.rs
UTF-8
6,090
2.828125
3
[]
no_license
#![cfg(feature = "sync-client")] extern crate reredis; mod utils; use reredis::commands::*; use crate::utils::load_redis_instance; use quickcheck_macros::quickcheck; use std::collections::HashMap; #[test] fn getbit_and_setbit_work_on_a_single_bit() { let server = load_redis_instance(); let mut client = rere...
true
54cb173febd4de3dfc5cdba9a883537eda89139c
Rust
garrettpauls/AdventOfCode2018
/day4/src/main.rs
UTF-8
5,914
2.796875
3
[ "Unlicense" ]
permissive
extern crate aoc_common; extern crate regex; use aoc_common::advent; fn main() { advent(&parse_input, &part_one, &part_two); } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] enum Event { BeginShift(u64), Sleep, Wake, } #[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] struct Input { instant: u6...
true
56a5801d544d1d622e790deace0732a96c2740ec
Rust
yashcodezeros/Rust-Learning
/Phrases/src/greetings/english.rs
UTF-8
498
3.234375
3
[]
no_license
//! This module contains English Phrases //! rustdoc filename.rs generates doc for the comments we provided and u can see by running the index.html //! # Examples //!``` //! let username = "Adam"; //! println!("{} {}!", //! phrases::greetings::english::hello(), //! username); //!``` /// Applies to code that foll...
true
d1d0d05a1fd263da75837ef4c4e0d253e0c31e69
Rust
mrl00/urijudge_online
/rusturi/adhoc/uri3048/src/main.rs
UTF-8
502
3.03125
3
[]
no_license
use std::io; fn main() { let mut ns = String::new(); io::stdin().read_line(&mut ns); let n: u32 = ns.trim().parse().unwrap(); let mut z: Vec<u32> = vec![]; for _i in 0..n { let mut ks = String::new(); io::stdin().read_line(&mut ks); let k:u32 = ks.trim().parse().unwrap(); ...
true
4c9a359f1bc83f982a2f384b361b41bdc23da5f7
Rust
exastion/raytrace
/src/rt/ray.rs
UTF-8
814
3.625
4
[]
no_license
use crate::core::Point; use crate::core::Vector; #[derive(Debug, PartialEq, Copy, Clone)] pub struct Ray { pub o: Point, pub d: Vector, } impl Ray { pub fn new(o: Point, d: Vector) -> Self { Self { o, d: d } } pub fn get_point(self, distance: f64) -> Point { self.o + self.d * dist...
true
60e867063ce4158c6fde46d80583776f38507320
Rust
ejrbuss/rust-tracer
/src/color.rs
UTF-8
1,849
3.671875
4
[ "MIT" ]
permissive
extern crate image; #[derive(Debug, Clone, Copy)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, } impl Color { /// Create a new Color isntance /// /// # Arguments /// * `r` - the red channel /// * `g` - the green channel /// * `b` - the blue channel /// pub fn new(r: ...
true
625a964b5137e82038e4a8ed502b2322db2f081b
Rust
Niraj-Fonseka/advent-of-code-2020
/day4/part1/solution.rs
UTF-8
1,488
3.203125
3
[]
no_license
use std::fs::File; use std::io::{BufRead,BufReader}; use std::collections::HashMap; fn main(){ println!("Running Day 4 solution !"); let file = File::open("./../input.txt").unwrap(); let reader = BufReader::new(file); let mut map = HashMap::new(); map.insert("byr", true); map.insert("iyr", t...
true
8d521e4b949a903145b7a1842d45b00a2dd48765
Rust
ivanacostarubio/yolounwrap
/src/main.rs
UTF-8
490
2.734375
3
[]
no_license
use std::net::SocketAddrV4; fn main() { println!("YOLO UNWRAPS!!"); let socket_addr_string = match std::env::args().into_iter().skip(1).next() { Some(s) => s, None => String::from("127.0.0.1:90009") }; if let Ok(socket_addr) = socket_addr_string.parse::<SocketAddrV4>(){ pr...
true
36eaa108984fb6545db6c4024235a0aae7f91585
Rust
ellbur/key-repeater-test
/src/main.rs
UTF-8
2,125
2.859375
3
[]
no_license
// vim: shiftwidth=2 use std::collections::HashMap; use tokio::sync::oneshot; use tokio::time::{sleep, interval_at, Duration, Instant}; use std::cell::RefCell; use tokio::task; use std::rc::Rc; #[derive(Eq, PartialEq, Debug, Ord, PartialOrd, Hash, Copy, Clone)] enum KeyCode { A, B, C, D, E } struct PressedKey { ...
true
7d420188461668de43794885bd065dbeb11e4188
Rust
mdiflorio/torrenter
/src/pieces.rs
UTF-8
3,999
3.34375
3
[]
no_license
use crate::queue::PieceBlock; use crate::utils::torrents::{BLOCK_LEN, calculate_torrent_size, Torrent}; #[derive(Debug, Clone)] pub struct Pieces { requested: Vec<Vec<bool>>, received: Vec<Vec<bool>>, percent_received: f32, } impl Pieces { pub fn new(torrent: &Torrent) -> Pieces { Pieces { ...
true
35497851dc5511f64c17c6d458e5785bb6216fc0
Rust
reformat0r/nae
/nae-gfx/src/shapes.rs
UTF-8
4,775
2.84375
3
[]
no_license
use lyon::lyon_tessellation::basic_shapes::{ fill_circle, fill_rounded_rectangle, stroke_circle, stroke_rectangle, stroke_rounded_rectangle, stroke_triangle, BorderRadii, }; use lyon::lyon_tessellation::math::Rect; use lyon::lyon_tessellation::{ BuffersBuilder, FillOptions, FillTessellator, FillVertexConstr...
true
006c09c7a0710e54cf6ffadcbca513a5a5b5e74f
Rust
neunenak/rust-meta-interpreter
/schala-lang/src/typechecking.rs
UTF-8
13,815
2.9375
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use std::collections::HashMap; use std::fmt; use std::fmt::Write; /* use std::collections::hash_set::Union; use std::iter::Iterator; use itertools::Itertools; */ use ast; use util::ScopeStack; use symbol_table::{SymbolSpec, SymbolTable}; pub type TypeName = Rc<String>; type Ty...
true
4eddc66be9bb522003f03182470dd2419f6a0bf0
Rust
glopez3008/vit-testing
/vitup/src/config/env.rs
UTF-8
1,924
2.609375
3
[ "MIT" ]
permissive
use super::initials::Initials; use chrono::NaiveDateTime; use iapyx::Protocol; use serde::{Deserialize, Serialize}; use std::time::Duration; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct VitStartParameters { pub initials: Option<Initials>, #[serde(default = "Protocol::http")] pub protocol: Pro...
true
9c8ed58daed4895035c3c74c3e56a22d73af187e
Rust
camchenry/boon
/src/build/windows.rs
UTF-8
6,178
2.53125
3
[ "MIT" ]
permissive
#![allow(clippy::too_many_lines)] use crate::build::{Iterator, collect_zip_directory, get_love_file_name, get_love_version_path, get_output_filename, get_zip_output_filename}; use crate::types::{Bitness, BuildSettings, BuildStatistics, LoveVersion, Platform, Project}; use glob::glob; use remove_dir_all::remove_dir_all;...
true
384047c559bcd0c9303dae321199f29b2dff66d3
Rust
phorkyas-tg/advent-of-code
/aoc2015/src/d2.rs
UTF-8
1,049
2.921875
3
[]
no_license
#[path = "filereader.rs"] mod filereader; pub fn day_two() { let lines = filereader::read_lines_from_file("./data/day2.txt".to_string()); let mut complete_area = 0; let mut ribbon_length = 0; for line in lines { let mut dimensions: Vec<i32> = line.split('x') .map(str:...
true
ad3258e54d67c557a5037de9013b216b351ea88e
Rust
innerr/tikv
/components/tikv_util/src/keybuilder.rs
UTF-8
5,049
3
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. use std::ptr; #[derive(Clone)] pub struct KeyBuilder { buf: Vec<u8>, start: usize, } impl KeyBuilder { pub fn new(max_size: usize, reserved_prefix_len: usize) -> Self { assert!(reserved_prefix_len < max_size); let mut buf ...
true
3b2f566df4dfabb7699ca50dbb5d75fcc5703076
Rust
naoki9911/rsFHE
/src/tlwe.rs
UTF-8
4,899
2.9375
3
[ "Apache-2.0" ]
permissive
use crate::key; use crate::params; use crate::utils; use rand::Rng; use std::iter::Iterator; use std::ops::Add; use std::ops::Neg; #[derive(Debug, Copy, Clone)] pub struct TLWELv0 { pub p: [u32; params::tlwe_lv0::N + 1], } impl TLWELv0 { pub fn new() -> TLWELv0 { return TLWELv0 { p: [0; pa...
true
6524154f25cb07f40eb9f886fb772f99e2cfbf61
Rust
kamilpitula/RustPlatformer
/src/animation_manager.rs
UTF-8
1,167
2.875
3
[ "MIT" ]
permissive
use graphics::math::*; use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; use std::cell::RefMut; use opengl_graphics::Texture; use super::texture_loader::TextureLoader; use super::animator::Animator; pub struct AnimationManager { animators: HashMap<String, RefCell<Animator>>, tex_loader: R...
true
30d375de354396a1c88f10f64f3a6f66281b8f22
Rust
pum-purum-pum-pum/image-rest-rs
/src/image_preview_request.rs
UTF-8
1,781
2.546875
3
[]
no_license
use actix_web::http::header::{HeaderValue, CONTENT_TYPE}; use actix_web::http::StatusCode; use actix_web::{web, Error, HttpResponse}; use futures::Future; use image::ImageFormat; use image::{self}; use serde_derive::{Deserialize, Serialize}; use std::fs; use std::io::BufReader; use std::io::{Error as IoError, ErrorKind...
true
7ba75289b0869807521136c4279f48f712f178f0
Rust
WesleyM314/farnans-farming-game
/src/population.rs
UTF-8
3,672
2.8125
3
[ "MIT" ]
permissive
use crate::crop::Crop; use crate::genes; use crate::tile::Tile; use crate::{BOTTOM_TILE_BOUND, RIGHT_TILE_BOUND, TILE_SIZE}; //Struct used to combine tile and crop structs into one for easy storage into the vector pub struct CropTile<'a> { pub tile: Tile<'a>, pub crop: Crop<'a>, } impl<'a> CropTile<'a> { ...
true
687e8a42fc9213a7d9a00a63597cb8a1bb83961a
Rust
iCodeIN/advent-of-code-3
/crates/core/src/year2017/day25.rs
UTF-8
3,262
3.03125
3
[ "MIT" ]
permissive
use crate::input::Input; use std::collections::HashSet; struct Action { write_one: bool, move_direction: i8, next_state: u8, } struct State { if_zero_action: Action, if_one_action: Action, } pub fn solve(input: &mut Input) -> Result<usize, String> { let mut tape = HashSet::new(); let mut ...
true
2b7d6a572b13f684e5cfa59a32d2d7e3602f49bb
Rust
Caligari/rust-dropbox
/src/test.rs
UTF-8
4,513
2.59375
3
[ "MIT" ]
permissive
#[cfg(test)] mod tests { use crate::*; use std::env; use std::{ fs::File, io::{Read, Write}, }; #[tokio::test] async fn test_user_check() { let token = env::var("DROPBOX_TOKEN").unwrap(); let client = client::AsyncDBXClient::new(&token); tokio::time::slee...
true
88fc022303c24699a702839cdc35d6d70b11defe
Rust
iPTF14hls/rust_sorting_algorithms
/src/ss.rs
UTF-8
572
2.734375
3
[]
no_license
use std::{ cmp::{Ord, Ordering}, mem::swap, }; #[bench] fn selection_sort_properly_sorts(b: &mut test::Bencher) { use crate::test_functions::{sort_testing, BENCH_CONSTANT}; sort_testing(&selection_sort, BENCH_CONSTANT, b) } pub fn selection_sort<T: Ord + Copy>(array: &mut [T]) { for i in 1..array....
true
f3d2aeb0aa49365bb3cc5e8f735ecc9911445fc0
Rust
superdave/falcon
/lib/executor/driver.rs
UTF-8
6,734
3.109375
3
[ "Apache-2.0" ]
permissive
//! A driver concretely executes a Falcon IL programs. use error::*; use executor::State; use executor::successor::*; use il; use RC; use types::Architecture; /// A driver for a concrete executor over Falcon IL. #[derive(Debug, Clone)] pub struct Driver<'d> { program: RC<il::Program>, location: il::ProgramLoc...
true
e3b06c67a3f8a201be5b70742e730a44ea0ea7eb
Rust
cgc/rnd
/ray-tracer-challenge/src/shapes/csg.rs
UTF-8
4,227
3.109375
3
[]
no_license
use std::{str::FromStr}; use crate::{Shape, LocalShape, test_shape, ShapeType, Intersections, intersections, BoundingBox, transform}; #[derive(PartialEq, Debug, Clone)] enum Operation { Union, Intersection, Difference, } impl FromStr for Operation { type Err = (); fn from_str(s: &str) -> Result<...
true
7a253aa2b3a6912026feb163b1b4bcc0561b1f56
Rust
marvelm/beagle
/src/beagle/pipes/heroku.rs
UTF-8
2,837
3.078125
3
[]
no_license
use std::sync::mpsc::{channel, Receiver}; use std::thread; use iso8601; use LogLine; #[derive(Debug, Clone)] pub struct HerokuRouterLogLine { pub timestamp: iso8601::DateTime, pub at: String, pub method: String, pub path: String, pub host: String, pub request_id: String, pub fwd: String, ...
true
91126daf39f664a3b6539d66660d9edb9dbc5896
Rust
Alberto-Izquierdo/snake_webassembly
/src/game.rs
UTF-8
1,996
2.890625
3
[]
no_license
use stdweb::traits::*; use stdweb::unstable::TryInto; use stdweb::web::html_element::CanvasElement; use stdweb::web::{document, CanvasRenderingContext2d}; pub struct Game { pub canvas: CanvasElement, pub ctx: CanvasRenderingContext2d, pub grid_width: u32, pub grid_height: u32, width: f64, heigh...
true
e341e951e89e541acffd59c6f46bd069faffd3a5
Rust
freeduck/akula
/src/models/bloom.rs
UTF-8
2,504
3.015625
3
[ "Apache-2.0" ]
permissive
use super::*; use ethereum_types::Bloom; use sha3::{Digest, Keccak256}; pub const BLOOM_BYTE_LENGTH: usize = 256; // See Section 4.3.1 "Transaction Receipt" of the Yellow Paper fn m3_2048(bloom: &mut Bloom, x: &[u8]) { let hash = Keccak256::digest(x); let h = hash.as_slice(); for i in [0, 2, 4] { ...
true
083cc016344a818958591095dab9ae6cd16e5ba7
Rust
l1h3r/did_url
/src/error.rs
UTF-8
1,015
2.890625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::fmt::Debug; use core::fmt::Display; use core::fmt::Formatter; use core::fmt::Result as FmtResult; pub type Result<T, E = Error> = core::result::Result<T, E>; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] #[non_exhaustive] pub enum Error { InvalidAuthority, InvalidFragment, Invali...
true
bd780685cf6a4317ac82c4bcdbc771056c412a35
Rust
mathw/adventofcode
/aoc2020/src/day14/part2.rs
UTF-8
5,763
3.21875
3
[]
no_license
use crate::DayError; use regex::Regex; use std::{collections::HashMap, str::FromStr}; pub fn part2() -> Result<String, DayError> { let input = include_str!("input.txt"); let mut computer = Computer::from_str(input)?; computer.run(); Ok(format!( "The sum of all memory is now {}", compute...
true
7348068355ce795adfae551212479274f1ae2de8
Rust
reitermarkus/parallalg
/week_05/heat_stencil-rs/src/print_temperature.rs
UTF-8
991
3.375
3
[]
no_license
pub fn print_temperature(matrix: &Vec<f32>, n: usize, m: usize) { let colors = [' ', '.', '-', ':', '=', '+', '*', '#', '%', '@']; let max = 273.0 + 30.0; let min = 273.0 + 0.0; let h = 30; let w = 50; let h_s = n / h; let w_s = m / w; // Upper Wall println!("┌{}┐", "─".repeat(w)); for i in 0...
true
44abe2326f549c1c68cf1c79fd658770cdee441b
Rust
iCodeIN/trash-rs
/src/linux.rs
UTF-8
4,740
2.671875
3
[ "MIT" ]
permissive
use std::env; use std::ffi::OsString; use std::path::{Path, PathBuf}; use std::process::Command; use crate::Error; static DEFAULT_TRASH: &str = "gio"; pub fn is_implemented() -> bool { true } /// This is based on the electron library's implementation. /// See: https://github.com/electron/electron/blob/34c4c8d5088f...
true
571237cf5f7badfdca2ad7517d97009901b903e4
Rust
TomBebbington/ecs.rs
/src/test.rs
UTF-8
705
2.90625
3
[ "BSD-3-Clause" ]
permissive
use testy::Bencher; use std::iter::range; use std::collections::{VecMap, HashMap}; struct Position { x: f64, y: f64 } fn get_vec() -> VecMap<Position> { range(0us, 100).map(|i| (i, Position {x: i as f64, y: i as f64})).collect() } fn get_map() -> HashMap<usize, Position> { range(0us, 100).map(|i| (i, Position {x: i...
true
b234485fc17a7d737c63a3066164900317cc03e7
Rust
darwins-challenge/nadezhda
/examples/evolve.rs
UTF-8
1,499
2.625
3
[ "MIT" ]
permissive
extern crate rand; extern crate nadezhda; use nadezhda::grammar::Program; use nadezhda::environment::Environment; use nadezhda::population::Population; use nadezhda::evaluate::Evaluator; use nadezhda::darwin::evolve::succesion; fn survivors(population: Population, environment: Environment) -> Vec<Program> { let P...
true
79a18fa9641007f042c65a274b6cf933e91b6dda
Rust
mr-tron/flutter-rs
/flutter-engine/src/ffi.rs
UTF-8
10,426
2.796875
3
[ "MIT" ]
permissive
//! Internal wrappers around some of the types/functions in [`flutter_engine_sys`] use std::{ borrow::Cow, ffi::{CStr, CString}, mem, ptr, time::{SystemTime, UNIX_EPOCH}, }; use log::{error, trace}; use flutter_engine_sys::{ FlutterPlatformMessage, FlutterPlatformMessageResponseHandle, FlutterTas...
true
3e71393da683b241670b2baaa61ff2e37a12cd51
Rust
caelunshun/legion
/src/schedule.rs
UTF-8
12,250
3.046875
3
[ "MIT" ]
permissive
use crate::{ borrow::{Exclusive, RefMut}, command::CommandBuffer, resource::ResourceTypeId, storage::ComponentTypeId, world::World, }; use bit_set::BitSet; use itertools::izip; use std::iter::repeat; use std::{ collections::{HashMap, HashSet}, sync::atomic::{AtomicUsize, Ordering}, }; #[cfg...
true
7e15abe67d868f12eae775a6c71174a983612698
Rust
GaloisInc/mir-verifier
/lib/libstd/net/tcp.rs
UTF-8
61,342
3.109375
3
[]
permissive
use crate::io::prelude::*; use crate::fmt; use crate::io::{self, Initializer, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr, ToSocketAddrs}; use crate::sys_common::net as net_imp; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::Duration; /// A TCP stream between a local and a re...
true
6f0b5e0d8ae1fe20fe5ca1b22686586476f05f32
Rust
gobanos/advent-of-code-2017
/day9_parser/src/lib.rs
UTF-8
4,840
3.21875
3
[]
no_license
#[macro_use] extern crate nom; use std::str; use nom::anychar; pub use Content::{Garbage, Group}; #[derive(Debug, Eq, PartialEq)] pub enum Content { Garbage(u32), Group(Vec<Content>), } named!( garbage<Content>, map!( delimited!( tag!("<"), fold_many0!(garbage_bit, 0...
true
e5e9c5d7352ace5576daddc2b98b800c116bfca2
Rust
githubchry/studyrust
/syntax/src/35unsafe.rs
UTF-8
14,496
3.671875
4
[]
no_license
/* [不安全 Rust](https://rustwiki.org/zh-CN/book/ch19-01-unsafe-rust.html) 可以在不安全 Rust 中进行而不能用于安全 Rust 的操作: 解引用裸指针 调用不安全的函数或方法 访问或修改可变静态变量 实现不安全 trait 访问 union 的字段 有一点很重要,unsafe 并不会关闭借用检查器或禁用任何其他 Rust 安全检查:如果在不安全代码中使用引用,它仍会被检查。 unsafe 关键字只是提供了那五个不会被编译器检查内存安全的功能。你仍然能在不安全块中获得某种程度的安全。 再者,unsafe 不意味着块中的...
true
3d418eb63df55950b0a687f63278a86ac3452d8d
Rust
jonasbb/serde_with
/serde_with/tests/serde_as/frominto.rs
UTF-8
5,248
3.125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::*; use core::convert::TryFrom; use serde_with::{FromInto, TryFromInto}; #[derive(Clone, Debug, PartialEq)] enum IntoSerializable { A, B, C, } impl From<IntoSerializable> for String { fn from(value: IntoSerializable) -> Self { match value { IntoSerializable::A => "String ...
true
24b50928ef3763fb3f88bb0d5cd3f3f903256b40
Rust
YesSeri/findrun
/src/args_parser.rs
UTF-8
830
3.046875
3
[]
no_license
use clap::{App, Arg}; use std::path::PathBuf; pub fn get_args() -> (String, PathBuf) { let matches = App::new("FindRun") .version("0.1") .author("Henrik Zenkert <henrik.zenkert@gmail.com>") .about("Use this to search for a program, get all similar results and choose to launch the program. ") .arg( Arg::with...
true
4bbbabf04fa5f1d69a337f65debc495976331545
Rust
lecrepuscule/fahrenheit_to_celsius
/src/main.rs
UTF-8
855
3.9375
4
[]
no_license
use std::io; fn main() { loop{ println!("Enter the temperature."); let mut f_temp = String::new(); io::stdin().read_line(&mut f_temp) .expect("Failed to read line"); let f_temp: f64 = match f_temp.trim().parse() { Ok(num) => num, Err(_) => continue, }; println!("Enter...
true
dd1f164f3c698b59037319da13908fe05df09613
Rust
ludwigpacifici/adventofcode2017
/src/bin/day2.rs
UTF-8
1,769
3.390625
3
[]
no_license
extern crate failure; use failure::Error; use std::fs::File; use std::io::Read; use std::string::String; fn main() { if let Err(ref err) = run() { eprintln!("error: {:?}", err); eprintln!("bactrace: {:?}", err.backtrace()); ::std::process::exit(1); } } fn run() -> Result<(), Error> { ...
true
ca0cf9fd8516453ea12e42ccbcba98b4218eac22
Rust
tg-rs/tgbot
/src/methods/chat/photo/delete.rs
UTF-8
1,649
3.421875
3
[ "MIT" ]
permissive
use crate::{methods::Method, request::Request, types::ChatId}; use serde::Serialize; /// Delete a chat photo /// /// Photos can't be changed for private chats /// The bot must be an administrator in the chat for this /// to work and must have the appropriate admin rights /// Note: In regular groups (non-supergroups), ...
true
0d7abc376ed452cb2e557bff7ff31e511d6b5980
Rust
jorendorff/nsswitch_service
/src/errors.rs
UTF-8
3,471
2.8125
3
[]
no_license
use libc::{self, c_int, EINVAL, ERANGE}; use std::result; #[repr(C)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum NssStatus { TryAgain = -2, Unavailable = -1, NotFound = 0, Success = 1, } #[derive(Clone, Debug)] pub struct Error { status: NssStatus, errno: c_int, h_errno: c_int, }...
true
1897e3e73af076fd5bb170134c3959c75fb628a4
Rust
jason-wolfe/tantivy
/src/termdict/streamdict/mod.rs
UTF-8
1,237
2.546875
3
[ "MIT" ]
permissive
use std::io::{self, Read, Write}; use common::BinarySerializable; mod termdict; mod streamer; mod delta_encoder; pub use self::delta_encoder::{TermDeltaDecoder, TermDeltaEncoder}; pub use self::delta_encoder::{DeltaTermInfo, TermInfoDeltaDecoder, TermInfoDeltaEncoder}; pub use self::termdict::TermDictionaryImpl; pub...
true
01470c97eba33aa401a5f241e03d88780c4952b4
Rust
jasongraalum/CS510_Rust_Summer2018
/homework/HW3/hw3/protein-translation/src/lib.rs
UTF-8
2,834
3.515625
4
[]
no_license
/// Copyright (c) 2018 Jason Graalum /// /// CS510 Rust Programming /// Summer 2018 /// /// HW #3 /// Translate codon series to proteins /// use std::collections::HashMap; // use a Hash within a Hash within a Hash to decode the three letter codon pub struct Protein { codon_protein_map: HashMap<char, HashMap<char, ...
true
291fbec0560ffe470e6e1a5c2546b6e81d655be7
Rust
ivanceras/svgbob
/packages/svgbob/src/buffer/cell_buffer/cell/cell_grid.rs
UTF-8
4,115
3.390625
3
[ "Apache-2.0" ]
permissive
use crate::Point; /// 4x8 - 32 subcells /// /// with 5x9 = 45 intersections /// /// ```ignore /// 0 1 2 3 4 B C D /// 0┌─┬─┬─┬─┐ A┌─┬─┬─┬─┐E /// 1├─┼─┼─┼─┤ │ │ │ │ │ /// 2├─┼─┼─┼─┤ F├─G─H─I─┤J /// 3├─┼─┼─┼─┤ │ │ │ │ │ /// 4├─┼─┼─┼─┤ K├─L─M─N─┤O ...
true
35ef397a6fb64336b6b1fe6b90e98177ee867521
Rust
iho/qdrant
/lib/segment/src/segment_constructor/segment_builder.rs
UTF-8
3,995
2.75
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::common::error_logging::LogError; use crate::entry::entry_point::{OperationError, OperationResult, SegmentEntry}; use crate::segment::Segment; use crate::segment_constructor::{build_segment, load_segment}; use crate::types::{PayloadKeyType, SegmentConfig}; use core::cmp; use std::collections::HashSet; use std...
true
df3ef695fac448d1cf622402d6776248fd26bb93
Rust
k7f/ascetic
/dam/macro/src/lib.rs
UTF-8
3,070
2.671875
3
[ "MIT" ]
permissive
#![feature(extend_one)] use proc_macro::TokenStream; use proc_macro2::Span; use quote::quote; use syn::spanned::Spanned; fn parse_string(lit: syn::Lit, span: Span, field: &str) -> Result<String, syn::Error> { match lit { syn::Lit::Str(s) => Ok(s.value()), syn::Lit::Verbatim(s) => Ok(s.to_string())...
true
193f1d78b959c42ba6e77ffa186f08a8baead278
Rust
arnohub/vertex
/lib/buffers/src/acker.rs
UTF-8
1,064
2.984375
3
[ "Apache-2.0" ]
permissive
use futures::task::AtomicWaker; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; #[derive(Clone, Debug)] pub enum Acker { Disk(Arc<AtomicUsize>, Arc<AtomicWaker>), Null, } impl Acker { // This method should be called by a sink to indicate that it has // successfully flushed the next...
true
2ca0c4da0ce9c29908054c5e570304b0c6397d41
Rust
billnote/rust-exercism
/nth-prime/src/lib.rs
UTF-8
1,814
3.421875
3
[ "MIT" ]
permissive
use std::error::Error; use std::fmt; use std::cmp::Eq; #[derive(Debug)] pub struct NthPrimeError {} impl fmt::Display for NthPrimeError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "find prime error!") } } impl Error for NthPrimeError { fn description(&self) -> &str { ...
true
28e00bd4227629790fcce2773d8446bbd0b161ef
Rust
astral-sh/ruff
/crates/ruff/src/rules/flake8_simplify/rules/ast_if.rs
UTF-8
29,085
3.03125
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use log::error; use ruff_python_ast::{ self as ast, Arguments, CmpOp, Constant, ElifElseClause, Expr, ExprContext, Identifier, Ranged, Stmt, }; use ruff_text_size::TextRange; use rustc_hash::FxHashSet; use ruff_diagnostics::{AutofixKind, Diagnostic, Edit, Fix, Violation}; use ruff_macros::{derive_message_forma...
true
1c7e7ee361fb5be068da3ea92ae7a7cabb6e4d26
Rust
flada-auxv/game_of_life-rust
/src/main.rs
UTF-8
2,966
3.125
3
[]
no_license
use std::fmt; use std::io; #[allow(unused_variables)] #[allow(unused_must_use)] fn main() { let traffic_light = vec!((4,2), (4,3), (4,4), (4,5), (4,6)); let galaxy = vec!( (3,3),(3,4),(3,5),(3,6),(3,7),(3,8),(3,10),(3,11), (4,3),(4,4),(4,5),(4,6),(4,7),(4,8),(4,10),(4,11), (5,10),(5,11)...
true
e4a1b52547dc53ffcdb822c736afa50ef2097f28
Rust
rustgd/cgmath
/src/quaternion.rs
UTF-8
28,876
2.703125
3
[ "Apache-2.0" ]
permissive
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors, // refer to the Cargo.toml file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a ...
true
c07f0ff30303ace0944ae52a51819967692fae2c
Rust
hershi/AoC2018
/aoc_12/src/main.rs
UTF-8
2,762
3.03125
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate regex; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use std::collections::HashSet; use regex::Regex; type Pots = HashSet<isize>; fn pots_from_str(s: &str) -> Pots { s.chars() .enumerate() .fold(HashSet::new(), |mut acc, (i...
true
08525b34138225653ca7b305409510bc863295ad
Rust
meganetaaan/suburi-rust
/okiraku/tarai.rs
UTF-8
2,343
3.03125
3
[]
no_license
use std::time::Instant; use std::collections::hash_map::HashMap; fn tarai(x: i32, y: i32, z: i32) -> i32 { if x <= y { y } else { tarai(tarai(x - 1, y, z), tarai(y - 1, z, x), tarai(z - 1, x, y)) } } fn tarai_lazy(x: i32, y: i32, z: &Fn() -> i32) -> i32 { if x <= y { y } el...
true
a6f1934104d0fd5731d15c153b68b3654e742787
Rust
konamilk/atcoder-abc157
/src/bin/c.rs
UTF-8
956
2.875
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::source::auto::AutoSource; #[allow(unused_imports)] use proconio::marker::{Chars, Bytes}; #[allow(unused_imports)] use num::integer::{sqrt, gcd, lcm}; #[allow(unused_imports)] use std::cmp::{max, min, Reverse}; fn main() { // let source = AutoSource::from(...
true
bda956fc5e37a83e8bf918afe7ad380873aad18a
Rust
johanlindblad/advent-of-code-2018
/src/day4.rs
UTF-8
5,743
3.359375
3
[]
no_license
use std::str::FromStr; use std::cmp::Ordering; use regex::Regex; #[derive(Eq, PartialEq, Debug)] enum Observation { BeginsShift(u32), FallsAsleep, WakesUp } #[derive(Eq, Debug)] pub struct LogEntry { date: (u32, u8, u8), time: (u8, u8), observation: Observation } impl Ord for LogEntry { f...
true
23d980923d749008312001dd9bcf2c0cc57666bb
Rust
sgreenlay/aoc-2019
/src/day03.rs
UTF-8
4,372
3.40625
3
[]
no_license
use std::io; use std::io::BufRead; use std::cmp; use std::fmt; use std::fs; use std::hash; use std::ops; use std::collections::HashMap; fn read_inputs(filename: String) -> io::Result<Vec<Vec<Direction>>> { let file_in = fs::File::open(filename)?; let file_reader = io::BufReader::new(file_in); Ok(file_rea...
true
e768bcecd1fd27589e4d4cfdf0e2ffb7694539d2
Rust
jonas-schievink/rubble
/rubble/src/att/handle.rs
UTF-8
3,227
3.359375
3
[ "0BSD", "BSD-3-Clause" ]
permissive
//! Attribute handles. use crate::att::{AttError, ErrorCode}; use crate::{bytes::*, Error}; use core::{fmt, ops::RangeInclusive}; /// A 16-bit handle uniquely identifying an attribute on an ATT server. /// /// The `0x0000` handle (`NULL`) is invalid and must not be used. #[derive(Copy, Clone, PartialEq, Eq)] pub stru...
true
726e1520c0efef970a44905ba74ee94fd640cf0e
Rust
rust9x/rust
/src/test/ui/llvm-asm/llvm-asm-parse-errors.rs
UTF-8
924
2.953125
3
[ "MIT", "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
#![feature(llvm_asm)] fn main() { llvm_asm!(); //~ ERROR requires a string literal as an argument llvm_asm!("nop" : struct); //~ ERROR expected string literal llvm_asm!("mov %eax, $$0x2" : struct); //~ ERROR expected string literal llvm_asm!("mov %eax, $$0x2" : "={eax}" struct); //~ ERROR expected `(` ...
true
b967e85ff4c4b05ff167cc16393894c51a8a25b9
Rust
danielvschoor/rust-sc2
/examples/reaper-rush.rs
UTF-8
13,647
2.515625
3
[ "MIT" ]
permissive
#[macro_use] extern crate clap; use rand::prelude::*; use rust_sc2::prelude::*; use std::{cmp::Ordering, collections::HashSet}; #[bot] #[derive(Default)] struct ReaperRushAI { reapers_retreat: HashSet<u64>, last_loop_distributed: u32, } impl Player for ReaperRushAI { fn on_start(&mut self) -> SC2Result<()> { if...
true
a5a8f8300cfe841af121dae86139d44f93b8d9df
Rust
The127/oath2
/src/ds/flow_removed.rs
UTF-8
3,321
2.71875
3
[ "MIT" ]
permissive
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use num_traits::{FromPrimitive, ToPrimitive}; use std::convert::{Into, TryFrom}; use std::io::Cursor; use super::flow_match::Match; use super::super::err::*; #[derive(Debug, PartialEq, Clone)] pub struct FlowRemoved { cookie: u64, priority: u16, r...
true
326c42e055ba083e67beb2e5a2189b685ef78e24
Rust
chorddown/chordr
/synchord/src/service/abstract_service_config.rs
UTF-8
1,852
2.9375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::error::{Error, Result}; use crate::service::{ServiceConfigurationTrait, ServiceIdentifier}; use std::path::{Path, PathBuf}; /// A container for Service Configuration data read from user input or a configuration file #[derive(Clone)] pub struct AbstractServiceConfig { api_key: Result<String>, url: Re...
true
0a688933010a21388b94770ecd579ac441ff6b90
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0093.restore-ip-addresses/restore-ip-addresses.go
UTF-8
1,389
3.125
3
[ "MIT" ]
permissive
package problem0093 import ( "fmt" ) func restoreIpAddresses(s string) []string { n := len(s) if n < 4 || n > 12 { return []string{} } res := []string{} combination := make([]string, 4) var dfs func(int, int) dfs = func(idx, begin int) { if idx == 3 { temp := s[begin:] if isOK(temp) { combinat...
true
a5639f3a1c826ffc70143db5ebe2ca7f9da5ebc5
Rust
chiboubys/aero
/src/vga/rendy.rs
UTF-8
2,487
2.90625
3
[]
no_license
use core::fmt::{self, Write}; use super::{ buffer::{Buffer, ScreenChar, BUFFER_HEIGHT, BUFFER_WIDTH}, color::{Color, ColorCode}, }; use lazy_static::lazy_static; lazy_static! { pub static ref RENDERER: spin::Mutex<Rendy> = spin::Mutex::new(Rendy { column_position: 0, color_code: ColorCode...
true
8d5b6506c95edb0cc754e83363079d00b97d7006
Rust
Redtef/f1-gif-portal-backend
/programs/myepicproject/src/lib.rs
UTF-8
3,255
2.921875
3
[]
no_license
use anchor_lang::prelude::*; declare_id!("BgMok6icXoS1kUs6qgpKKBPHouRcZsDVRFCoTLCcUSCd"); #[program] pub mod myepicproject { use super::*; // initializes everything pub fn start_stuff_off(ctx: Context<StartStuffOff>) -> ProgramResult { // get a mutable reference to the account // this helps us persist...
true
a5901e2e1282e919d913f3e03e50ed4f293e722f
Rust
andrewcharlton/advent-of-code
/2018/day13/src/main.rs
UTF-8
4,273
3.203125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::fs; fn main() { let input = fs::read_to_string("input").expect("Couldn't read file"); let map = parse_map(&input); let mut carts = parse_carts(&input); while carts.len() > 1 { carts.sort(); let mut to_remove = Vec::new(); for i in 0..ca...
true
a96100d5e9fab9391454ff06b258731214ac5461
Rust
Awfa/advent_of_code_2019
/src/day5.rs
UTF-8
741
2.625
3
[]
no_license
use super::get_intcode_memory_from_file; use super::intcode::*; use std::iter::once; pub fn run_part_1(path: &str) -> EmulatorMemoryType { let initial_memory = get_intcode_memory_from_file(path); let emulator = Emulator::new(&initial_memory, once(Ok(1))); let outputs = emulator .into_output_iter()...
true
94d45f3ca9cb91c11deb366c803b2fef9378fae0
Rust
maghoff/wad
/src/error.rs
UTF-8
1,218
2.90625
3
[ "MIT" ]
permissive
macro_rules! verify { ($condition:expr, $err:expr) => { if !$condition { return Err($err); } }; } #[derive(Debug)] pub enum Error { Invalid, InvalidLength, InvalidHeader, InvalidEntry, OutOfBounds, } impl std::fmt::Display for Error { fn fmt(&self, fmt: &mut...
true
03d319a710c1f545f6f196e3ee467acb59e862ce
Rust
lovesegfault/genesis
/dada/src/main.rs
UTF-8
3,701
2.765625
3
[]
no_license
#[global_allocator] static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc; mod chromosome; use chromosome::Chromosome; use indicatif::{ProgressBar, ProgressStyle}; use rand::{distributions::WeightedIndex, prelude::*}; use rayon::prelude::*; use std::io::{stdin, Read}; use std::path::PathBuf; use structopt::S...
true
e5d5605d0eab04c4ce85758d5476623c74a032ff
Rust
LiveSplit/livesplit-core
/src/run/parser/source_live_timer.rs
UTF-8
3,011
2.921875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Provides the parser for the SourceLiveTimer splits files. use crate::{platform::prelude::*, GameTime, Run, Segment, TimeSpan}; use alloc::borrow::Cow; use core::result::Result as StdResult; use serde_derive::Deserialize; use serde_json::Error as JsonError; /// The Error type for splits files that couldn't be pars...
true
30747cc9ef642ae5878147defcf34f8626c88a70
Rust
wayofthepie/ctlogs-cli
/src/consumer.rs
UTF-8
7,481
2.9375
3
[ "MIT" ]
permissive
use crate::{ parser, producer::{LogsChunk, PinnedStream}, }; use futures::StreamExt; use parser::{EntryType, PreCertMarker}; use std::error::Error; use tokio::io::{AsyncWrite, AsyncWriteExt, BufWriter}; pub async fn consume( stream: PinnedStream<LogsChunk>, writer: impl AsyncWrite + Unpin + Send, ) -> ...
true
b9754049def86988ef50dff64f3e4dc2e2ca1c29
Rust
dainslef/RustPractice
/src/leetcode/q52_n_queens_ii.rs
UTF-8
1,511
3.484375
3
[ "BSD-3-Clause" ]
permissive
/** * The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. * * Given an integer n, return the number of distinct solutions to the n-queens puzzle. * * Example: * * Input: 4 * Output: 2 * Explanation: There are two distinct solutions to the 4-que...
true
db60f488f204d762b18cb42d1d5423f8857a0853
Rust
leod/ultimate-scale
/src/exec/level.rs
UTF-8
4,870
2.78125
3
[ "MIT" ]
permissive
use crate::exec::Activation; use crate::machine::level::{self, InputsOutputs}; use crate::machine::{BlipKind, Block, BlockIndex, Machine}; #[derive(PartialEq, Eq, Debug, Clone, Copy)] pub enum LevelStatus { Running, Completed, Failed, } #[derive(Debug, Clone)] pub struct Input { pub block_index: Optio...
true
7ebec63b979aa4eede9793133b86b9dc006f4bb7
Rust
CM-Tech/rjs
/src/rt/env/json/writer.rs
UTF-8
10,043
2.703125
3
[ "Apache-2.0" ]
permissive
use ::{JsResult, JsError}; use rt::{JsEnv, JsArgs, JsValue, JsType, JsItem, JsObject, JsString, JsFnMode, JsDescriptor}; use rt::object::JsStoreKey; use gc::*; use syntax::token::name; use syntax::Name; use std::fmt::Write; use std::collections::HashSet; use std::rc::Rc; pub struct JsonWriter<'a> { env: &'a mut Js...
true
3558015da0aed8f63e46c7ccd0df609a1bb059ff
Rust
yzddzy/raytracer-2021
/.history/raytracer/src/rtweekend_20210721130906.rs
UTF-8
542
3.265625
3
[ "MIT" ]
permissive
pub const INFINITY: f64 = f64::INFINITY; pub const PI: f64 = std::f64::consts::PI; use rand::Rng; pub fn degrees_to_radians(degrees: f64) -> f64 { degrees * PI / 180.0 } pub fn random_double1() -> f64 { let mut rng = rand::thread_rng(); rng.gen_range(0.0, 1.0) } pub fn random_double2(min: f64, max: f64) ...
true
946644a261d2ea97c1b7be510ae2d9a5cfed3920
Rust
lukexor/pix-engine
/examples/hello_world.rs
UTF-8
838
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
use pix_engine::prelude::*; struct HelloWorld; impl PixEngine for HelloWorld { // Set up any state or resources before starting main event loop. fn on_start(&mut self, s: &mut PixState) -> PixResult<()> { s.background(220); Ok(()) } // Main render loop. Called as often as possible, or...
true
461f7584e08deb8b016bad66adf1ff52c334ae64
Rust
avp/lox
/src/lir/gen.rs
UTF-8
7,770
2.796875
3
[]
no_license
//! Generator for LIR. use std::collections::HashMap; use super::inst::*; use super::*; use crate::ast; use super::inst::Opcode::*; struct Generator<'ctx> { ctx: &'ctx Ctx, builder: Builder<'ctx>, name_table: HashMap<UniqueString, VReg>, } impl<'ctx> Generator<'ctx> { pub fn gen(ctx: &'ctx Ctx, f...
true
b11787b94ec4f596023a6fc9a517c07839633278
Rust
konrad-c/docgen
/src/parser/error.rs
UTF-8
750
3.3125
3
[]
no_license
#[derive(Debug, Clone)] pub struct PlaceholderParseError { pub placeholder: String, pub reason: String } impl PlaceholderParseError { pub fn invalid_placeholder(placeholder_string: &str) -> PlaceholderParseError { PlaceholderParseError { placeholder: String::from(placeholder_string), ...
true
a02a53f3f1f16c72f486f5083b5acf551dff78a2
Rust
theotherphil/spimdy
/src/examples.rs
UTF-8
16,818
2.90625
3
[]
no_license
// Shouldn't be in the library, but will worry about code organisation // when I have something that's actually usable use ::kernel::*; use ::vector_types::*; use std::arch::x86_64::*; //-------------------------------------------------------------------- // Conditional //--------------------------------------------...
true
3705804373ac4d32677afb644d4ab0063530ea6a
Rust
Type-3/yew-property-info
/src/lib.rs
UTF-8
504
2.59375
3
[]
no_license
pub use yew_property_info_derive::PropertyInfo; #[derive(Debug, PartialEq, Clone)] pub struct PropertyRef { pub name: &'static str, pub ty: &'static str, pub required: bool, pub default: Option<&'static str>, pub description: Option<&'static str> } #[derive(Debug, PartialEq, Clone)] pub struct Pro...
true
59d014d76268a208983f8e436e78c2d4cc173135
Rust
mvniekerk/mci-rs
/mci/src/registers/ocr.rs
UTF-8
5,698
3.0625
3
[ "Apache-2.0", "MIT" ]
permissive
use bit_field::BitField; use core::hint::unreachable_unchecked; pub struct OcrRegister { pub val: u32, } #[derive(PartialEq)] pub enum AccessMode { /// Byte access mode Byte = 0, /// Sector access mode Sector = 2, } impl From<u32> for AccessMode { fn from(val: u32) -> Self { match val...
true
3d51292709a61c1ebed3da988b5266b460e9f6e5
Rust
DasCapschen/rusterizer
/src/engine.rs
UTF-8
5,644
2.78125
3
[ "MIT" ]
permissive
/*! File containing main engine loop */ use winit::{ dpi::LogicalSize, event::{DeviceEvent, DeviceId, Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::{Window, WindowBuilder}, }; use std::time::{Duration, Instant}; use crate::gui; use crate::renderer; #[derive(Copy, Clone)] pub str...
true
be828afe95a57ebd5c371252bc6e8dd4f9b4f950
Rust
devsnek/slither
/rust-gc/gc/tests/gymnastics_cycle.rs
UTF-8
1,139
2.828125
3
[ "MIT" ]
permissive
#![cfg_attr(feature = "nightly", feature(specialization))] #[macro_use] extern crate gc_derive; extern crate gc; use gc::{force_collect, Gc, GcCell}; use std::cell::Cell; thread_local!(static COUNTER: Cell<u8> = Cell::new(0u8)); #[derive(Trace)] struct Cyclic { prev: GcCell<Option<Gc<Cyclic>>>, name: u8, } ...
true
c21e48318c921bcc24aee397ff347232e38a4935
Rust
nbliznashki/radix_new
/radix_column/src/binarycolumn.rs
UTF-8
11,774
3.09375
3
[]
no_license
use std::any::TypeId; use super::{asbytes::AsBytes, ErrorDesc}; #[derive(Debug)] pub struct OnwedBinaryColumn { item_type_id: std::any::TypeId, offset: usize, data: Vec<u8>, start_pos: Vec<usize>, len: Vec<usize>, } impl OnwedBinaryColumn { pub fn item_type_id(&self) -> TypeId { self....
true
197f418ecefcdfc2a48a5878f5849f4a89912616
Rust
killix/generated
/gen/games/v1/cli/src/main.rs
UTF-8
17,472
2.640625
3
[]
no_license
use clap::{App, AppSettings, Arg, SubCommand}; use default_boxed::DefaultBoxed; #[derive(DefaultBoxed)] struct Outer<'a, 'b> { inner: HeapApp<'a, 'b>, } struct HeapApp<'a, 'b> { app: App<'a, 'b>, } impl<'a, 'b> Default for HeapApp<'a, 'b> { fn default() -> Self { let mut app = App::new("games1") ...
true
01e361ffa0f286fd7bab8edf5adc48c6b5768948
Rust
harris2001/Write-Ups
/Misc/Misc/i_c_u/src/main.rs
UTF-8
4,463
2.734375
3
[]
no_license
use img_hash::image; use img_hash::HasherConfig; mod secret; //use crate::secret::{FLAG, FLAG_TOO}; //fn1 : filename1 //fn2 : filename2 fn bindiff_of_1(fn1: &str, fn2: &str) -> u32 { use std::io::Read; //b1 : file1 in binary format let b1: Vec<u8> = std::fs::File::open(fn1) .unwrap() .byte...
true