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
d4c3d89cd9e35646fed6208d3f2b38382b42198a
Rust
songlinshu/so_58246366_proc_macro
/fields_impl/src/lib.rs
UTF-8
421
3.0625
3
[]
no_license
#[macro_use] extern crate derive_fields; #[cfg(test)] mod tests { use derive_fields::derivefields; #[derivefields(u32, "field", 3)] pub struct MyTest { foo: u32 } #[test] fn has_fields() { let mut o = MyTest { foo: 4, field_0: 1, field_1: ...
true
55e0fd6751315acf1afb0b854852266bfba3fdad
Rust
Roblox-GitHub-Archive/rbx-dom
/rbx_xml/src/types/axes.rs
UTF-8
1,275
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::io::{Read, Write}; use rbx_dom_weak::types::Axes; use crate::{ core::XmlType, deserializer_core::XmlEventReader, error::{DecodeError, DecodeErrorKind, EncodeError}, serializer_core::XmlEventWriter, }; impl XmlType for Axes { const XML_TAG_NAME: &'static str = "Axes"; fn write_xml<W:...
true
c27546ae54151aa09ed92c6d419b26bc11730916
Rust
fbriden/market-finance-rs
/src/indicators/averages.rs
UTF-8
3,194
3.6875
4
[ "MIT" ]
permissive
use crate::Bar; use super::traits::{ TechnicalIndicator, UpdatableIndicator }; type Precision = f64; /// Exponential Moving Average /// /// Uses an alpha of 2 / (1 + number of periods) #[derive(Clone, Copy, Debug)] pub struct ExponentialMovingAverage { /// The degree of weighting decrease - always between 0 and 1 ...
true
6a6ed5e3e01e07524b4d24897ca67269bdce7772
Rust
litcc/vertx-rust
/src/vertx/message.rs
UTF-8
10,643
2.796875
3
[ "BSD-3-Clause" ]
permissive
use std::convert::TryInto; use std::sync::Arc; use std::ops::Deref; use crate::vertx::message::Body::{ByteArray, Byte, Short}; //Message used in event bus in standalone instance and cluster #[derive(Clone, Default, Debug)] pub struct Message { //Destination sub address pub(crate) address: Option<String>, /...
true
61f4f777fbcc8e05009229b6e6c5bc5276db81fa
Rust
lex148/hadlock
/src/xlibwrapper/util/mod.rs
UTF-8
1,921
3.0625
3
[ "MIT" ]
permissive
pub mod keysym_lookup; use serde::{self, de, Deserialize, Deserializer, Serialize}; #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Position { pub x: i32, pub y: i32, } #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Size { pub width: i32, pub height: i32, } #[derive(Clone, Copy, Deb...
true
7ae222ea1924a9d9adc2b77810feb05aab3ca150
Rust
tonygallotta/adventofcode-2020
/day15/src/main.rs
UTF-8
1,781
3.6875
4
[]
no_license
use std::collections::HashMap; use std::time::Instant; // PART 1: 662 // PART 2: 37312 // Execution completed in 17580ms fn main() { let timer = Instant::now(); let (part_1_answer, part_2_answer) = answers(&vec![16, 11, 15, 0, 1, 7]); println!("PART 1: {}", part_1_answer); println!("PART 2: {}", part_...
true
0d1c82551e50421bb074aced8e888d36d4a49559
Rust
mbresson/rosalind-rust
/src/bin/locating-restriction-sites.rs
UTF-8
2,950
3.09375
3
[ "MIT" ]
permissive
extern crate rosalind; // solution to http://rosalind.info/problems/revp/ use std::convert::TryFrom; use rosalind::dna::Sequence as DnaSequence; #[cfg(test)] mod tests { use std::convert::TryFrom; use std::cmp::Ordering::Equal; use rosalind::dna::Sequence as DnaSequence; fn sort_positions_and_length...
true
8f59971a6824ec62a53dd0673e3f30efa8888887
Rust
kohbis/leetcode
/algorithms/0703.kth-largest-element-in-a-stream/solution.rs
UTF-8
968
3.6875
4
[]
no_license
use std::cmp::Reverse; use std::collections::BinaryHeap; struct KthLargest { size: usize, heap: BinaryHeap<Reverse<i32>>, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl KthLargest { fn new(k: i32, nums: Vec<i3...
true
0edf1507441c55e2f3cf3356c898096f42ed6e1f
Rust
jerielverissimo/taskbook
/src/taskbook.rs
UTF-8
662
2.625
3
[]
no_license
use super::config::Config; use super::item::Items; use super::options::Options; use super::render::Render; use super::storage::Storage; use super::task::Task; #[derive(Debug)] pub struct Taskbook { _storage: Storage, _render: Render, } impl Taskbook { pub fn new() -> Self { let task = Taskbook { ...
true
34d63924c4d14ce106b1fa580381bed66214194f
Rust
Logicalshift/flowbetween
/animation/src/traits/brush_drawing_style.rs
UTF-8
299
3.203125
3
[ "Apache-2.0" ]
permissive
/// /// Represents the drawing style to use with a brush /// #[derive(Clone, Copy, PartialEq, Serialize, Deserialize, Debug)] pub enum BrushDrawingStyle { /// Draw this brush directly on to the current layer Draw, /// Erase what's underneath this brush on the current layer Erase }
true
1414768f394f609fbe9fce4f71447e1b8858e746
Rust
sourcedennis/wasm-pathtracer
/src/math/empirical_pdf.rs
UTF-8
3,058
3.34375
3
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
use std::fmt; use crate::rng::Rng; /// An empirical Probability Distribution Function, with a fixed bin count /// Warning: Bins are initialised with the value 1.0 /// If small actual values are written, this skews the PDF /// Though, this is done to make no probability ever 0.0 #[derive(Clone)] pub s...
true
d914580c616f50db7ca62f12cae534290fba0552
Rust
Salehbigdeli/rust-with-lists
/src/second.rs
UTF-8
1,141
3.6875
4
[]
no_license
use std::mem; #[derive(Debug)] struct Node<T> { elem: T, next: Link<T> } type Link<T> = Option<Box<Node<T>>>; #[derive(Debug)] pub struct List<T> { head: Link<T>, } impl<T> List<T> { pub fn new() -> Self { List{head: None} } } impl<T> List<T> { pub fn push(&mut self, elem: T) { ...
true
3f270d73fbfca8cc5c47ae970dd34d9799618c70
Rust
brennengarland/thesis
/src/functions/calculate_rcs.rs
UTF-8
1,224
3.265625
3
[]
no_license
// use super::*; pub fn calculate_rcs(angle: f32, rcs_angles: &Vec<f32>, rcs_values: &Vec<f32>) -> f32 { let mut refl_pwr: f32 = -1.0; // Check to see if the rcs has a power specified for the angle if rcs_angles.contains(&angle) { refl_pwr = rcs_values[rcs_angles.iter().position(|&r| r == angle).un...
true
786e8dbb87fabbd3ecd19aba82d1bee88258205d
Rust
ajithk444/dicom-rs
/parser/src/stateful/encode.rs
UTF-8
5,151
3.421875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Module holding a stateful DICOM data encoding abstraction, //! in a way which supports text encoding. //! use crate::error::{Error, Result}; use dicom_core::{value::PrimitiveValue, DataElementHeader, VR}; use dicom_encoding::transfer_syntax::DynEncoder; use dicom_encoding::{ encode::EncodeTo, text::{Defaul...
true
5b8e009843cfc3be5e387c9bd467a13ab6067988
Rust
ula-lang/ula
/src/lexer/keyword.rs
UTF-8
1,869
3.203125
3
[ "Apache-2.0" ]
permissive
use std::fmt; #[derive(Clone, Eq, PartialEq)] pub enum Keyword { Async, Await, Break, Case, Class, Else, Enum, Extends, Export, For, ForEach, From, Function, If, Import, In, Var, Local, New, Return, Static, Switch, While, Y...
true
b13913dab5df67a9982194fd86bc6fec12986122
Rust
rbenua/AdventOfCode
/2021/src/day16/mod.rs
UTF-8
3,414
3
3
[]
no_license
use crate::Problem; use crate::read_lines; use std::error::Error; use regex::Regex; extern crate string_error; use string_error::new_err; use parse_display::{Display, FromStr}; pub struct Day16{ bits: Vec<bool>, parsed: Packet, } #[derive(Debug)] struct Packet{ version: u64, ptype: u64, contents: ...
true
0dc1f3388bdb3171d41b7d6e393a043825c75c99
Rust
isgasho/lopez
/lib-lopez/src/cli.rs
UTF-8
3,304
2.828125
3
[ "Apache-2.0" ]
permissive
#[macro_export] macro_rules! cli_impl { ($backend_ty:ty) => { use std::path::PathBuf; use $crate::backend::Backend; use $crate::Profile; use $crate::StructOpt; #[derive(StructOpt)] pub struct Cli { #[structopt(long, env, default_value = "/usr/share/lopez...
true
6f7296cc2d583e3876b0614f31bf87998e8ca5af
Rust
imxrt-rs/imxrt-rt
/board/src/shared/imxrt11xx.rs
UTF-8
1,818
2.53125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Code shared across all i.MX RT 11xx chips. use crate::ral; pub(crate) fn prepare_pit(timer_delay_microseconds: u32) -> Option<crate::Pit> { #[cfg(feature = "rtic")] { extern "C" { // Not actually mut in cortex-m. But, no one is reading it... static __INTERRUPTS: [core::cell...
true
53f6441ed31991c98713103cda4b14bea49ada56
Rust
leod/particle-frenzy
/src/spawn.rs
UTF-8
1,597
3.15625
3
[ "MIT" ]
permissive
use rand::{self, Rng}; use gfx; use {Particle, System}; pub struct Cone<F> { pub spawn_time: f32, pub life_time: f32, pub pos: [f32; 2], pub orientation: f32, pub spread: f32, pub min_speed: f32, pub max_speed: f32, pub angle: f32, pub friction: f32, pub size: [f32; 2], pub...
true
c6b7e12c149723f9371954e199b3b9d27ccbd54f
Rust
copterust/f3-eva
/src/cmd.rs
UTF-8
685
3.109375
3
[]
no_license
const BUFFER_SIZE: usize = 32; const CR: u8 = '\r' as u8; const LF: u8 = '\n' as u8; pub struct Cmd { buffer: [u8; BUFFER_SIZE], pos: usize, } impl Cmd { pub fn new() -> Cmd { Cmd { buffer: [0; BUFFER_SIZE], pos: 0 } } pub fn push(&mut self, b: u8) -> Option<&[u8]> { if b == CR ||...
true
880a7c5a5f134b01da380ab943882fde1a2e6b54
Rust
omar2535/leetcode
/rust/src/problems/p242_valid_anagram.rs
UTF-8
1,194
3.5
4
[]
no_license
use std::{collections::HashMap, hash::Hash}; struct Solution; impl Solution { pub fn is_anagram(s: String, t: String) -> bool { let mut tracker = HashMap::new(); for c in s.chars() { if tracker.contains_key(&c) { *tracker.get_mut(&c).unwrap() += 1; } else {...
true
08d4c96be05ee9c853a1d3015c7be474043da401
Rust
speaker73/hunter.rs
/src/events.rs
UTF-8
3,601
2.765625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate ggez; use ggez::*; use ggez::graphics::{Point}; use ::MainState; use draw::{Hex}; struct HexParam { w: f32, h: f32, point:Point, } #[derive(Debug,Clone)] struct Triangle { a:Point, b:Point, c:Point, } pub fn on_hex_press(x:i32, y:i32, tself: &mut MainState){ let mut hex_param ...
true
cd97d5302ed9f731d49f13792543074c8f8af60b
Rust
rust-rosetta/rust-rosetta
/tasks/hamming-numbers/src/lib.rs
UTF-8
4,577
3.828125
4
[ "Unlicense" ]
permissive
extern crate num; use std::cmp::min; use std::collections::VecDeque; use std::ops::Mul; use num::bigint::{BigUint, ToBigUint}; use num::one; use num::traits::One; /// representing a Hamming number as a `BigUint` impl HammingNumber for BigUint { // returns the multipliers 2, 3 and 5 in the representation for the ...
true
851e8fe8de40a0e2bb61971e5502e1a7bb829bd8
Rust
liguangsheng/leetcode-rust
/src/a1317_convert_integer_to_the_sum_of_two_no_zero_integers.rs
UTF-8
1,010
3.53125
4
[ "MIT" ]
permissive
/* * [1317] convert-integer-to-the-sum-of-two-no-zero-integers */ pub struct Solution {} // solution impl starts here impl Solution { pub fn get_no_zero_integers(n: i32) -> Vec<i32> { for i in 0..n { if !Solution::contains_zero(i) && !Solution::contains_zero(n - i) { return ...
true
fed55b54e4ca80ffb372f451bd4af39d3ff06092
Rust
salimclevy/csml-interpreter
/src/data/event.rs
UTF-8
350
2.640625
3
[ "Apache-2.0" ]
permissive
#[derive(Debug, Clone)] pub struct Event { pub content_type: String, pub content: String, pub metadata: serde_json::Value, } impl Event { pub fn text(text: &str) -> Self { Self { content_type: "text".to_owned(), content: text.to_owned(), metadata: serde_json:...
true
61a8d0df69f876d93046ae033575fd88faae2e2e
Rust
ikornaselur/corrosiones
/src/cpu/opcodes/stack/push.rs
UTF-8
1,199
3.578125
4
[]
no_license
use cpu::CPU; /// Push Accumulator onto the stack pub fn pha(cpu: &mut CPU) -> u8 { let cycles = 3; let acc = cpu.a; cpu.push_stack(acc); cycles } /// Push flags onto the stack pub fn php(cpu: &mut CPU) -> u8 { let cycles = 3; let flags = cpu.flags.as_byte(); cpu.push_stack(flags | 0b00...
true
7128463559271b716857aa0a02bea4a955557a32
Rust
brharrelldev/wabash_db
/src/main.rs
UTF-8
1,994
3.28125
3
[]
no_license
use serde::export::fmt::Error; use serde::export::Formatter; use std::fmt::Display; use serde::ser::{Serialize, Serializer, SerializeStruct}; use std::io::Write; pub struct PersonRecord { name: String, age: u8, phones: String, } impl PersonRecord { pub fn new(name: String, age: u8, phones: String) ->...
true
b3e4eadd90d240a1cd1d1c4be323eb3501f037e5
Rust
ekke-rs/ekke_core
/src/ekke_core/app.rs
UTF-8
3,036
2.609375
3
[ "Unlicense" ]
permissive
use crate :: { import::*, services::RegisterApplication, AppConfig, EkkeError, EkkeResult }; mod frontend_request; mod backend_response; pub use frontend_request::*; pub use backend_response::*; pub struct App { pub name : String , pub path : PathBuf , pub peer : Rec...
true
0016605506f833649d28b1081e1630819c5b9487
Rust
burnt43/rust-ncurses
/src/attribute/mod.rs
UTF-8
2,495
2.921875
3
[]
no_license
use super::ll::{attr_t, color_t}; use std::ops::{BitOr}; #[macro_export] macro_rules! chtype_vec { ( $( $x:expr ),* ) => { { let mut temp_vec : Vec<chtype> = Vec::new(); $( temp_vec.push($x.to_attr_t()); )* temp_vec } }; } #[macro_export] macro_rules! string...
true
edf263d54f69a113192c0d0aa2c6b93bff73ef7e
Rust
MrShiister/convert_kindle_vocab_to_anki
/src/main.rs
UTF-8
2,823
2.875
3
[ "MIT" ]
permissive
use clap::{Arg, App, SubCommand}; use convert_kindle_vocab_to_anki::run; use std::time::Instant; fn main() { let start_time = Instant::now(); // argparse let matches = App::new("Convert Kindle Vocab to Anki") .version("1.0") .author("https://github.com/...
true
432668adb8084795008273ef9798d321d03cc830
Rust
kaj/rsass
/rsass/tests/spec/libsass/color_functions/opacity/alpha.rs
UTF-8
1,087
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Tests auto-converted from "sass-spec/spec/libsass/color-functions/opacity/alpha.hrx" #[allow(unused)] fn runner() -> crate::TestRunner { super::runner().with_cwd("alpha") } #[test] fn test() { assert_eq!( runner().ok("foo {\ \n c0: opacity(rgba(0,0,0,0.0));\ \n c1: opac...
true
fc1f69e14bb9ba8dac46fda4017614919eb26e25
Rust
divinerapier/weaver
/weaver/src/error/storage_error.rs
UTF-8
2,963
2.984375
3
[ "Apache-2.0" ]
permissive
use std::fmt::{Display, Formatter, Result as FmtResult}; #[derive(Debug)] pub enum StorageError {} impl Display for StorageError { fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult { write!(f, "") } } // use failure::Fail; // #[derive(Debug, Fail)] // pub enum StorageError { // #[fail(display = ...
true
af59025bd6928c7a029048db38f95304f90a9af7
Rust
NatoliChris/rust-learn
/rust-by-example/arrays_and_size.rs
UTF-8
442
3.75
4
[]
no_license
use std::mem; fn analyze_slice(slice: &[i32]) { println!("The slize occupies {} bytes", mem::size_of_val(&slice)); println!("The slice has {} elements and the first element is {}", slice.len(), slice[0]); } fn main() { // Define size and type of array let xs: [i32; 5] = [1,2,3,4,5]; //All element...
true
9c057a993634f2e106164e02b92bc18a5436bf9a
Rust
rustviz/rustviz
/src/examples/struct_string/input/annotated_source.rs
UTF-8
737
2.703125
3
[ "MIT" ]
permissive
struct <tspan class="fn" data-hash="0" hash="5">Foo</tspan> { <tspan data-hash="2">x</tspan>: i32, <tspan data-hash="3">y</tspan>: String, } fn main() { let <tspan data-hash="4">_y</tspan> = <tspan class="fn" data-hash="0" hash="6">String::from</tspan>("bar"); let <tspan data-hash="1">f</tspan> = <tspa...
true
e2d1f154c7e56bf8c6cb108ff51e0698f3838f56
Rust
zBaitu/rfmt
/src/main.rs
UTF-8
1,251
2.625
3
[]
no_license
use std::path::PathBuf; use structopt::StructOpt; mod ast; mod ft; mod ir; mod rfmt; mod tr; mod ts; #[derive(Debug, StructOpt)] pub struct Opt { #[structopt(long, short)] /// Print the rust original syntax ast debug info ast: bool, #[structopt(long, short)] /// Check exceed lines and trailing w...
true
489573ed20cb8cb721dc41e50cc3a0212fe84c81
Rust
mchesser/gdbstub
/gdbstub_arch/src/mips/mod.rs
UTF-8
3,333
2.828125
3
[ "MIT" ]
permissive
//! Implementations for the MIPS architecture. use gdbstub::arch::Arch; use gdbstub::arch::RegId; pub mod reg; /// MIPS-specific breakpoint kinds. /// /// Extracted from the GDB documentation at /// [E.5.1.1 MIPS Breakpoint Kinds](https://sourceware.org/gdb/current/onlinedocs/gdb/MIPS-Breakpoint-Kinds.html#MIPS-Brea...
true
82ba7612d0e5d1dec5be00de09f28fd4267b5032
Rust
ousttrue/frame_factory
/from_jsonschema/src/generator.rs
UTF-8
4,753
3.03125
3
[ "MIT" ]
permissive
use std::{ collections::{HashMap, HashSet}, fs, io::{BufWriter, Write}, rc::Rc, }; use itertools::Itertools; use crate::{ baseiterator::BaseIterator, jsonschema::{JsonSchema, JsonSchemaError, JsonSchemaType}, }; fn escape(src: &str) -> &str { if src == "type" { &"r#type" } els...
true
7dc6b36d31b34ba2456cdcc72b5ac758d06e634f
Rust
NyleCohen/bacon-cypher-compsci
/src/main.rs
UTF-8
1,349
3.3125
3
[]
no_license
use bacon_cipher::codecs::char_codec::CharCodec; use bacon_cipher::BaconCodec; use std::iter::FromIterator; use std::io; fn main() { let mut input = String::new(); println!("Welcome to my bacon cypher presentation"); let mut input = String::new(); println!("Input the text you want to encode"); ...
true
03225f1f65080ce249641bc463d87b8c23c39868
Rust
redox-os/redoxfs
/src/dir.rs
UTF-8
2,285
2.859375
3
[ "MIT" ]
permissive
use core::{mem, ops, slice, str}; use crate::{Node, TreePtr}; #[repr(packed)] pub struct DirEntry { node_ptr: TreePtr<Node>, name: [u8; 252], } impl DirEntry { pub fn new(node_ptr: TreePtr<Node>, name: &str) -> Option<DirEntry> { let mut entry = DirEntry { node_ptr, ..Defa...
true
85bb51e6ed3702e73c8477e2b1e9f3d0ed5cfa40
Rust
AndreasOM/omt-experiments
/0004-atlas/atlas/src/main.rs
UTF-8
3,223
2.796875
3
[ "MIT" ]
permissive
use clap::{Arg, App, SubCommand}; use std::process; // :TODO: figure out rust conventions for module structure //use atlas::atlas::Atlas; use atlas::Atlas; use atlas::OmError; fn main() { // omt-atlas combine --output test-atlas-%d --size 2048 --border 0 --input ../Content/test.png let matches = App::new("omt-atlas")...
true
3d456143fecb93eafdcce1abfdc9a7584dcf1085
Rust
xcaptain/rust-algorithms
/leetcode/src/p300.rs
UTF-8
924
3.25
3
[]
no_license
// https://leetcode-cn.com/problems/longest-increasing-subsequence/ pub fn length_of_lis(nums: Vec<i32>) -> i32 { let l = nums.len(); if l == 0 { return 0; } let mut dp = vec![0; l]; dp[0] = 1; let mut res = 1; for i in 1..l { let mut maxval = 0; for j in 0..i { ...
true
ca86df113eb0566f2b7d9bf4ae5da54234c690ad
Rust
Garvys/rustfst
/rustfst-cli/src/cmds/tr_sort.rs
UTF-8
1,130
2.625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow::{bail, Result}; use rustfst::prelude::*; use crate::unary_fst_algorithm::UnaryFstAlgorithm; pub struct TrsortAlgorithm { path_in: String, sort_type: String, path_out: String, } impl UnaryFstAlgorithm for TrsortAlgorithm { fn get_path_in(&self) -> &str { self.path_in.as_str() ...
true
ea415d81d7f204923c353b561d5aff4fe9390aa8
Rust
Nehliin/Encrypter
/encrypter-server/src/peer.rs
UTF-8
3,144
3.046875
3
[]
no_license
use async_std::net::SocketAddr; use async_std::net::TcpStream; use encrypter_core::Result; use std::collections::hash_map::{Iter, Values}; use std::collections::HashMap; #[derive(Debug)] pub struct Peer { pub peer_id: String, pub tcp_stream: TcpStream, pub public_key: [u8; 32], } impl Peer { pub fn ne...
true
a1b13c504efab39a518bc561bebf560cf34b23f8
Rust
luminalang/lumina
/lumina-parser/src/ast/function.rs
UTF-8
4,372
2.796875
3
[]
no_license
use super::{walker::Bounds, Entity, Type}; use crate::Attr; use colored::*; use itertools::Itertools; use lumina_util::{PFlags, Tr}; use std::fmt; /// A function header paired with an AST Entity. #[derive(PartialEq, Debug, Clone)] pub struct Function { pub header: Header, pub name: String, pub body: Body, ...
true
b29255a72a143ea5f311b002caf3ca481935e07e
Rust
Nexure/rbxlx-mesh-fixer
/src/utils/cframe.rs
UTF-8
6,317
2.875
3
[]
no_license
use rbx_types::{CFrame, Matrix3, Vector2, Vector3}; use super::TupleComponent; pub trait MatrixExt { fn default() -> Self; } pub trait CFrameExt { fn default() -> Self; fn components(&self) -> TupleComponent; fn from_components(components: &[f32]) -> Self; fn mult(&self, b: CFrame) -> Self; f...
true
383bceccfc9c9a6738d502263ab66ee4319470d7
Rust
Prometeo/rust_tutorial
/projects/advanced_types/Never_Type/src/main.rs
UTF-8
424
3.578125
4
[]
no_license
// Rust has a special type named ! that’s known in type theory lingo as the empty type // because it has no values. We prefer to call it the never type because it stands in the // place of the return type when a function will never return. Here is an example: fn bar() -> ! { // --snip-- } // This code is read as ...
true
cdb3285552bc9742e0e3d0ebcd7a3a03f7cd3e72
Rust
NebulousPigeon/10-weeks-10-languages
/rust/examples/concepts/variables.rs
UTF-8
287
3.578125
4
[]
no_license
fn main(){ // immutable type let i = 10; // i = i+1; // compile error println!("i is {}", i); let mut b = 10; b = b+1; // works just fine println!("but b now is {}", b); // let pi = &i; // *pi = *pi+1; // compile error: cannot borrow as mutable! }
true
a331535da9f5b6eaf6fa07d5144961fa76732d1d
Rust
MamadouSDiallo/advent_of_code_2020
/src/day_08/day08.rs
UTF-8
2,514
3.28125
3
[]
no_license
use std::io::prelude::*; use std::{fs::File, io::BufReader}; fn accumulate(operation: &Vec<String>, argument: &Vec<i32>) -> (usize, i32) { let mut execution: Vec<bool> = vec![false; operation.len()]; let mut accumulator = 0; let mut k = 0; while k < execution.len() && !execution[k] { execution...
true
1ab33d9d2b45696cf10891a1a8593419732078b3
Rust
adminSxs/service_derive
/src/lib.rs
UTF-8
2,315
2.5625
3
[]
no_license
#[macro_use] extern crate quote; #[macro_use] extern crate syn; use syn::Ident; use syn::{parse_macro_input, DeriveInput}; use proc_macro::TokenStream; use darling::{FromVariant,FromDeriveInput}; #[proc_macro_derive(ServiceError,attributes(error))] pub fn detail_error_fn(input: TokenStream)->TokenStream{ let p...
true
1f948a5aa3fd27b2231d4cf68fe560373bca307e
Rust
matt-thomson/advent-of-code
/2019/src/day19/mod.rs
UTF-8
995
2.90625
3
[ "MIT" ]
permissive
mod beam; mod scan; mod square; use std::path::PathBuf; use structopt::StructOpt; use crate::problem::Problem; use beam::Beam; use scan::Scan; use square::Square; pub type Position = (usize, usize); #[derive(Debug, StructOpt)] pub struct Day19 { #[structopt(parse(from_os_str))] input: PathBuf, } impl Pro...
true
cbd7edf0eb16592e55bcbc66a14571740bfa4fe2
Rust
anxolerd/rust-gamedev-tutorial
/src/main.rs
UTF-8
2,426
3.03125
3
[]
no_license
use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::{Point, Rect}; use sdl2::render::{Texture, WindowCanvas}; use std::time::Duration; // "self" imports the "image" module itself as well as everything else we listed use sdl2::image::{self, InitFlag, LoadTexture}; #[derive(Debu...
true
1aadb9298adadf5df757bb8ef176e4874a7330c7
Rust
a-mackay/raystack
/src/grid.rs
UTF-8
36,422
3.328125
3
[ "MIT" ]
permissive
use raystack_core::Ref; use raystack_core::{is_tag_name, TagName}; use serde_json::json; use serde_json::map::Map; use serde_json::Value; use serde_json::{to_string, to_string_pretty}; use std::cmp::Ordering; use std::collections::HashSet; use std::convert::TryInto; use std::iter::FromIterator; use thiserror::Error; /...
true
fdef4e419b675231f81d9195691ca0ad6e03dd13
Rust
redzic/alacritty-conf
/src/theme.rs
UTF-8
18,593
3.03125
3
[]
no_license
use rgb::RGB8; use std::fmt; use std::num::ParseIntError; use std::str::FromStr; #[derive(Debug, Default, Copy, Clone)] pub struct ThemeColors { pub black: RGB8, pub red: RGB8, pub green: RGB8, pub yellow: RGB8, pub blue: RGB8, pub magenta: RGB8, pub cyan: RGB8, pub white: RGB8, } impl...
true
bd804cb1051f446eb3ceeaa53db6999dd07aeb48
Rust
listless/Project-Euler-in-Rust
/src/Problem 002.rs
UTF-8
261
3.125
3
[]
no_license
fn main() { let mut first = 1; let mut second = 2; let mut sum = 2; for i in range(3, 4000000) { if (i == (first + second)) { if(i % 2 == 0) { sum += i; } first = second; second = i; println!("{:d}", i); } } println!("{:d}", sum); }
true
37520da9fd701d23cc0594ec70de0db16b11411f
Rust
blofroth/corrosive-fog
/src/dbmodel.rs
UTF-8
1,658
2.5625
3
[ "MIT" ]
permissive
use model; use super::schema::notes; #[derive(Debug,Clone,Queryable,Insertable)] #[table_name="notes"] pub struct Note { pub guid: String, pub title: String, pub note_content: String, pub note_content_version: f64, pub last_change_date: String, pub last_metadata_change_date: String, pub cr...
true
d859aad9cc171bfd5a0526cfdf79949e8d38c9b7
Rust
mass10/rust.note
/code/filesystem/diagnose-file-types/src/core.rs
UTF-8
2,824
3.15625
3
[]
no_license
use crate::io; use crate::configuration::Configuration; /// 拡張子診断クラス /// /// lifetime 'a の明示によって、`Calculator` と `Configuration` の生存期間をコンパイル時に保証しています。 #[allow(unused)] pub struct Application<'a> { /// コンフィギュレーションへの参照 conf: &'a Configuration, /// 拡張子と件数を管理します。 map: std::collections::BTreeMap<String, u32>, } impl<'...
true
fd58fcc9bb591bf0c09d308bd44399d59e9ff023
Rust
helcaraxeals/reesolve
/src/data.rs
UTF-8
7,517
2.890625
3
[ "Unlicense" ]
permissive
use crate::OutputFormat; use crate::Result; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::collections::VecDeque; use std::net::IpAddr; use std::sync::Arc; use tokio::sync::Mutex; use trust_dns_proto::error::ProtoErrorKind; use trust_dns_proto::rr; use trust_dns_resolver::error::{ResolveEr...
true
e2fda642725484b6ed5aec2ccdc1a4d1d7544b54
Rust
samcday/exercism
/rust/bob/src/lib.rs
UTF-8
618
3.109375
3
[]
no_license
#![deny(clippy::all, clippy::pedantic)] pub fn reply(message: &str) -> &str { let message = message.trim(); if message.is_empty() { return "Fine. Be that way!"; } let mut chars = message.chars().rev(); let last_char = chars.next().unwrap(); let mut chars = chars.filter(|c| c.is_alpha...
true
48d4136fb3c0a001a84bab5c56800425fb1ecef3
Rust
ratschance/rs-ray-tracer
/src/camera.rs
UTF-8
2,407
3.5
4
[]
no_license
//! A camera that "views" the scene. extern crate rand; use geometry::{Ray, Vec3}; use std::f64; /// The camera struct. /// /// # Fields /// * `origin` - The origin of the scene. /// * `lower_left_corner` - The bottom left corner of the scene. /// * `horizontal` - The maximum x coordinate of the scene. /// * `vertica...
true
71a187d1779bf56e7a070ab5de970f00046355ae
Rust
HenryWConklin/advent-of-code-2020
/src/bin/d21.rs
UTF-8
3,061
2.984375
3
[]
no_license
use itertools::Itertools; use std::collections::{HashMap, HashSet}; use std::io::{stdin, BufRead}; struct IngredientList { ingredients: HashSet<String>, allergens: HashSet<String>, } fn main() { let foods: Vec<_> = stdin() .lock() .lines() .map(|l| l.unwrap()) .map(|l| { ...
true
af7ec91393e0f30fedde1284e5a4e8d365423279
Rust
problame/rust-srs
/src/srs/util.rs
UTF-8
3,479
3.5625
4
[]
no_license
#[derive(Debug)] pub enum Base64Err { PaddingErr(usize), // Pad to multiple of n bytes DecodingErr, } pub fn base64_email_safe_encode(b: &[u8]) -> Result<String, Base64Err> { let base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".as_bytes(); let blen = b.len(); if blen =...
true
5b943e70742494a508c2c4a58b16e1a04b4b0552
Rust
steveorsomethin/azure-kinect-rs
/azure-kinect/src/capture.rs
UTF-8
2,613
2.6875
3
[ "MIT" ]
permissive
use super::*; use std::ptr; pub struct Capture<'a> { factory: &'a Factory, pub(crate) handle: k4a_capture_t, } impl Capture<'_> { pub fn new(factory: &Factory) -> Result<Capture, Error> { let mut handle: k4a_capture_t = ptr::null_mut(); Error::from((factory.k4a_capture_create)(&mut handle)...
true
1889e233c175d6046ba16b7054872e36216c8cd4
Rust
isgasho/druid-rustdoc-frontend
/src/lens.rs
UTF-8
793
2.609375
3
[ "Apache-2.0" ]
permissive
use druid::Data; use druid::Lens; use rustdoc_types::{Item, ItemSummary}; use crate::AppData; pub struct IdLens; impl Lens<AppData, (Item, Option<ItemSummary>)> for IdLens { fn with<V, F: FnOnce(&(Item, Option<ItemSummary>)) -> V>(&self, data: &AppData, f: F) -> V { let value = data.krate.index.get(&data....
true
9ac8e364c3874751c0aefefd3f41c7c6c0cabdcc
Rust
Cheshulko/Algorithms
/exercism.io/rust/all-your-base/src/lib.rs
UTF-8
1,752
3.75
4
[]
no_license
#[derive(Debug, PartialEq, Eq)] pub enum Error { InvalidInputBase, InvalidOutputBase, InvalidDigit(u32), } /// /// Convert a number between two bases. /// /// A number is any slice of digits. /// A digit is any unsigned integer (e.g. u8, u16, u32, u64, or usize). /// Bases are specified as unsigned integer...
true
782bbcf2eaa785f4df5fa22b8779ce47de6af4b3
Rust
pbzweihander/daummap-rs
/src/keyword.rs
UTF-8
5,054
2.671875
3
[ "Apache-2.0", "MIT" ]
permissive
use { crate::{request, CategoryGroup, Meta, Sort, KAKAO_LOCAL_API_BASE_URL}, serde::Deserialize, }; #[derive(Debug, Clone)] pub struct Place { pub id: Option<usize>, pub name: String, pub category: String, pub category_group: Option<CategoryGroup>, pub phone: String, pub address: String...
true
a0952c5c95f9a03ae2351a4e061f04e87c12d48b
Rust
utilForever/BOJ
/Rust/1701 - Cubeditor.rs
UTF-8
671
2.734375
3
[ "MIT" ]
permissive
use std::{cmp, io}; fn main() { let mut p = String::new(); io::stdin().read_line(&mut p).unwrap(); let p_chars = p.as_bytes(); let p_len = p_chars.len(); let mut ret = 0; let mut fail = vec![0; 5000]; for i in 0..p_len { let mut cmp = 0; fail.fill(0); for j in i ...
true
b8083d4f3c312493dda152e0c119b6a49febf8f2
Rust
aicacia/rs-code_runner
/src/build_output.rs
UTF-8
1,846
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::convert::TryInto; use std::fs::{create_dir_all, File}; use std::io::Write; use std::path::PathBuf; use tempfile::{tempdir, TempDir}; use super::{create_executable, BuildInput, Error, Lang}; #[derive(Debug)] pub struct BuildOutput { pub lang: Lang, pub root_dir: TempDir, pub inputs: Vec<PathBuf>,...
true
b85fee8cea4289a43a1fabc3d2749ccabafd2520
Rust
ncitron/OxidizeVM
/src/frame.rs
UTF-8
482
3.046875
3
[]
no_license
use std::collections::HashMap; use crate::stackobj::StackObj; pub struct Frame<'a> { pub vars: HashMap<&'a str, StackObj>, pub return_address: i32 } impl<'a> Frame<'a> { pub fn get_var(&self, key: &str) -> StackObj { match self.vars.get(&key) { Some(&ans) => ans, ...
true
7508d8964280b614d1a46f4038b8735f7edf484f
Rust
gwenn/lemon-rs
/src/parser/mod.rs
UTF-8
4,240
2.96875
3
[ "Unlicense" ]
permissive
//! SQLite parser use log::error; pub mod ast; pub mod parse { #![allow(unused_braces)] #![allow(unused_comparisons)] // FIXME #![allow(clippy::collapsible_if)] #![allow(clippy::if_same_then_else)] #![allow(clippy::absurd_extreme_comparisons)] // FIXME #![allow(clippy::needless_return)] #![...
true
358c6419114bfd319606fb1c73a046805e293db9
Rust
marco-c/gecko-dev-wordified
/third_party/rust/uuid/src/builder.rs
UTF-8
23,682
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/ / Copyright 2013 - 2014 The Rust Project Developers . / / Copyright 2018 The Uuid Project Developers . / / / / See the COPYRIGHT file at the top - level directory of this distribution . / / / / Licensed under the Apache License Version 2 . 0 < LICENSE - APACHE or / / http : / / www . apache . org / licenses / LICENSE...
true
97941f224ccec9f497b970eb9d3cae249d4522a7
Rust
zwhitchcox/leetcode_rs
/src/_1180_count_substring_with_only_one_distinct_letter.rs
UTF-8
827
3.671875
4
[ "MIT" ]
permissive
struct Solution; impl Solution { fn count_letters(s: String) -> i32 { let mut prev: Option<char> = None; let mut count = 0; let mut sum = 0; for c in s.chars() { if let Some(prev_c) = prev { if c == prev_c { count += 1; ...
true
7a7a68fcb668aa70d943f73e664ccd4c70a11d60
Rust
pit-rpg/Viz
/src/core/face3.rs
UTF-8
2,355
2.953125
3
[]
no_license
use math::vector3::*; use std::cmp::{ Eq, Ord, Ordering}; use std::ops::{Div,AddAssign,SubAssign,MulAssign, Mul, Add, DivAssign, Sub, Neg}; // use std::ops::{Div}; // use self::num_traits::Float; use helpers::Nums; #[derive(Clone, Debug)] pub struct Face3<T> where T:Nums<T>+MulAssign+AddAssign+SubAssign+Mul<Output=T>...
true
8a689c703d5461c45a9cc0c80d8461ce8656ae22
Rust
iceiix/fs-web
/src/nop_fs.rs
UTF-8
4,677
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
#![allow(unused_variables, dead_code)] // no-operation filesystem implementation // based on https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/fs.rs use std::ffi::OsString; use std::path::{Path, PathBuf}; use std::io::{self, SeekFrom}; #[derive(Copy, Clone, Debug)] pub struct File {} impl File {...
true
0abfcd861dbf7d48bb0d190c4e9321ab8959b885
Rust
SallySoul/prisma
/src/ehsi.rs
UTF-8
16,743
2.578125
3
[ "MIT" ]
permissive
//! The eHSI device-dependent polar color model use crate::channel::{ AngularChannel, AngularChannelScalar, ChannelCast, ChannelFormatCast, ColorChannel, PosNormalBoundedChannel, PosNormalChannelScalar, }; use crate::color; use crate::color::{Bounded, Color, FromTuple, Invert, Lerp, PolarColor}; use crate::con...
true
9f34e0de5197d2cc061d1d4597efbd90a3643a30
Rust
coriolinus/exercism-rs
/ocr-numbers/src/numbers.rs
UTF-8
1,158
2.734375
3
[]
no_license
pub const CHAR_W: usize = 3; pub const CHAR_H: usize = 4; pub const ZERO: &'static str = " _ \n| |\n|_|\n "; pub const ONE: &'static str = " \n |\n |\n "; pub const TWO: &'static str = " _ \n _|\n|_ \n "; pub const THREE: &'static str = " _ \n _|\n _|\n "; pub const FOUR: &'static str = " \n|_|\n |\n ...
true
a6b359b991fda4a68ab49a5f5c163eadb43dc04e
Rust
adarshpannu/lists
/src/second.rs
UTF-8
2,549
3.4375
3
[]
no_license
#![allow(unused_variables)] #![allow(unused_assignments)] #![allow(unused_mut)] #![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_labels)] pub struct List<T> { head: Link<T>, } type Link<T> = Option<Box<Node<T>>>; struct Node<T> { elem: T, next: Link<T>, } struct ListIntoIter<T> { list:...
true
e30cd70090c7918e8f554beaecee664359ae7584
Rust
veeg/interest-calculator-rs
/src/bin/cli.rs
UTF-8
3,798
3.328125
3
[]
no_license
//! A command line utility to calculate a loans lifespan and the costs associated with that. use interest_calculator::*; use chrono::{Datelike, Month, NaiveDate}; use num_traits::FromPrimitive; use structopt::StructOpt; #[derive(Debug, StructOpt)] #[structopt(name = "interest-calculator")] struct Opt { /// Total...
true
a0a0fbd6630b767f9deb98265c1c8e2df6a8df49
Rust
udoprog/ptscan
/crates/ptscan/src/address.rs
UTF-8
9,016
3.390625
3
[ "MIT", "Apache-2.0", "CC-BY-SA-3.0" ]
permissive
//! Abstraction to help deal with virtual addresses. use crate::{error::Error, FollowablePointer, Offset, ProcessHandle, Sign, Size}; use std::{ convert::{self, TryFrom, TryInto}, fmt, num, str, }; #[derive(Debug, thiserror::Error)] #[error("failed to parse address")] pub struct ParseError; #[derive(Clone, ...
true
7101a8375df877d9db5dfe2645f990e2b572df8f
Rust
Yatekii/flash-rs
/src/flash_algorithm.rs
UTF-8
1,060
2.984375
3
[]
no_license
#[derive(PartialEq, Eq, Hash)] pub struct FlashAlgorithm {} pub enum FlashAlgorithmInstruction { PCInit, PCUninit, PCProgramPage, PCEraseSector, PCEraseAll, } pub enum FlashAlgorithmLocation { LoadAddress, StaticBase, BeginStack, BeginData, PageSize, } impl FlashAlgorithm { ...
true
d2cde3dff5a06158b70bc4989bb9781c2dd9c019
Rust
Ameobea/minutiae
/minutiae/src/entity.rs
UTF-8
2,896
3
3
[]
no_license
//! These units reside in the a grid separate from the main universe but have the power to directly interact both with it and //! with other entities. They are the smallest units of discrete control in the simulation and are the only things that are //! capable of mutating any aspect of the world outside of the simula...
true
5b873cf1c8a6b5be79c4f23f146877aca5fbceeb
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/past202004-open/src/bin/j.rs
UTF-8
794
2.875
3
[]
no_license
use proconio::input; use proconio::marker::Chars; fn main() { input! { s: Chars, }; let mut stack = vec![vec![]]; for &s_i in s.iter() { match s_i { '(' => { stack.push(vec![]); } ')' => { let mut a = stack.pop().unwrap...
true
6ceda345af9348a135744af9db27606e024644f3
Rust
jtdubs/rust-light
/src/shapes/sphere.rs
UTF-8
5,777
2.875
3
[]
no_license
use log::*; use std::default::Default; use std::f32::consts::PI; use crate::geometry::{Transform, Trans, TransMut, HasTransform, BoundingBox, Ray, Point, Vector}; use crate::math::quadratic; use crate::shapes::{Shape, ShapeIntersection, SurfaceContext}; #[derive(Copy, Clone, Debug)] pub struct Sphere { transform ...
true
7294b0b7eea24b60b2407ce368b2c4850c7354b0
Rust
FrozenDroid/nrf91-rs
/src/twim0_ns/shorts.rs
UTF-8
21,360
2.6875
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::SHORTS { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mu...
true
31ee9f12e710292552ee29790f9d9400dc9c8e5f
Rust
Lythenas/adventofcode
/src/day3.rs
UTF-8
1,074
3.265625
3
[]
no_license
use crate::utils::read_lines; pub fn day3() { let lines: Vec<_> = read_lines("day3.input") .map(|line| line.as_bytes().to_vec()) .collect(); println!("Part 1: {}", part1(&lines)); println!("Part 2: {}", part2(&lines)); } fn part1(lines: &[Vec<u8>]) -> usize { let slope_x = 3; let s...
true
4e1f2312eca152415c1bfeebe8fb6f58c6b79adb
Rust
AlexanderWillner/gtp
/src/info.rs
UTF-8
4,580
3.015625
3
[]
no_license
use byteorder::{ByteOrder, LittleEndian}; use parser::{Parser, ParseError, ParseResult}; pub enum InfoElement<'a> { // 14, TS29281, 8.2 // The Restart Counter value is unused and shall be zeroed/ignored. Recovery(RestartCounter), // 16, TS29281, 8.3 // UNCLEAR: I have no idea what this is used for...
true
1e484e55b3f5e2470ddec1565bfb19489a16c99c
Rust
kaj/rsass
/spectest/src/testfixture.rs
UTF-8
4,756
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
use super::options::Options; use super::writestr::WriteStr; use super::{fn_name, ignore, Error, TestRunner}; use lazy_regex::regex_replace_all; use std::io::Write; pub struct TestFixture { name: Option<String>, input: String, expectation: TestExpectation, options: Options, } enum TestExpectation { ...
true
7ba976940404f2985e4f44798c6ac3a3761b88d8
Rust
rayon-rs/rayon
/src/iter/interleave_shortest.rs
UTF-8
2,298
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::plumbing::*; use super::*; /// `InterleaveShortest` is an iterator that works similarly to /// `Interleave`, but this version stops returning elements once one /// of the iterators run out. /// /// This struct is created by the [`interleave_shortest()`] method on /// [`IndexedParallelIterator`]. /// /// [`i...
true
ce646ff73193df587c2ea99e34c7fbade4f39563
Rust
realjohnward/timecapsule
/secret_contracts/timecapsule/src/lib.rs
UTF-8
4,075
2.5625
3
[]
no_license
#![no_std] // Imports extern crate eng_wasm; extern crate eng_wasm_derive; extern crate serde; use eng_wasm::*; use eng_wasm_derive::pub_interface; use eng_wasm_derive::eth_contract; use histogram::Histogram; use serde::{Serialize, Deserialize}; // Timecapsule contract abi #[eth_contract("Timecapsule.json")] struct ...
true
83444aa3886fae1bc4ddcbf4d92295b7953f605b
Rust
LaurentMazare/tch-rs
/src/nn/linear.rs
UTF-8
2,173
3.0625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A linear fully-connected layer. use crate::Tensor; use std::borrow::Borrow; /// Configuration for a linear layer. #[derive(Debug, Clone, Copy)] pub struct LinearConfig { pub ws_init: super::Init, pub bs_init: Option<super::Init>, pub bias: bool, } impl Default for LinearConfig { fn default() -> Se...
true
9c0b1dfd0dcff0f10578b4fc68bedecc94675801
Rust
karjonas/advent-of-code
/2021/day21/src/lib.rs
UTF-8
3,107
3.34375
3
[]
no_license
extern crate common; #[macro_use] extern crate scan_fmt; use std::collections::HashMap; fn modulo(mut value: usize, min: usize, max: usize) -> usize { if value >= max { let range = max - min; let q = 1 + (value - max) / range; value -= q * range; } return value; } fn parse_input(i...
true
6670e45bc54dba3619da1c020c4beae6ecad2043
Rust
cameronfyfe/go-go-life
/src/lib.rs
UTF-8
1,730
2.640625
3
[]
no_license
use std::rc::Rc; use std::cell::RefCell; use wasm_bindgen::prelude::*; use web_sys::console; mod cell; mod canvas; mod universe; #[wasm_bindgen] extern "C" { fn setInterval(closure: &Closure<dyn FnMut()>, millis: u32) -> f64; fn cancelInterval(token: f64); #[wasm_bindgen(js_namespace = console)] fn l...
true
d0fbde4df944a80810cc0ab8763763e4ddb1848b
Rust
lannonbr/marc_cli
/src/query.rs
UTF-8
1,259
2.6875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate marc; use marc::*; use std::collections::HashMap; pub fn query_field(field_tag: String, variable_name: String, records_storage: &mut HashMap<String, Vec<marc::Record<'static>>>) { match records_storage.get(variable_name.as_str()) { Some(record_vec) => { for record in record_vec.i...
true
bbb9adca12314512d22bdccd4bfdbc96ccc29fd8
Rust
gyn/exercism
/rust/minesweeper/src/lib.rs
UTF-8
1,632
3.125
3
[ "BSD-2-Clause" ]
permissive
#[inline] fn neighbors(x: usize, y: usize, width: usize, height: usize) -> Vec<(usize, usize)> { let mut result = Vec::new(); if x != 0 && y != 0 { result.push((x - 1, y - 1)); } if x != width - 1 && y != height - 1 { result.push((x + 1, y + 1)); } if x != 0 && y != height - 1...
true
f7bcd7246757d0085847cd002f0d51adda896dab
Rust
sugyan/atcoder
/aising2020/src/bin/c.rs
UTF-8
451
2.703125
3
[]
no_license
use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, } let mut answers = vec![0; n]; for x in 1..100 { for y in 1..100 { for z in 1..100 { let i = x * x + y * y + z * z + x * y + y * z + z * x; if i <= n { ...
true
56c5a74adbf9f0b351648216b3bc63c9b8b9bb21
Rust
tuckersn/Simple_Rust_HTTP
/src/http/server.rs
UTF-8
2,954
2.765625
3
[ "MIT" ]
permissive
use async_std::{stream::{StreamExt}, task}; use async_std::net::{TcpListener, TcpStream}; use futures::Future; use std::result::Result; use std::{io::ErrorKind, io::{Error}, net::Shutdown, sync::Arc}; use crate::http::request::Request; use crate::http::response::Response; use crate::http::routes::Router; async fn e...
true
0115fc11c5f64162bcade3c5a233486d146a2ad3
Rust
pwildani/bkchainsaw
/src/keyquery.rs
UTF-8
706
2.65625
3
[]
no_license
use crate::metric::Metric; use crate::Dist; pub trait KeyQuery: Default { type Key: Clone; type Query: ?Sized; fn distance<M: Metric<Self::Query>>( &self, metric: &M, key: &Self::Key, query: &Self::Query, ) -> Dist; fn distance_static<M: Metric<Self::Query>>( ...
true
a9c8753672ceff26d3d93cd7b3e84aef01dcbbaf
Rust
IThawk/rust-project
/rust-master/src/test/ui/or-patterns/feature-gate-or_patterns.rs
UTF-8
1,776
3.09375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn main() {} pub fn example(x: Option<usize>) { match x { Some(0 | 1 | 2) => {} //~^ ERROR: or-patterns syntax is experimental _ => {} } } // Test the `pat` macro fragment parser: macro_rules! accept_pat { ($p:pat) => {} } accept_pat!((p | q)); //~ ERROR or-patterns syntax is expe...
true
0d0c140d60788dfba7e43b75e3a7e2421960288c
Rust
zoosky/oauth-lite
/src/oauth/request.rs
UTF-8
2,646
2.515625
3
[ "MIT" ]
permissive
use { super::*, oxide_auth::frontends::dev::*, parking_lot::Mutex, std::{collections::HashMap, sync::Arc}, url::form_urlencoded, warp::http::HeaderMap, }; #[derive(Debug, Clone)] pub struct AuthRequest(pub Arc<InnerAuthRequest>); #[derive(Debug)] pub struct InnerAuthRequest { pub query: Ha...
true
34b8dd0eba7cc7f36282821440e23fcd9b7260d3
Rust
vbarua/databass
/src/lexer.rs
UTF-8
4,287
3.96875
4
[]
no_license
use itertools::Itertools; use std::iter::Peekable; use std::str::Chars; // Note // Iterator::take_while consumes the character for which the predicate returns false. // This screws up lexing in some places where we still want to look at that character. // Itertools::peeking_take_while avoids this issue. #[derive(Debu...
true
579458a13f865ab5a4a2345e373700865f087154
Rust
TartanLlama/advent-of-code-2020
/src/day6.rs
UTF-8
1,715
3.015625
3
[]
no_license
use alga::general::*; #[derive(Clone, Copy)] struct BitAnd; impl Operator for BitAnd { fn operator_token() -> Self { BitAnd } } #[derive(Clone, Copy)] struct BitOr; impl Operator for BitOr { fn operator_token() -> Self { BitOr } } impl Identity<BitAnd> for u32 { fn identity() -> u3...
true