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
a290ce9f59944863af7cd927b6ba85436979e748
Rust
paolosimone/advent-of-code-2020
/src/days/day_13.rs
UTF-8
3,175
3.25
3
[]
no_license
use num::Integer; use super::Day; pub struct Day13 { target: usize, buses: Vec<Option<usize>>, } impl Day13 { pub fn load(input: &str) -> Self { let target = input.lines().next().unwrap().parse::<usize>().unwrap(); let buses = input .lines() .skip(1) .n...
true
f8a07360750695ea26b5d24213a93b723d53df03
Rust
DanielSchuette/elf
/src/utils/mod.rs
UTF-8
3,353
3.265625
3
[ "MIT" ]
permissive
/* * A set of utility functions. * * Author: Daniel Schuette (d.schuette@online.de) * License: MIT (see LICENSE.md at https://github.com/DanielSchuette/elf) */ extern crate byteorder; use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; use std::fs; use std::io::prelude::*; use std::io::Cursor; use crate::par...
true
11ac0b15b8a8d917fb3a16bddb7ae50ac62eb6dc
Rust
shurizzle/tomography
/src/timer/timer.rs
UTF-8
1,696
3
3
[]
no_license
use std::sync::{ atomic::{AtomicBool, Ordering}, mpsc::{channel, SendError, Sender}, Arc, }; use std::thread::{sleep, spawn, JoinHandle}; use std::time::{Duration, Instant}; pub struct Timer(JoinHandle<()>, Sender<()>, Arc<AtomicBool>); impl Timer { pub fn new<F>(time: Duration, f: F) -> Timer whe...
true
b6e5d0691f40d729deb11c81dbb620df7c0f74c8
Rust
wang-q/intspan
/src/cmd_linkr/filter.rs
UTF-8
3,042
3.0625
3
[ "MIT" ]
permissive
use clap::*; use intspan::*; use std::io::BufRead; // Create clap subcommand arguments pub fn make_subcommand() -> Command { Command::new("filter") .about("Filter links by numbers of ranges or length differences") .after_help( r###" * It's assumed that all ranges in input files are vali...
true
ed4fa35bba18d229d1809309fa47db5379d67e11
Rust
pathalog/pathalog_rs
/src/bin/paths.rs
UTF-8
2,743
3.15625
3
[ "Apache-2.0" ]
permissive
use lexpr::Value; use std::error::Error; use std::fmt; use std::fmt::{Debug, Display, Formatter, Write}; use std::fs; use std::io; #[derive(Debug, Clone)] struct Path(String, Vec<Path>); impl Display for Path { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "{} ", self.0)?; m...
true
8383e2afa5ffb12017434464b0342051f5a2b7ba
Rust
PacktPublishing/The-Complete-Rust-Programming-Reference-Guide
/Chapter08/threads_sharing.rs
UTF-8
456
2.734375
3
[ "MIT" ]
permissive
// shared_owner_threads.rs use std::thread; use std::rc::Rc; use std::sync::Mutex; struct Payload { data: Mutex<u32> } impl Payload { fn new(val: u32) -> Self { Payload { data: Mutex::new(val) } } fn inc(&mut self) { *self.data.lock().unwrap() += 1; } } fn m...
true
28e4b8fdd461594cfcd69e9dce2373f107c6dd73
Rust
KeenS/chema
/src/parser.rs
UTF-8
37,805
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
//! TOP = ITEMS //! ITEMS = ITEM+ //! ITEM = TYPEDEF //! //! TYPEDEF = "type" IDENT ""=" TYPE ";" //! //! TYPE = "null" | "boolean" | "object" | "number" | "string" | "integer" //! | IDENT | "[" TYPE "]" | STRUCT | ENUM | TYPE "?" //! | "format" "(" STRING ")" | "url" "(" STRING ")" //! | TYPE "&" TYPE |...
true
947b25ec271479e3adcd1d28ae12a8b86a931016
Rust
robbycerantola/orbtk
/src/rect.rs
UTF-8
1,264
3.625
4
[ "MIT" ]
permissive
use super::Point; #[derive(Clone, Copy, Debug, Default)] pub struct Rect { pub x: i32, pub y: i32, pub width: u32, pub height: u32, } impl Rect { pub fn new(x: i32, y: i32, width: u32, height: u32) -> Rect { Rect { x: x, y: y, width: width, h...
true
8dada01943a8f765de9dc631f8530ca03eecf01b
Rust
vorner/signal-hook
/src/iterator/mod.rs
UTF-8
12,017
3.515625
4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! An iterator over incoming signals. //! //! This provides a higher abstraction over the signals, providing //! the [`SignalsInfo`] structure which is able to iterate over the //! incoming signals. The structure is parametrized by an //! [`Exfiltrator`][self::exfiltrator::Exfiltrator], which specifies what informatio...
true
f7979eb425a359f5f1dee0a18a901b35facc8197
Rust
zicklag/evoli
/src/systems/experimental/perception.rs
UTF-8
3,597
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use amethyst::{ core::{nalgebra::Vector4, transform::GlobalTransform}, ecs::{ BitSet, Entities, Join, ReadExpect, ReadStorage, System, Write, WriteExpect, WriteStorage, }, renderer::DebugLines, }; use crate::components::perception::{DetectedEntities, Perception}; use crate::resources::spatial_g...
true
4f1574810e52042cf87a3532706eab12d2d48dfd
Rust
benschau/rust_chip8
/src/cpu.rs
UTF-8
16,855
2.9375
3
[]
no_license
extern crate rand; use std::vec::Vec; use std::fs::File; use std::io::prelude::*; use cpu::rand::prelude::*; use font::FONT; const DELAY_FREQ: ::BYTE = 60; const SOUND_FREQ: ::BYTE = 60; static mut SCREEN: [[::BYTE; 32]; 64] = [[0; 32]; 64]; static mut KEYBOARD: [bool; 16] = [false; 16]; static mut DELAY_TIMER: ::BY...
true
f366ac224b2e4c452565c5cfeaed483e0883c1f0
Rust
rklaehn/interval-rs
/vec-set/src/merge_state.rs
UTF-8
11,257
3.09375
3
[]
no_license
use crate::binary_merge::{ EarlyOut, MergeOperation, MergeStateMut, MergeStateRead, ShortcutMergeOperation, }; use crate::iterators::SliceIterator; use flip_buffer::FlipBuffer; use std::cmp::Ord; use std::default::Default; use std::fmt::Debug; pub(crate) struct UnsafeInPlaceMergeState<A, B> { a: FlipBuffer<A>,...
true
63a152da81bf331f2c729d0e56d95acd3648be4d
Rust
itsintern/edgedns
/src/libedgedns/src/udp_stream.rs
UTF-8
1,426
2.578125
3
[ "ISC" ]
permissive
//! A streaming interface to tokio-io UDP sockets. //! //! This provides a consistent interface with TCP sockets. use futures::{Async, Poll, Stream}; use net::SocketAddr; use std::io; use std::net; use std::rc::Rc; use super::DNS_MAX_UDP_SIZE; use tokio_core::net::UdpSocket; use tokio_core::reactor::Handle; pub struc...
true
86341edd3fd73042c88f1fd1526a23f469cf9060
Rust
sleepy-monax/fraeser
/firmware/src/gpio.rs
UTF-8
4,484
2.71875
3
[ "MIT" ]
permissive
use crate::{cutter::*, units::*}; use rppal::gpio::*; use std::str::RSplitTerminator; use std::thread::sleep; use std::time::Duration; pub struct GPIOPinLayout { pub x_ena_pin: u8, pub x_dir_pin: u8, pub x_pul_pin: u8, pub x_stp_pin: u8, pub y_ena_pin: u8, pub y_dir_pin: u8, pub y_pul_pin:...
true
1c446cc648aa6c87806a33a389ac39524a037c88
Rust
jonstites/aoc_2019
/day1_part1/src/main.rs
UTF-8
475
3.40625
3
[]
no_license
use std::io; use std::io::prelude::*; fn main() { let stdin = io::stdin(); let mut total = 0; for line in stdin.lock().lines() { let line = line.unwrap(); let mass = line.parse::<u32>().unwrap(); total += fuel(mass); } println!("{}", total); } fn fuel(mass: u32) -> u32 { (mass / 3) - 2 } ...
true
cb4fe8f3ff26e8d23e699cd38e1d0b45311d9b91
Rust
ArifSanaullah/rust-all-codes
/method_with_more_parameters/src/main.rs
UTF-8
758
3.625
4
[]
no_license
#[derive(Debug)] struct Rectangle { height: u32, width: u32, } fn main() { impl Rectangle { // add code here fn can_hold (&self, other: &Rectangle) -> bool { self.height > other.height && self.width > other.width } } let rect_1 = Rectangle { height: 100, ...
true
8ccedb07f398e141525653fab52a0a9f4b70e823
Rust
spotzero/distance_resistance
/src/bin/test-game.rs
UTF-8
2,220
2.65625
3
[]
no_license
extern crate distance_resistance; use distance_resistance::resistance::*; use std::fmt; fn main() { let mut games = ResistanceGames::new(); let gid = games.create(5).unwrap(); println!("{:#?}", games); let player0 = games.get_mut(&gid).unwrap().join().unwrap(); let player1 = games.get_mut(&gid).u...
true
5fc080e9e6e60583a53ecfee462470aa2f035298
Rust
EEP-Benny/AdventOfCode
/src/year2022/day25.rs
UTF-8
3,145
3.453125
3
[]
no_license
use core::panic; use crate::utils::get_input; fn snafu_to_decimal(snafu: &str) -> i64 { let mut decimal = 0i64; for digit in snafu.chars() { decimal *= 5; decimal += match digit { '0' => 0, '1' => 1, '2' => 2, '-' => -1, '=' => -2, ...
true
1fddf3d4a9e9e8179dfd5b5950046676c2cedfdc
Rust
nel215/sudare
/src/lib.rs
UTF-8
304
2.890625
3
[ "Apache-2.0" ]
permissive
pub mod bitvector; pub mod wavelet_tree; pub fn rank(x: i64, i: i32) -> i32 { let mut res = 0; for idx in 0..i { if (x >> idx & 1) > 0 { res += 1; } } return res; } #[test] fn it_works() { assert_eq!(rank(0b10, 1), 0); assert_eq!(rank(0b10, 2), 1); }
true
cf70b2f741f65b9250424470650ff020e8e8b052
Rust
mujahiddmalikarain/Rustwork
/loops/src/main.rs
UTF-8
345
3.421875
3
[]
no_license
fn main() { let mut count = 0; another(); let result=loop { count +=1; if count == 10 { break count * 3; } }; println!("The result is break loop result {}", result); } fn another() { for number in (1..100).rev() { println!(" for loop result{}!", number); } ...
true
38cef807c00dd60ef281ef76ce11c4ed6c477f74
Rust
cryptape/consensus-bft
/src/util.rs
UTF-8
2,338
2.578125
3
[ "MIT" ]
permissive
use crate::types::*; use bft_core::{types::CoreOutput, FromCore}; use crossbeam_channel::Sender; use rlp::{Decodable, Encodable}; use serde::{de::DeserializeOwned, Serialize}; /// An independent function to check proof. pub fn check_proof< F: Encodable + Decodable + Encodable + Clone + Send + 'static + Serialize +...
true
e0acc3c93f88a3c059a91b93d93ac42b146bb726
Rust
brucelevis/ProDBG
/src/plugins/memory_view/src/state.rs
UTF-8
538
2.65625
3
[ "MIT" ]
permissive
use number_view::NumberView; use serde; use serde_json; pub struct MemoryViewState { pub start_address: usize, pub columns: usize, pub number_view: Option<NumberView>, pub text_shown: bool, } impl MemoryViewState { pub fn to_string(&self) -> String { serde_json::to_string(self).unwrap() ...
true
f47a02e75358abf1a999cb5dddf9aa2bfd27c690
Rust
ryo33/Zombie
/src/game/world/world.rs
UTF-8
1,830
2.546875
3
[]
no_license
use piston_window::G2d; use std::collections::HashMap; use graphics::Transformed; use graphics::math::{ Scalar, Vec2d, Matrix2d }; use std::f64::consts::PI; use super::chunk::Chunk; use util::graphics::Image; use game::camera::Camera; use game::player::{ self, Player }; use game::*; use game::operation::*; pub const ...
true
aded8d80204e7dedb052692ec57344ff3cd1ae24
Rust
CCL77/twitch_api
/src/users.rs
UTF-8
11,804
2.5625
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 Matt Shanker // // 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 copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in...
true
21fa15f8f01670bdc3d33b426c848161a9403a57
Rust
HamzaMouhcine/Leetcode-Rust
/1295.-Find-Numbers-with-Even-Number-of-Digits.rs
UTF-8
548
3.1875
3
[]
no_license
// https://leetcode.com/problems/find-numbers-with-even-number-of-digits/submissions/ impl Solution { pub fn find_numbers(mut nums: Vec<i32>) -> i32 { let mut even_digits_count = 0; let mut cnt_digits = 0; for int in &mut nums { cnt_digits = 0; while *int != ...
true
37321b999cecf1b3475e3248efde982cd4fcab8e
Rust
xxuejie/ckb-vm
/tests/test_simple.rs
UTF-8
3,853
2.828125
3
[ "MIT" ]
permissive
extern crate ckb_vm; use bytes::Bytes; use ckb_vm::{ run, DefaultCoreMachine, DefaultMachine, DefaultMachineBuilder, Error, FlatMemory, Instruction, SparseMemory, SupportMachine, }; use std::fs::File; use std::io::Read; #[test] pub fn test_simple_instructions() { let mut file = File::open("tests/programs/...
true
d270d535d4aef7890a830018f5bce20750fe8634
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_509/src/solution3.rs
UTF-8
573
3.609375
4
[ "MIT" ]
permissive
// 简单递推,时间复杂度 O(n) impl Solution { pub fn fib(n: i32) -> i32 { let mut f1 = 0; let mut f2 = 1; for _i in 0..n { let t = f1 + f2; f1 = f2; f2 = t; } f1 } } pub struct Solution; #[cfg(test)] mod tests { use super::*; #[test] fn test_1() { assert_eq!(Solution::fib(0),...
true
6ca5529ace0b8835ba788257bb269c244f37164e
Rust
peterkhayes/simpledb
/src/server.rs
UTF-8
2,453
2.6875
3
[]
no_license
extern crate futures; extern crate tokio_core; extern crate tokio_proto; extern crate tokio_service; use parser; use std::io; use std::str; use std::net::SocketAddr; use self::tokio_core::io::{Io, Framed, Codec, EasyBuf}; use self::tokio_proto::pipeline::{ServerProto}; use self::tokio_proto::TcpServer; use self::toki...
true
cd24bea9dc79d542da427b6ad685c5a899ceaaa0
Rust
owlinux1000/rust-casl2
/src/literal.rs
UTF-8
384
3.4375
3
[]
no_license
use constant::{is_decimal,is_hex,is_char}; // リテラルは,10進定数,16進定数又は文字列定数の前に等号(=)が付く pub fn is_literal(s: &str) -> bool { if !s.starts_with('=') { return false; } let constant = &s[1..]; return !(is_decimal(constant) && is_hex(constant) && is_char(constant) ...
true
da58f8d8ebcf1489fcddb6fa4b7a0e36371bfa44
Rust
ArturAralin/web3tech-test
/src/http.rs
UTF-8
3,066
2.578125
3
[]
no_license
use std::convert::Infallible; use std::sync::Arc; use uuid::Uuid; use warp::Filter; use serde::{Serialize, Deserialize}; use tokio::sync::mpsc; use super::Storage; use super::worker; use super::config::Config; #[derive(Serialize)] struct TaskBody { status: String, successful_responses_count: u32, sum: u32, } ...
true
a2eb20de01cac1f79b998be607b39b8e3f94ce10
Rust
chw741852/hellorust
/src/chrono_test.rs
UTF-8
289
2.515625
3
[]
no_license
use chrono::Local; pub fn current_time_slice() { let now = Local::now(); let today_start = Local::today().and_hms(0, 0, 0); println!("{}", now); println!("{}", today_start); println!("current time slice is {}", (now.timestamp() - today_start.timestamp()) / 60 / 10); }
true
f4ed760273f36aca8debdce43d3c2132fbceff88
Rust
google/minetest_pnr
/src/channel_router.rs
UTF-8
11,000
2.765625
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 Google LLC // // 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 copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
5c704c71088b3311ebcbde759094a034058db432
Rust
equal-l2/novelang
/src/fuzz_utils.rs
UTF-8
1,771
2.796875
3
[]
no_license
use crate::lex; use lex::items::*; #[derive(Debug)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub enum FuzzItem { Key(Keyword), Cmd(Command), Op(Ops), Num(crate::types::IntType), Ident(crate::types::IdentName), Str(String), Semi, Comma, LPar, RPar, LB...
true
debe5bccca74773bfa60d90f77a3c920a253abf8
Rust
JCapucho/rusty-shades
/rsh-parser/src/lexer.rs
UTF-8
9,383
2.96875
3
[]
no_license
use logos::{Lexer as LogosLexer, Logos}; use rsh_common::{ src::{Loc, Span}, EntryPointStage, Rodeo, RodeoResolver, ScalarType, Symbol, }; use std::fmt; fn ident(lex: &mut LogosLexer<Token>) -> Option<Symbol> { let slice = lex.slice(); Some(lex.extras.get_or_intern(&slice[..slice.len()])) } fn functi...
true
840d4e9490bf55723e41a73ec5aa0f9693cfec8b
Rust
fmarts/chip8
/src/chip8.rs
UTF-8
10,377
2.6875
3
[ "MIT" ]
permissive
#![allow(dead_code)] use std::path::Path; use std::fs::File; use std::io::Read; use std::fmt::{Debug, Formatter, Result as FmtResult}; use rand::{thread_rng, Rng}; use sdl2::Sdl; use sdl2::rect::Rect; use ep::FromPrimitive; use screen::Screen; use instruction::{Opcodes, Instruction}; const FONT_SET: [u8; 80] = [ ...
true
687116c2fd3e6338101416c73201e633b83b8ba8
Rust
tocklime/aoc-rs
/aoc/src/solutions/y2022/day01.rs
UTF-8
614
2.765625
3
[]
no_license
use aoc_harness::*; aoc_main!(2022 day 1, generator gen, part1 [solve::<1>] => 67633, part2 [solve::<3>] => 199_628, example both EG => (24000, 45000)); fn gen(input: &str) -> Vec<usize> { input .split("\n\n") .map(|x| x.lines().map(|y| y.parse::<usize>().unwrap()).sum()) ...
true
ca3a73ef4ec812beddea6e86fd188e4944b0a3d1
Rust
yingheio/salvo
/core/src/writer.rs
UTF-8
2,811
2.890625
3
[ "MIT" ]
permissive
use async_trait::async_trait; use serde::Serialize; use crate::http::errors::*; use crate::http::header::HeaderValue; use crate::http::{Request, Response}; use crate::Depot; #[async_trait] pub trait Writer { #[must_use = "write future must be used"] async fn write(mut self, req: &mut Request, depot: &mut Depo...
true
ae8d4fb6e72ebd52ec4237f16b9f9b9d92cdfa96
Rust
HerringtonDarkholme/leetcode
/src/986_interval_intersection.rs
UTF-8
1,870
3.375
3
[]
no_license
pub struct Solution; impl Solution { pub fn interval_intersection(a: Vec<Vec<i32>>, b: Vec<Vec<i32>>) -> Vec<Vec<i32>> { let mut ret = vec![]; let mut i = 0; let mut j = 0; while i < a.len() && j < b.len() { let ia = &a[i]; let ib = &b[j]; if ia[0...
true
0a13fc6b7191505214c117ad1308eafc03bf764f
Rust
huntiep/legv8debug
/src/bytecode.rs
UTF-8
28,054
2.8125
3
[]
no_license
#![allow(non_snake_case, unused)] use Register; use std::fmt; #[derive(Copy, Clone, Debug, PartialEq)] pub struct Opcode(pub u32); impl fmt::Display for Opcode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use self::Instruction::*; match self.instruction() { Prnt | Prn...
true
219557893689ba0479f2227e4b3449854f42cdab
Rust
snoyberg/routetype-rs
/routetype-derive/src/lib.rs
UTF-8
817
3.140625
3
[]
no_license
mod route_parse; use syn::{parse_macro_input, DeriveInput}; /** Derive the `Route` trait for the given type. Typically, this is used on an `enum` to provide a `Route` `impl`. You'll need to provide `route` attributes on each individual variant, e.g.: ```ignore #[derive(Route, Clone, PartialEq, Debug)] enum MyRoute ...
true
59549eaf96fcf2da51df46aa55eb75e00fc4c51e
Rust
niuyuling/denyhosts
/clamav/libclamav_rust/.cargo/vendor/exr/src/image/channel_groups.rs
UTF-8
9,828
2.578125
3
[ "BSD-3-Clause" ]
permissive
use std::collections::HashMap; use crate::image::write::channels::{WritableChannels, ChannelsWriter}; use crate::meta::attribute::{LevelMode, ChannelList, Text, TextSlice, ChannelInfo}; use crate::meta::header::Header; use crate::image::read::layers::{ReadChannels, ChannelsReader}; use crate::block::{BlockIndex,...
true
f4ddaddf91ef7fe18fb5079f0d6266c3c83bb769
Rust
styrowolf/cryptopals
/set1/challenge_three/src/main.rs
UTF-8
1,787
3.09375
3
[]
no_license
use std::collections::BTreeMap; use std::collections::HashMap; extern crate hex; fn main() { const HEX_STRING: &str = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736"; let hex_bytes = hex::decode(HEX_STRING).unwrap(); let length: usize = hex_bytes.len(); let mut texts: Vec<String>...
true
731f9cef024b1583e1d72f4c6a89bdb82b265b72
Rust
BurntSushi/regex-automata
/src/nfa/thompson/compiler.rs
UTF-8
62,062
3.1875
3
[ "MIT", "Unlicense" ]
permissive
/* This module provides an NFA compiler using Thompson's construction algorithm. The compiler takes a regex-syntax::Hir as input and emits an NFA graph as output. The NFA graph is structured in a way that permits it to be executed by a virtual machine and also used to efficiently build a DFA. The compiler deals with a...
true
8c295b83bc4fcae9238d46767ccb7920bb3d4b04
Rust
gomesalexandre/boa
/boa/src/builtins/function.rs
UTF-8
4,764
3.0625
3
[ "MIT", "Unlicense" ]
permissive
use crate::{ builtins::{ object::Object, property::Property, value::{to_value, ResultValue, Value, ValueData}, }, exec::Interpreter, syntax::ast::expr::Expr, }; use gc::{custom_trace, Gc}; use gc_derive::{Finalize, Trace}; use std::fmt::{self, Debug}; /// fn(this, arguments, ctx...
true
d1d23da6050ed8d6632ebb7d9f0dc79028aa033a
Rust
gs-akhan/learning-rust
/src/armstrong.rs
UTF-8
431
3.609375
4
[ "MIT" ]
permissive
fn main() { println!("{}", "==== Armstrong Numbers ===="); let num = "153"; let str = num.to_string(); let count = 3; let mut result = 0; for (_, c) in str.chars().enumerate() { let num: i64 = c.to_string().parse().expect("Failed to convert"); println!("{}", num); resu...
true
18a36c125852d93c2ebcad1ceaf0842fff44e65a
Rust
dprint/dprint
/crates/core/src/formatting/writer.rs
UTF-8
10,807
2.75
3
[ "MIT" ]
permissive
use super::collections::GraphNode; use super::print_items::WriterInfo; use super::StringContainer; use super::WriteItem; use bumpalo::Bump; #[derive(Clone)] pub struct WriterState<'a> { current_line_column: u32, current_line_number: u32, last_line_indent_level: u8, indent_level: u8, expect_newline_next: bool...
true
1340703a6b5a65e865022f4d4f67bcf3962ec97b
Rust
mrozycki/rust-fst
/src/main.rs
UTF-8
1,052
3.234375
3
[ "MIT" ]
permissive
use fst::FST; mod fst; fn print_matches(fst: &FST, string: &str) { fst.match_string(string).into_iter() .for_each(|path| println!("{}", path.join(""))); } fn main() { let digits = vec!('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); let number = FST::at_least_once(FST::one_of_symbols(digits)); ...
true
da30fd04b1d6c24bdc56ef9bbea5af80570ddcdd
Rust
redsnapper2006/leetcode-cn
/S/1574-shortest-subarray-to-be-removed-to-make-array-sorted/main.rs
UTF-8
1,430
3.125
3
[]
no_license
struct Solution {} impl Solution { pub fn find_length_of_shortest_subarray(arr: Vec<i32>) -> i32 { let mut start: usize = 0; let mut end: usize = arr.len() - 1; while start < arr.len() { if start < arr.len() - 1 && arr[start] > arr[start + 1] { break; } start += 1; } if ...
true
8072b2afd72db89916c97e1f93464cec6e845bb1
Rust
despegar/mot
/monch-project/src/semaphore.rs
UTF-8
2,638
3.828125
4
[ "BSD-2-Clause" ]
permissive
use std::sync::{Mutex, Condvar}; use time::precise_time_ns; use std::time::duration::Duration; /// A counting, blocking, semaphore. /// /// Semaphores are a form of atomic counter where access is only granted if the /// counter is a positive value. Each acquisition will block the calling thread /// until the counter i...
true
70b4df4da8863dbe67398896ce7c8ebf2b70b846
Rust
sjinno/fe3
/src/bin/events.rs
UTF-8
2,883
3.140625
3
[]
no_license
use std::fmt; use std::io::{stdin, stdout, Write}; use rand::{thread_rng, Rng}; use termion::{clear, cursor, event::Key, input::TermRead, raw::IntoRawMode}; #[derive(Clone)] enum Square { Empty, Taken, HiddenTreasure, Found, } impl fmt::Display for Square { fn fmt(&self, fmt: &mut fmt::Formatter)...
true
44d1914c84d81630aa4b39cf7c0f5fee805e92a1
Rust
jiyilanzhou/chw
/substrate_polkadot/substrate_dev/knowledge_base/2_runtime/3_Pallets.rs
UTF-8
3,366
2.9375
3
[]
no_license
/* 0. Pallets 货盘(调色板,托盘) 1. What is a Pallet 调色板定义 每个货盘都有自己的离散逻辑,这些逻辑可以修改区块链状态转换功能的特征和功能 2. Skeleton of a Pallet 托盘骨架 一个 Substrate pallet 由 5 个主要部分组成 // 1. Imports and Dependencies // The pallet supports the use of any Rust library which compiles // with the `no_std` flag. use support::{decl_...
true
fe0887ad5724cf13d919988918af1dc50d3dce83
Rust
Xiphoseer/rust-ms-oforms
/src/properties/types/mod.rs
UTF-8
3,496
3.296875
3
[ "MIT" ]
permissive
#[allow(unused_imports)] use num_traits::{FromPrimitive, ToPrimitive}; pub mod color; pub mod font; pub mod parser; pub mod picture; pub mod string; /// An unsigned integer that specifies the type of icon displayed as the mouse pointer for the control. #[derive(Debug, FromPrimitive, ToPrimitive)] pub enum MousePointe...
true
16ba07e9b53932fe16cc9abd69843ebb40ccfd47
Rust
akks800/atcoder
/abc165/src/bin/f.rs
UTF-8
1,703
2.78125
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::{Bytes, Chars, Usize1}; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::ops::*; #[derive(Clone, Debug, Default)] struct Struct; // [l,h) の中でもっとも手前のfalseになる場所を探す. 全てのtrueはf...
true
29d627c065c74b31cc122ead0bf4a5e231834a11
Rust
rusch95/SpaceFort
/src/net/client.rs
UTF-8
4,121
2.59375
3
[]
no_license
use std::io; use std::io::{Read, Write}; use std::net::{Ipv4Addr, SocketAddrV4, TcpStream}; use std::thread; use std::sync::mpsc::channel; use bincode::{deserialize, serialize, Infinite}; use game::base::*; use entities::entity::EntID; use net::base::*; pub struct ClientNetIn { stream: TcpStream, send_incom...
true
67cdf6685f034a1aaecc261787b9bfa93d4fe2e3
Rust
vitorsvt/stockstacean
/src/rank.rs
UTF-8
1,277
4.03125
4
[]
no_license
/// Ranks (horizontal lines) of the board #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum Rank { First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, } impl Rank { /// The rank above. Wraps around. pub fn up(&self) -> Rank { Rank::from(*self as usize + 1) ...
true
07c2dca9f09b28055979c380fb70ca1a65636cb7
Rust
iTakeshi/YARS
/src/kinematics.rs
UTF-8
355
2.75
3
[]
no_license
pub fn forward( base: &[f32; 3], angle_offset: &f32, length: &f32, angle: &f32, ) -> ([f32; 3], f32) { ( [ base[0] + length * (angle_offset + angle).cos(), base[1] + length * (angle_offset + angle).sin(), base[2], ], ...
true
d4759194b2ae425b0680d5106cdbfb2c1f014892
Rust
nuxeh/dinky
/src/http.rs
UTF-8
4,033
2.515625
3
[ "ISC" ]
permissive
use failure::Error; use iron::mime; use iron::modifiers::Redirect; use iron::prelude::*; use iron::status::{Found, NotFound, Ok as StatusOk}; use params::{Params, Value}; use router::Router; use std::fs::read_to_string; use std::process; use url::Url; use crate::conf::Conf; use crate::db; // pull in static index cont...
true
fc1d3f61be3f3f478f24ef7d01da49371f7b1b8e
Rust
cramertj/async-await
/src/tiny.rs
UTF-8
2,123
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
#![feature(async_await, await_macro, futures_api, pin)] use std::future::{Future, FutureObj}; use std::mem::PinMut; use std::sync::{Arc, Mutex}; use std::sync::mpsc::{sync_channel, SyncSender, SendError, Receiver}; use std::task::{ self, Executor, local_waker_from_nonlocal, Poll, SpawnErrorKind, ...
true
1051a12185430997bf1e372984db8f7cf05c59d0
Rust
mchristen/rustgl-playground
/src/render/array_buffer.rs
UTF-8
2,390
3.109375
3
[]
no_license
use gl; pub trait BufferType { const BUFFER_TYPE: gl::types::GLuint; } pub struct BufferTypeArray; impl BufferType for BufferTypeArray { const BUFFER_TYPE: gl::types::GLuint = gl::ARRAY_BUFFER; } pub struct BufferTypeElementArray; impl BufferType for BufferTypeElementArray { const BUFFER_TYPE: gl::types...
true
ab601b201b0be77a7821d39c77e691e804b0c036
Rust
bsed/rust_example
/ref_mode/src/main.rs
UTF-8
1,915
3.53125
4
[ "MIT" ]
permissive
#![feature(core_intrinsics)] #[derive(Clone, Copy)] struct Point {x: i32, y: i32} fn main() { println!("Hello, world!"); let s = String::from("hello"); let sref1 = &s; let ref sref2 = s; println!("{:p}", sref1); println!("{:p}", sref2); f1(&s); f2(s); println!("==============...
true
b9df265378cfc2e5bc90bd0693616f4523f8266e
Rust
Guang1234567/minigrep
/src/oop_demo/mod.rs
UTF-8
2,678
3.3125
3
[]
no_license
use std::fmt::{Debug, Error, Formatter}; trait State: Debug { fn request_review(self: Box<Self>) -> Box<dyn State>; fn approve(self: Box<Self>) -> Box<dyn State>; fn content<'a>(&self, post: &'a Post) -> &'a str { "" } } #[derive(Debug)] struct Draft {} #[derive(Debug)] struct PendingRevie...
true
22b204b897635847056393785b12c1956ef63671
Rust
seitamuro/atcoder_base90
/p022/src/main.rs
UTF-8
394
2.875
3
[]
no_license
use proconio::input; fn main() { input! { a: u64, b: u64, c: u64, } let d = gcd(a, gcd(b, c)); println!("{}", a/d + b/d + c/d - 3); } fn gcd(mut n1: u64, mut n2: u64) -> u64 { if n1 < n2 { let tmp = n1; n1 = n2; n2 = tmp; } let n1 = n1 %...
true
b7b3fc066fd443f85c989215c4fd0d15f4dc3711
Rust
aonorin/gunship-rs
/src/component/mesh.rs
UTF-8
3,864
2.984375
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::slice::Iter; use std::rc::Rc; use std::cell::RefCell; use polygon::gl_render::{GLMeshData, ShaderProgram}; use ecs::{Entity, ComponentManager}; use resource::ResourceManager; use super::{EntityMap, EntitySet}; #[derive(Debug, Clone)] pub struct Mesh { pub gl_mes...
true
2cc82ae827f6304fe73e22a237f6d1605de893a0
Rust
Kixiron/lasso
/src/interface/tests.rs
UTF-8
8,457
2.8125
3
[ "Apache-2.0", "MIT" ]
permissive
#![cfg(test)] use crate::{ interface::{Interner, IntoReader, IntoReaderAndResolver, IntoResolver, Reader, Resolver}, Key, Rodeo, RodeoReader, RodeoResolver, Spur, }; compile! { if #[feature = "multi-threaded"] { use crate::ThreadedRodeo; } if #[feature = "no-std"] { use alloc::{bo...
true
6542ad6d749a6b097e07432f0473684684f3f8b7
Rust
SethDusek/dcpu
/dcpu/src/lib.rs
UTF-8
1,879
2.984375
3
[]
no_license
#![feature(attr_literals)] #[macro_use] extern crate dcpu_macros; pub mod registers; #[macro_use] mod macros; pub mod instruction; pub mod instructions; pub use instruction::Instr; use registers::*; ///The CPU type ///0x10000 words of ram ///8 registers (A, B, C, X, Y, Z, I, J) pub struct CPU { pub exit: bool, //...
true
56f9ab2a38f0e66f0304713c088ec1fa8a0a76e6
Rust
birkenfeld/rustyline
/src/tty/unix.rs
UTF-8
4,237
2.53125
3
[ "MIT" ]
permissive
extern crate nix; extern crate libc; use std; use nix::sys::termios; use nix::errno::Errno; use super::Terminal; use super::StandardStream; use ::Result; use ::error; /// Unsupported Terminals that don't support RAW mode static UNSUPPORTED_TERM: [&'static str; 3] = ["dumb", "cons25", "emacs"]; #[cfg(any(target_os = ...
true
64d046bb15a40c0649bc9fa55aa675a000a6357d
Rust
mkirsche/RustAoC
/1_1/src/main.rs
UTF-8
442
3.4375
3
[]
no_license
use std::io; fn main() { let mut sum : i32 = 0; while true { // Declare variable and read it in let mut val = String::new(); let num_bytes = io::stdin().read_line(&mut val).ok().expect("Failed to read line"); if num_bytes == 0 { break; } let val_num:...
true
53b7c2785f3631943b0fee4f2a6e9e000ce96824
Rust
ToonSpin/adventofcode-2019-rust
/src/bin/day16.rs
UTF-8
2,327
3.25
3
[]
no_license
use std::io; use std::io::prelude::*; fn double_vec(v: Vec<i32>) -> Vec<i32> { [&v[..], &v[..]].concat() } fn quintuple_vec(v: Vec<i32>) -> Vec<i32> { [&v[..], &v[..], &v[..], &v[..], &v[..]].concat() } fn fft_phase(input: &Vec<i32>) -> Vec<i32> { let mut output: Vec<i32> = Vec::with_capacity(input.len()...
true
b72c813766de0d748196f1eb12e4ce72834325aa
Rust
7sDream/amiya
/src/middleware/m.rs
UTF-8
3,873
3.28125
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause-Clear" ]
permissive
use { crate::{async_trait, Context, Middleware, Result}, std::{future::Future, pin::Pin}, }; type BoxedResultFut<'x> = Pin<Box<dyn Future<Output = Result> + Send + 'x>>; /// The wrapper for use async function or closure as a middleware. /// /// This is the type when you use macro [`m`] , **Do Not** use this t...
true
38ec6586ccaacb4dbbd9012bdb348c470d07d256
Rust
kiliaosi/my-explorer
/classic/src/lib/tree.rs
UTF-8
492
3.546875
4
[]
no_license
use std::rc::Rc; use std::cell::RefCell; /// 完全二叉树的节点个数 pub struct TreeNode{ pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode{ fn new(item:i32)->Self{ TreeNode{ value:item, left:None, right:None, } } } pub fn cout(node...
true
73b03770fc7c1f1f6906c26c61031b74ec336a20
Rust
cchuang1024/rosetta-leetcode
/Algorithm#1/TwoSum_rs/src/main.rs
UTF-8
764
3.515625
4
[]
no_license
use std::collections::HashMap; struct Solution {} impl Solution { pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> { let mut his: HashMap<i32, i32> = HashMap::new(); for (i, n) in nums.iter().enumerate() { let comp = target - *n; if his.contains_key(&comp) { ...
true
12379b0e6121392f882e2c4c60704d5e4a3365b2
Rust
dust1/kvs
/src/lib.rs
UTF-8
845
2.515625
3
[]
no_license
mod kv; mod error; pub use kv::KvStore; pub use error::{KvsError, Result}; #[cfg(test)] mod tests { use crate::KvStore; use std::path::{PathBuf, Path}; #[test] fn kvTest() { let mut path = PathBuf::from("/"); path.push("Users"); path.push("kous"); path.push("Desktop");...
true
7f0eca43514daed7e7dd2b7e5b94c955da0ec211
Rust
michaeldoaty/chalk
/src/colors.rs
UTF-8
523
3.21875
3
[]
no_license
pub enum Colors { Normal, Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, } pub fn color_code(color: Colors) -> i32 { match color { Colors::Normal => 0, Colors::Black => 30, Colors::Red => 31, Colors::Green => 32, Colors::Yellow => ...
true
3b986781704a12eed51940d733b24cce5621b359
Rust
pemoreau/advent-of-code-2018
/rust/src/day02.rs
UTF-8
2,533
3.5
4
[]
no_license
// use std::env::var; use itertools::Itertools; use std::collections::HashMap; fn analyse(line: &str) -> (u32, u32) { let mut count2 = 0; let mut count3 = 0; let mut frequency: HashMap<char, u32> = HashMap::new(); for letter in line.chars() { let entry = frequency.entry(letter).or_insert(0); ...
true
15b48d3963e78c1e2becfd7f6af67928b45baf59
Rust
iliakonnov/warp
/src/or_tree.rs
UTF-8
3,127
3.453125
3
[ "MIT" ]
permissive
// https://github.com/seanmonstar/warp/issues/619 /// Takes a list of handler expressions and `or`s them together /// in a balanced tree. That is, instead of `a.or(b).or(c).or(d)`, /// it produces `(a.or(b)).or(c.or(d))`, thus nesting the types /// less deeply, which provides improvements in compile time. /// /// It a...
true
aadcb847742adbaf2107acf09a722042df1c09f2
Rust
hubitor/electron-with-rust
/native/src/transfer/client/mod.rs
UTF-8
3,195
2.5625
3
[ "MIT" ]
permissive
use crate::helpers; use crate::prelude::*; use crate::runtime; use crate::types::TransferFileMeta; use std::path::PathBuf; use std::sync::Arc; use tokio::fs::File; use tokio::net::TcpStream; pub fn send_file(mut cx: FunctionContext) -> JsResult<JsUndefined> { let config = cx.argument::<JsObject>(0)?; let ref_...
true
be4d24dab926a3f7ff7be0bd6f20b059ee0c7cd1
Rust
dseres/AdventOfCode2015
/src/bin/day12.rs
UTF-8
2,016
3.21875
3
[]
no_license
use json::object::Object; use json::JsonValue; use regex::Regex; fn main() { let contents = std::fs::read_to_string("./input/input12.txt").unwrap(); solution1(&contents); solution2(&contents); } //Very fast solution for question 1. fn solution1(contents: &str) { lazy_static::lazy_static! { sta...
true
64909bdae2f6112422d548b20dede86cb021bc92
Rust
yudhiesh/The-Rust-Book
/src/closures/anon_func.rs
UTF-8
2,652
4
4
[]
no_license
use std::thread; use std::time::Duration; // Closures have a concrete type attached to each of the variables // They are a form of anonymous funnctions // Using a cached closure which is stored in a struct struct Cacher<T> where T: Fn(u32) -> u32, { calculation: T, // Closure is stored in Value value:...
true
6fd2944a13ab8034a582188db9d1794656609dc1
Rust
evan-brass/sudoku-gen-rs
/src/main.rs
UTF-8
9,223
3
3
[]
no_license
use rand::prelude::*; struct Board { pub inner: [[Option<u8>; 9]; 9] } struct PossibleSet { pub inner: u16 } impl PossibleSet { pub fn size(&self) -> usize { let mut size = 0; for offset in 0..9 { if self.inner & 1 << offset != 0 { size += 1; } } size } pub fn remove(&mut self, other: Self) { ...
true
5e3e915b6fad01c752ac0ca8b1e50548671b2867
Rust
vchugreev/tbot
/pr/src/args.rs
UTF-8
3,217
2.890625
3
[]
no_license
use anyhow::{anyhow, Context}; use clap::{App, Arg, ArgMatches}; use std::ops::Deref; const CONFIGS: &str = "configs"; const MIGRATIONS: &str = "migrations"; const STORING: &str = "storing"; const READING: &str = "reading"; const SPEED: &str = "speed"; pub struct Args(ArgMatches); pub enum Mode { Storing, Re...
true
8bcef14f511fe437557deaeecb636f96f3a9185c
Rust
SouthamptonRust/rustcurrent
/src/testing/automaton.rs
UTF-8
8,482
3
3
[]
no_license
use std::hash::{Hash, Hasher}; use std::fmt::{Debug, Formatter}; use std::fmt; use super::time_stamped::{InvokeEvent}; #[derive(Eq)] #[derive(Clone)] #[derive(Debug)] pub struct Configuration<Seq: Hash + Eq + Clone, Ret: Eq + Copy> { sequential: Seq, states: StatesWrapper<Seq, Ret> } impl<Seq: Hash + Eq + Cl...
true
c2c8600637e3a267370f88f7fdd47db54a5babf2
Rust
rustwasm/wasm-bindgen
/crates/js-sys/tests/wasm/Reflect.rs
UTF-8
8,042
2.96875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use js_sys::*; use wasm_bindgen::prelude::*; use wasm_bindgen_test::*; #[wasm_bindgen(module = "tests/wasm/Reflect.js")] extern "C" { fn get_char_at() -> Function; #[wasm_bindgen(js_name = Rectangle)] static RECTANGLE_CLASS: Function; #[wasm_bindgen(js_name = Rectangle2)] static RECTANGLE2_CLASS: ...
true
d08339216c5b6539772b54e16ce750f9d2c3a829
Rust
phact/cql-bindgen
/src/ffi_util.rs
UTF-8
350
2.546875
3
[ "Apache-2.0" ]
permissive
use std::slice; use std::str; use std::ffi::CString; #[inline] pub fn str2ref(query:&str) -> *const i8 { CString::new(query).unwrap().as_ptr() as *const i8 } pub unsafe fn raw2utf8(data:*const i8, length:u64) -> String { let slice = slice::from_raw_parts(data as *const u8,length as usize); str::from_utf8(...
true
02f2185dccf17c695492bdea245c67def0eb4612
Rust
EFanZh/LeetCode
/src/problem_1491_average_salary_excluding_the_minimum_and_maximum_salary/mod.rs
UTF-8
448
3.09375
3
[]
no_license
pub mod iterative; pub trait Solution { fn average(salary: Vec<i32>) -> f64; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ (&[4000, 3000, 1000, 2000] as &[_], 2500.0), (&[1000, 2000, 3000], 2000.0), ]; for (...
true
2c05d1f7c8b25fecbbb9758b96decfc2cd85edb2
Rust
isgasho/polyhorn
/crates/polyhorn-core/src/compositor.rs
UTF-8
796
2.703125
3
[ "MIT" ]
permissive
use super::Platform; pub trait CommandBuffer<P> where P: Platform + ?Sized, { /// This function initializes a new container by running the given /// initializer on the UI thread and mounts it to the given parent by /// invoking the parent's mounting function (see /// [Container::Mount](Container::M...
true
4b3b38ad3b358c7fd4f38cf0293d70f46050ac20
Rust
TheZoq2/BspwmWorkspaceSwitcher
/src/camera_state.rs
UTF-8
1,915
3.203125
3
[]
no_license
extern crate nalgebra as na; pub struct CameraState { position: na::Vector2<f32>, zoom: f32 } impl CameraState { pub fn new() -> CameraState { CameraState { position: na::zero(), zoom: 1. } } pub fn get_matrix(&self) -> na::Matrix4<f32> { le...
true
763d90cb79c43edef0779913acc38e2fb943d83d
Rust
knokko/griphin-rs
/src/grid/dump.rs
UTF-8
2,435
3.828125
4
[]
no_license
/// For debugging purposes, it can be very useful to see what a *ColorGrid* /// currently looks like. This struct represents a copy of the state of a /// color grid, made at a given moment. /// /// Unlike color grids, these dumps are stored in RAM, which means the /// individual colors in the grid can be read easily (a...
true
80a51318dc35894631f49abf79f0aed72d5c7100
Rust
designer-jqy/Project
/Project/Rust/hello-cargo/src/main.rs
UTF-8
4,003
3.578125
4
[]
no_license
use std::collections::HashMap; mod cli; #[derive(Debug)] struct TestStruct { number: u8, string: String, char: char, } #[derive(Debug)] enum TestEnum { WEunit(bool), WEstruct(TestStruct), WEtuple(String, bool), } struct Person { first: String, middle: Option<String>, last: String, }...
true
4ea108878a55ae75e6d3c41295376bb707260b74
Rust
rustbasic-arch/rust_smart_pointer
/impl_trait_copy_it_func/src/main.rs
UTF-8
206
2.953125
3
[ "MIT" ]
permissive
trait Foo{ fn foo(){ println!("foo"); } } struct Bar1; struct Bar2; impl Foo for Bar1{} impl Foo for Bar2{} fn main(){ println!("{:p}",&Bar1::foo); println!("{:p}",&Bar2::foo); }
true
6dbd4df9dfc980524b1b58f148757d6b8c9c1eff
Rust
KuangjuX-Archived/rCore
/os/src/console.rs
UTF-8
1,169
2.75
3
[ "MIT" ]
permissive
use crate::sbi::* ; use core::fmt::{self, Write}; struct Stdout; impl Write for Stdout{ // print string fn write_str(&mut self, s: &str) -> fmt::Result { let mut buffer = [0u8; 4]; for c in s.chars() { for code_point in c.encode_utf8(&mut buffer).as_bytes().iter() { ...
true
496d458be1cfe2a469f5c54ed7171a3494b9e130
Rust
jherman3/ifs_fractal
/src/ifs.rs
UTF-8
1,970
3.21875
3
[]
no_license
use vertex::Vertex; use rand::Rng; /// Represents a single equation in an IFS /// Contains equations parameters and the probability value #[derive(Copy, Clone, Debug, PartialEq, Default)] pub struct Eqn { pub a: f32, pub b: f32, pub c: f32, pub d: f32, pub e: f32, pub f: f32, pub p: f32, }...
true
edf89bbf2e4208eaad33df01e41245e2c37b1083
Rust
agrif/sprunk
/src/samplerate.rs
UTF-8
7,200
2.703125
3
[]
no_license
use libsamplerate_sys::*; pub fn version() -> &'static str { let cstr = unsafe { std::ffi::CStr::from_ptr(src_get_version()) }; cstr.to_str().unwrap() // assume libsamplerate uses valid utf-8 } #[derive(Debug)] pub struct SampleRate { state: *mut SRC_STATE, channels: u16, } impl Clone for SampleRate ...
true
3673e54ad3c7ee7c78b0a8715fcf369b6c31dd2a
Rust
suyash67/MProvePlus-Ristretto
/src/util.rs
UTF-8
4,273
3.125
3
[]
no_license
/* Copyright (c) 2018 Chain, Inc. Some parts of this file are from the bulletproofs package by dalek-cryptography. Link: https://github.com/dalek-cryptography/bulletproofs Description: Utilities for Scalar operations. */ #![allow(non_snake_case)] use curve25519_dalek::scalar::Scalar; use alloc::vec; use alloc::vec:...
true
cb572f29c52055dbaffae75c074418f855173454
Rust
Nugine/wrong-answer
/wa-server/src/types/judge.rs
UTF-8
3,439
2.84375
3
[]
no_license
use super::*; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum JudgeType { Strict, IgnoreTrialingSpace, SpecialJudge, Interactive, } #[derive(Serialize, Deserialize)] pub struct Submission { pub id: u64, pub problem_id: u64, pub judge_type: JudgeType, pub t...
true
859817e4a533d8152b951cf561034e57719b7464
Rust
pnnl/lamellar-runtime
/examples/kernels/am_flops.rs
UTF-8
6,505
2.609375
3
[ "BSD-3-Clause" ]
permissive
/// ------------Lamellar Bandwidth: AM flops ------------------------- /// similar to the AM bandwidth tests but instead of transferring data /// each active message performs some number of dummy multiply add operations /// Not to be used as a true measure of the flops of a system but can be /// useful to compare mult...
true
216b9a4b3d04ae0ccf1ef658085bee12af9a6a33
Rust
aldhsu/aoc2020
/day7/src/main.rs
UTF-8
4,278
3.40625
3
[]
no_license
type RulesMap = std::collections::HashMap<String, Vec<(String, usize)>>; fn part1(rules: &RulesMap) -> usize { fn find_matching_inner<'a>(rules: &'a RulesMap, mut key: &'_ str) -> Vec<&'a str> { if key.ends_with('s') { key = &key[..key.len() - 1] // drop s; } rules.iter().filter...
true
3815590a62d24bb72366353b648870407d1b45a4
Rust
GabrielMajeri/directx-rs
/dxgi/src/factory.rs
UTF-8
4,158
3.0625
3
[]
no_license
use {ComPtr, Interface, dxgi, dxgi1_2, winerror}; //use winapi::HWND; use std::ptr; use adapter::Adapter; // Use this type when referring to the contained interface. // This allows to change the interface's version without rewriting all the references. type FactoryInterface = dxgi1_2::IDXGIFactory2; /// Interface use...
true
874db25476bb4bbf16e47db658e82e00c7004ce3
Rust
niuez/toptree-rust
/src/query/center.rs
UTF-8
2,265
3.015625
3
[]
no_license
use crate::node::*; use crate::link::*; use crate::select::*; use crate::expose::*; #[derive(Clone, Debug)] struct Center { radius: usize, max_dist_left: usize, max_dist_right: usize, length: usize } impl Center { fn new(l: usize) -> Self { Center { radius: l, max_d...
true
df5a2986b075bb0bb8365b78a9c0ff55fd7c1cbe
Rust
jedisct1/rust-coarsetime
/src/tests.rs
UTF-8
2,473
2.625
3
[ "BSD-2-Clause" ]
permissive
#[cfg(all(feature = "nightly", test))] extern crate test; use std::thread::sleep; use std::time; #[cfg(feature = "nightly")] use self::test::Bencher; #[cfg(not(any(target_arch = "wasm32", target_arch = "wasm64")))] use super::Updater; use super::{Clock, Duration, Instant}; #[test] fn tests() { let ts = Instant::...
true
c0266518e32159e264a3f6d7d69ff89dc327c406
Rust
robkorn/jormungandr
/src/utils/task.rs
UTF-8
2,370
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::log_wrapper::logger::update_thread_logger; use tokio_bus::{Bus, BusReader}; use std::clone::Clone; use std::sync::mpsc::{channel, Receiver, Sender}; use std::thread; #[allow(dead_code)] pub struct Task { handler: thread::JoinHandle<()>, name: &'static str, } #[allow(dead_code)] pub struct TaskWit...
true