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
1adc8e359615c7394c72b80484beb72b7736951e
Rust
Mokosha/pbrt_rust
/src/shape/mod.rs
UTF-8
8,218
2.765625
3
[]
no_license
mod helpers; mod cylinder; mod disk; mod loopsubdiv; mod mesh; mod sphere; use std::sync::Arc; use std::sync::atomic::AtomicUsize; use bbox::BBox; use bbox::HasBounds; use diff_geom::DifferentialGeometry; use geometry::normal::Normal; use geometry::point::Point; use geometry::vector::Vector; use intersection::Inters...
true
dd69add4f008ac0843e45bfa37e687bff0cbff22
Rust
akks800/atcoder
/arc106/src/bin/c.rs
UTF-8
735
2.5625
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; //#[proconio::fastout] fn main() { inpu...
true
3ff5df990c0224941969ba3d30b027b021f78b58
Rust
riscv-rust/k210-hal
/src/clock.rs
UTF-8
1,002
2.78125
3
[ "ISC" ]
permissive
//! Clock configuration //use crate::pac::PRCI; // use crate::sysctl::ACLK; use crate::time::Hertz; /// Frozen clock frequencies /// /// The existence of this value indicates that the clock configuration can no /// longer be changed. #[derive(Clone, Copy)] pub struct Clocks { pub(crate) aclk: Hertz, pub(crate)...
true
cd5cc813a7c3d91220f4cbc5903859121d07ecb8
Rust
elastic-rs/elastic-types
/types/src/geo/point/formats.rs
UTF-8
8,352
3.25
3
[ "Apache-2.0" ]
permissive
use std::str::FromStr; use std::fmt::Write; use serde::{Serialize, Serializer, Deserialize, Deserializer}; use serde::de::{Error, Unexpected, Visitor, SeqAccess}; use geohash; use super::{Coordinate, Point, GeoPointFormat}; use super::mapping::GeoPointMapping; use geo::mapping::Distance; /** The default `geo_point` fo...
true
f44e28d521c8bf8bd4fd3229e0eeb521e8e9a13c
Rust
wfraser/strong-xml
/test-suite/tests/display.rs
UTF-8
878
2.734375
3
[ "MIT" ]
permissive
use std::fmt; use strong_xml::{XmlResult, XmlWrite}; #[derive(PartialEq, Debug)] struct Foo; impl fmt::Display for Foo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "foo") } } #[derive(XmlWrite, PartialEq, Debug)] #[xml(tag = "root")] struct Root { #[xml(attr = "foo")] ...
true
9fa6e1cf02311d1965894a53a20825fc5f4f7e01
Rust
media-io/srt-media
/src/source/filters/parameters/video_scaling.rs
UTF-8
1,832
3.125
3
[ "MIT" ]
permissive
use schemars::JsonSchema; use std::collections::HashMap; #[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)] #[cfg_attr(feature = "python", derive(FromPyObject, IntoPyObject))] pub struct VideoScaling { pub width: Option<u32>, pub height: Option<u32>, } impl Into<HashMap<String, String>> for &V...
true
cfd05e8991106aca9c324737830e338c7bd5dac8
Rust
bell-liang/sspropc_rust
/src/main.rs
UTF-8
2,480
2.59375
3
[]
no_license
mod function_sspropc; mod function_tools; use csv::{Reader, Writer}; use fftw::types::*; use function_sspropc::sspropc; fn main() { // 读取数据 let n = (2_u32).pow(15); let mut date = vec![c64::new(0.0, 0.0); n as usize]; let mut rdr = Reader::from_path("date.csv").unwrap(); for (i, result) in rdr.re...
true
8d344f8527b1705c75f3e257e1866aed1e84c18a
Rust
0x28/aoc_2020
/src/bin/day20.rs
UTF-8
11,174
2.84375
3
[ "MIT" ]
permissive
use aoc_2020::input_file; use std::{ collections::{HashMap, HashSet}, fs, }; #[derive(Debug, PartialEq, Eq, Clone, Hash)] struct Tile { id: u64, top: u64, bottom: u64, left: u64, right: u64, pixel: Vec<Vec<char>>, } fn border_to_number(border: &str) -> u64 { u64::from_str_radix(&bo...
true
cc64ce57395d411df96361711a6e71225e6796ca
Rust
pimors/rag
/src/main.rs
UTF-8
1,820
2.921875
3
[]
no_license
use ndarray::prelude::*; fn main() { // test closure to get ndim let getdim = |p_arr: &Array<f32, _>| { p_arr.ndim() }; // return squared input array // can't handle differnt array ndims. // all arrays must have same ndim during execution // needs change ...
true
744df9bdc2b5affc2077c0182a1685abd6396be6
Rust
stickeritis/sticker2
/sticker2/src/config.rs
UTF-8
9,813
2.546875
3
[ "BlueOak-1.0.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::convert::TryFrom; use std::fs::File; use std::io::{BufRead, BufReader, Read}; use std::path::Path; use sentencepiece::SentencePieceProcessor; use serde::{Deserialize, Serialize}; use sticker_transformers::models::albert::AlbertConfig; use sticker_transformers::models::bert::BertConfig; use wordpieces::WordPie...
true
f0e62411cc98c9ae3587cb073088b605736828a6
Rust
tmokenc/tomoka-rs
/src/commands/general/avatar.rs
UTF-8
1,590
2.8125
3
[ "MIT" ]
permissive
use crate::commands::prelude::*; use crate::utils::get_dominant_color; use futures::future::{self, TryFutureExt}; #[command] #[aliases("ava")] #[usage = "?[@someone]"] #[example = "@SuperUser"] /// Get the avatar of an user /// If mention multiple users, I will take the first one /// If none, I will response with the ...
true
e402af7a395a510b3da1a430b3ddb5dd266e7106
Rust
Clarencef/rust-sandbox
/src/vectors.rs
UTF-8
1,428
3.890625
4
[ "MIT" ]
permissive
/* Vec (pronounced as vector) called buffer. vec! is a macro to create a Vec more easily with an array-like syntax. An alternative would be to use Vec::new(). Rust actually has array's, too, and they look a lot like JavaScripts arrays (e.g. [1, 2]). However they don't behave like JavaScripts arrays. A JavaS...
true
bb3ed8bedb08dd1ad3c2937b503339ef3e1654ea
Rust
Jkierem/rust-sandbox
/ex2-structs/structs/src/main.rs
UTF-8
383
3.171875
3
[]
no_license
fn maybe_add (a: Option<i32>, b: Option<i32>) -> Option<i32> { match (a,b) { (Some(i), Some(j)) => Some(i+j), (Some(i), None) => Some(i), (None, Some(i)) => Some(i), (_ , _) => None, } } fn main() { println!("{:?}",maybe_add(Some(5),Some(2))); println!("{:?}",maybe_add(S...
true
3029fb41aee8321a590244230cc342afc073c62a
Rust
mhallin/socrates
/socrates-core/src/tests/instance_iterator.rs
UTF-8
1,401
2.703125
3
[]
no_license
use crate::gaf::GroundTerm; use super::new_tal_context; fn assert_instances(expected: &[GroundTerm<'_>], mut actual: Vec<GroundTerm<'_>>) { let mut expected = expected.to_vec(); expected.sort(); actual.sort(); assert_eq!(expected, actual); } #[test] fn iterate_interpreted() { let ctx = new_tal_...
true
349cf9ae87b7f670f4695b0acb9abd08d14c5caf
Rust
tinkerware/graphsurge
/src/graph/properties/property_value_type.rs
UTF-8
721
3.09375
3
[ "Apache-2.0" ]
permissive
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] pub enum PropertyValueType { KeyId, Isize, String, Strings, Bool, Pair, } impl std::fmt::Display for PropertyValueType { fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> { write!( ...
true
617328739fcc83dc15832672477bad12a0a00b72
Rust
wez/max32630
/max32630_svd/src/i2cs/dev_id/mod.rs
UTF-8
7,966
2.59375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
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::DEV_ID { #[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
cc6ddc5e62977443f768c9163e4fb24e20cab20b
Rust
risooonho/kludgine
/src/shape/circle.rs
UTF-8
1,912
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ math::{Length, Point, Raw, Scale, Scaled}, scene::Target, shape::{Fill, Stroke}, KludgineError, KludgineResult, }; #[derive(Clone, Debug)] pub(crate) struct Circle<S> { pub center: Point<f32, S>, pub radius: Length<f32, S>, } impl Circle<Scaled> { pub(crate) async fn translate_...
true
622c20bb02cd62afb4e65dc2b57b75b83f2d274c
Rust
bytecodealliance/wasmtime
/cranelift/codegen/src/flowgraph.rs
UTF-8
12,601
3.125
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! A control flow graph represented as mappings of basic blocks to their predecessors //! and successors. //! //! Successors are represented as basic blocks while predecessors are represented by basic //! blocks. Basic blocks are denoted by tuples of block and branch/jump instructions. Each //! predecessor tuple corre...
true
01002d3cce7052c7e11f03b5235c6cdf159e814f
Rust
sugyan/leetcode
/others/september-leetcoding-challenge/week-2/3455/lib.rs
UTF-8
955
3.734375
4
[]
no_license
pub struct Solution {} impl Solution { pub fn get_hint(secret: String, guess: String) -> String { let (mut a, mut b) = (0, 0); let mut d1 = [0; 10]; let mut d2 = [0; 10]; for (s, g) in secret.as_bytes().iter().zip(guess.as_bytes()) { if s == g { a += 1; ...
true
0120853098317acc2d5213bf0e060b71c21b8a18
Rust
rust-lang/cargo
/src/cargo/util/diagnostic_server.rs
UTF-8
11,534
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-only", "Apache-2.0", "MIT", "GCC-exception-2.0", "BSD-3-Clause", "LGPL-2.0-or-later", "Zlib", "OpenSSL", "curl", "LGPL-2.1-only", "BSD-2-Clause", "LicenseRef-scancode-ssleay-windows", "Unlicense" ]
permissive
//! A small TCP server to handle collection of diagnostics information in a //! cross-platform way for the `cargo fix` command. use std::collections::HashSet; use std::io::{BufReader, Read, Write}; use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream}; use std::path::PathBuf; use std::sync::atomic::{AtomicBool,...
true
4d30567ca056a1d794777cf194085fd052d5ee9b
Rust
varkor/reflections
/src/reflectors.rs
UTF-8
12,337
2.953125
3
[]
no_license
use std::collections::{HashMap, HashSet}; use rstar::{primitives::Line, PointDistance, RTree}; use crate::approximation::{Equation, Interval, View}; use crate::spatial::{Pair, Point2D, Quad, RTreeObjectWithData}; /// A `ReflectionApproximator` provides a method to approximate points lying along the reflection /// of...
true
96149b0b4d9af55dc46c2c1aca6257176d6823d9
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/time/src/date.rs
UTF-8
19,888
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use core::fmt; use core::ops::{Add, Sub}; use core::time::Duration as StdDuration; #[cfg(feature = "formatting")] use std::io; #[cfg(feature = "formatting")] use crate::formatting::Formattable; #[cfg(feature = "parsing")] use crate::parsing::Parsable; use crate::util::{days_in_year, days_in_year_month, is_leap_year,...
true
c20616618055d672b49a6445f7b85b4ec2a8e4c3
Rust
aion-camus/aion_utils
/terminal/src/main.rs
UTF-8
1,367
2.734375
3
[]
no_license
use std::io::{self, Write}; use std::thread; use std::sync::mpsc::{channel, Sender}; mod parser; use parser::AppOptions; fn start(tx: Sender<i32>, info: String) { let apps = AppOptions::new("avm"); match thread::Builder::new().name("cmd".to_string()).spawn(move || { loop { print!("{}", in...
true
530c472bff5ca02c7c78bdb9df120f6338e98477
Rust
bartsmykla/codewars
/src/katas/k7_sum_of_odd_numbers.rs
UTF-8
988
3.75
4
[ "MIT" ]
permissive
#![allow(unused)] /* Kata (7kyu): Sum of odd numbers Url: https://www.codewars.com/kata/sum-of-odd-numbers/train/rust Given the triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ... Ca...
true
5beb4c3410319ae36b1359a143f863a688d7970e
Rust
cloudflare/lol-html
/src/rewritable_units/tokens/capturer/to_token.rs
UTF-8
3,115
2.625
3
[ "BSD-3-Clause", "CC-BY-SA-4.0" ]
permissive
use super::*; use crate::html::TextType; use crate::parser::{NonTagContentLexeme, NonTagContentTokenOutline, TagLexeme, TagTokenOutline}; use encoding_rs::Encoding; use std::rc::Rc; pub enum ToTokenResult<'i> { Token(Box<Token<'i>>), Text(TextType), None, } impl<'i> From<Token<'i>> for ToTokenResult<'i> {...
true
bf15bd247a5fbf38167d3d3fd21af7591f334a6b
Rust
dainslef/RustPractice
/src/leetcode/q37_sudoku_solver.rs
UTF-8
5,388
3.328125
3
[ "BSD-3-Clause" ]
permissive
/** * Write a program to solve a Sudoku puzzle by filling the empty cells. * * A sudoku solution must satisfy all of the following rules: * * Each of the digits 1-9 must occur exactly once in each row. * Each of the digits 1-9 must occur exactly once in each column. * Each of the the digits 1-9 must occur exactl...
true
005b86d83d0e7af9415eba3ce3d6a7faed89e427
Rust
kerskuchen/Advent-of-Code-2017-Rust
/day14_disk_fragmentation/src/main.rs
UTF-8
4,730
3.109375
3
[ "Unlicense" ]
permissive
const GRID_DIMENSIONS: usize = 128; const INPUT_STRING: &str = "stpzcrnm"; fn main() { // Create grid: // - filled cells == 1 // - empty cells == 0 let mut grid = Vec::new(); for i in 0..GRID_DIMENSIONS { let input_string = INPUT_STRING.to_owned() + &format!("-{}", i); let knot_has...
true
e1d697e7ad5f63e9344c8eb7c0ce7de9d10b02d6
Rust
jamwt/rust-pico
/src/response.rs
UTF-8
3,571
2.6875
3
[ "MIT" ]
permissive
use sys::ffi; use std::{mem, slice}; use libc::{c_char, c_int, size_t}; use common::slice_to_mut_pair; use {Status, Header, Headers, Version, Chunks, ChunkReader}; /// A parsed Response, borrowing a ResponseParser. #[derive(Debug)] pub struct Response<'s: 'h, 'h> { pub version: Version, pub status: Status, ...
true
a1b051bfdb70a44230b3bd9ee6495902a2fc96f5
Rust
sugyan/adventofcode
/2019/rust.old/day02/main.rs
UTF-8
1,230
3.171875
3
[]
no_license
use std::io::stdin; use utils::IntCode; struct Solution { codes: Vec<i64>, } impl Solution { pub fn new(input: String) -> Solution { let codes: Vec<i64> = input .split(",") .map(|s| s.trim().parse().unwrap()) .collect(); return Solution { codes }; } f...
true
62f12b86f7b43647664a16f9b1047bd62ce28309
Rust
zimbatm/jailthis
/jail.rs
UTF-8
3,427
2.71875
3
[]
no_license
pub use jail::common::Config; pub use jail::common::look_path; pub use jail::macos::run; mod common { use std::path::Path; use std::path::BytesContainer; pub struct Config { root_dir: Path, work_dir: Path, uid: u32, mem: uint, cpu: uint, net: bool, program: Path, args: ~[~str], ...
true
05fde6cf0fb72b842fb2cfa11c3264cca155ee9c
Rust
jble/piston
/src/gl_back_end.rs
UTF-8
10,621
2.734375
3
[ "MIT" ]
permissive
//! OpenGL back-end for Rust-Graphics. // External crates. use gl; use gl::types::*; use std::ptr; use std::mem; use shader_utils::{compile_shader}; use BackEnd = graphics::BackEnd; // Local crate. use AssetStore = asset_store::AssetStore; static VERTEX_SHADER_TRI_LIST_XY_RGBA: &'static str = " attribute vec4 a_v4Po...
true
96433c258d37ebac0243db5c8c0359313d77bc58
Rust
rusty-io/coio-rs
/src/sync/semaphore.rs
UTF-8
3,826
2.765625
3
[ "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
// Copyright 2015 The coio Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except acco...
true
23119b3aa9d8ffb934c58f47c4904e3499a512aa
Rust
jmquigs/rs-pworker
/testproc/src/main.rs
UTF-8
162
2.609375
3
[]
no_license
use std::thread; use std::time::Duration; fn main() { println!("test proc activated! sleeping"); loop { thread::sleep(Duration::from_millis(60000)); } }
true
70086ce93fc737d8c15bde3aaf67976bc0acd849
Rust
quietboil/sibyl
/examples/binding.rs
UTF-8
1,365
2.734375
3
[ "MIT" ]
permissive
#[cfg(feature="blocking")] fn main() -> sibyl::Result<()> { use sibyl::*; let dbname = std::env::var("DBNAME").expect("database name"); let dbuser = std::env::var("DBUSER").expect("user name"); let dbpass = std::env::var("DBPASS").expect("password"); let oracle = Environment::new()?; let sessio...
true
acf2280d0a9dfe9bbc0d9b9ed1d944c2595e1944
Rust
ndgndg91/rust-practice
/src/builtin/option_combinator_practice.rs
UTF-8
681
3.1875
3
[]
no_license
#[derive(Debug)] enum Role { Manager, Admin, Normal, Observer } fn find_role(role: &str) -> Option<Role> { match role.to_lowercase().as_str() { "manager" => Some(Role::Manager), "admin" => Some(Role::Admin), "normal" => Some(Role::Normal), "observer" => Some(Role::Ob...
true
a4f533da941317915e53d7de6de1b0a970acb7fa
Rust
Qwaz/satire
/src/solver/cdcl.rs
UTF-8
6,786
2.578125
3
[]
no_license
use crate::formula::{Clause, Cnf, Literal, Model, Variable}; use self::{ conflict::{ConflictAnalyzer, ConflictDataProvider}, tracker::{ClauseIdx, Tracker}, vsids::VsidsScoring, }; use super::Solver; mod conflict; mod tracker; mod vsids; #[derive(Debug, Clone, Copy)] enum DecisionReason { Decision, ...
true
f8b2506a81e10b2daba149d695b33d2a0f2a537e
Rust
mcalawa/cs410pRust
/hw3/sieve/src/lib.rs
UTF-8
639
3.1875
3
[]
no_license
pub fn primes_up_to(upper_bound: u64) -> Vec<u64> { let mut size = upper_bound as usize; size += 1; let mut is_prime = vec![true; size]; is_prime[0] = false; is_prime[1] = false; for i in 2..size { if is_prime[i] != false { let prime_interval = i; let mut current ...
true
d70904e3623d31fa4d0716a06b0d403adc6c0274
Rust
gliptic/codec
/src/prefix_code.rs
UTF-8
14,491
2.75
3
[]
no_license
#![macro_escape] use std::mem; use std::intrinsics::ctlz32; use std::cmp::max; use std::iter::range_step; static MAX_SUPPORTED_SYMS: u32 = 1024; static MAX_EVER_CODE_SIZE: u32 = 34; static MAX_EXPECTED_CODE_SIZE: uint = 16; pub struct OrdFreq { f: u16, s: u16 } impl OrdFreq { pub fn new(sym: u32, freq: u32) -> O...
true
ccbd7d4a0a8d2db7a3bf9a534ce4a6e00e946185
Rust
rajinwonderland/rust_sandbox
/src/types.rs
UTF-8
1,206
3.71875
4
[]
no_license
/* @def Primitive Types -- @desc Integers: u8, i8, u16, i16, u32 i32, u64, i64, u128, i128 (number of bits they take up in memory) !: u === unsigned integer (can not contain negative numbers) !: i === integers @desc Float: f32, f64 @desc Boolean: {bool} @desc Characters: {char} !: fixed character, != string @desc ...
true
0c3121a34e7a72b63ba26c668324a5f9e3a0dbc6
Rust
petrusbatalha/jira-cli
/src/stories/add.rs
UTF-8
1,774
2.59375
3
[ "Apache-2.0" ]
permissive
use crate::commons::file_utilities::load_yaml; use crate::commons::req_builder::build_post_req; use crate::commons::structs::{AuthOptions, REST_URI}; use crate::stories::command_args::StoryOps; use crate::stories::stories_structs::{Stories, StoriesHandler, StoryRequest, StoryRequestFields}; use serde_json::json; use se...
true
1483d11e72a5f926232ef11081bf63b5a0825fd5
Rust
nicokoch/vulkan-driver
/rusterizer/src/version.rs
UTF-8
1,097
3.078125
3
[]
no_license
use std::fmt; use std::convert::Into; #[derive(PartialEq, Eq, PartialOrd, Copy, Clone)] pub struct Version { repr: u32, } impl Version { pub fn new(major: u16, minor: u16, patch: u16) -> Self { debug_assert!(major & (0b111111 << 10) == 0); debug_assert!(minor & (0b111111 << 10) == 0); ...
true
8370164585bd3df18f648ceb3fdef151e838a891
Rust
hashedone/aoc2020
/day7/src/parser.rs
UTF-8
1,814
2.78125
3
[]
no_license
use super::Bag; use anyhow::Error; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::{alpha1, char as ch, digit1}; use nom::combinator::map; use nom::multi::separated_list1; use nom::sequence::tuple; use nom::{Finish, IResult}; use std::collections::HashMap; fn color(input: &str) -> IR...
true
55bea141989d4d9a446a5c190307f57b45fd6913
Rust
Harry-Chen/rust-mips
/src/addr.rs
UTF-8
3,792
3.125
3
[ "MIT" ]
permissive
//! abstraction for virtual and physical addresses use bit_field::BitField; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct VirtAddr(usize); impl VirtAddr { pub fn new(addr: usize) -> VirtAddr { VirtAddr(addr) } pub fn as_usize(&self) -> usize { self.0 } ...
true
864caa2e70a447598de2bf29680c6448290a887a
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0515.find-largest-value-in-each-tree-row/find-largest-value-in-each-tree-row_test.go
UTF-8
759
2.59375
3
[ "MIT" ]
permissive
package problem0515 import ( "fmt" "testing" "github.com/aQuaYi/LeetCode-in-Go/kit" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { pre, in []int ans []int }{ { []int{}, []int{}, []int{}, }, { []int{1, 3, 5, 6, 2, 9}, []int{5, 3, 6, 1, 2, 9}, []int{1, ...
true
851afe3dd5b1bbe2ed2cd516cc25dfaa21dd0f4d
Rust
serejkus/env_file
/src/lib.rs
UTF-8
2,673
3.609375
4
[ "MIT" ]
permissive
//! This crate helps to read contents of a file with name taken from environment variable. //! //! Some applications have sensitive data, like API keys, which is unsafe to keep in VCS. One //! possible solution is keeping secret data in files, taking their names from environment //! variables. Say, you have to use clou...
true
8e5e4626e659ac04111c51f5fb2f500035e71324
Rust
malt03/grpc_gcp
/src/config.rs
UTF-8
591
2.53125
3
[]
no_license
use once_cell::sync::OnceCell; static CONFIG: OnceCell<Config> = OnceCell::new(); pub(crate) fn init(project_id: impl Into<String>) { CONFIG.set(Config::new(project_id)).unwrap(); } pub(crate) fn project_id() -> &'static String { match CONFIG.get() { None => panic!("need to set project_id with grpc_g...
true
94e36b4c4e538997b963aa0e20fda0f5b351646e
Rust
dicej/bincode-benchmark
/src/lib.rs
UTF-8
4,691
2.609375
3
[]
no_license
#![feature(test)] #[macro_use] extern crate serde_derive; extern crate test; use uuid::Uuid; #[derive(Serialize, Deserialize)] pub enum Frame<'a> { #[serde(borrow)] Yuv(YuvFrame<'a>), #[serde(borrow)] Rgb(RgbFrame<'a>), } #[repr(C)] #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] pu...
true
b1c01133e18edc16e673e39cf7000253db6ad679
Rust
JJag/raytracer
/src/main.rs
UTF-8
7,145
2.609375
3
[]
no_license
extern crate rand; use camera::Camera; use hitable::Hitable; use hitable::Sphere; use material::*; use ray::Ray; use std::f32; use std::time::Instant; use vec3::Vec3; use std::rc::Rc; mod vec3; mod ray; mod material; mod camera; mod hitable; mod util; const GRAY: Vec3 = Vec3 { x: 0.5, y: 0.5, z: 0.5 }; const RED: Ve...
true
7f56c4083f5ab4c24dfe5b4fa68ad28dd93fd324
Rust
cowang4/lightracer
/src/intersectable.rs
UTF-8
3,352
3.28125
3
[]
no_license
use std::mem; use enum_dispatch::enum_dispatch; use crate::color::Color; use crate::math::solve_quadratic; use crate::point::Point; use crate::ray::Ray; use crate::scene::*; use crate::vector::Vector3; #[derive(Debug, Copy, Clone)] pub struct Hit { pub dist: f32, pub color: Color, pub hit_light: bool, ...
true
36ac9761e8e38e0fb6bfd62640931462d2656a4b
Rust
IThawk/rust-project
/rust-master/src/test/ui/nll/unused-mut-issue-50343.rs
UTF-8
146
2.765625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
#![deny(unused_mut)] fn main() { vec![(42, 22)].iter().map(|(mut x, _y)| ()).count(); //~^ ERROR: variable does not need to be mutable }
true
f6eb308e1efbf07e93fe64f03147fe3c2c1a1c32
Rust
qinxiaoguang/rs-lc
/src/solution/l086.rs
UTF-8
2,510
3.578125
4
[]
no_license
use super::ListNode; pub struct Solution {} /* * @lc app=leetcode.cn id=86 lang=rust * * [86] 分隔链表 * * https://leetcode-cn.com/problems/partition-list/description/ * * algorithms * Medium (56.42%) * Likes: 219 * Dislikes: 0 * Total Accepted: 41.2K * Total Submissions: 70.6K * Testcase Example: '[1,...
true
6bb58275de2a606ea37f3f3992b38b019b97e31f
Rust
hartl3y94/trojan-rust
/src/auth/mod.rs
UTF-8
1,884
2.828125
3
[ "MIT" ]
permissive
pub mod from_config; pub mod redis; use self::{from_config::ConfigAuthenticator, redis::RedisAuthenticator}; use crate::utils::config::Config; use anyhow::{anyhow, Context, Result}; use async_trait::async_trait; #[async_trait] pub trait Auth: Send + Sync + Unpin { async fn auth(&self, password: &str) -> Result<bo...
true
1278e5b1ce5afa743ef0d0de8a5d25dd9b052446
Rust
lcnr/tindex
/src/iter.rs
UTF-8
1,158
2.984375
3
[ "MIT" ]
permissive
use std::{ iter::{DoubleEndedIterator, ExactSizeIterator, FusedIterator}, marker::PhantomData, ops::Range, }; use crate::TIndex; #[derive(Debug)] pub struct IndexIter<I> { _marker: PhantomData<I>, inner: Range<usize>, } impl<I> IndexIter<I> { pub(crate) fn new(end: usize) -> Self { Se...
true
2376f6fbdd80928fddfe7711b2f35023b8aebe6e
Rust
General-Beck/jsonrpc
/core-client/transports/src/lib.rs
UTF-8
13,464
2.640625
3
[ "MIT" ]
permissive
//! JSON-RPC client implementation. #![deny(missing_docs)] use failure::{format_err, Fail}; use futures::sync::{mpsc, oneshot}; use futures::{future, prelude::*}; use jsonrpc_core::{Error, Params}; use serde::de::DeserializeOwned; use serde::Serialize; use serde_json::Value; use std::marker::PhantomData; pub mod tra...
true
33415fbc2ce1372642106c4b12677493724e68da
Rust
sotolf2/aoc2015
/day16/src/main.rs
UTF-8
3,352
3
3
[ "BSD-2-Clause" ]
permissive
use std::fs::File; use std::io::{BufRead, self, Error}; use std::env; use std::collections::HashMap; use regex::Regex; #[macro_use] extern crate lazy_static; fn parse(in_line: Result<String, Error>) -> Result<(i32, HashMap<String,i32>), Error> { let line = in_line?; lazy_static! { static ref SUE: Rege...
true
3b9a86117b3da27c465e67364ca3b9f4ebded9c9
Rust
ferrous-systems/imxrt1052
/src/trng/mctl/mod.rs
UTF-8
21,999
2.625
3
[]
no_license
#[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::MCTL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut ...
true
712e54a062a8fd102ce904c15853211a86d8edfe
Rust
wiasliaw/swe-analysis
/src/utils/path.rs
UTF-8
794
2.8125
3
[]
no_license
use std::fs; use std::path::PathBuf; use crate::types::InputData; fn get_path(pi: &str) -> Vec<PathBuf> { let ps = fs::read_dir(pi).unwrap(); let mut pv = Vec::<PathBuf>::new(); ps.filter_map(Result::ok) .filter_map(|p| { p.path() .to_str() .and_then(|f...
true
fa75f4a44bf94ef9115d584fc554a323a37980b3
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/owo_colors/v3/crate/src/colors/xterm.rs
UTF-8
14,638
2.578125
3
[ "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later" ]
permissive
macro_rules! xterm_colors { ($( $xterm_num:literal $name:ident ($r:literal, $g:literal, $b:literal) )*) => { pub(crate) mod dynamic { use core::fmt; #[allow(unused_imports)] use crate::OwoColorize; /// Available Xterm colors for use with [`OwoCo...
true
3728903dcc77cbc2ad6cc6723e5f68f0549648fa
Rust
N-give/learning_rust
/rsorts/src/lib.rs
UTF-8
2,784
3.28125
3
[]
no_license
pub mod rsorts { use std::thread; pub fn gen_rqsort<T> (arr: &mut[T], rev: bool) where T: Eq + Ord + Copy, { if arr.len() <= 1 { return; } let mut front: usize; let mut back: usize; let cmp = arr[arr.len() - 1]; while { front ...
true
6001eead2aad1f7d53c40860cb63573c249fa63f
Rust
UMASHIBA1/MyRustTutorialPractice
/4/4_1/variable/src/main.rs
UTF-8
418
3.796875
4
[]
no_license
// 束縛変数 fn main() { let x = 5; // x = 6; 再代入は不可 let x: i32 = 2; //再定義は可能(デフォルトでイミュータブル) let (x,y) = (1,2); let y = "aaa"; let mut z = 5; //mutを付ける事で変数をミュータブルにできる println!("{}", z); z = 1; println!("{}", z); println!("{}",x); println!("{}",y); println!("Hello, world!"); ...
true
ba3d5194a0b0f18a9338ca95267f2740bf8b299a
Rust
yajamon/study-mini-rdbms
/src/buffer.rs
UTF-8
3,595
3
3
[ "MIT" ]
permissive
use std::cell::{Cell, RefCell}; use std::collections::HashMap; use std::ops::{Index, IndexMut}; use std::rc::Rc; use crate::disk_manager::*; pub enum Error { NoFreeBuffer, IoError(std::io::Error), } impl From<std::io::Error> for Error { fn from(e: std::io::Error) -> Self { Error::IoError(e) } ...
true
edcb053fbc5db61c785fc9aecedc9c61fae1c669
Rust
azreika/RAT
/src/cnf.rs
UTF-8
4,748
3.6875
4
[]
no_license
use std::fmt; use std::collections::HashMap; /// Represents the overall conjunction in a CNF. /// Composed of a set of disjunctions. #[derive(Clone)] pub struct Conjunction { disjunctions: Vec<Disjunction>, } impl Conjunction { pub fn new() -> Conjunction { Conjunction { disjunctions: Vec:...
true
a92aca7fd2f6aa6134f2ba8ee513c812cbff69ab
Rust
shaddyshad/analyzer
/src/tokenizer/stack.rs
UTF-8
789
3.65625
4
[]
no_license
use std::collections::VecDeque; #[derive(Debug)] pub struct Stack<T: Sized>{ items: VecDeque<T> } impl <T> Stack<T> { pub fn new() -> Self { Self { items: VecDeque::new() } } pub fn push(&mut self, item: T){ self.items.push_back(item); } pub fn pop(&mut s...
true
fcf05d46e0d9f0e8dda60506b679c7a2d3421ce2
Rust
pcein/trust-rust
/code/product-types/struct/ex1.rs
UTF-8
301
3.375
3
[]
no_license
#[derive(Debug)] struct Complex { re: f64, im: f64, } impl Complex { fn add(&self, other: Complex) -> Complex { } } fn main() { let c = Complex { re : 1.0, im : 2.0 }; let d = Complex { re : 3.0, im : 4.0 }; let result = c.add(d); println!("{:?}", result); }
true
f68deaff93339c7ebfc65b4b1454d9d4bdd23377
Rust
rust-lang/rust
/src/bootstrap/channel.rs
UTF-8
5,336
3.0625
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
//! Build configuration for Rust's release channels. //! //! Implements the stable/beta/nightly channel distinctions by setting various //! flags like the `unstable_features`, calculating variables like `release` and //! `package_vers`, and otherwise indicating to the compiler what it should //! print out as part of it...
true
3e415d8b54eaa54317d54db4e6d8c4406ff4582d
Rust
aunetx/nit_os
/src/interrupts/exceptions.rs
UTF-8
1,262
2.9375
3
[ "MIT" ]
permissive
//! Defines functions to be called when an exception occurs. //! // internal crate use crate::println; // external crates use x86_64::{ registers::control::Cr2, structures::idt::{InterruptStackFrame, PageFaultErrorCode}, }; // ! ------------- exceptions handlers ------------- /// Exception handler for the b...
true
0f7fac4e7d4a3e4f44df49a1f1ca38f05f05e586
Rust
chromium/chromium
/third_party/rust/regex/v1/crate/examples/shootout-regex-dna-replace.rs
UTF-8
462
2.8125
3
[ "BSD-3-Clause", "MIT", "LicenseRef-scancode-unicode", "Apache-2.0", "GPL-1.0-or-later", "LGPL-2.0-or-later" ]
permissive
use std::io::{self, Read}; macro_rules! regex { ($re:expr) => {{ use regex::internal::ExecBuilder; ExecBuilder::new($re).build().unwrap().into_regex() }}; } fn main() { let mut seq = String::with_capacity(50 * (1 << 20)); io::stdin().read_to_string(&mut seq).unwrap(); let ilen = se...
true
8237ca103ea8bfd3bbeb82df05826688e5cbf5ca
Rust
aurelj/embedded-graphics
/embedded-graphics/src/style/styled.rs
UTF-8
1,061
3.203125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ geometry::{Dimensions, Point}, primitives::Rectangle, transform::Transform, }; /// Styled. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] pub struct Styled<T, S> { /// Primitive. pub primitive: T, /// Style. pub style: S, } impl<T, S> Styled<T, S>...
true
389ef0e85c5a9d54cfd063b459bdd741f415aec4
Rust
vi/mal-rust-vi
/step3c/src/tests.rs
UTF-8
3,535
2.90625
3
[ "MIT" ]
permissive
// ; Testing REPL_ENV #[test] fn test0() { super::test_it ( &vec!["(+ 1 2)"], Some("3"), ); } #[test] fn test1() { super::test_it ( &vec!["(/ (- (+ 5 (* 2 3)) 3) 4)"], Some("2"), ); } // ; Testing def! #[test] fn test2() { super::test_it ( &vec!["(def! x 3)"...
true
eb9525fcfa1d39438aa8c6cbad0b876ca257d1f1
Rust
lytedev/advent-of-code
/2022/rust/src/day2.rs
UTF-8
3,880
3.265625
3
[]
no_license
use std::cmp::{Ord, Ordering, PartialEq}; use std::str::FromStr; mod common; #[derive(Debug, PartialEq, Eq, Copy, Clone)] enum Choice { Rock = 1, Paper = 2, Scissors = 3, } impl PartialOrd for Choice { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) } } im...
true
92d55815f64252ddc7a81fb3b3a88e4eccb0775b
Rust
crsaracco/parks-mcclellan-rs
/src/pm/extremal_frequency_search.rs
UTF-8
8,294
2.921875
3
[]
no_license
use super::DenseGrid; use super::ExtremalFrequencies; pub fn find_extremal_frequencies( num_coefficients: usize, grid: &DenseGrid, x: &[f64; 66], y: &[f64; 66], ad: &[f64; 66], deviation: f64, sign: &mut i32, comp: &mut f64, extremal_frequencies: &mut ExtremalFrequencies, ) -> bool...
true
5d05848408c4f27afd9625cfba4097a2e761a750
Rust
maximeborges/svd2rust_efm32gg990
/src/gpio/pe_modeh.rs
UTF-8
93,920
2.609375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
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::PE_MODEH { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w ...
true
38f601326750d27d760510689747590c27bba59b
Rust
daily-boj/RanolP
/3447/solution.rs
UTF-8
1,870
3.21875
3
[ "Unlicense" ]
permissive
use std::collections::VecDeque; use std::io::{stdin, BufRead}; #[derive(Debug)] enum State { Nope, B, BU, } impl AsRef<str> for State { fn as_ref(&self) -> &str { match self { State::Nope => "", State::B => "B", State::BU => "BU", } } } fn main(...
true
4e86de59f85d3622abda8f41f595d1a10b8e3f6b
Rust
peter-leonov/exercisms-rust
/grains/src/lib.rs
UTF-8
470
3.1875
3
[]
no_license
// pub fn square(s: u32) -> u64 { // if !(1..=64).contains(&s) { // panic!("Square must be between 1 and 64"); // } // (2u64).pow(s - 1) // } pub fn square(s: u32) -> u64 { match s { // 1. range check on unsigned is just one sub and one test // 2. rust does not optimize 2.pow(),...
true
e5e7cc8904fae3f058648fcded3b61d39e54ee73
Rust
skyline-rs/fake-ld
/src/main.rs
UTF-8
3,785
2.765625
3
[]
no_license
use std::{fs, env}; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; fn exists(command: &str) -> bool { Command::new(command) .stdin(Stdio::null()) .stdout(Stdio::null()) .stderr(Stdio::null()) .status() .is_ok() } fn llvm_path() -> Option<PathBuf> { ...
true
d549a2caf83f1ccb909e9dff229fa0b17bcdb9fa
Rust
worace/nom_example
/src/example.rs
UTF-8
582
3.125
3
[]
no_license
fn is_non_brace(a: char) -> bool { a != '{' && a != '}' } named!(content<&str, &str>, take_while!(is_non_brace)); named!(balanced_braces<&str, &str>, recognize!(delimited!(tag!("{"), alt!(balanced_braces|content), tag!("}"))) ); #[cfg(test)] mod te...
true
adb755e8e3a90e29a1d409bbcb223ad7d7fe858d
Rust
Papierkorb/rust-examples
/tutorial-15_3-do.rs
UTF-8
741
3.671875
4
[ "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive", "MIT", "Apache-2.0" ]
permissive
/** * 15.3 Do syntax * http://static.rust-lang.org/doc/master/tutorial.html#do-syntax * * @license MIT license <http://www.opensource.org/licenses/mit-license.php> */ // A function that takes a procedure as argument: fn call_it(op: proc(v: int)) { op(10) } fn each(v: &[int], op: |v: &int|) { let mut n = 0; wh...
true
21728a7d291301b2280fbef649d0cc03012a482c
Rust
clumsy/rsrl
/rsrl/src/policies/mod.rs
UTF-8
3,724
3.140625
3
[ "MIT" ]
permissive
//! Agent policies module. //! //! This module contains fixed and parameterised policies for reinforcement //! learning control problems. A policy is considered to be either deterministic //! or stochastic, for which we have the following definitions, respectively: 1) //! _π(X) -> U_; 2) _π(X, U) -> R_, or equivalently...
true
f09571b8c6c9a7e4a311ee16828d69fe20ce81f3
Rust
SEL4PROJ/cakeml-bake
/src/holmake.rs
UTF-8
898
3.234375
3
[]
no_license
use std::path::{Path, PathBuf}; use std::process::Command; #[derive(Debug)] pub struct Holmake { path: PathBuf, } impl Holmake { /// Create a new pub fn new(holmake_path: &Path) -> Self { Self { path: holmake_path.into(), } } /// Run Holmake in the given directory ...
true
a012875547adf040b39625566677088e1b892028
Rust
ankit-mogha/KUP_Rust
/Assignment2/src/fibonacci.rs
UTF-8
262
2.734375
3
[]
no_license
pub fn fibo_series() { let mut num1=0; let mut num2=1; let mut fibo=0; let mut loopvar=0; print!("0"); while loopvar < 10 { fibo=num1+num2; print!(" {}",fibo); num1=num2; num2=fibo; loopvar +=1; } }
true
f0074305a5004eb17fc65fbfd2b2c20cbe7f5024
Rust
TheTriumvirate/brainstorm
/window/src/abstract_window.rs
UTF-8
1,156
2.953125
3
[ "MIT" ]
permissive
use crate::Event as EventWrapper; /// The "abstract interface" for a "window" in both web and desktop /// environments. pub trait AbstractWindow { /// Creates the "window". fn new(title: &str, width: u32, height: u32) -> Self; /// Starts the main loop. Only returns if the window is closed. /// Unless i...
true
8374398e4c165bca67ef31f0467c60c73494d1ed
Rust
imorph/vector
/lib/vrl/compiler/src/expression/literal.rs
UTF-8
9,550
3.015625
3
[ "MPL-2.0" ]
permissive
use crate::expression::Resolved; use crate::{value::Regex, Context, Expression, Span, State, TypeDef, Value}; use bytes::Bytes; use chrono::{DateTime, SecondsFormat, Utc}; use diagnostic::{DiagnosticError, Label, Note, Urls}; use ordered_float::NotNan; use parser::ast::{self, Node}; use std::borrow::Cow; use std::conve...
true
d4a1051b0bfbe445c13313828dba4485c2a41aa1
Rust
Tonyce/hellorust
/src/timer/task.rs
UTF-8
1,197
3.09375
3
[]
no_license
use futures::{future::BoxFuture, task::ArcWake}; use std::sync::mpsc::SyncSender; use std::sync::{Arc, Mutex}; /// A future that can reschedule itself to be polled by an `Executor`. pub struct Task { /// In-progress future that should be pushed to completion. /// /// The `Mutex` is not necessary for correc...
true
14f3a71b6b5c8d6fa46abd1a6c7686261e9af2c5
Rust
jneem/gesture
/libgestures/src/geom.rs
UTF-8
9,421
3.796875
4
[ "Apache-2.0", "MIT" ]
permissive
use euclid; use std::f64; use std::f64::consts::PI; use std::ops::{Add, Neg, Sub}; pub struct Mm; pub type Point = euclid::TypedVector2D<f64, Mm>; /// Represents an angle. /// /// This type doesn't differentiate between multiples of full rotations; that is, /// an angle of 360 degrees is treated the same as an angle ...
true
e1b15d3ec5eb3027d042ea4a415fa18babf09828
Rust
acmcarther/cargo-raze-examples
/bazel/non_cratesio_library/cargo/vendor/futures-util-0.2.0-alpha/src/future/select_ok.rs
UTF-8
2,910
3.4375
3
[ "Apache-2.0" ]
permissive
//! Definition of the `SelectOk` combinator, finding the first successful future //! in a list. use std::mem; use std::prelude::v1::*; use futures_core::{Future, IntoFuture, Poll, Async}; use futures_core::task; /// Future for the `select_ok` combinator, waiting for one of any of a list of /// futures to successfull...
true
286879ffdc82efb8ed288cdb9b79ecc278517249
Rust
sbeckeriv/rust_basics
/link_list/link_list/src/lib.rs
UTF-8
1,033
3.171875
3
[]
no_license
mod link_list{ type Link<T> = Option<Box<Node<T>>>; struct Rawlink<T> { p: *mut T, } struct Node<T>{ value: T, next: Link<T>} impl <T> Node<T>{ fn new(value: T) -> Node<T>{ Node{ value: value, next: None} } } pub struct List<T>{ head: Link<T>, tail: Link<...
true
23a685e35fa9aeeda4da771f305d448af89fb593
Rust
ZhongliGao/memtable-rs
/memtable-core/src/prelude.rs
UTF-8
1,685
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! # The MemTable Prelude //! //! The memtable library comes with a variety of tools to help with building, //! parsing, and transforming tables. While these could be brought in via a //! mixture of `use memtable::*;` and other imports, this prelude serves as //! the one-stop shop to import required traits, common str...
true
03d9e33abc2096023270dd7f451b014c657c1d92
Rust
bitemyapp/MagenBoy
/lib_gb/src/apu/channel.rs
UTF-8
1,916
2.96875
3
[]
no_license
use super::sample_producer::SampleProducer; use super::timer::Timer; pub struct Channel<Procuder: SampleProducer>{ pub enabled:bool, pub frequency:u16, pub sound_length:u16, pub length_enable:bool, pub sample_producer:Procuder, pub timer:Timer, last_sample:u8, } impl<Procuder: SampleProdu...
true
00a76963ba9f48c38ae75a58c2b9d6fa701d529c
Rust
cda-group/arcon
/examples/custom_operator.rs
UTF-8
2,407
2.65625
3
[ "Apache-2.0" ]
permissive
use arcon::{ignore_timeout, prelude::*}; #[arcon::proto] #[derive(Arcon, Copy, Clone)] pub struct CustomEvent { pub id: u64, } #[derive(Default)] pub struct MyOperator; impl Operator for MyOperator { type IN = u64; type OUT = CustomEvent; type TimerState = ArconNever; type OperatorState = EmptySt...
true
333dbbe8ac1c22ed7b22f626908f28c97e9b0d35
Rust
HerringtonDarkholme/leetcode
/src/integer_break.rs
UTF-8
482
3.375
3
[]
no_license
pub struct Solution; impl Solution { pub fn integer_break(n: i32) -> i32 { let mut cache = [1; 59]; let n = n as usize; for i in 3..=n { populate(&mut cache, i); } cache[n] as i32 } } fn populate(cache: &mut [usize], num: usize) { let mut max = 1; for...
true
e0bfc29df7b07c07c0e25d4dc2ecb0ba84e95c57
Rust
LinusU/amethyst_sokoban
/src/systems/player.rs
UTF-8
4,881
2.546875
3
[]
no_license
use amethyst::{ core::{Time, Transform}, ecs::{Join, Read, ReadStorage, System, WriteStorage}, input::InputHandler, renderer::SpriteRender, }; use crate::sokoban::{Box, Direction, Movable, PlayState, Player}; pub struct PlayerSystem; impl<'s> System<'s> for PlayerSystem { type SystemData = ( ...
true
801126a675f71fe04250a402dc68d28ff56ee9c7
Rust
ia7ck/competitive-programming
/AtCoder/abc300/src/bin/e/main.rs
UTF-8
827
2.828125
3
[]
no_license
use std::collections::HashMap; use mod_int::ModInt998244353; use proconio::input; // p(6) = 1/6 * p(6) + 1/6 * p(3) + 1/6 * p(2) + 1/6 * p(1) // p(3) = 1/6 * p(3) + 1/6 * p(1) // p(2) = 1/6 * p(2) + 1/6 * p(1) // // 5/6 * p(6) = 1/6 * 1/5 + 1/6 * 1/5 + 1/6 // p(6) = (1/5 + 1/5 + 1) / 5 = 7/25 type Mint = ModInt99824...
true
64287ddeb3db55049935d084776a7f9192e6bf5f
Rust
rrcwang/algolia-rs
/src/key.rs
UTF-8
1,930
3.28125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::fmt; use crate::request::VirtualKeyRestrictions; #[derive(Clone)] // TODO: make an invariant that this _must_ be valid visible-ascii pub struct ApiKey(pub String); impl fmt::Debug for ApiKey { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("ApiKey").field(&"***").finish...
true
1c4edcc4fee94a3e16c4af4b216c7e5dd7401512
Rust
k124k3n/competitive-programming-answer
/leetcode/find-common-characters.rs
UTF-8
885
2.59375
3
[ "MIT" ]
permissive
impl Solution { pub fn common_chars(a: Vec<String>) -> Vec<String> { let mut alph = vec![vec![0; 26]; a.len()]; let mut ret = vec![]; let mut temp; let mut min; for i in a.iter(){ temp = vec![0; 26]; for j in i.chars(){ temp[((j as u8) ...
true
5d29394aa206c223b427e0d0e21f68db828b774b
Rust
bincode-org/bincode-core
/src/serialize.rs
UTF-8
14,640
3.046875
3
[]
no_license
use super::*; use config::{BincodeByteOrder, IntEncoding, Options}; use serde::{ser::*, serde_if_integer128}; #[cfg(feature = "std")] use std::error::Error as StdError; /// Serialize a given `T` type into a given `CoreWrite` writer with the given `B` byte order. /// /// `T` can be any value that derives `serde::Seria...
true
d01a51024a80584044c1689df62f9421c17a61f2
Rust
nathankleyn/handlebars-cli
/src/main.rs
UTF-8
3,057
3.296875
3
[ "MIT" ]
permissive
use std::env; use std::path::PathBuf; use std::process; use std::str::FromStr; use handlebars::Handlebars; use serde_json::value::Value as Json; use snafu::{ResultExt, Snafu}; /// An enumeration of the possible errors this program may encounter. #[derive(Debug, Snafu)] enum Error { /// This error represents the p...
true
33efc476d99be36e25c76a130e97d67059ff0e65
Rust
mtak-/swym
/src/internal/starvation.rs
UTF-8
16,393
2.765625
3
[ "MIT" ]
permissive
//! `Starvation` is a private type used for blocking other threads in order to finish some work that //! was unable to be performed speculatively in a finite amount of time. //! //! `Progress` contains the logic of when to signal that a thread is starving, and waits for other //! threads that are starving. //! //! Ever...
true
8b66f8cadc8c4fab58e4f3e48883aaffcb858e4b
Rust
lisael/parallel_bench
/rust/montecarlo/src/main.rs
UTF-8
968
3
3
[]
no_license
extern crate rand; use std::thread; use std::sync::mpsc; use rand::distributions::{IndependentSample, Range}; fn main() { let loops = 100_000_000; let num = 4; let chunk = loops/num; let (input, out) = mpsc::channel(); let (total_in,total_out) = mpsc::channel(); thread::spawn( move || { let m...
true
76f238b420830422fe5248035acffa4ee2d8edde
Rust
superdump/p5-rs
/examples/goop.rs
UTF-8
7,724
2.71875
3
[ "MIT" ]
permissive
/* * MIT License * * Copyright (c) 2017 Robert Swain <robert.swain@gmail.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rig...
true
6f89bd237fc57ab113ad79f724a3f0a2ae81237e
Rust
gereeter/bad-crypto
/src/utils/traits/wrapping.rs
UTF-8
2,709
3.203125
3
[ "MIT" ]
permissive
use std::ops::{Add, Sub}; pub struct Wrapping<T>(pub T); impl<Lhs: WrappingAdd<Rhs>, Rhs> Add<Wrapping<Rhs>> for Wrapping<Lhs> { type Output = Wrapping<<Lhs as WrappingAdd<Rhs>>::Output>; fn add(self, rhs: Wrapping<Rhs>) -> Self::Output { Wrapping(self.0.wrapping_add(rhs.0)) } } impl<Lhs: Wrappin...
true