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
ea65e504b42805c49e0019707342bab6198214e9
Rust
harpsword/tex-rs
/src/tex_the_program/section_1337.rs
UTF-8
3,409
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
//! @ When we begin the following code, \TeX's tables may still contain garbage; //! the strings might not even be present. Thus we must proceed cautiously to get //! bootstrapped in. //! //! But when we finish this part of the program, \TeX\ is ready to call on the //! |main_control| routine to do its work. // @<Get ...
true
c55d1180162214364c62fd5b77dd3034f4ad87db
Rust
zacharydenton/rtchallenge
/src/color.rs
UTF-8
2,921
3.84375
4
[]
no_license
use std::ops; #[derive(Copy, Clone, Debug, PartialEq)] pub struct Color { pub r: f32, pub g: f32, pub b: f32, } impl Color { pub const WHITE: Color = Color { r: 1., g: 1., b: 1., }; pub const BLACK: Color = Color { r: 0., g: 0., b: 0., }; ...
true
412dad27705b25e3c21e999c6d0c73f353710cfe
Rust
WizardOfMenlo/AOC
/day1/src/main.rs
UTF-8
1,263
2.984375
3
[]
no_license
use itertools::Itertools; use std::fs::File; use std::io::{self, prelude::*}; use std::path::PathBuf; use structopt::StructOpt; #[derive(Debug, StructOpt)] struct Opt { /// Input file #[structopt(parse(from_os_str))] input: PathBuf, #[structopt(default_value = "3")] folds: usize, #[structopt(...
true
69215ebea7870ac18816de14367f985b76e8c2c9
Rust
adriankumpf/night-watch
/src/sun.rs
UTF-8
1,724
2.984375
3
[ "MIT" ]
permissive
use std::fmt; use std::ops::Deref; use anyhow::Result; use chrono::{offset::Utc, DateTime}; use log::debug; use serde::Deserialize; use crate::home_assistant::{Entity, HomeAssistant}; #[derive(Debug, Deserialize)] #[serde(rename_all = "snake_case")] enum State { BelowHorizon, AboveHorizon, } #[derive(Debug,...
true
7fe02b02015433b311c1dc04c1cac4d30e737fb2
Rust
isgasho/modelator
/modelator/src/artifact/tla_trace.rs
UTF-8
2,525
3.265625
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
use crate::Error; pub(crate) type TlaState = String; #[derive(Debug, Clone, PartialEq, Eq)] pub struct TlaTrace { states: Vec<TlaState>, } impl TlaTrace { pub(crate) fn new() -> Self { Self { states: Vec::new() } } pub(crate) fn add(&mut self, state: TlaState) { self.states.push(stat...
true
ea801d6b8d39e4490e513eee193434b74e758c5d
Rust
richardpringle/advent-rust
/problem-5/src/main.rs
UTF-8
7,403
3.4375
3
[]
no_license
use std::{ error::Error, fs, ops::{Add, Mul}, }; fn get_input() -> Result<Vec<isize>, Box<dyn Error>> { let result = fs::read_to_string("input.txt")? .trim() .split(',') .map(|line| line.parse()) .collect::<Result<Vec<isize>, std::num::ParseIntError>>()?; Ok(result)...
true
a02e481532a5161626a423700c30d9191d4fc739
Rust
openacid/celeritasdb
/components/epaxos/src/qpaxos/test_instance_ids.rs
UTF-8
4,454
2.859375
3
[ "Apache-2.0" ]
permissive
use crate::qpaxos::InstanceId; use crate::qpaxos::InstanceIds; pub use std::cmp::Ordering; #[test] fn test_instance_ids_deref() { let ids = InstanceIds { ids: hashmap! { 1 => 2, 3 => 4, }, }; assert_eq!(ids[&1], 2); assert_eq!(ids[&3], 4); let mut ids = Ins...
true
f7389d4dc65746f9fec4d6c55c42a809a78890bf
Rust
siabard/sdl_isometric
/src/states/builder_state.rs
UTF-8
1,869
2.75
3
[]
no_license
use crate::constant::*; use crate::entities::*; use crate::map::*; use crate::states::*; use std::collections::HashMap; use std::collections::HashSet; use sdl2::mixer::Chunk; use sdl2::mixer::Music; use uuid::Uuid; /// 빌드 게임용 State pub struct BuilderState<'a> { texture_manager: TextureManager<'a>, entities:...
true
4c680de23ec894e015ea396bf938824fd44dc34e
Rust
acmcarther/next_space_coop
/cargo/vendor/nphysics3d-0.5.0/src/integration/body_exp_euler_integrator.rs
UTF-8
1,052
2.59375
3
[ "BSD-2-Clause" ]
permissive
//! Explicit Euler integrator. use ncollide::math::Scalar; use na::Transformation; use object::RigidBody; use integration::Integrator; use integration::euler; /// An explicit Euler integrator. /// /// Do not use this, prefer the `BodySmpEulerIntegrator` instead. pub struct BodyExpEulerIntegrator; impl BodyExpEulerIn...
true
4edc0b444d058b39bdedc2ca06a2918cc6a19944
Rust
TuserSheikh/advent-of-code-2015
/src/puzzles/day01.rs
UTF-8
775
3.15625
3
[]
no_license
use std::env; use std::fs; pub fn part_one() -> i32 { let file_path = env::var("CARGO_MANIFEST_DIR").unwrap() + "/input/01.txt"; let directions = fs::read_to_string(file_path).unwrap(); let mut floor = 0; for i in directions.chars() { match i { '(' => floor += 1, _ => f...
true
0b6eb79a3035d0074e2c59f62dafb57d22f5ed99
Rust
sivertjoe/Rust-Chess
/src/temp_move.rs
UTF-8
965
3.296875
3
[]
no_license
use pieces::Piece; use square::Square; use std::rc::Rc; use std::cell::RefCell; pub struct TempMove<'a> { pub piece: Option<Rc<RefCell<Piece<'a>>>>, pub old_pos: Option<Square> } impl<'a> TempMove<'a> { pub fn new() -> Self { TempMove { piece: None, old_pos: None ...
true
62c63a9cc109f2ccd1bbcba4e15c66dc5dbced51
Rust
alexanderkjall/adventofcode2020
/src/day4.rs
UTF-8
9,025
2.71875
3
[]
no_license
use anyhow::anyhow; use nom::branch::alt; use nom::bytes::complete::{tag, take_while}; use nom::combinator::map_res; use nom::lib::std::collections::HashMap; use nom::sequence::tuple; use nom::{AsChar, IResult}; struct Passport { ecl: Option<String>, pid: Option<String>, eyr: Option<String>, hcl: Optio...
true
218a3438a70b068513a4195374e683db40f261c0
Rust
mhmmdd/rust-playground
/rmain/src/main.rs
UTF-8
154
2.578125
3
[]
no_license
#[link(name = "cfib", kind="static")] extern { fn fib(n: i32) -> i32; } fn main() { let n = 7; println!("F({}) = {}", n, unsafe {fib(n)}); }
true
b5a4fbba25f9d36855de2a2467d2e4148d35d62a
Rust
u4ium/ray-tracer
/src/scene/object/parsers/common/whitespace.rs
UTF-8
446
2.765625
3
[]
no_license
use nom::{character::complete::multispace0, error::ParseError, sequence::terminated, IResult}; /// A combinator that takes a parser `inner` and produces a parser that also consumes /// trailing whitespace, returning the output of `inner`. pub fn tws<'a, F: 'a, O, E: ParseError<&'a str>>( inner: F, ) -> impl FnMut(...
true
3b6685b4e66294368e40bbf40df2aa829cdab53c
Rust
yamash723/til
/rust/TRPL_Second/ch14/example/src/lib.rs
UTF-8
238
3.828125
4
[]
no_license
//! # Example crate //! //! `example` crate is ....... /// Adds one to the number given. /// /// # Example /// /// ``` /// let five = 5; /// /// assert_eq!(6, example::add_one(5)); /// ``` pub fn add_one(x: i32) -> i32 { x + 1 }
true
e28fe505d74c1ae644109590e6212c979dc59647
Rust
pmatern/tcp_service_lib
/src/lib.rs
UTF-8
3,888
2.59375
3
[]
no_license
#![recursion_limit = "1024"] #[macro_use] extern crate error_chain; #[macro_use] extern crate log; extern crate byteorder; extern crate mio; extern crate slab; mod worker; mod connection; mod server; pub mod errors { use worker::MsgBuf; // Create the Error, ErrorKind, ResultExt, and Result types error_...
true
e3b42a92eff738bf89e0d7173b19bdcec1a789fd
Rust
sinesc/avec
/src/avec.rs
UTF-8
9,612
3.28125
3
[]
no_license
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{Mutex}; use std::ops::{Deref, DerefMut}; use std::cell::UnsafeCell; use std::{fmt, ptr, cmp}; /// Result of AVec::get(). While this reference is valid, the associated AVec will panic on /// concurrent writes. pub struct AVecReadGuard<'a, T: 'a> { owne...
true
23b0692dc998d8cd4cecba25eda2029e9885cdca
Rust
drmason13/ascii
/src/main.rs
UTF-8
939
2.65625
3
[]
no_license
use std::io::{Write}; use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor}; use image::{self, Luma}; use anyhow::{anyhow, Result}; use ascii::{AsciiArt, luma_to_ascii}; fn main() -> Result<()> { let filepath = std::env::args().skip(1).next().ok_or(anyhow!("No filename provided"))?; let...
true
abe04445de7648d6ce4481c1a28beb5bb4a94c21
Rust
kicad-cn/kicad-parser
/src/sch/model.rs
UTF-8
846
2.75
3
[]
no_license
use std::collections::{HashMap}; #[derive(Default)] pub struct SCHPageInfo { pub page_type: String, pub width: u64, pub height: u64, pub encoding: String, pub sheet:(u64,u64), pub is_portrait: bool, pub title_block:HashMap<String,String> } #[derive(Default)] pub struct SCHTitleBlocks { ...
true
2715bac394b58b12bc297093dad77f4d8bf34753
Rust
Azure/azure-sdk-for-rust
/services/mgmt/healthbot/src/package_2022_08_08/models.rs
UTF-8
19,722
2.515625
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
#![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::de::{value, Deserializer, IntoDeserializer}; use serde::{Deserialize, Serialize, Serializer}; use std::str::FromStr; #[doc = "Available operations of the service"] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)] pub struct Availabl...
true
0e2f2c8491db2fee32bed7ac5f70643a143ddbd2
Rust
starship/starship
/src/configs/character.rs
UTF-8
1,043
2.515625
3
[ "ISC" ]
permissive
use serde::{Deserialize, Serialize}; #[derive(Clone, Deserialize, Serialize)] #[cfg_attr( feature = "config-schema", derive(schemars::JsonSchema), schemars(deny_unknown_fields) )] #[serde(default)] pub struct CharacterConfig<'a> { pub format: &'a str, pub success_symbol: &'a str, pub error_symb...
true
dbf67055a1c540a954eb42a12223743e560e7898
Rust
Hinogary/knapsack
/src/solvers/tabusearch.rs
UTF-8
5,722
2.65625
3
[]
no_license
use super::{sort_by_cost_weight_ratio, Item, Problem, Solution, SolverTrait, ratio}; use arrayvec::ArrayVec; use itertools::izip; #[derive(Debug, Clone)] pub struct TabuSearchSolver { pub memory_size: usize, pub iterations: usize, } fn cost_weight(state: &[bool], items: &[Item]) -> (u32, u32) { state ...
true
872b593592b95c9871011aedd8e27b8fe2d10a01
Rust
U007D/k210_pac
/src/rtc/alarm_time.rs
UTF-8
2,615
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = "Reader of register alarm_time"] pub type R = crate::R<u32, super::ALARM_TIME>; #[doc = "Writer for register alarm_time"] pub type W = crate::W<u32, super::ALARM_TIME>; #[doc = "Register alarm_time `reset()`'s with value 0"] impl crate::ResetValue for super::ALARM_TIME { type Type = u32; #[inline(always...
true
783afad5fc46c546399fabc1cf921a60ff641ee5
Rust
jstzwj/justscript
/src/syntax/ast.rs
UTF-8
3,397
3.046875
3
[]
no_license
use std::boxed::Box; #[derive(Debug)] pub struct VariableDeclaration { pub identifier: String, pub initializer: AssignmentExpression, } impl VariableDeclaration { pub fn new() -> VariableDeclaration { VariableDeclaration { identifier: String::new(), initializer: AssignmentE...
true
6ceb9dffd0b9c9e838490d25defd69d9d53a91b8
Rust
dalalsunil1986/spinel
/src/arch/mod.rs
UTF-8
1,517
2.5625
3
[ "MIT" ]
permissive
#[cfg(target_arch = "x86_64")] pub mod amd64; cfg_if::cfg_if! { if #[cfg(target_arch = "x86_64")] { pub use amd64::central::arch_info; pub use amd64::central::init::arch_init; } } /// Reexports for the virtual memory subsystem pub mod memory { #[derive(Debug)] pub enum MapError { ...
true
d8d64417505238c9c36ce6743cb97c934ea69fea
Rust
pchampin/sophia_rs
/xml/src/parser.rs
UTF-8
2,990
2.765625
3
[ "LicenseRef-scancode-cecill-b-en", "CECILL-B" ]
permissive
//! Parser for the [RDF/XML] concrete syntax of RDF, //! based on [`rio_xml`]. //! //! [RDF/XML]: https://www.w3.org/TR/rdf-syntax-grammar/ use rio_xml::RdfXmlParser as RioRdfXmlParser; use sophia_api::parser::TripleParser; use sophia_iri::Iri; use sophia_rio::parser::*; use std::io::BufRead; /// N-Triples parser bas...
true
e5e56df793109b46a2265e8ecf1fc77dfcc4c7d2
Rust
mtvu/influxdb_iox
/iox_object_store/src/lib.rs
UTF-8
38,254
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
//! Wraps the object_store crate with IOx-specific semantics. The main responsibility of this crate //! is to be the single source of truth for the paths of files in object storage. There is a //! specific path type for each IOx-specific reason an object storage file exists. Content of the //! files is managed outside ...
true
693968e8f81a5573e9f07a2e859cd1817fd795a0
Rust
zz85/packet_radar
/src/tcp.rs
UTF-8
13,059
2.5625
3
[]
no_license
use std::cmp; use std::collections::HashMap; use std::sync::RwLock; use tls_parser::{ parse_tls_encrypted, parse_tls_extensions, parse_tls_plaintext, TlsExtension, TlsMessage, TlsMessageHandshake, TlsVersion, }; use itertools::Itertools; use std::time::{Duration, Instant}; use md5; use tls_parser::tls::*; u...
true
311b5d7c571a2a97a3aa680499ffe863aaafe9e2
Rust
spbots/euler-rs
/src/euler/prime_utils.rs
UTF-8
2,003
3.578125
4
[]
no_license
use super::bit_vector::BitVector; pub fn primes_below(n: u64) -> Vec<u64> { /* from https://stackoverflow.com/questions/1042717/ is-there-a-way-to-find-the-approximate-value-of-the-nth-prime/1069023#1069023 Wikipedia gives the following upper bound for n >= 6 p_n <= n log n + n log log n (1) ...
true
8802f2b10c3c2703d10b7645faca84cf411cd0b2
Rust
librallu/dogs-color
/src/solvers/cgshop/cgshop_aog.rs
UTF-8
13,179
2.703125
3
[]
no_license
use std::rc::Rc; use bit_set::BitSet; use ordered_float::OrderedFloat; use crate::{cgshop::CGSHOPInstance, color::{ColoringInstance, Solution}}; /** Admissible Orientation Greedy algorithm for the CGSHOP challenge Sorts the segments by orientation and apply a simple coloring algorithm. */ pub fn cgshop_aog(inst:Rc<...
true
6a93ad80e0a5ef7cdf651944cc9b28d09e2040a9
Rust
Lapz/lox
/src/object.rs
UTF-8
2,716
3.4375
3
[]
no_license
use std::fmt::{self, Display}; use std::ops::Deref; use std::mem; pub type RawObject = *mut Object; #[derive(PartialEq, Debug, Clone, Copy)] #[repr(C)] pub enum ObjectType { String, } #[derive(Debug, Clone)] #[repr(C)] pub struct Object { pub ty: ObjectType, pub next: RawObject, } #[derive(Debug, Clone)...
true
700de2072bb8de1992f7a23dc5811a27c683658c
Rust
vinnyhoward/til
/rust/toy-problems/basic-arithmetic/multiplication_table_for_number.rs
UTF-8
1,387
4.03125
4
[ "MIT" ]
permissive
// Multiplication table for number // Your goal is to return multiplication table for number that is always an integer from 1 to 10. // For example, a multiplication table (string) for number == 5 looks like below: // P. S. You can use \n in string to jump to the next line. // Note: newlines should be added between...
true
8e70e198331a84761b9ec6581f1be663d600a228
Rust
w23/alacritty
/alacritty/src/daemon.rs
UTF-8
2,079
2.640625
3
[ "Apache-2.0" ]
permissive
use std::ffi::OsStr; use std::fmt::Debug; use std::io; #[cfg(not(windows))] use std::os::unix::process::CommandExt; #[cfg(windows)] use std::os::windows::process::CommandExt; use std::process::{Command, Stdio}; use log::{debug, warn}; #[cfg(windows)] use winapi::um::winbase::{CREATE_NEW_PROCESS_GROUP, CREATE_NO_WINDO...
true
ad5348da2987fc0d855a461954bdca585c97d33b
Rust
kayoumido/Secure-Auth
/src/db.rs
UTF-8
542
2.671875
3
[]
no_license
/*! * Database configurations * * # Author * Doran Kayoumi <doran.kayoumi@heig-vd.ch> */ pub mod models; pub mod repository; pub mod schema; use diesel::prelude::*; use dotenv::dotenv; use std::env; /// Establish a connection to a SQLite database with the url set in a `.env` file fn establish_connection() -> Sq...
true
e0b71784ae6ac21e8c2cd80293ad4ec780416e2f
Rust
Fahien/exrust
/the-book/common-collections/src/exvec.rs
UTF-8
981
3.6875
4
[ "MIT" ]
permissive
fn mean(list: &Vec<i32>) -> f32 { let mut sum = 0; for v in list { sum += v; } sum as f32 / list.len() as f32 } fn median(list: &Vec<i32>) -> f32 { let mut temp = list.clone(); temp.sort(); if list.len() % 2 == 0 { let i = list.len() / 2; let n = temp[i] as f32; let d = temp[i - 1] as f32; (n + d) / 2...
true
c5febbc35221058ac8f7acc1c5c34201bc775c8f
Rust
Baoyx007/LeetCode-Rust
/48.旋转图像.rs
UTF-8
446
2.90625
3
[]
no_license
impl Solution { fn swap(matrix: &mut Vec<Vec<i32>>, i: usize, j: usize) { let tmp = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = tmp; } pub fn rotate(matrix: &mut Vec<Vec<i32>>) { let len = matrix.len(); if len <= 1 { return; } for i in 0..len { for j in i.....
true
aa296366e692977b3e1e73e2fe47e10ac14b623d
Rust
alesbolka/advent2019
/src/task_10/map.rs
UTF-8
6,479
3.140625
3
[]
no_license
use super::asteroid::Asteroid; use std::f64::consts::PI; use std::collections::HashMap; pub struct Map { asteroids: Vec<Asteroid>, best: usize, station: usize, } impl Map { pub fn parse (raw: &str) -> Map { let mut map = Map{ asteroids: vec![], station: 0, b...
true
46064ae4e05e653ffabbcb3e5b4e82318e8f1c5c
Rust
gwenn/sqlpop
/src/ast/mod.rs
UTF-8
13,946
2.640625
3
[]
no_license
//! Abstract Syntax Tree #[derive(Clone, Debug, PartialEq, Eq)] pub enum Cmd { Explain(Stmt), ExplainQueryPlan(Stmt), Stmt(Stmt), } #[derive(Clone, Debug, PartialEq, Eq)] pub enum Stmt { // table name, body AlterTable(QualifiedName, AlterTableBody), // object name Analyze(Option<QualifiedN...
true
a58c4918671e195b55529f36c45526c29fd53f87
Rust
Cryptobyte/dirstructcopy
/src/main.rs
UTF-8
3,637
2.953125
3
[ "MIT" ]
permissive
use std::fs; use termion::color; use walkdir::WalkDir; use question::{ Answer, Question }; use clap::{ AppSettings, Clap }; extern crate question; extern crate termion; #[derive(Clap)] #[clap(version = "1.0", author = "Cryptobyte <me@cryptobyte.dev>")] #[clap(setting = AppSettings::ColoredHelp)] struct Opts { #[...
true
d6df7d0bdcbba72207f97bf42aa633c59f7e1d7b
Rust
Dam1403/Rust-Blackjack
/src/black_jack_tools.rs
UTF-8
5,039
3.453125
3
[]
no_license
use std::fmt; use rand::thread_rng; use rand::seq::SliceRandom; use crate::player_strategies::{get_player_strat, get_betting_strat}; //0 - 12 Heart //13 - 25 Diamond //26 - 38 Club //39 - 51 Spade #[derive(Copy, Clone)] pub enum Suit{ Heart, Diamond, Club, Spade } #[derive(Copy, Clone)] pub enum Fac...
true
f52b6f1fdc136cf47090c8c26714f1bb817a4dff
Rust
forbesmyester/linked-in-learning-first-look-rust
/guessing_game/src/main.rs
UTF-8
917
3.421875
3
[]
no_license
extern crate rand; use std::io; use rand::Rng; use std::cmp::Ordering; fn main() { println!("Please input your guess: "); let secret_number = rand::thread_rng().gen_range::<u8>(1, 101); loop { let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Could n...
true
522f6e7eb2b4bdbf04537fd2625d4e71ded2e804
Rust
hkbudb/vchain-plus
/src/chain/trie_tree/proof/sub_tree.rs
UTF-8
655
2.65625
3
[ "Apache-2.0" ]
permissive
use crate::{ chain::trie_tree::TrieNodeId, digest::{Digest, Digestible}, }; use serde::{Deserialize, Serialize}; #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub(crate) struct TrieSubTree { pub(crate) node_id: Option<TrieNodeId>, pub(crate) nibble: String, pub(crate) node_hash: Digest, ...
true
3b0fc7862ad55e974f33745cb8d8c395796b96c9
Rust
wezm/cc2650
/src/cpu_tpiu/sspsr.rs
UTF-8
4,139
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::SSPSR { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get() } } } #[doc = r" Value of the field"] pub struct RESERVED4R { bits: u32, } impl RESE...
true
7a3f746875378bfaf43ba820b4c7a409b78617be
Rust
thenozzl3/oddsandends
/rust_things/mio-listener/src/main.rs
UTF-8
5,054
2.703125
3
[]
permissive
use getopts::Options; use std::env; use std::str; #[macro_use] extern crate log; //#[macro_use] log; use mio::*; use mio::tcp::*; use bytes::{ByteBuf, MutByteBuf}; use std::io; use std::io::Write; use std::net::SocketAddr; use std::str::FromStr; use std::collections::*; ////use slab; struct WebSocketServer { socket:...
true
7bc201ef392d96cd396208b0575d5303cd2455ab
Rust
elsuizo/ndarray-linalg
/src/lapack/cholesky.rs
UTF-8
2,054
2.609375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Cholesky decomposition use lapacke; use crate::error::*; use crate::layout::MatrixLayout; use crate::types::*; use super::{into_result, UPLO}; pub trait Cholesky_: Sized { /// Cholesky: wrapper of `*potrf` /// /// **Warning: Only the portion of `a` corresponding to `UPLO` is written.** unsafe fn...
true
5eb5a93875d324462a84dfcdd0ba6a960fd4b78d
Rust
wezm/dslite2svd
/crates/tm4c129x/src/emac0/mmcrxris/mod.rs
UTF-8
3,531
2.625
3
[ "0BSD", "BSD-3-Clause" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } impl super::MMCRXRIS { #[doc = r" Reads the contents of the register"] #[inline] pub fn read(&self) -> R { R { bits: self.register.get() } } } #[doc = r" Value of the field"] pub struct GBFR { bits: bool, } impl GBFR {...
true
8b8adc49ae201098666a33561b082856ea584950
Rust
phigley/taxi
/src/doormax/effect.rs
UTF-8
4,098
3.03125
3
[]
no_license
use std; use std::fmt; use crate::state; use crate::state::State; use crate::world::World; pub enum Error { InvalidState(state::Error), } impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::InvalidState(ref state_error) => { ...
true
f2fd78bb843387637383b153e0084e9bc23cfc20
Rust
brn/fss
/api/src/utils/storage.rs
UTF-8
2,007
3.5
4
[]
no_license
use crate::error::FileStorageError; use std::fs::{remove_file, File}; use std::io::{BufReader, BufWriter}; use std::io::{Read, Write}; use std::vec::Vec; pub type StorageResult<T> = Result<T, FileStorageError>; /// File entity maanger. /// This struct has storage path of the file entity. #[derive(Debug, Clone)] pub s...
true
d97e20fa4bc647474668d8f675bbd3ce1682ce72
Rust
vercel/next.js
/packages/next-swc/crates/core/src/top_level_binding_collector.rs
UTF-8
3,497
2.53125
3
[ "MIT" ]
permissive
use std::hash::Hash; use turbopack_binding::swc::core::{ common::{collections::AHashSet, SyntaxContext}, ecma::{ ast::{ ClassDecl, FnDecl, Ident, ImportDefaultSpecifier, ImportNamedSpecifier, ImportStarAsSpecifier, ModuleItem, ObjectPatProp, Param, Pat, Stmt, VarDeclarator, ...
true
f8bb06cbaf90f478b6ae8121802b1047180f487e
Rust
glurbi/rustwars
/square-into-squares-protect-trees/src/lib.rs
UTF-8
1,411
3.453125
3
[]
no_license
// https://www.codewars.com/kata/square-into-squares-protect-trees/ #[allow(dead_code)] fn decompose(n: i64) -> Option<Vec<i64>> { //println!("n:{}", n); let mut v: Vec<i64> = vec![]; match decompose_rec(n, n, &mut v) { Some(v) => Some(v.iter().rev().map(|x| *x).collect()), None => None, ...
true
894f4d5c0fb52c7a48a9ea0bcb721310cca04141
Rust
CavHack/EinsteinDB
/ einsteindb-sys(0).einsteindb-sys/causet-algebrizer/brane_options/src/codec/mysql/json/json_depth.rs
UTF-8
3,403
2.53125
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//Copyright 2021-2023 WHTCORPS INC ALL RIGHTS RESERVED. APACHE 2.0 COMMUNITY EDITION SL // AUTHORS: WHITFORD LEDER // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file File except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/...
true
4dbd6077e0f49b74fe610f3d5f8d284120300b5e
Rust
gsingh93/trace
/examples/example_prefix.rs
UTF-8
431
2.578125
3
[ "MIT" ]
permissive
use trace::trace; trace::init_depth_var!(); fn main() { foo(1, 2); } #[trace] fn foo(a: i32, b: i32) { println!("I'm in foo!"); bar((a, b)); } #[trace(prefix_enter = "[ENTER]", prefix_exit = "[EXIT]")] fn bar((a, b): (i32, i32)) -> i32 { println!("I'm in bar!"); if a == 1 { 2 } else ...
true
ca6bc4f95570a99d09bc3a4a5f9da7381c6cde0a
Rust
Kimundi/long_strings_without_repeats
/src/lib.rs
UTF-8
1,894
3.203125
3
[]
no_license
pub mod rust_naive; pub mod cpp_naive; pub mod rust_unsafe; /// Create example in paper by mapping a = 0, b = 1, c = 2 ... pub fn new_paper_example_string() -> Vec<u8> { "cabageheadbag".chars().map(|c| (c as u8) - b'a').collect() } /// returns bit at index i fn bit(i: u8, byte: u8) -> u8 { (byte >> i) & 1 } ...
true
50c09961df53d18fce8c8329afa003e4d31b2d2e
Rust
isgasho/ecc_calc
/src/ecc/ecc_value.rs
UTF-8
1,097
3.625
4
[]
no_license
extern crate num; use self::num::{BigInt, Integer}; /// Value wil be defined as /// - a point on curve /// - infinity (not a point) #[derive(Debug, Clone)] pub enum ECCValue { Finite { x: BigInt, y: BigInt }, Infinity, } /// This is supposed to replace the current `ECCValue`. /// Calculating ECCValue::Finate ev...
true
402f289a3f2ea0ee3c0a2a05d32efbd68e92f424
Rust
Lemonzyy/building-blocks
/crates/building_blocks_storage/src/octree/clipmap.rs
UTF-8
15,138
2.90625
3
[ "MIT" ]
permissive
use crate::prelude::{ChunkKey, ChunkKey3, ChunkUnits, OctreeNode, OctreeSet, VisitStatus}; use building_blocks_core::prelude::*; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub struct ClipMapConfig3 { /// The number of levels of detail. num_lods: u8, /// The radius (in chunks) of a clipbox at any level o...
true
a547bd3bfd06268bb9008c12bc4b3d7061afaec4
Rust
Azure/azure-sdk-for-rust
/services/mgmt/sphere/src/package_2022_09_01_preview/models.rs
UTF-8
56,480
2.5625
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
#![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::de::{value, Deserializer, IntoDeserializer}; use serde::{Deserialize, Serialize, Serializer}; use std::str::FromStr; #[doc = "Allow crash dumps values."] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[serde(remote = "AllowCrashDumpCollec...
true
7ba0c03caf5b8aa4ee5b3d98b6e5ec1dc2e4bff8
Rust
thodges314/Rust
/learn-rust-in-7-days/day02/intro/src/main.rs
UTF-8
868
4.21875
4
[]
no_license
use std::ops::Add; // lets us override the Add (+) function for the Point struct #[derive(Debug, Copy, Clone)] // by derriving Copy and Clone, Add will *copy* self and other rather than consume them // by derriving Debug we can print with {:?} struct Point { x: i32, y: i32, } impl Add for Point { type Out...
true
1771d3ee2f25f7d7ed1a0c1ff85b238fed2c683a
Rust
pavlov-dmitry/photometer
/src/db/mailbox.rs
UTF-8
6,539
2.6875
3
[]
no_license
use mysql; use mysql::conn::pool::{ PooledConn }; use mysql::value::{ from_row, ToValue, Value }; use time; use types::{ Id, CommonResult, EmptyResult, MailInfo, CommonError }; use std::fmt::Display; use parse_utils::{ GetMsecs }; use database::Database; pub trait DbMailbox { /// посылает письмо одному...
true
312c5e268041b4ab29d52b5956aee810bc85a8cf
Rust
7db9a/scabere
/eosio-rust/crates/eosio_rpc/src/clients/browser.rs
UTF-8
1,938
2.53125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::error::Error; use crate::Client; use futures::future::{self, Future}; use js_sys::Promise; use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use wasm_bindgen_futures::JsFuture; use web_sys::{Request, RequestInit, RequestMode, Response, Window}; pub struct WebSysCli...
true
ad164241b7a86f0fae49fe8135fa098711b312b7
Rust
Razaekel/noise-rs
/examples/texturewood.rs
UTF-8
2,344
2.75
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate noise; use noise::{utils::*, *}; mod utils; fn main() { // Base wood texture. Uses concentric cylinders aligned on the z-axis, like a log. let base_wood = Cylinders::new().set_frequency(16.0); // Basic Multifractal noise to use for the wood grain. let wood_grain_noise = BasicMulti::<Per...
true
9eb80320dab9e8db58cb663546c65f25001bc774
Rust
Diggsey/srcl
/src/bigint/ubigint.rs
UTF-8
3,156
2.921875
3
[]
no_license
use std::cmp::{self, Ordering, PartialEq, PartialOrd, Eq, Ord}; use super::algorithms::{self, Limb, LIMB_BITS}; use super::montgomery; use utils::slice_ext::SliceExt; #[derive(Clone)] pub struct UBigInt { limbs: Box<[Limb]>, bits: u32 } impl UBigInt { pub fn new(bits: u32) -> Self { assert!(bits ...
true
f45fcb0e206bfc222cc10e928d340c58c7ca9aeb
Rust
enso-org/enso
/build/build/src/config.rs
UTF-8
5,722
3
3
[ "AGPL-3.0-only", "Apache-2.0", "AGPL-3.0-or-later" ]
permissive
use crate::prelude::*; use byte_unit::Byte; use ide_ci::program; use ide_ci::programs; use semver::VersionReq; /// Load the build configuration, based on the `build-config.yaml` and `.node-version` files in /// the repo root. pub fn load() -> Result<Config> { let yaml_text = include_str!("../../../build-config....
true
ba64aa05941bc42379fb11795b64c8b651349100
Rust
sajid-munawar/Rust-learning
/arguments_parameters/src/main.rs
UTF-8
383
4
4
[]
no_license
fn main() { // println!("Hello, world!"); let (value,value_1)=square(2,5.5); println!("{},{}",value,value_1); } fn square(x:u32,y:f64) -> (u32,f64) { let result=x*x; let result_1=y*y; //result //there should not be a semicolon here //above is for one value if we need two we pass a tuple ...
true
02d0be9a4d701d5df41684504ef284a078215259
Rust
chalme/coco
/src/infrastructure/git/git_log_parser.rs
UTF-8
10,768
2.546875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::collections::HashMap; use regex::{Captures, Regex}; use crate::domain::git::coco_commit::FileChange; use crate::domain::git::CocoCommit; lazy_static! { static ref COMMIT_INFO: Regex = Regex::new( r"(?x) \[(?P<commit_id>[\d|a-f]{5,12})\] \s(?P<author>.*?)<(?P<email>.*?)> \s(?P<date>\d{10}) \s\((?...
true
50e851890a2a05b8618535609b49d157b54fbd5c
Rust
paritytech/substrate
/client/rpc-spec-v2/src/transaction/event.rs
UTF-8
12,236
2.796875
3
[ "GPL-3.0-or-later", "Classpath-exception-2.0", "Apache-2.0", "GPL-1.0-or-later", "GPL-3.0-only" ]
permissive
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Softwa...
true
ee1c915735878bf62754a950e8cce3c568618156
Rust
DelSkayn/rquickjs
/core/src/context/ctx.rs
UTF-8
19,041
2.703125
3
[ "MIT" ]
permissive
use std::{ convert::TryInto, ffi::{CStr, CString}, fs, mem, path::Path, ptr::NonNull, }; #[cfg(feature = "futures")] use std::future::Future; #[cfg(feature = "futures")] use crate::AsyncContext; use crate::{ markers::Invariant, qjs, runtime::raw::Opaque, Context, Error, FromJs, Function, IntoJ...
true
03c7b4634ae9e53baca37db06bba19b6f0732146
Rust
chridou/metrix
/src/instruments/other_instruments/multi_meter.rs
UTF-8
4,838
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::time::{Duration, Instant}; use crate::instruments::meter::{MeterRate, MeterSnapshot}; use crate::instruments::{BorrowedLabelAndUpdate, Instrument, Meter, Update, Updates}; use crate::snapshot::{ItemKind, Snapshot}; use crate::util; use crate::{Descriptive, HandlesObservations, Observation, PutsSnapshot}; pub...
true
80cfb0e95a0e27c79bf7fb4474abfc93cf69670b
Rust
pwoolcoc/tantivy
/src/schema/field.rs
UTF-8
725
2.96875
3
[ "MIT" ]
permissive
use common::BinarySerializable; use std::io; use std::io::Read; use std::io::Write; /// `Field` is actually a `u8` identifying a `Field` /// The schema is in charge of holding mapping between field names /// to `Field` objects. /// /// Because the field id is a `u8`, tantivy can only have at most `255` fields. /// Val...
true
b63ffae90232ac4da14168ce2901f83f26d9d461
Rust
tjwilson90/turbo-hearts
/api/src/game_phase.rs
UTF-8
2,810
3.203125
3
[]
no_license
use crate::{ChargingRules, PassDirection, Seat}; use std::mem; #[repr(u8)] #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum GamePhase { PassLeft, ChargeLeft, PlayLeft, PassRight, ChargeRight, PlayRight, PassAcross, ChargeAcross, PlayAcross, ChargeKeeper1, PassKeeper, ...
true
2e743693ae25d4b3ec0ba7b24af0435674aa858d
Rust
erikdesjardins/jsssa
/src/opt_ast/tests/merge_vars.rs
UTF-8
1,088
2.515625
3
[ "MIT" ]
permissive
use crate::opt_ast::merge_vars; case!(basic, || merge_vars::MergeVars, r#" var x; var y; var z; let a; let b; let c; const d; const e; const f; "#, @r###" var x, y, z; let a, b, c; const d, e, f; "###); case!(basic_values, || merge_vars::MergeVars, r#" var x; var y = 1; ...
true
7bd2599e9190d21058e90c7ee141597945da61fb
Rust
teiesti/fussel
/src/tree/print.rs
UTF-8
917
3.1875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::{ Node, traverse::{Visitor}, }; pub(crate) struct Printer { level: usize, } impl Printer { pub(crate) fn new() -> Self { Self { level: 0 } } } impl Visitor for Printer { fn enter(&mut self, node: Node) -> bool { for _ in 0..self.level { print!(" "); ...
true
0a396542643cf2811386a213d2ffe00eccad3f8c
Rust
oconnor0/system-zero
/core/src/main.rs
UTF-8
2,278
2.515625
3
[ "ISC" ]
permissive
// Copyright (c) 2016, Matthew O'Connor extern crate system_zero_core; use system_zero_core::*; use system_zero_core::ast::Normalize; fn main() { // use ast::*; // // let codata = Const::Codata; // println!("{:?}", codata); // let a = Var::new("a", 0); // let x = Var::new("x", 0); // let expra = var(&a)...
true
41901bfa228f798f265c96d908fe45ecc0f8f0fb
Rust
sgysh/laurel
/src/builtin/mod.rs
UTF-8
414
2.609375
3
[ "MIT" ]
permissive
mod ps; use alloc::string::String; use console; pub fn run_command(mut command: String) -> String { if !command.is_empty() { match command.as_str() { ":" => {} "ps" => ps::run(), _ => { console::write_console("\r\n"); console::write_conso...
true
b4fa3300c63d516b15e5475048d8a57125062b8c
Rust
reeFridge/side-run-rs
/src/connection.rs
UTF-8
4,418
3.046875
3
[]
no_license
use std::net::TcpStream; use byteorder::{ByteOrder, BigEndian}; use std::time::Duration; use scenes::common::*; use std::io::{Read, Write}; use piston_window::types::Color; use piston_window::math::Vec2d; pub type NetToken = usize; pub struct Connection { pub socket: TcpStream, pub token: NetToken } pub enum...
true
c91092b25281d06744805c7fabf70eadbc82441f
Rust
rusterlium/juicy
/native/juicy_native/src/tree_spec/walker.rs
UTF-8
4,633
2.921875
3
[]
no_license
use super::{Spec, NodeId, ValueType}; use ::rustler::{NifEnv, NifTerm, NifEncoder}; use ::rustler::types::binary::OwnedNifBinary; use std::io::Write; #[derive(Debug)] pub enum PathEntry { Key(Vec<u8>), /// The index field is 1 indexed so that 0 can be used as a sentinel value. /// This is a massive hack a...
true
e285f54874ef8ad08c08055d83367c6a2771a5fe
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc127/src/bin/b.rs
UTF-8
240
2.515625
3
[]
no_license
use proconio::input; fn main() { input! { r: usize, d: usize, x_2000: usize, }; let mut x = x_2000; for _ in 1..=10 { x = r * x - d; let ans = x; println!("{}", ans); } }
true
a9266adfd392522e38d4f8d0c98366c3563ea5bc
Rust
jswrenn/Rust-X11
/lib/refined_type/src/lib.rs
UTF-8
3,794
2.65625
3
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive" ]
permissive
#![feature(macro_rules)] #[macro_export] macro_rules! refined_type( ($(use $USING_IDS:ident);*; $(#[$ATTRIBUTES:meta])* refined $A:ident = $B:ident where |$ID:ident:$C:ty| -> $($PROPERTIES:ident <=> $PREDICATES:expr),+) => ( #[change_ident_to(snake_case($A))] pub mod $A...
true
dbe6d3e4c76efb1ac8bb47f6db599ecc7cd5e9c9
Rust
kaz9120/line-bot-sdk-rust
/src/objects/narrowcast/recipient.rs
UTF-8
1,090
2.765625
3
[ "Apache-2.0" ]
permissive
use serde_derive::Serialize; /// # Details /// Please read. /// <https://developers.line.biz/ja/reference/messaging-api/#narrowcast-recipient> #[derive(Serialize, Debug)] pub struct Recipient { #[serde(flatten)] pub r#type: RecipientType, } #[derive(Serialize, Debug)] #[serde(tag = "type")] pub enum Recipient...
true
68460b9fc010fd0c3c6f82806368a3dc7e19c146
Rust
Asethon/coding_game
/coders-strike-back.rs
UTF-8
6,076
2.953125
3
[ "MIT" ]
permissive
use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } #[derive(Debug, Copy, Clone)] pub struct Pod { x: i32, y: i32, vx: i32, vy: i32, angle: i32, next_checkpoint_id: usize, thrust: i32, } impl Pod { fn new( x: i32, ...
true
e467fc5ece23c159a9a2c67ec8e155a267616c7b
Rust
diecast/paginate
/src/lib.rs
UTF-8
3,616
2.828125
3
[]
no_license
extern crate typemap; extern crate diecast; use std::sync::Arc; use std::path::PathBuf; use std::collections::HashMap; use std::ops::Range; use diecast::{Bind, Item, Handle}; // TODO: should this just contain the items itself instead of the range? #[derive(Clone)] pub struct Page { pub first: (usize, Arc<PathBuf...
true
0e04f17147f7588c1564a73e6c87674ccd0eeeaa
Rust
sucaba/miniml
/ast/src/exprs.rs
UTF-8
4,096
3.125
3
[]
no_license
use Type; use Ident; use std::fmt::{self, Write}; pub enum Expr { Var(Ident), Literal(Literal), ArithBinOp(Box<ArithBinOp>), CmpBinOp(Box<CmpBinOp>), If(Box<If>), Fun(Box<Fun>), LetFun(Box<LetFun>), LetRec(Box<LetRec>), Apply(Box<Apply>), } macro_rules! into_expr { ($id:ident)...
true
2c55d0a0ee9d7340103074f4166474fd6dcf4499
Rust
zhanglei/celeritasdb
/components/epaxos/src/qpaxos/display.rs
UTF-8
2,768
2.90625
3
[ "Apache-2.0" ]
permissive
use crate::qpaxos::BallotNum; use crate::qpaxos::Command; use crate::qpaxos::Instance; use crate::qpaxos::InstanceId; use crate::qpaxos::InstanceIdVec; use crate::qpaxos::OpCode; use std::fmt; trait ToStringExt { fn tostr_ext(&self) -> String; } impl<T: ToStringExt> ToStringExt for Option<T> { fn tostr_ext(&s...
true
a8785991b887a22a85ffb0da91ca62818d716f67
Rust
sgx-test/p256-sgx
/ecdsa/src/asn1.rs
UTF-8
10,907
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Support for ECDSA signatures encoded as ASN.1 DER. // Adapted from BearSSL. Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>. // Relicensed under Apache 2.0 + MIT (from original MIT) with permission. // // <https://www.bearssl.org/gitweb/?p=BearSSL;a=blob;f=src/ec/ecdsa_atr.c> // <https://www.bearssl.org/gitweb...
true
95629f1c5e6380f7a549a0a5063a13238ed51aa8
Rust
pbzweihander/yaircc
/gen/parser.rs
UTF-8
1,658
3.640625
4
[ "Apache-2.0", "MIT", "Zlib" ]
permissive
fn capfirst(s: &str) -> String { s[..1].to_ascii_uppercase() + &s[1..].to_ascii_lowercase() } pub struct Code { pub code: String, pub value: String, pub is_reply: bool, pub is_error: bool, pub format_code: String, pub format_value: String, } impl Code { pub fn from_iter<'a>(mut iter: i...
true
c662e2f6a1172d830bb7e217393b69bbef0716da
Rust
chinedufn/psd
/src/psd_channel.rs
UTF-8
12,069
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::sections::image_data_section::ChannelBytes; use crate::sections::PsdCursor; use thiserror::Error; pub trait IntoRgba { /// Given an index of a pixel in the current rectangle /// (top left is 0.. to the right of that is 1.. etc) return the index of that pixel in the /// RGBA image that will be ge...
true
ed9f7e82e93441bd765ca2a9e11991ed4fe39146
Rust
qwelyt/advent-of-code
/2022/src/day13/mod.rs
UTF-8
8,124
3.09375
3
[]
no_license
use std::cmp::{max, Ordering}; use crate::util::{lines, time, vecs}; pub fn day13() { println!("== Day 13 =="); let input = "src/day13/input.txt"; time(part_a, input, "A"); time(part_b, input, "B"); } fn part_a(input: &str) -> usize { let pairs = vecs(&lines(input)); pairs.iter().enumerate() ...
true
f00c6e64dc8724aecea5788312d2a29970356924
Rust
GaloisInc/balboa
/balboa/rewriter/src/read_state.rs
UTF-8
14,678
2.96875
3
[ "MIT", "BSD-3-Clause" ]
permissive
use crate::{IncomingRewriter, StreamChangeData}; /// Is a given read operation "peek" or "consume"? #[derive(Clone, Copy)] pub enum ReadIsPeek { /// A read operation which advances the buffer, and reads from it. ConsumingRead, /// A read operation which reads from the buffer but doesn't advance it. Pe...
true
eb1bf293e3d1c85dd859f074af25cb22df405b04
Rust
gorilskij/rust_turing_machine
/src/turing_machine/entry.rs
UTF-8
1,109
3.4375
3
[]
no_license
use bimap::BiMap; use std::hash::Hash; /// A very limited implementation of the entry API for bimap::BiMap. pub enum LEntry<'a, L, R> { Vacant(&'a mut BiMap<L, R>, L), Occupied(&'a mut BiMap<L, R>, L), } impl<'a, L, R> LEntry<'a, L, R> where L: Eq + Hash, R: Eq + Hash, { pub fn or_insert(self, val...
true
b1a1b09a0e6fb5a4a7963453cf14e796497b64ef
Rust
ruchira/RustExercisesSolutions
/largest_clonable/src/main.rs
UTF-8
404
3.578125
4
[ "MIT" ]
permissive
fn largest<T: PartialOrd + Clone>(list: &[T]) -> T { let mut largest = list[0].clone(); for item in list.iter() { if item > &largest { largest = item.clone(); } } largest } fn main() { let string_list = vec![String::from("alembic"), String::from("crucible")]; let ...
true
13d0e3b8adc046c4efa7ebf1789a1c918f0ab8b8
Rust
twetzel59/vista
/src/buffers.rs
UTF-8
2,344
3.25
3
[ "Unlicense" ]
permissive
use std::mem; use gl; use gl::types::*; use gl_object::{GlEnum, GlObject}; /// A VBO, or vertex buffer object pub struct Buffer { id: GLuint, kind: Kind, } impl Buffer { /// Creates a new VBO pub fn new(kind: Kind) -> Buffer { let mut id = 0; unsafe { gl::GenBuffers(1, &mut...
true
0ec09c0ae968dad29ea6530ca97986a27957380d
Rust
cbarrete/candle
/src/main.rs
UTF-8
1,006
3.078125
3
[]
no_license
use std::io::Write; const BRIGHTNESS_PATH: &str = "/sys/class/backlight/intel_backlight/brightness"; const MAX_BRIGHTNESS_PATH: &str = "/sys/class/backlight/intel_backlight/max_brightness"; fn parse_file(path: &str) -> u32 { std::fs::read_to_string(path) .unwrap() .trim_end() .parse::<u32>...
true
bcd66e90dbdac163ab8485cee517672b234c9830
Rust
houssemDevs/rfloat-rs
/src/floatx4/float32/simd_traits.rs
UTF-8
1,047
2.546875
3
[]
no_license
use simd::SseArth; use super::rf32x4; extern "C" { fn _add_f32x4(a: rf32x4, b: rf32x4) -> rf32x4; fn _sub_f32x4(a: rf32x4, b: rf32x4) -> rf32x4; fn _mul_f32x4(a: rf32x4, b: rf32x4) -> rf32x4; fn _div_f32x4(a: rf32x4, b: rf32x4) -> rf32x4; fn _max_f32x4(a: rf32x4, b: rf32x4) -> rf32x4; fn _min_...
true
123053bc38245568a9e618fdcd60a5ab42db4244
Rust
AmaranthineCodices/superparticle
/src/state.rs
UTF-8
2,982
3.09375
3
[ "MIT" ]
permissive
use std::time::Instant; pub const EQUILIBRIUM_PARTICLE_COUNT: usize = 1_000_000; use rand::distributions::{Distribution, Uniform}; use rand::Rng; // All slices have length EQUILIBRIUM_PARTICLE_COUNT. pub struct Particles { pub positions: Box<[(f32, f32)]>, pub velocities: Box<[(f32, f32)]>, pub colors: B...
true
2b34f181a561b0afc3420d088ecb594d5aebef41
Rust
pt2121/scion
/src/core/game_layer.rs
UTF-8
9,213
3.296875
3
[ "MIT" ]
permissive
//! Everything that is linked to the running of game layers. use std::collections::VecDeque; use legion::{Resources, World}; /// Trait to implement in order to define a `GameLayer`. pub trait SimpleGameLayer { /// Will be called once before the new game loop iteration. Useful to initialize resources and add every...
true
9b0b0acd52aec1bd94429caba7dcd784eac0b3bd
Rust
chromium/chromium
/third_party/rust/serde_json/v1/crate/tests/lexical/float.rs
UTF-8
14,186
3.046875
3
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
// Adapted from https://github.com/Alexhuszagh/rust-lexical. use crate::lexical::float::ExtendedFloat; use crate::lexical::rounding::round_nearest_tie_even; use std::{f32, f64}; // NORMALIZE fn check_normalize(mant: u64, exp: i32, shift: u32, r_mant: u64, r_exp: i32) { let mut x = ExtendedFloat { mant, exp }; ...
true
007542b0587f0fb23b3ac3bb9c6dd265c9f19b46
Rust
flanfly/rust-graph-algos
/src/order.rs
UTF-8
7,659
3
3
[ "MIT" ]
permissive
use std::collections::{ HashMap }; use traits::{ Graph, VertexListGraph, IncidenceGraph, }; use std::iter::FromIterator; use std::usize; use std::fmt::Debug; #[derive(PartialEq,Debug)] pub enum HierarchicalOrdering<T: Clone> { Component(Vec<Box<HierarchicalOrdering<T>>>), Element(T) } /// Bour...
true
311c2ab7b96b9a28c588c245fc3b3cd7d5410bf8
Rust
hexj/QUANTAXIS
/qapro-rs/src/parsers/parser/elements.rs
UTF-8
2,984
3.03125
3
[ "MIT" ]
permissive
use nom::branch::alt; use nom::bytes::complete::escaped; use nom::bytes::complete::tag; use nom::bytes::complete::take_while; use nom::character::complete::alphanumeric1; use nom::character::complete::char; use nom::character::complete::digit1; use nom::character::complete::multispace0; use nom::character::complete::on...
true
914736fd79d43aaf0e52e5f40922be4f99c89fb3
Rust
ZhongliGao/menmos
/bin/menmosd/tests/util/mod.rs
UTF-8
520
2.609375
3
[ "Apache-2.0" ]
permissive
use anyhow::Result; use bytes::Bytes; use futures::{Stream, StreamExt, TryStreamExt}; pub async fn stream_to_bytes< S: Stream<Item = std::result::Result<Bytes, E>>, E: Into<anyhow::Error>, >( stream: S, ) -> Result<Bytes> { let buffer_vector = stream .map_err(|e| e.into()) .collect::<Ve...
true
78317902ca1bfa8daeef4f7c4961acafd200e32e
Rust
IceSentry/bevy_df
/src/utils.rs
UTF-8
2,342
2.921875
3
[ "MIT" ]
permissive
use bevy::{math::Vec2, prelude::*, window::Window}; use std::ops::Sub; #[allow(unused)] pub fn lerp<T: num::Float + Sub>(a: T, b: T, v: T) -> T { (T::one() - v) * a + b * v } #[allow(unused)] pub fn inverse_lerp<T: num::Float + Sub>(a: T, b: T, v: T) -> T { (v - a) / (b - a) } /// Transforms a p...
true
1a9a79d8f5274925e51c2961adb7ee23fb2b6645
Rust
doytsujin/googapis
/googapis/genproto/google.devtools.artifactregistry.v1beta2.rs
UTF-8
38,549
3.328125
3
[ "Apache-2.0", "MIT" ]
permissive
/// A hash of file content. #[derive(Clone, PartialEq, ::prost::Message)] pub struct Hash { /// The algorithm used to compute the hash value. #[prost(enumeration = "hash::HashType", tag = "1")] pub r#type: i32, /// The hash value. #[prost(bytes = "vec", tag = "2")] pub value: ::prost::alloc::vec...
true