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
7b2747c902afd2a24240dd5b18685cf43e74bb4c
Rust
Ekleog/loom
/src/rt/thread.rs
UTF-8
8,599
3.125
3
[ "MIT" ]
permissive
use crate::rt::execution; use crate::rt::object::Operation; use crate::rt::vv::VersionVec; use std::{fmt, ops}; #[derive(Debug)] pub struct Thread { pub id: Id, /// If the thread is runnable, blocked, or terminated. pub state: State, /// True if the thread is in a critical section pub critical: ...
true
72c14608992ac7aee0e32a87688697fc8b448787
Rust
wasmerio/wasmer-rust-customabi-example
/src/abi.rs
UTF-8
813
2.671875
3
[]
no_license
use wasmer_runtime::{Array, Ctx, WasmPtr}; use crate::env::CustomAbiEnv; // Let's define our "print" function. pub fn print(ctx: &mut Ctx, ptr: WasmPtr<u8, Array>, len: u32) { let (memory, env) = CustomAbiEnv::get_memory_and_environment(ctx, 0); // Use helper method on `WasmPtr` to read a utf8 string let ...
true
fda3ece079289db15e026761756fa94888036b46
Rust
robidev/rproc
/src/main.rs
UTF-8
2,650
2.625
3
[ "MIT" ]
permissive
//#![allow(unused_imports)] //#![allow(dead_code)] extern crate minifb; extern crate byteorder; extern crate num; extern crate ncurses; extern crate time; extern crate enum_primitive; #[macro_use] mod utils; mod virpc; mod debugger; mod editor; use virpc::cpu; use minifb::*; use std::env; use ncurses::*; use editor...
true
ee4f0010312552721a6446dd25de71a3e6974d7a
Rust
hinagis/typical90
/src/bin/018.rs
UTF-8
474
2.6875
3
[]
no_license
use std::f64::consts::PI; fn main() { proconio::input! { t: u32, l: f64, tx: f64, ty: f64, q: usize, e: [u32; q] } for &e in &e { let d = 2f64 * PI * ((e % t) as f64 / t as f64); let y = l * (d + PI / 2f64).cos() / 2f64; let z = l * ((d - PI / 2f64).s...
true
2bb8923f34f4fe7a97ecd230ec2a5b885f893239
Rust
mozilla/gecko-dev
/third_party/rust/wast/src/wat.rs
UTF-8
2,056
3.140625
3
[ "LLVM-exception", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::component::Component; use crate::core::{Module, ModuleField, ModuleKind}; use crate::kw; use crate::parser::{Parse, Parser, Result}; use crate::token::Span; /// A `*.wat` file parser, or a parser for one parenthesized module. /// /// This is the top-level type which you'll frequently parse when working with...
true
591c8ae26e277556a61c3bd5b0ce3771e74b6250
Rust
wwylele/citrii
/citrii/src/text_renderer.rs
UTF-8
2,350
3.09375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::rect_renderer; use crate::texture; pub struct TextRenderer { rect_renderer: std::rc::Rc<rect_renderer::RectRenderer>, font: texture::Texture, font_width: usize, font_height: usize, } impl TextRenderer { pub fn new(rect_renderer: std::rc::Rc<rect_renderer::RectRenderer>) -> TextRenderer ...
true
55a46f0ab3732b03599b2810371336a55865bbba
Rust
plus7wist/Rust
/src/sorting/bubble_sort.rs
UTF-8
631
3.234375
3
[]
no_license
pub fn bubble_sort<T: Ord>(arr: &mut [T]) { for i in 0..arr.len() { for j in 0..arr.len() - 1 - i { if arr[j] > arr[j + 1] { arr.swap(j, j + 1); } } } } #[cfg(test)] mod tests { use super::super::tests::is_sorted; use super::*; #[test] fn...
true
69920bdb5aae24cb68d3961deb08da668992c565
Rust
bytecodealliance/wasmtime
/crates/fuzzing/src/generators/stacks.rs
UTF-8
13,686
2.953125
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Generate a Wasm program that keeps track of its current stack frames. //! //! We can then compare the stack trace we observe in Wasmtime to what the Wasm //! program believes its stack should be. Any discrepencies between the two //! points to a bug in either this test case generator or Wasmtime's stack //! walker....
true
cf476e1cbbf799a8f9e3252f7df5d02afd1a80a7
Rust
Rahix/avr-hal
/examples/arduino-leonardo/src/bin/leonardo-blink.rs
UTF-8
711
2.609375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![no_std] #![no_main] use panic_halt as _; #[arduino_hal::entry] fn main() -> ! { let dp = arduino_hal::Peripherals::take().unwrap(); let pins = arduino_hal::pins!(dp); let mut leds = [ pins.led_rx.into_output().downgrade(), pins.led_tx.into_output().downgrade(), pins.d13.into_ou...
true
5a109c5b89c2432718b5a5b9ffd926714bc7611e
Rust
jstarry/solana
/ledger/src/erasure.rs
UTF-8
6,286
3.15625
3
[ "Apache-2.0" ]
permissive
//! # Erasure Coding and Recovery //! //! Shreds are logically grouped into erasure sets or blocks. Each set contains 16 sequential data //! shreds and 4 sequential coding shreds. //! //! Coding shreds in each set starting from `start_idx`: //! For each erasure set: //! generate `NUM_CODING` coding_shreds. //! ...
true
5e6d410877c8fa7a1d7b564ad9e04e6a4dc9ac1f
Rust
plol/adventofcode2020
/src/advent_10.rs
UTF-8
1,151
2.9375
3
[ "MIT" ]
permissive
pub struct Advent; impl super::common::Advent for Advent { fn advent_number() -> u8 { 10 } fn main1(input: &String) -> String { let mut data = input .lines() .map(|line| line.parse().unwrap()) .collect::<Vec<i32>>(); data.push(0); data.so...
true
e1dc7844e9a19dca00698e1f34b626c001f98187
Rust
hisland/my-learn
/rust-programming-1/10-generic-trait-lifetime/05-trait-sign.rs
UTF-8
345
2.625
3
[]
no_license
pub trait Summarizable { fn summary(&self) -> String; } pub struct NewsArticle { pub headline: String, pub location: String, pub author: String, pub content: String, } impl Summarizable for NewsArticle { fn summary(&self) -> String { format!("{}, by {} ({})", self.headline, self.author...
true
2b88c6adcd50fb9a5edce125570e1ab2c6d7a5dc
Rust
chom-parser/ir
/src/ident.rs
UTF-8
2,981
3.515625
4
[]
no_license
use std::{ cmp::Ordering, convert::TryFrom, fmt, hash::{Hash, Hasher}, }; /// Normalized identifier. #[derive(Clone, Eq, Debug)] pub struct Ident { normalized: String, prefered: Option<String>, } impl PartialEq for Ident { fn eq(&self, other: &Ident) -> bool { self.normalized.eq(&other.normalized) } } impl...
true
64c5e43c879ed89c39e1adcbfa4648bbb92aada7
Rust
surpriseyou/rust-exercises
/src/exercises/mod.rs
UTF-8
1,671
2.890625
3
[]
no_license
mod day1; mod day2; mod day3; mod day4; use crate::exercises::day4::guess_number; use day1::*; use day2::*; use day3::*; pub fn exec(day: i32) { match day { 1 => { println!(); let mut arr = [0; 10]; for i in 0..10 { arr[i] = fibonacci(i as i32); ...
true
13e810cf0a45f518c17955c34a4918651474dbcb
Rust
yixxxichen/Rust-pair-programming
/graph/src/main.rs
UTF-8
3,644
3.359375
3
[]
no_license
// find path // Read a graph from graph.dat. And select a start point and an end point, // This program will find the shortest path and print out. If no path is found, // it will print a message. // Each line is a list of word, where the first word names some node // in the graph and the remaining words enumerate it...
true
176c3f57fca8983f525826e74818f25fd85c7497
Rust
Mark-Simulacrum/advent-of-code
/src/bin/y2016/day21.rs
UTF-8
5,367
3.5625
4
[ "MIT" ]
permissive
use std::str; #[derive(Copy, Clone, Debug)] enum Instruction { SwapPositions(usize, usize), SwapLetters(u8, u8), RotateLeft(usize), RotateRight(usize), RotateLetter(u8), Reverse(usize, usize), Move(usize, usize), } fn parse(s: &str) -> Vec<Instruction> { s.trim() .lines() ...
true
92b0f4c79c26562b374cf17bdd9e86009446d016
Rust
fossabot/tic
/src/data/gauges.rs
UTF-8
1,374
3.34375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// `Gauges` is a map of u64 gauges, keyed by metric use fnv::FnvHashMap; use std::hash::Hash; pub struct Gauges<T> { data: FnvHashMap<T, u64>, } impl<T: Hash + Eq> Gauges<T> { pub fn new() -> Gauges<T> { Gauges { data: FnvHashMap::default() } } pub fn init(&mut self, key: T) { self.d...
true
d101340fdab47fe3db79b48c91cd97b803c75e32
Rust
bradyjoestar/merklebtree
/src/iterator.rs
UTF-8
14,546
3.1875
3
[ "Apache-2.0" ]
permissive
use crate::merklebtree::{MerkleBTree, Nodes}; use crate::traits::CalculateHash; use std::fmt::Debug; use serde::{Deserialize, Serialize}; pub enum position { begin, between, end, } pub struct btree_iterator<'a, T> where T: PartialEq + PartialOrd + Ord + Clone + Debug + CalculateHash, { pub mbtree...
true
730ca32946f8fe1fd845c6ade993c3a34f3bf862
Rust
kurtlawrence/kserd
/src/encode/encoder.rs
UTF-8
14,141
3.546875
4
[ "MIT" ]
permissive
use super::*; use serde::{ser, Serialize}; use std::{error, fmt}; type Res = Result<Kserd<'static>, Error>; /// Encoder to pass to [`Serialize::serialize`] to encode a type into a [`Kserd`]. /// /// There is no data associated with the `Encoder`, instead it is used to implement `serde`'s /// `Serializer` trait. It ca...
true
2f443ac6160767105ed64f54c36da753f4ba99a1
Rust
frozberry/pngme
/src/chunk_type.rs
UTF-8
5,139
3.53125
4
[]
no_license
use crate::{Error, Result}; use std::convert::TryFrom; use std::fmt; use std::str::FromStr; #[derive(Debug, Clone, PartialEq, Eq)] pub struct ChunkType { bytes: [u8; 4], } #[allow(dead_code)] impl ChunkType { pub fn bytes(&self) -> [u8; 4] { self.bytes } pub fn is_critical(&self) -> bool { ...
true
f6ce6cd5a65758cf9d507308cc3a3218444b1386
Rust
fdovero/codingame
/solo/easy/rust/brick_in_the_wall.rs
UTF-8
880
2.9375
3
[]
no_license
use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } fn main() { let mut input_line = String::new(); io::stdin().read_line(&mut input_line).unwrap(); let x = parse_input!(input_line, usize); let mut input_line = String::new(); io::stdin().read_lin...
true
ea9daa1521eb925a66a9f4409fa72f7bc98c3cea
Rust
huwb/learningrust
/src/adv_lifetimes.rs
UTF-8
614
3.484375
3
[]
no_license
pub fn run() { let c = Context("hellloooooo"); let result = parse_context(c); println!("{:?}", result); } #[derive(Debug)] struct Context<'s>(&'s str); struct Parser<'a, 's: 'a> { context: &'a Context<'s>, } impl<'a, 's> Parser<'a, 's> { fn parse(&'a self) -> Result<(), &'s str> { Err(&se...
true
c15f62a41f0168ea2001fc7e8c2d26b3af351d4c
Rust
PaulGrandperrin/demo-inheritance-rust-vs-cpp
/src/main.rs
UTF-8
3,611
3.5
4
[]
no_license
#![feature(specialization)] use std::marker::PhantomData; // FlatObject trait FlatObject: Drop { fn get_surface(&self) -> f32; fn get_thickness(&self) -> f32; fn get_volume(&self) -> f32 { println!(" computing volume from FlatObject"); self.get_surface() * self.get_thickness() } ...
true
e971b5be2c39a144b4b80923d7d5742a715c1abd
Rust
whilestevego/artist
/graphics/src/vector.rs
UTF-8
2,757
3.6875
4
[ "MIT" ]
permissive
use std::cmp::Ordering; use std::ops::{Add, Sub}; #[derive(Clone, Copy, Debug, Default, PartialEq, PartialOrd)] pub struct Vector(pub f32, pub f32); impl Vector { /// The scalar porpotion of the vector or its length. /// /// ``` /// extern crate graphics; /// use graphics::*; /// /// asser...
true
89e00b553b22ba606ab6ac7bae3e140efe05e3a6
Rust
kalix-systems/riqtshaw_types
/src/lib.rs
UTF-8
1,836
2.546875
3
[]
no_license
pub use libc::{c_char, c_int, c_ushort}; pub use std::char::decode_utf16; pub use std::ptr::null; pub use std::sync::atomic::{AtomicPtr, Ordering}; pub use std::sync::Arc; use std::convert::TryInto; #[macro_export] macro_rules! qba_slice { ($qba: expr, $qba_len: expr) => { match (to_usize($qba_len), $qba....
true
32d105749083fc3732069f1c8c6f3207e62b5cc2
Rust
eric7237cire/rust-algorithm-problems
/codejam/src/y2017round1B/B_check.rs
UTF-8
5,682
2.515625
3
[]
no_license
///////////////////////////////////////////// Template ///////////////////////////////////////////// use std::io::Write; use std::collections::*; macro_rules! debug { ($($v: expr),*) => { $(let _ = write!(::std::io::stderr(), "{} = {:?} ", stringify!($v), $v);)* let _ = writeln!(::std::io::stderr(), ...
true
3bd1abffdaf66327aa1a2399b94c6734bbccf9af
Rust
tokiwadai/rust_prog_lang
/src/bin/chap15/7_rc_weak_samples.rs
UTF-8
2,355
3.515625
4
[]
no_license
use std::cell::RefCell; use std::rc::{Rc, Weak}; /** pp. 386 */ #[derive(Debug)] struct Node { value: i32, parent: RefCell<Weak<Node>>, children: RefCell<Vec<Rc<Node>>>, } fn main() { /** leaf starts out without a parent, so we create a new, empty Weak<Node> reference instance, pp. 386 */ let...
true
a9c83fc296d9b58c9ff3347c8006a14b2a0305ec
Rust
aloucks/vki
/src/imp/vec.rs
UTF-8
2,384
3.21875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! # Unstable functions from `std::vec::Vec` use std::ptr; use std::slice; /// `Vec::drain_filter` /// #[unstable(feature = "drain_filter", reason = "recently added", issue = "43244")] pub fn drain_filter<T, F>(this: &mut Vec<T>, filter: F) -> DrainFilter<T, F> where F: FnMut(&mut T) -> bool, { let old_len =...
true
4d0dc402ba8e9d8ac7d5a43fd8212b13fc787ef7
Rust
lin121291/DTP
/src/scheduler/dtp_scheduler.rs
UTF-8
3,833
2.703125
3
[ "BSD-2-Clause" ]
permissive
use crate::scheduler::Block; use crate::scheduler::Scheduler; pub struct DtpScheduler { ddl: u64, size: u64, prio: u64, last_block_id: Option<u64>, max_prio: u64 } impl Default for DtpScheduler { fn default() -> Self { DtpScheduler { ddl: 0, size: 0, pr...
true
9b3f07d17207e9b3c4f0588cf4a2b4f429db517a
Rust
7e4/himalaya
/src/domain/msg/msg_entity.rs
UTF-8
26,620
2.5625
3
[]
no_license
use ammonia; use anyhow::{anyhow, Context, Error, Result}; use chrono::{DateTime, FixedOffset}; use html_escape; use imap::types::Flag; use lettre::message::{Attachment, MultiPart, SinglePart}; use log::trace; use regex::Regex; use rfc2047_decoder; use std::{ collections::HashSet, convert::{TryFrom, TryInto}, ...
true
697ef58984a383fc462da3a69f81ae944780d88c
Rust
ebtaleb/bulletml-rs
/src/bulletml.rs
UTF-8
1,473
2.71875
3
[]
no_license
pub enum BarrageType { HorizontalBarrage, VerticalBarrage } pub enum AttributeType { Aim, Absolute, Relative, Sequence } pub enum BulletAttributes { Repeat { times: uint, action : Action }, ChangeSpeed { direction: Speed, term: uint }, ChangeDirection { direction: Direction, term: ...
true
3860da2f88f1430ff9c1d0579a70288a1ab313fc
Rust
niftynif/rust-projects
/btree-new.rs
UTF-8
8,030
3.25
3
[]
no_license
// // btree.rs // Nif Ward // 10/24/13 // // starting implementation of a btree for rust // inspired by github user davidhalperin's gist //What's in a BTree? pub struct BTree<K, V>{ root: Node<K, V>, len: uint, lower_bound: uint, upper_bound: uint } impl<K: Clone + TotalOrd, V: Clone> BTree<K, V>{ ...
true
e1fefb6bb5172e2a33c47fc4f142eebf9e4d01b9
Rust
Leinnan/learn-opengl-rs
/src/_1_getting_started/_2_5_hello_triangle_exercise3.rs
UTF-8
8,610
2.53125
3
[ "Unlicense" ]
permissive
#![allow(non_upper_case_globals)] extern crate glfw; use self::glfw::{Context, Key, Action}; extern crate gl; use self::gl::types::*; use std::sync::mpsc::Receiver; use std::ffi::CString; use std::ptr; use std::str; use std::mem; use std::os::raw::c_void; // settings const SCR_WIDTH: u32 = 800; const SCR_HEIGHT: u32...
true
cfca77df7df445bef7850582e89844210818a5e4
Rust
spacejam/demikernel
/src/rust/catnip/src/protocols/tcp/segment/transcode/header/options/mod.rs
UTF-8
6,143
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. #![allow(dead_code)] #[cfg(test)] mod tests; mod parsers; use crate::prelude::*; use byteorder::{NetworkEndian, WriteBytesExt}; use num_traits::FromPrimitive; use std::{collections::HashMap, convert::TryFrom}; pub const MIN_MSS: usize = 536...
true
803dd3d561fbd0470de84aa4d121cc8fb07795fe
Rust
shenphen/cloud-security-protocols
/src/oblivious_polynomial_evaluation/mod.rs
UTF-8
1,858
2.8125
3
[]
no_license
mod receiver; mod sender; use super::traits::Protocol; use pairing::bls12_381::Fr; use pairing::Field; use rand::Rand; use receiver::Receiver; use sender::Sender; use std::process::exit; pub struct ObliviousPolynomialEvaluation { k: usize, d_p: usize, } impl ObliviousPolynomialEvaluation { ...
true
e7fd84e92605aca4f34969d78b968ee5d9ce830d
Rust
rAzoR8/rustest
/src/strahl/scene.rs
UTF-8
2,147
2.984375
3
[ "Apache-2.0" ]
permissive
use super::primitives::*; use super::material::*; use super::hit::*; use super::ray::*; use super::vec::*; use super::texture::DynamicTextureType; //use std::vec::*; pub struct Scene { objects: std::vec::Vec<Object>, materials: std::vec::Vec<Material>, miss: u32 } impl Scene { pub fn new() -> Scene { ...
true
2ac2c76fa9fd211809af02f790a731154e066ff8
Rust
imor/zeno
/src/geometry.rs
UTF-8
15,001
4.15625
4
[ "Apache-2.0", "MIT" ]
permissive
//! Geometric primitives. use core::borrow::Borrow; use core::ops::{Add, Div, Mul, Sub}; /// Represents an angle in degrees or radians. #[derive(Copy, Clone, PartialEq, Default, Debug)] pub struct Angle(f32); impl Angle { /// Angle of zero degrees. pub const ZERO: Self = Self(0.); /// Creates a new angl...
true
bdef7560034963bd50246773ae78e5a3a744cb27
Rust
asSqr/puzz_sqr
/src/endview/mod.rs
UTF-8
2,598
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, Not}; mod field; mod generator; pub use self::field::*; pub use self::generator::*; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Cand(pub u32); impl Cand { fn singleton(n: i32) -> Cand { Cand(1u32 << n) } fn is_set(&self, n: i32...
true
740dbdcb43b773d527cc95a4de60aec38abdb5e6
Rust
monsieurbadia/qoeur-and-qoeur-lab-and-qompo
/src/qoeurc/src/value/instruction/loop_while.rs
UTF-8
2,896
3.0625
3
[ "MIT" ]
permissive
use crate::analyzer::interpreter::{Interpreter, ValueResult}; use crate::converter::parser::{Parser, ParserResult}; use crate::tokenizer::kind::*; use crate::transformer::transpiler::{TKind, Transpiler}; use crate::value::instruction::block::Block; use crate::value::instruction::expression::Expression; use crate::value...
true
7a87c28c232d1d09000c3bde7c54ae1798c11e52
Rust
marosluuce/rchip8
/src/ops/sprite.rs
UTF-8
746
3.25
3
[]
no_license
use cpu::Cpu; use ops::op::{Matcher, Op}; use std::fmt; pub struct Sprite { register1: usize, register2: usize, nibble: u8, } impl Op for Sprite { fn execute(&self, cpu: Cpu) -> Cpu { cpu } } impl Matcher for Sprite { const MASK: u16 = 0xDFFF; fn new(opcode: u16) -> Sprite { ...
true
b8308574dd0b4397bb7b69ccf166783ae7438f2c
Rust
mo7sen/rustracer
/src/tracer/material/color.rs
UTF-8
1,458
3.6875
4
[]
no_license
#[derive(Clone, Copy)] pub struct Color { pub r: u8, pub g: u8, pub b: u8, pub a: u8, } impl Color { pub fn RGB(r: u8, g: u8, b: u8) -> Self { Self { r, g, b, a: 255 } } pub fn RGBA(r: u8, g: u8, b: u8, a: u8) -> Self { Self { r, g, b, a } } } impl Default for Color { ...
true
8686a6db369b62ace80eaca4ef1e8e7d6aedee3b
Rust
arbel03/os
/filesystem/std/src/syscalls/io.rs
UTF-8
447
2.90625
3
[ "MIT" ]
permissive
pub fn printf(string: &str) -> usize { use syscalls::syscall::syscall2; // SYSCALL(SYS_FOPEN, ptr, size) unsafe { syscall2(0x2, string.as_ptr() as usize, string.len()) } } pub fn getc() -> usize { use syscalls::syscall::syscall0; // SYSCALL(IO_GETC) unsafe { syscall0(0x5) ...
true
1b1d68e5311f567687ba5132cbd3374116936306
Rust
camallo/dkregistry-rs
/src/lib.rs
UTF-8
2,707
2.734375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A pure-Rust asynchronous library for Docker Registry API. //! //! This library provides support for asynchronous interaction with //! container registries conformant to the Docker Registry HTTP API V2. //! //! ## Example //! //! ```rust,no_run //! # extern crate dkregistry; //! # extern crate tokio; //! # #[tokio::...
true
d99567bf4566760f4315486ddb3ebcdccbafee36
Rust
8bitslime/text-rendering-stuff
/src/shader.rs
UTF-8
3,441
2.96875
3
[]
no_license
use gl::types::*; use std::io::{Error, ErrorKind, Read, Result}; use std::fs::File; use std::path::Path; pub enum Stage { Vertex, Fragment } impl Stage { pub(crate) fn opengl_enum(&self) -> GLenum { match self { Self::Vertex => gl::VERTEX_SHADER, Self::Fragment => gl::FRAGME...
true
1cc7012261cc9a4c2ee2c41ba10f06bc45b9dd7c
Rust
qinxiaoguang/rs-lc
/src/solution/j2_071.rs
UTF-8
1,613
3.609375
4
[]
no_license
use rand::prelude::*; struct Solution { pre: Vec<i32>, } // 按权重生成随机数 // 如数组[1,3]其中下标0出现的概率是1/4,下标1出现的概率是3/4 // 构造前缀和并随机生成一个随机数,在前缀和中使用二分查找找到对应位置 // 如上述例子,前缀和是[1,4],随机数如果是0-1,则返回0,而如果是1-4,则返回1 impl Solution { fn new(w: Vec<i32>) -> Self { let mut sum = 0; Self { pre: w ...
true
f0c8765a512df9d5681054ff2b8c19eb26730402
Rust
bjnord/coding_practice
/advent-2020/day-16/src/rule.rs
UTF-8
3,776
3.625
4
[]
no_license
use std::fmt; use std::str::FromStr; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct RuleRange { pub start: u32, pub end: u32, } impl FromStr for RuleRange { type Err = Box<dyn std::error::Error>; fn from_str(range: &str) -...
true
72a485623503d8fdc81a9e50e5eb9aa600f28a22
Rust
flo-l/flip
/src/grammar/error_printing.rs
UTF-8
4,863
3.015625
3
[ "MIT" ]
permissive
use ::lalrpop_util::ParseError; use super::lexer::Token; use super::error::Error; use std::iter; pub fn create_error_message(input: &str, err: &ParseError<usize, Token, Error>) -> String { match err { &ParseError::InvalidToken { location } => invalid_token(input, location), &ParseError::Unrecognize...
true
840dbe3c10d54c7a807ba806e23beff9ca200ab3
Rust
FreeCX/vf-transtion
/src/ffmpeg.rs
UTF-8
4,107
2.875
3
[ "BSD-3-Clause" ]
permissive
use std::io::Write; use std::path::Path; use std::process::{Command, Stdio}; use crate::rgb::ComponentBytes; pub trait TransitionFunc { fn calc(&self, value: f32, im1: &Vec<u8>, im1: &Vec<u8>, size: &Size) -> Vec<u8>; } #[derive(Debug, Default, PartialEq, Eq)] pub struct Size { pub width: usize, pub heig...
true
79fcfa2c4516a10717369288b719391bbf5a7c6c
Rust
alexgenco/exercisms
/rust/difference-of-squares/src/lib.rs
UTF-8
325
3.21875
3
[]
no_license
pub fn square_of_sum(n: i64) -> i64 { let mut sum = 0; for i in 1..n+1 { sum += i; } sum * sum } pub fn sum_of_squares(n: i64) -> i64 { let mut sum = 0; for i in 1..n+1 { sum += i * i; } sum } pub fn difference(n: i64) -> i64 { square_of_sum(n) - sum_of_squares(...
true
f7b2b09d9275af64a9ea27cc56d56a8b42541833
Rust
xiaoqixian/Wonderland
/leetcode/longest_substring.rs
UTF-8
2,205
3.265625
3
[]
no_license
/********************************************** > File Name : longest_substring.rs > Author : lunar > Email : lunar_ubuntu@qq.com > Created Time : Sat 27 Feb 2021 03:07:49 PM CST > Location : Shanghai > Copyright@ https://github.com/xiaoqixian **********************************************/ ...
true
b7dbed62e09218387144128be7888236e7f92bee
Rust
TheAlgorithms/Rust
/src/sorting/shell_sort.rs
UTF-8
1,894
3.875
4
[ "MIT" ]
permissive
pub fn shell_sort<T: Ord + Copy>(values: &mut [T]) { // shell sort works by swiping the value at a given gap and decreasing the gap to 1 fn insertion<T: Ord + Copy>(values: &mut [T], start: usize, gap: usize) { for i in ((start + gap)..values.len()).step_by(gap) { let val_current = values[i]...
true
059b287718d28a8067c70b444631ac7ca64c31d6
Rust
jsorkin22/schreier-graphs
/src/graph-generator/src/main.rs
UTF-8
13,299
3.203125
3
[ "MIT" ]
permissive
use num_complex::Complex32 as Complex; fn main() { let zero = 0.0 * Complex::i(); let tree = BiColorTree { nodes: vec![ (zero, 0, vec![1, 2, 3, 4]), (zero, 0, vec![]), (zero, 0, vec![]), (zero, 0, vec![]), (zero, 0, vec![]), ], };...
true
43aa221c817c6a5c73e504b708160ed739f74ab8
Rust
simmons/tupm
/src/upm/sync.rs
UTF-8
12,221
3.09375
3
[ "MIT", "Apache-2.0" ]
permissive
//! This module supports synchronizing a UPM database with a copy on a remote repository. The //! remote repository should be an HTTP or HTTPS server supporting the "download", "upload", and //! "delete" primitives of the UPM sync protocol. use reqwest::multipart; use std::io::Read; use std::path::{Path, PathBuf}; us...
true
b9ef5beef74eda3242820b8874321bf31c580f5d
Rust
acvcmaster/RS1
/src/memory_region.rs
UTF-8
2,949
2.875
3
[ "MIT" ]
permissive
#[derive(Clone, Copy, Debug)] pub struct MemoryRegion(pub u32, pub u32, pub MemoryRegionType); #[derive(Clone, Copy, Debug)] pub enum MemoryRegionType { RAM, ExpansionRegion, Scratchpad, HardwareRegisters, BIOS, IOPorts, MemlControl, RAMSize, CacheControl } impl MemoryRegion { ...
true
706f47dd0406343fea7cafac7960457ed43a3b0d
Rust
Moxcr/autodio
/src/wav_format.rs
UTF-8
1,962
2.890625
3
[]
no_license
use std::mem::transmute; use std::vec::Vec; use audio::{AudioData,AudioFile}; //Structs struct WavFormat { channels: u8, //1 for mono, 2 for stereo sampleLen: u8, //in bytes sampleRate: u32, } //Implementation impl AudioFile for WavFormat { fn getSamples(&self, audioData: &AudioData) { return (audioData.get...
true
ee1eadcfd4be5b725410f0ad61b03f07d3ad1366
Rust
xaviripo/aoc2020
/src/day12/part2.rs
UTF-8
2,450
3.328125
3
[]
no_license
use crate::lib; use super::{Letter, manhattan_distance, parse_instruction}; #[derive(Debug, Clone, Copy)] struct Ship { position: (isize, isize), /// The waypoint's coordinates are relative to the ship waypoint: (isize, isize), } fn rotate_r(mut ship: Ship, times: usize) -> Ship { for _ in 0..(times ...
true
d3be6604283068d5afd57317e8c9a8bc4f9a9358
Rust
mfkiwl/maia
/src/relocate.rs
UTF-8
1,839
2.6875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::EfiStatus; use super::elf::dynamic::{ Dynamic, ElfRela, DT_NULL, DT_RELA, DT_RELASZ, DT_RELAENT, R_RISCV_RELATIVE, }; #[inline(always)] pub unsafe fn relocate( base_address: *const core::ffi::c_void, elf_dyn: *const core::ffi::c_void, ) -> EfiStatus { let elf_dyn = el...
true
7c6f67900653a009da0607e9babcf26d0cb74fa3
Rust
mesalock-linux/http-sgx
/sgx/http-sgx-test/enclave/src/extensions.rs
UTF-8
519
3.078125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use http::*; pub fn test_extensions() { #[derive(Debug, PartialEq)] struct MyType(i32); let mut extensions = Extensions::new(); extensions.insert(5i32); extensions.insert(MyType(10)); assert_eq!(extensions.get(), Some(&5i32)); assert_eq!(extensions.get_mut(), Some(&mut 5i32)); asser...
true
e901087e9b85c4888261de7df27e57f810093faa
Rust
janus/neighbor
/src/serialization.rs
UTF-8
4,897
2.65625
3
[]
no_license
use bytes::{BufMut, BytesMut}; use neighbor::Neighbor; use time; use std::str; use edcert::ed25519; use base64::{decode, encode}; const BUFFER_CAPACITY_MESSAGE: usize = 400; const HELLO_CONFIRM: &'static str ="hello_confirm"; pub fn decode_key(mstr: &str) -> Vec<u8> { let empty_result: Vec<u8> = Vec::new(); m...
true
ff29cf9ac9081bbc8fc304949884685d1e967fbc
Rust
music-apps/Rustalizer
/src/equalizer/dsp/fft.rs
UTF-8
9,141
3.1875
3
[ "MIT" ]
permissive
use crate::errors::Error; use std::cell::Cell; // receives already extended vector of both real and imaginary values // requires the input data to be a power of two, lest wrong indexing happens! pub fn fft<T>(mut data: Vec<Cell<T>>) -> Vec<Cell<T>> where T: Copy + std::cmp::PartialEq + std::convert...
true
2f9ccec2790496bed765c87a9894992783a89d0c
Rust
chakrit/wright
/src/folder.rs
UTF-8
3,507
2.984375
3
[]
no_license
use crate::result::*; use std::fmt::Display; use std::fs::{canonicalize, metadata, File}; use std::iter::IntoIterator; use std::path::PathBuf; #[derive(Debug)] pub struct Folder { path: PathBuf, } impl Folder { pub fn new(base_path: &str) -> Result<Folder> { let canon_path = canonicalize(&base_path)?;...
true
905e1277eeabb3c7b186cfe272301d2d7168b96f
Rust
elsuizo/embedded-hal
/src/spi/blocking.rs
UTF-8
4,275
3.4375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Blocking SPI API /// Blocking transfer with separate buffers pub trait Transfer<W = u8> { /// Error type type Error: crate::spi::Error; /// Writes and reads simultaneously. `write` is written to the slave on MOSI and /// words received on MISO are stored in `read`. /// /// It is allowed fo...
true
842fe8d4f47ace3c3161db639df890bb375b2e2f
Rust
bheisler/criterion.rs
/src/stats/univariate/kde/kernel.rs
UTF-8
2,251
3.4375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Kernels use crate::stats::float::Float; /// Kernel function pub trait Kernel<A>: Copy + Sync where A: Float, { /// Apply the kernel function to the given x-value. fn evaluate(&self, x: A) -> A; } /// Gaussian kernel #[derive(Clone, Copy)] pub struct Gaussian; impl<A> Kernel<A> for Gaussian where ...
true
071f80ef7bd0cccadd3b40d814b04cb9e9310c1f
Rust
KlasafGeijerstam/Kattis
/rust/rationalarithmetic.rs
UTF-8
626
2.78125
3
[]
no_license
mod fast_input; mod rational; use fast_input::{Str, FastInput}; use std::io::Result; use rational::Rational; fn main() -> Result<()> { type Line<'a> = (i64, i64, Str<'a>, i64, i64); let inp = FastInput::new(); let n = inp.next(); for _ in 0..n { let (n1, d1, op, n2, d2): Line = inp.next_quintu...
true
8a4cb5008437e22ec974ff16ebd791ae0f9e375b
Rust
kaneko-takayuki/Rust_Reversi
/src/reversi/core.rs
UTF-8
9,829
3.46875
3
[]
no_license
/// /// ビットボードを初期化する /// pub fn init_board() -> (u64, u64) { let black: u64 = (1 << 28) | (1 << 35); let white: u64 = (1 << 27) | (1 << 36); (black, white) } /// /// 石数をカウントする /// pub fn count(x: &u64) -> i32 { let mut tmp: u64 = (*x & 0x5555_5555_5555_5555) + ((*x >> 1) & 0x5555_5555_5555_5555); t...
true
d59c7f974244756791c9c46397bbaa65ec036b99
Rust
IThawk/rust-project
/rust-master/src/test/ui/borrowck/borrowck-block-unint.rs
UTF-8
185
2.515625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn force<F>(f: F) where F: FnOnce() { f(); } fn main() { let x: isize; force(|| { //~ ERROR borrow of possibly-uninitialized variable: `x` println!("{}", x); }); }
true
6af75bc52de4b66f4af509f06c64002605fb28d3
Rust
l4l/flow
/flowclib/src/model/process_reference.rs
UTF-8
1,967
2.984375
3
[ "MIT" ]
permissive
use model::name::Name; use model::name::HasName; use model::route::Route; use model::route::HasRoute; use model::process::Process; use loader::loader::Validate; use std::fmt; use url::Url; #[derive(Deserialize, Debug, Clone)] #[serde(deny_unknown_fields)] pub struct ProcessReference { pub alias: Name, pub sour...
true
46770a684e766991ef18e4dadb678e47b693be02
Rust
dylandoamaral/shaped-image
/src/genetic/population.rs
UTF-8
4,174
2.984375
3
[]
no_license
use crate::genetic::specimen::Specimen; use crate::utils::cli::Opts; use crate::utils::error::Error; use crate::utils::io; use crate::utils::reference::Reference; use crate::utils::time::duration_to_human; use chrono; use rand::{self, Rng}; use rayon::prelude::*; pub struct Population { pub generation: u32, pu...
true
c24315f031612989e62956c8d838d938f37e008d
Rust
LightHero/lightspeed
/file_store/src/web/actix_web.rs
UTF-8
7,884
2.828125
3
[ "MIT" ]
permissive
use crate::model::BinaryContent; use actix_files::NamedFile; use actix_web::http::header::DispositionType; use actix_web::{http, HttpRequest, HttpResponse}; use lightspeed_core::error::LightSpeedError; use log::*; pub async fn into_response( content: BinaryContent<'_>, file_name: Option<&str>, set_content_...
true
54b6e2280b031dff6dc334b15ae57f4d53e3e9f2
Rust
rcore-os/zCore
/drivers/src/virtio/gpu.rs
UTF-8
1,854
2.671875
3
[ "MIT" ]
permissive
use lock::Mutex; use virtio_drivers::{VirtIOGpu as InnerDriver, VirtIOHeader}; use crate::prelude::{ColorFormat, DisplayInfo, FrameBuffer}; use crate::scheme::{DisplayScheme, Scheme}; use crate::DeviceResult; pub struct VirtIoGpu<'a> { info: DisplayInfo, inner: Mutex<InnerDriver<'a>>, } const CURSOR_HOT_X: u...
true
8c11e75c5f5805228c54b6d6a82883f81c24603b
Rust
psychon/x11rb
/x11rb-async/src/rust_connection/stream.rs
UTF-8
4,262
2.703125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Implements the `Stream` trait for `RustConnection`. use std::future::Future; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; #[cfg(unix)] use std::os::unix::io::{AsRawFd as AsRaw, RawFd}; #[cfg(windows)] use std::os::windows::io::{AsRawSocket as AsRaw, RawSocket}; use async_io::Async; use future...
true
e03a363cc8444cb667264c5a38267eddf8c31e07
Rust
rust-lang/rust-analyzer
/crates/ide/src/view_crate_graph.rs
UTF-8
2,740
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
use dot::{Id, LabelText}; use ide_db::{ base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt}, FxHashSet, RootDatabase, }; use triomphe::Arc; // Feature: View Crate Graph // // Renders the currently loaded crate graph as an SVG graphic. Requires the `dot` tool, which // is part of graph...
true
646c1e09cc4cfa1e98d83bd4b93ec0550420d33f
Rust
frondeus/microtree
/crates/parser/examples/modes/main.rs
UTF-8
8,281
2.9375
3
[ "MIT" ]
permissive
use microtree::{Ast, Red}; mod generated; use generated::*; use microtree_parser::State; mod str_parser { use microtree_parser::{parsers::*, Builder, Parser, SmolStr, TokenKind}; #[derive(Debug, PartialEq, Clone, Copy)] pub enum Token { DQuote, OpenI, CloseI, Text, } ...
true
37d4f5467d8feb633c07936601dc00f63cc21f6d
Rust
jedhsu/monk
/src/interpret/interpret.rs
UTF-8
2,274
2.75
3
[]
no_license
//! A generic, standalone implementation of Monte Carlo Tree Search. //! //! An oracle can be any function or callable object. //! //! oracle(state) //! //! evaluates a single state from the current player's perspective and returns //! a pair `(P, V)` where: //! // impl<'m, S, Q, R> Handler<&'m Transition<S, usize...
true
480918688ae7516ef9b177f984fb61931a575eb8
Rust
JohnTitor/chalk
/tests/test/coinduction.rs
UTF-8
3,718
2.96875
3
[ "MIT", "Apache-2.0", "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
//! Tests targeting coinduction specifically use super::*; #[test] fn mixed_semantics() { test! { program { #[coinductive] trait Send { } trait Foo { } struct Bar { } impl Send for Bar where Bar: Foo { } impl Foo for Bar where Bar: Send { } ...
true
6d8eb88168436a2973bf67ef8d0772eba0b50dd9
Rust
kornelski/yuv
/src/depth.rs
UTF-8
733
2.90625
3
[ "BSD-2-Clause" ]
permissive
use num_traits::PrimInt; pub trait Bounded { const MIN: Self; const MAX: Self; } impl Bounded for u8 { const MIN: u8 = 0; const MAX: u8 = 255; } impl Bounded for u16 { const MIN: u16 = 0; const MAX: u16 = 65535; } pub trait Depth: 'static { type Pixel: PrimInt + Bounded; const MAX: S...
true
90025b830c5da47ec9413035999abff01b60bea3
Rust
codetojoy/gists
/rust/copy_jul_2020/sandbox/src/main.rs
UTF-8
753
3.3125
3
[ "Apache-2.0" ]
permissive
#[derive(Debug)] struct Player<'a> { name: &'a str, cards: Vec<u32>, } #[derive(Debug)] struct Bid<'a> { offer: u32, bidder_name: &'a str, } fn get_bids(players: Vec<Player>) -> Vec<Bid> { let mut bids = vec![]; for player in players { let bid = Bid{offer: 10, bidder_name: player.name...
true
e747fdc9ee737b93477d6459701765edd650f64b
Rust
TimonPost/anes-rs
/anes/src/parser/types.rs
UTF-8
1,914
3.4375
3
[ "Apache-2.0", "MIT" ]
permissive
use bitflags::bitflags; /// A parsed ANSI escape sequence. /// /// Check the [`Parser`](struct.Parser.html) structure documentation for examples /// how to retrieve these values. #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub enum Sequence { /// A keyboard event sequence. Key(KeyCode, KeyModifiers), ...
true
4d65f54b618d8ea520483efaf0748b4f44132b7a
Rust
rforcen/rust
/pi_decs/src/pi_decimals.rs
UTF-8
5,254
3.421875
3
[]
no_license
pub fn generate_pi_decimals(digits: usize) -> String { let words = digits / 4 + 3; let mut sum = vec![0_i32; words + 2]; let mut term = vec![0_i32; words + 2]; // -- 32*atan(1/10) - let mut denom = 3; sum[1] = 32; for firstword in 2..=words { let mut atan10 = |denom: i32| { ...
true
93c2bdc5c500c0adf0aad96abad020244b833379
Rust
Aiden01/ls
/src/filesystem.rs
UTF-8
2,222
3.296875
3
[]
no_license
use std::ffi::OsString; use std::fmt; use std::fs; use std::fs::DirEntry; use std::io::Result; use std::path::{Path, PathBuf}; use crate::app::Options; #[derive(Debug)] pub enum FileType { File, Directory, } pub enum Size { Kb(u64), Bytes(u64), Mb(u64), Gb(u64), } impl fmt::Display for Size ...
true
db02f87ebd65e8468b6a122dd3b45d4cd6c7bdb5
Rust
1600/xerxism
/rust/raindrops/src/lib.rs
UTF-8
677
3.46875
3
[]
no_license
/* Convert a number to a string, the contents of which depend on the number's factors. - If the number has 3 as a factor, output 'Pling'. - If the number has 5 as a factor, output 'Plang'. - If the number has 7 as a factor, output 'Plong'. - If the number does not have 3, 5, or 7 as a factor, just pass the number's ...
true
731e011a2d90199a5f0cf2ebf40e2e9c1d450c97
Rust
goodcodedev/rui
/comp-lang/src/lang/backup/ast.rs
UTF-8
1,381
2.546875
3
[ "MIT" ]
permissive
#[derive(Debug)] pub struct ActionItem<'a> { pub ident: &'a str, } #[derive(Debug)] pub struct Actions<'a> { pub action_items: Vec<ActionItem<'a>>, } #[derive(Debug)] pub struct Comp<'a> { pub items: Vec<SourceItem<'a>>, } #[derive(Debug)] pub struct Content<'a> { pub content: &'a str, } #[derive(De...
true
fced59635542e1ea6a26de2f664f9dcdc2fc3035
Rust
conradludgate/atuin
/src/local/history.rs
UTF-8
1,255
2.78125
3
[ "MIT" ]
permissive
use std::env; use uuid::Uuid; #[derive(Debug)] pub struct History { pub id: String, pub timestamp: i64, pub duration: i64, pub exit: i64, pub command: String, pub cwd: String, pub session: String, pub hostname: String, } impl History { pub fn new( timestamp: i64, c...
true
d102ce37e3db76dab00d763806a439f18d7a2eee
Rust
gzbakku/quick-fuc
/src/main.rs
UTF-8
2,252
2.59375
3
[]
no_license
extern crate iron; extern crate router; extern crate bodyparser; extern crate persistent; extern crate crypto; extern crate rand; extern crate serde_json; extern crate serde; #[macro_use] extern crate serde_derive; //i have no idea what to do with this // maybe it was used in iron to impliment max body size for inc...
true
cf13f23300a862e9a5e258437ccf53f0fa8858b6
Rust
onlyhavecans/img_trash
/src/bin/blurs.rs
UTF-8
850
2.890625
3
[]
no_license
use img_trash::image::save_and_open_file; use img_trash::image::NewImage; use std::fs; fn main() { let dir = fs::read_dir("img").expect("Unable to read from img"); let files = dir.filter_map(|f| f.ok()); for file in files { let n = match NewImage::parse(file.path()) { Ok(i) => i, ...
true
de12d700e53c23a3ac5ae89e39d543a0dc981202
Rust
IWahner/read-simulator-for-benchmark-datasets
/src/errors.rs
UTF-8
327
2.515625
3
[ "MIT" ]
permissive
use thiserror::Error; #[derive(Error, Debug, PartialEq)] pub enum Error { #[error("file not found")] FileNotFound, #[error("failed solving the problem")] SolvingProblem, #[error("wrong input for solver")] SolverInputProblem, #[error("invalid input for wanted frequency")] InvalidFrequ...
true
8bb1db3b81c7b90c4108c0e6ac0ca6bf1c9b081a
Rust
rust-analyzer/rowan
/src/green/node.rs
UTF-8
9,727
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{ borrow::{Borrow, Cow}, fmt, iter::{self, FusedIterator}, mem::{self, ManuallyDrop}, ops, ptr, slice, }; use countme::Count; use crate::{ arc::{Arc, HeaderSlice, ThinArc}, green::{GreenElement, GreenElementRef, SyntaxKind}, utility_types::static_assert, GreenToken, NodeOr...
true
855cb4a53ea5b8094d5520dd5368e1dd189870bb
Rust
grantlindberg4/wsu-crypt
/src/convert_types.rs
UTF-8
2,858
3.8125
4
[]
no_license
/// # Description /// Takes two unsigned 8-bit integers and concatenates them into an unsigned 16-bit integer /// /// # Arguments /// * `first` - an unsigned 8-bit integer /// * `second` - an unsigned 8-bit integer /// /// # Example /// let first = 0xab; /// let second = 0xcd; /// let together = convert_types...
true
4170210c01c767bb7e10aee364ad6cb108ba7b44
Rust
hilbert-space/recommender
/src/dataset/mod.rs
UTF-8
1,156
3.21875
3
[ "Apache-2.0", "MIT" ]
permissive
//! Datasets. use Result; use reader::Reader; pub use self::drive::Drive; pub use self::drive::DriveConfig; pub use self::memory::Memory; mod drive; mod memory; /// A user. pub type User = u64; /// An item. pub type Item = u64; /// A rating. pub type Rating = f64; /// A user and an item. pub type Pair = (User, I...
true
2bd4388f19963430b134729b66330b985dbe9946
Rust
tamuhey/pyo3
/src/type_object.rs
UTF-8
6,771
2.546875
3
[ "Python-2.0", "Apache-2.0" ]
permissive
// Copyright (c) 2017-present PyO3 Project and Contributors //! Python type object information use crate::once_cell::GILOnceCell; use crate::pyclass::{initialize_type_object, PyClass}; use crate::pyclass_init::PyObjectInit; use crate::types::{PyAny, PyType}; use crate::{ffi, AsPyPointer, PyNativeType, Python}; use par...
true
d09b13a84a91b6b4a124d1d3c3e8412c0d4641f1
Rust
diesel-rs/diesel
/diesel/src/expression/sql_literal.rs
UTF-8
11,434
3.265625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::marker::PhantomData; use crate::backend::Backend; use crate::expression::*; use crate::query_builder::*; use crate::query_dsl::RunQueryDsl; use crate::result::QueryResult; use crate::sql_types::{DieselNumericOps, SqlType}; #[derive(Debug, Clone, DieselNumericOps)] #[must_use = "Queries are only executed when...
true
8a855f9d6e112a7ad5bbc8685e5feb957d996712
Rust
sayrer/rust
/src/test/run-pass/lib-sort.rs
UTF-8
755
2.65625
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-1-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "MIT", "BSD-2-Clause", "bzip2-1.0.6" ]
permissive
use std; fn check_sort(vec[int] v1, vec[int] v2) { auto len = std::vec::len[int](v1); fn lteq(&int a, &int b) -> bool { ret a <= b; } auto f = lteq; auto v3 = std::sort::merge_sort[int](f, v1); auto i = 0u; while (i < len) { log v3.(i); assert (v3.(i) == v2.(i)); i += 1u; } } fn main() { ...
true
96f0993bf2e8bbcc19665d6b32fa19257eea8ba3
Rust
emann/dobby
/src/prompt.rs
UTF-8
898
2.8125
3
[ "MIT" ]
permissive
use std::fmt::Display; use color_eyre::eyre::{eyre, Result, WrapErr}; use console::Term; use dialoguer::theme::ColorfulTheme; use dialoguer::{Input, Select}; // TODO: Switch this to use references instead of owned types to avoid copies pub(crate) fn select<T: Display>(mut items: Vec<T>, prompt: &str) -> Result<T> { ...
true
a6444aa66916e445078e3987ed0c315e08d5bec4
Rust
2vg/valve-server-query
/src/query/mod.rs
UTF-8
3,835
2.90625
3
[]
no_license
use std::net::UdpSocket; use std::time::Duration; // reference: https://developer.valvesoftware.com/wiki/Server_queries const SPECIAL_CHARA_VEC: &'static [u8] = &[0xff, 0xff, 0xff, 0xff]; const PAYLOAD: &'static [u8] = "Source Engine Query".as_bytes(); pub struct QueryContext { socket: UdpSocket, } impl QueryCo...
true
cb997e9f07e3b733985269b8e94b5e29c66fb384
Rust
acmcarther/next_space_coop
/cargo/vendor/nalgebra-0.9.0/src/structs/dvector.rs
UTF-8
4,481
3.234375
3
[ "BSD-2-Clause" ]
permissive
//! Vector with dimensions unknown at compile-time. use std::slice::{Iter, IterMut}; use std::iter::{FromIterator, IntoIterator}; use std::iter::repeat; use std::ops::{Add, Sub, Mul, Div, Neg, AddAssign, SubAssign, MulAssign, DivAssign, Index, IndexMut}; use std::mem; use rand::{self, Rand}; use num::{Zero, One}; use ...
true
29679f2898bf2210495f3f99f50ad3583bfe4177
Rust
barreiro/euler
/src/main/rust/euler/solver017.rs
UTF-8
1,853
3.1875
3
[ "MIT" ]
permissive
// COPYRIGHT (C) 2017 barreiro. All Rights Reserved. // Rust solvers for Project Euler problems use Solver; // number of letters for zero (0), one, two [...] nineteen const LOOKUP_ONES: &[i64] = &[0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8]; // number of letters for zero (0), ten, twenty [...] ninety...
true
1bd4e84d7174ce7b504ab300b7ecf4dd3b220880
Rust
Ainevsia/Leetcode-Rust
/11. Container With Most Water/src/main.rs
UTF-8
747
3.828125
4
[ "BSD-2-Clause" ]
permissive
fn main() { println!("Hello, world!"); Solution::max_area(vec![1,2,3]); } struct Solution {} impl Solution { pub fn max_area(height: Vec<i32>) -> i32 { use std::cmp; let (mut l, mut r) = (0, height.len() - 1); let mut area = 0; while l < r { area = cmp::max(area...
true
8312773690cbfd1861056bd573200561f4f24b05
Rust
lukas-code/rust-clippy
/clippy_lints/src/exhaustive_items.rs
UTF-8
3,712
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::source::indent_of; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Item, ItemKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; declare_clippy_l...
true
ae6c71cc4f45e0c50d5007e875106d4a8b1489f8
Rust
mun-lang/mun
/crates/mun_syntax/src/tests/lexer.rs
UTF-8
7,637
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fmt::Write; fn dump_tokens(tokens: &[crate::Token], text: &str) -> String { let mut acc = String::new(); let mut offset = 0; for token in tokens { let len: u32 = token.len.into(); let len = len as usize; let token_text = &text[offset..offset + len]; offset += len; ...
true
81fea63054155505064e22cb9492590be0003b55
Rust
blueluna/psila
/psila-data/src/security/header.rs
UTF-8
9,554
3.046875
3
[ "MIT" ]
permissive
use core::convert::TryFrom; use byteorder::{ByteOrder, LittleEndian}; use crate::common::address::{ExtendedAddress, EXTENDED_ADDRESS_SIZE}; use crate::error::Error; use crate::pack::{Pack, PackFixed}; pub const SECURITY_LEVEL_MASK: u8 = 0b0000_0111; /// Security Level /// /// Describes the length of the message int...
true