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
02132d9ef66a27bfa08aa499f4f5a0c2fa4bec35
Rust
probe-rs/probe-rs
/probe-rs/src/bin/cargo-flash.rs
UTF-8
788
2.765625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[cfg(unix)] use std::os::unix::process::CommandExt; use std::process::{exit, Command}; fn main() { let mut args: Vec<_> = std::env::args_os().skip(1).collect(); args.insert(0, "cargo-flash".into()); let mut cmd = Command::new("probe-rs"); cmd.args(&args); #[cfg(unix)] let err = cmd.exec(); ...
true
1521aaaa6d3a5942bc8310a4fe683bd661c4b997
Rust
bmwill/tonic
/tonic/benches-disabled/benchmarks/request_response.rs
UTF-8
1,568
2.546875
3
[ "MIT" ]
permissive
use criterion::*; use crate::benchmarks::compiled_protos::helloworld::{HelloReply, HelloRequest}; use crate::benchmarks::utils; fn build_request(_name: String) { let _request = tonic::Request::new(HelloRequest { name: _name }); } fn build_response(_message: String) { let _response = tonic::Request::new(Hello...
true
af40c74d7d476c476bb597589a4f5113ddc782ef
Rust
estelendur/budget-app
/src/controllers/index.rs
UTF-8
1,221
2.625
3
[]
no_license
use crate::context::Context; use bigdecimal::BigDecimal; use num_traits::Zero; use rocket_contrib::templates::Template; use crate::error::Error; use crate::models::account; use crate::MainDbConn; #[get("/")] pub fn index(context: Context) -> Template { Template::render("index", context) } #[get("/budget")] pub f...
true
55578824ce29592bb8fa16fc7b1b80f17a179827
Rust
vindvaki/advent-of-code-2018
/src/bin/day_25.rs
UTF-8
3,043
3.421875
3
[]
no_license
use std::collections::BTreeSet; use std::io::Read; use std::iter::FromIterator; fn main() { let mut data = String::new(); std::io::stdin().read_to_string(&mut data).unwrap(); let points = parse_points(&data).unwrap(); println!("part_1: {}", part_1(&points)); } fn part_1(points: &Vec<Point>) -> usize {...
true
ff676927ab8212c7d19171bcb886e4ab8939a04e
Rust
ScarboroughCoral/Notes
/剑指Offer/剑指 Offer 09. 用两个栈实现队列.rs
UTF-8
866
3.546875
4
[]
no_license
struct CQueue { s1: Vec<i32>, s2: Vec<i32>, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl CQueue { fn new() -> Self { return CQueue { s1: Vec::new(), s2: Vec::new() } ...
true
add57933e600abead57249fd7bb5a5d46e014d85
Rust
xuyifangreeneyes/pngme
/src/chunk.rs
UTF-8
6,214
3.296875
3
[]
no_license
use crate::chunk_type::ChunkType; use anyhow::{anyhow, Error, Result}; use crc::crc32::checksum_ieee; use std::convert::{TryFrom, TryInto}; use std::fmt; use std::string::{FromUtf8Error, String}; use std::vec::Vec; #[derive(Debug)] pub struct Chunk { length: u32, chunk_type: ChunkType, data: Vec<u8>, c...
true
17297644b17dbdad151a49b9e8a58340c95609ea
Rust
trsupradeep/15618-project
/rust/mandelbrot/src/main.rs
UTF-8
12,627
2.546875
3
[]
no_license
#[macro_use] extern crate clap; extern crate crossbeam; extern crate num_cpus; extern crate rayon; use clap::{App, Arg}; use rayon::prelude::*; use std::time::{Instant, Duration}; fn main() { let mandel_config = parse_arguments(); // Create let mut image: Vec<u32> = vec![0; (mandel_config.img_size * man...
true
5180d531dccda8541aabb8a4a5b00684ca504f7c
Rust
kas-gui/kas
/crates/kas-widgets/src/label.rs
UTF-8
10,611
2.828125
3
[ "Apache-2.0" ]
permissive
// Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License in the LICENSE-APACHE file or at: // https://www.apache.org/licenses/LICENSE-2.0 //! Fixed text widgets use super::adapt::MapAny; use kas::...
true
65b34c3fa90c2e593b7e79a9c5c087075fc9e038
Rust
kuviman/lifeshot
/src/player/bot.rs
UTF-8
1,763
2.59375
3
[ "MIT" ]
permissive
use crate::*; pub struct BotController; impl BotController { const SHOT_HIT_SIZE: f32 = 0.3; const MIN_SIZE: f32 = 0.7; } impl Controller for BotController { fn act(&mut self, self_id: usize, game: &Game) -> Action { let me = game .players .iter() .find(|player...
true
f3c37cb7e4505611e2f08735abb0b873fe78f69c
Rust
optozorax/bufdraw
/src/image.rs
UTF-8
11,238
2.796875
3
[]
no_license
use core::ops::Range; use crate::ImageTrait; use crate::vec::*; use crate::rangetools::*; use std::path::Path; use static_assertions::*; pub enum PixelPos { R, G, B, A, } pub fn convert(slice: &mut [Color]) -> &mut [u32] { assert_eq_size!(Color, u32); assert_eq_align!(Color, u32); unsafe { std::slice::from_ra...
true
f354d79fd31702f7f9c5ab49161dd8816d264cf9
Rust
killercup/rust-more-asserts
/src/lib.rs
UTF-8
7,005
3.609375
4
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
//! Small library providing some macros helpful for asserting. /// Panics if the two expressions are equal. Requires that the types be /// comparable with `!=`. /// /// Prints the values out on panic. #[macro_export] macro_rules! assert_ne { ($left:expr, $right:expr) => ({ match (&($left), &($right)) { ...
true
bd0fc202e42890cd8c909c1daa2b7605edffcb5b
Rust
amourha/Rust-VM
/src/instruction.rs
UTF-8
547
3.171875
3
[]
no_license
#[derive(PartialEq, Debug)] pub enum Opcode { HLT, MOVI, MOV, ADD, SUB, AND, OR, XOR, JMP, INVALID } impl From<u8> for Opcode { fn from(opcode: u8) -> Self { match opcode { 0 => Opcode::HLT, 1 => Opcode::MOVI, 2 => Opcode::MOV, ...
true
77ec0d56cabdb773078e779fed6dddf58fca590e
Rust
ivanceras/restq
/src/ast/table.rs
UTF-8
9,655
2.96875
3
[ "MIT" ]
permissive
use crate::ast::{ddl::TableDef, BinaryOperation, ColumnName, Expr, Operator}; use serde::{Deserialize, Serialize}; use sql_ast::ast as sql; use std::{collections::BTreeMap, fmt}; use thiserror::Error; #[derive(Error, Debug)] pub enum TableError { #[error("Table join is specified, but no table lookup is supplied")]...
true
4c07d82e4c434f0a20a50dcafb862d47e6e95676
Rust
Luro02/tanoshi
/tanoshi-web/src/common/cover.rs
UTF-8
1,865
2.78125
3
[ "MIT" ]
permissive
use dominator::{html, link, Dom}; use futures_signals::signal::Mutable; use serde::{Deserialize, Serialize}; use crate::common::route::Route; use crate::utils::proxied_image_url; #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Cover { pub id: i64, pub source_id: i64, pub path: String, ...
true
03f5f00c2ebf6feb20ae31d60ff22c88d51eeee7
Rust
kbluescode/rust-http-server
/src/handlers/worker.rs
UTF-8
1,579
2.890625
3
[]
no_license
use super::{handle_connection, SharableReceiver}; use std::net::TcpStream; use std::sync::{mpsc::TryRecvError, Arc}; pub struct Worker<'a> { tcp_receiver: &'a SharableReceiver<TcpStream>, shutdown_receiver: &'a SharableReceiver<bool>, num: u8, } impl<'a> Worker<'a> { pub fn new( tcp_receiver: &'a Sharable...
true
f924698090ad9b5756d5c47568f3c52c15dc37cf
Rust
Bhavik-Makwana/Advent-Of-Code-2020
/calendar/src/day4.rs
UTF-8
3,253
3.359375
3
[]
no_license
// use std::collections::HashMap; use regex::Regex; use std::collections::HashSet; use std::fmt::Error; pub fn part_one(passports: &Vec<Vec<String>>) -> Result<i32, Error> { let mut total = 0; let mut map = HashSet::new(); for passport in passports.iter() { for line in passport.iter() { ...
true
37ba64067748414806ff7c6ca2dc8267d5e2b569
Rust
SwagColoredKitteh/airts
/src/map.rs
UTF-8
3,088
3.1875
3
[]
no_license
use size::Size; use loc::Loc; use vec2::Vec2; use std::io::prelude::*; use std::io; use std::ops::{Index, IndexMut}; pub type TileId = usize; pub const CELL_SIZE: f64 = 64.; pub struct TileInfo { pub solid: bool } static TILE_INFO: [TileInfo; 2] = [ TileInfo { solid: false }, TileInfo { ...
true
3cc0bdb053495b8191b1bceb8c65cf1a7fa30921
Rust
jacobrosenthal/hf2-rs
/cargo-hf2/src/main.rs
UTF-8
5,335
2.546875
3
[ "MIT" ]
permissive
use colored::*; use hf2::utils::{elf_to_bin, flash_bin, vendor_map}; use hidapi::{HidApi, HidDevice}; use std::path::PathBuf; use std::process::{Command, Stdio}; use std::time::Instant; use structopt::StructOpt; fn main() { // Initialize the logging backend. pretty_env_logger::init(); // Get commandline o...
true
f96d9ab7f6aeefe04c09128484db38c903bcefa7
Rust
doytsujin/googapis
/googapis/genproto/grafeas.v1beta1.provenance.rs
UTF-8
7,276
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
/// Provenance of a build. Contains all information needed to verify the full /// details about the build from source to completion. #[derive(Clone, PartialEq, ::prost::Message)] pub struct BuildProvenance { /// Required. Unique identifier of the build. #[prost(string, tag = "1")] pub id: ::prost::alloc::st...
true
4e856d3ed26c8aa63dd703f56a67e02b17accf60
Rust
max-ym/kobzar-old
/src/mem/arch/x86_64/alloc/mod.rs
UTF-8
1,007
2.65625
3
[]
no_license
/// Main controller that uses all submodules to provide interface for /// allocating and releasing pages of memory. pub mod ctrl; /// Structures related to 2MiB pages. pub mod p2m; /// Structures related to 4KiB pages. pub mod p4k; /// Page Status Object module. Page Status holds information that is used /// in page...
true
5b6d06d9af3f2ff5c821fd63aa727fa13c12957a
Rust
romixlab/uwb-playground
/src/radio/scheduler.rs
UTF-8
6,714
2.515625
3
[]
no_license
use super::channelization::{ Multiplex, ChannelId, LogicalDestination, }; use super::types::{ Slot, SlotType, RadioConfig, }; use dw1000::{ configs::{ UwbChannel, BitRate, PulseRepetitionFrequency, } }; use crate::units::MicroSeconds; use crate::config; use core::...
true
739236ba2b8fac4b4d4aacb97ec07cdae29200b7
Rust
iCodeIN/test-strategy
/tests/compile_fail/invalid_weight.rs
UTF-8
158
2.53125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use test_strategy::Arbitrary; #[derive(Arbitrary, Debug, PartialEq, Clone)] enum TestEnum { #[weight(1.1)] X, #[weight(2)] Y, } fn main() {}
true
95c4ac73c6c5aec4a3410d304bbbefd5579704e1
Rust
Nesquick0/Adventofcode
/2022/12/src/main.rs
UTF-8
4,802
3.203125
3
[]
no_license
#![allow(non_snake_case)] #![allow(unused_parens)] use std::collections::{HashSet, VecDeque}; use std::fs; fn readToString(filename: &str) -> std::io::Result<String> { let text = fs::read_to_string(filename)?; Ok(text) } struct World { pos: Vec<i64>, w: i64, h: i64, } impl World { pub fn new...
true
ff74780d18c4380f664900adca5ef4bd1193191c
Rust
h-ueno2/rust_fizzbuzz
/tests/integration_test.rs
UTF-8
746
2.890625
3
[]
no_license
extern crate fizz_buzz; use fizz_buzz::Config; use fizz_buzz::Manager; #[test] fn fizzbuzz_manager_01() { let config = Config::new(&[ String::new(), String::from("15"), String::from("3"), String::from("5"), ]); let manager = Manager::new(config); let expected = "1 2 Fizz...
true
9aaa4c8d63fc1cffab9c81edd530069fe7fefca4
Rust
herumi/misc
/rust/thread/t.rs
UTF-8
505
3.359375
3
[]
no_license
use std::thread; fn add(a:i32, b:i32) -> i32 { println!("add a={} b={}\n", a, b); return a + b; } fn main() { let n = 5; let mut handles = vec![]; for i in 0..n { let handle = thread::spawn(move|| { add(3, i); return (i, i+1) }); handles.push(handle); } let mut sum = 0; let mut first = true; for ...
true
fb603a0eb0cdd9e0a53066f957ef3b883d21096c
Rust
yxdunc/advent_of_code
/2022/day_00/ex_01/src/main.rs
UTF-8
1,592
3.40625
3
[]
no_license
use std::cmp::min; use std::fmt::Debug; use std::io::{Read, stdin}; /// O(n * len(list)) /// best for small value of n fn get_max_n<T: Ord + Debug>(list: &Vec<T>, n: usize) -> Vec<&T> { let mut top_n: Vec<&T> = vec![]; let mut limit: Option<&T> = None; let mut i = 0; while i < n && top_n.len() < n ...
true
3c186945a6363c16514a8e5dabeee83e56c8092f
Rust
esp-rs/esp32-hal
/src/analog/dac.rs
UTF-8
1,970
2.84375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Digital to analog (DAC) conversion. //! //! This module provides functions for controling two digital to //! analog converters, available on ESP32: `DAC1` and `DAC2`. //! //! The DAC1 is avilable on the GPIO pin 25, and DAC2 on pin 26. //! use core::marker::PhantomData; use crate::analog::{DAC1, DAC2}; use crate:...
true
b8bf15db8511a5cd300f666d4e7e859421172b16
Rust
rainqubit/chi-chan
/src/main.rs
UTF-8
2,853
2.8125
3
[]
no_license
use coffee::graphics::{Color, Frame, Window, WindowSettings, Rectangle, Shape, Mesh, Transformation, Vector}; use coffee::load::Task; use coffee::{Game, Result, Timer}; mod chip8; mod test_chip8; type Chip8 = chip8::Chip8; //Graphic setup const PIXEL_SIZE: usize = 8; const VIDEO_WIDTH: usize = 64; const VIDEO_HEIGH...
true
abfa7d1c8d5b9216846f005e85c76926d3324580
Rust
likr/atcoder
/typical90/src/bin/002.rs
UTF-8
1,330
2.78125
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; #[...
true
cedb536d972066305d6d271d3ef9ed6efba1f05d
Rust
phR0ze/rsmixer
/src/action_handlers/user_action.rs
UTF-8
2,504
2.53125
3
[ "MIT" ]
permissive
use crate::{ actor_system::Ctx, models::{PageType, PulseAudioAction, RSState, UIMode, UserAction}, }; pub fn handle(msg: &UserAction, state: &mut RSState, ctx: &Ctx) { match msg { UserAction::MoveUp(how_much) => { state.move_up(*how_much as usize); } UserAction::MoveDown(how_much) => { state.move_down(*...
true
1dab922529f242198247b25dd1673489b721f4ff
Rust
e-matteson/dotstar-bluepill
/src/timer.rs
UTF-8
1,148
2.875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::system::System; use dotstar::Duration; pub struct Timer { start_time: u32, length: u32, is_disabled: bool, } impl Timer { pub fn new() -> Self { Timer { start_time: 0, length: 0, is_disabled: true, } } pub fn restart(&mut self, sy...
true
d37511a39a40d0e74ff65dcb5842c03dda3a7570
Rust
maurer/compiler
/src/ast/defmap.rs
UTF-8
6,780
3.078125
3
[]
no_license
use std::collections::TreeMap; use util::Name; use std::fmt; use std::fmt::{Formatter, Show}; use ast::visit::*; use ast::*; /// DefMap maps a NodeId to a Def, where a Def is anything that can be defined /// by an Ident. This can be used by the Resolver to map the usages of Idents /// in types and expressions to th...
true
6ee146f5e09be8b4cb5184509674eef8c4c52ad6
Rust
kerinin/email-rs
/src/rfc2822/folding.rs
UTF-8
4,648
3.078125
3
[]
no_license
use chomp::*; use bytes::{Bytes, ByteStr}; use rfc2822::obsolete::*; use rfc2822::primitive::*; use rfc2822::quoted::*; // Folding white space // FWS = ([*WSP CRLF] 1*WSP) / obs-FWS // NOTE: Removes CRLF, returns any other characters pub fn fws(i: Input<u8>) -> U8Result<Bytes> { let a = |i| { option(i, |i...
true
1569e74118b76f0b381539e61c371b92336ac7c1
Rust
RUSTools/autograph
/src/backend.rs
UTF-8
29,282
2.53125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::Result; use anyhow::{anyhow, bail, ensure}; use derive_more::Display; use half::{bf16, f16}; use serde::{Deserialize, Serialize}; use smol::lock::Mutex; use std::borrow::Cow; use std::collections::HashMap; use std::fmt::{self, Debug}; use std::hash::Hash; use std::marker::PhantomData; use std::mem::size_of; ...
true
b101d31898994d0a5a0b5a96a28de98c0bc70538
Rust
isgasho/raiden-dynamo
/raiden/tests/all/key_condition.rs
UTF-8
3,791
2.9375
3
[]
no_license
#[cfg(test)] mod tests { #[cfg(test)] use pretty_assertions::assert_eq; use raiden::*; #[derive(Raiden)] #[raiden(table_name = "user")] #[derive(Debug, Clone)] pub struct User { #[raiden(partition_key)] id: String, name: String, year: usize, num: usi...
true
52522ef3e5a5764dd8474951108486a4637d9886
Rust
Akanoa/advent_calendar
/2019/common/src/computer.rs
UTF-8
29,181
3.34375
3
[]
no_license
use std::path::PathBuf; use std::error::Error; use std::io::{BufReader, BufRead}; use std::fs::File; use std::collections::{VecDeque, HashMap}; #[macro_use] mod macros { macro_rules! get_operand { ($memory:expr, $memory_address:expr, $instruction_cursor:expr, $parameter_mode:expr, $text_error:expr, $base:...
true
92908af4c59662da71bc991db72512956bcf094d
Rust
Phoenix-Chen/wifi-rs
/tests/mod.rs
UTF-8
515
2.59375
3
[]
no_license
extern crate wifi_rs; use self::wifi_rs::{prelude::*, WiFi}; #[test] fn connect_to_wifi_failed() { let config = Some(Config { interface: Some("wlo1"), }); let mut wifi = WiFi::new(config); assert_eq!(wifi.connect("ssid", "password").unwrap(), false); } #[test] fn create_hotspot() { let config = Some(C...
true
dae9128421796a9834de066ba905f270e939a0e1
Rust
khei4/sym_diff
/src/parser_combinator.rs
UTF-8
7,648
3.234375
3
[ "MIT" ]
permissive
// mutable referenceにするとmoveした値を使うなと言われるんだけど, moveってshared referenceでも起こるのでは? use super::expr::Env; pub type ParseResult<'a, Output> = Result<(&'a str, &'a Env, Output), &'a str>; pub trait Parser<'a, Output> { fn parse(&self, input: &'a str, env: &'a Env) -> ParseResult<'a, Output>; fn map<F, NewOutput>(se...
true
9148cbd489f91349d0d2e343a5f6cfb183c6128b
Rust
nbigaouette/advent_of_code_2018
/day05/src/iter_scan.rs
UTF-8
5,601
3.046875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::mem; use crate::{AoC, Day05SolutionPart1, Day05SolutionPart2}; // Different cases characters have a distance of 32 in the ASCII table static ASCII_CAPITAL_DISTANCE: i16 = 32; #[derive(Debug)] pub struct Day05IteratorScan<'a> { input: &'a str, } impl<'a> AoC<'a> for Day05IteratorScan<'a> { type Solu...
true
f6f4cd7cf18a47cbe992c3c66738f14b9897c0f5
Rust
mbillingr/lisp-in-small-pieces
/project/src/syntax/sequence.rs
UTF-8
1,788
2.8125
3
[]
no_license
use super::expression::Expression; use crate::ast_transform::Transformer; use crate::scm::Scm; use crate::source::SourceLocation; use crate::source::SourceLocation::NoSource; use crate::syntax::{NoOp, Reify}; #[derive(Debug, Clone)] pub struct Sequence { pub first: Box<Expression>, pub next: Box<Expression>, ...
true
0d7a455d614f59b603c37e46d40daf96e3aa5684
Rust
colton-howe/ProgrammingLanguages
/quicksort/src/main.rs
UTF-8
797
3.671875
4
[]
no_license
fn quicksort<E: Ord>(array: &mut [E]){ if 1 < array.len() { //Set pivot, and set the high point of the array let (mut pivot, mut hi) = (0, array.len()-1); //Loop through the elements in the array for _ in 0..array.len()-1 { //Order them all based on the pivot ...
true
85a9e88b3ce95aab5b75cc169d97ee7a8c50a665
Rust
ilknarf/pow-blockchain-rust
/src/main.rs
UTF-8
3,297
3.015625
3
[]
no_license
extern crate crypto; // aka rust-crypto use std::fmt::{Display, Formatter, Result}; use std::str; use std::u128; use std::boxed::Box; use std::option::Option; use self::crypto::digest::Digest; use self::crypto::sha3::Sha3; use hex::encode; const TARGET: usize = 4; // target number zeroes const ODD: bool = TARGET % 2 ...
true
2e889b19f299373b65f23d15b96c91051e10b21e
Rust
royaltm/rust-ym-file-parser
/examples/ym-player/src/main.rs
UTF-8
22,013
2.609375
3
[]
no_license
//! YM player use std::io::{stdout, Write}; use core::ops::AddAssign; use core::fmt; use spectrusty_core::{audio::*, chip::nanos_from_frame_tc_cpu_hz}; use spectrusty_audio::{ synth::ext::*, host::cpal::{AudioHandle, AudioHandleAnyFormat} }; use spectrusty_peripherals::ay::{audio::*, AyRegister, AyRegChange}; u...
true
8513952b1a96634b0a59255bc38ff987cb80e881
Rust
AKAStacks/sleeptime_r
/src/main.rs
UTF-8
5,803
2.734375
3
[ "MIT" ]
permissive
extern crate clap; extern crate gio; extern crate glib; extern crate gtk; extern crate system_shutdown; use gio::prelude::*; use gtk::prelude::*; use shrinkwraprs::*; use clap::{App, Arg}; use glib::source::source_remove; use gtk::{Application, Button, Dialog, ResponseType, SpinButton}; use std::{thread, time}; use s...
true
b8b7c00b1fca4f7cfc00a19ab36a41229d476748
Rust
vijfhoek/trillium
/server-common/src/server.rs
UTF-8
7,013
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::{Config, ConfigExt}; use futures_lite::{AsyncRead, AsyncWrite}; use std::{ future::{ready, Future}, io::Result, net::IpAddr, pin::Pin, sync::Arc, }; use trillium::{Handler, Info}; use trillium_http::Stopper; use trillium_tls_common::Acceptor; /** The server trait, for standard network-ba...
true
53bdb91f96650ec655cda32c8dbed8c8ab0d6a7f
Rust
cozydate/rust-in-production
/modules_and_binaries/src/multi_file_module/mod.rs
UTF-8
329
2.75
3
[ "MIT" ]
permissive
// This module is defined in a directory. // Use but don't export. mod internal; // Use and export. pub mod nested; pub fn c() -> String { String::from("C") } pub fn cde() -> String { // https://users.rust-lang.org/t/what-is-right-ways-to-concat-strings/3780/14 [&c() as &str, &internal::d(), &nested::e()].co...
true
87474b44aba8d32fb400f8c8702bbee285ef0388
Rust
T0mstone/tlibs
/nonempty_vec/src/lib.rs
UTF-8
6,655
3.84375
4
[]
no_license
//! This crate provides a `Vec`-like struct that cannot be empty use std::marker::PhantomData; use std::mem; use std::num::NonZeroUsize; mod private { use super::{HeadFirst, HeadLast}; pub trait Sealed {} impl Sealed for HeadFirst {} impl Sealed for HeadLast {} } /// Specifies the location the head ...
true
bf12f6ded064eb1744a87a3f14ee7bcda8ff51ac
Rust
Telixia/leetcode-3
/Medium/0090-Subsets II/Solution.rs
UTF-8
575
2.65625
3
[]
no_license
impl Solution { pub fn subsets_with_dup(nums: Vec<i32>) -> Vec<Vec<i32>> { let mut nums = nums; nums.sort_unstable(); let mut cnt = 1; let mut ret = vec![vec![]]; for i in 0..nums.len() { if i > 0 && nums[i] == nums[i - 1] { cnt += 1; ...
true
db713ee1334f3401dea1eb7ee379c2765c823fba
Rust
nindalf/advent-2019
/src/day04.rs
UTF-8
3,098
3.546875
4
[]
no_license
#[aoc(day4, part1)] pub fn passwords_1(input: &str) -> i32 { number_of_passwords(input, &is_valid_password_1) } #[aoc(day4, part2)] pub fn passwords_2(input: &str) -> i32 { number_of_passwords(input, &is_valid_password_2) } pub fn number_of_passwords(input: &str, password_validator: &dyn Fn(i32) -> bool) -> i...
true
53a974672443d711d2d99620daa01899dc295b42
Rust
Aehmlo/insteon-serial
/src/button.rs
UTF-8
1,228
3.796875
4
[]
no_license
use std::fmt; /// Represents a button on an Insteon device. #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum Button { /// The SET button. Set, /// A secondary button. Two, /// A tertiary button. Three, } impl fmt::Display for Button { fn fmt(&self, f: &mut fmt::Formatter) -> fmt...
true
0ff04a243bf04f98439bab9736de9f74b1be071c
Rust
mendess/SIRS
/server/src/model.rs
UTF-8
7,805
2.765625
3
[]
no_license
mod child; mod guardian; mod location; pub use child::{Child, ChildId, ChildView}; pub use guardian::GuardianId; pub use location::Location; use super::schema::{children, guardian_has_children, guardians, locations}; use crate::error::{Error, Result}; use diesel::{pg::PgConnection, prelude::*, Associations, Identifia...
true
0a42e6a1ed9fbfd3d089a0f20ebc64902031c646
Rust
csherland/Advent-of-Code-2019
/day3/src/main.rs
UTF-8
3,683
3.203125
3
[]
no_license
use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::str::FromStr; use std::error; use std::fmt; #[derive(Debug, PartialEq)] struct Edge { direction: String, length: i32, points: Vec<Point> } #[derive(Debug, Clone)] struct EdgeParseError; impl fmt::Display for EdgeParseError { fn fmt(&...
true
1124a39a52e13857f37da8786891d597a925915f
Rust
wenma/btget
/src/parser.rs
UTF-8
10,574
2.875
3
[ "Apache-2.0" ]
permissive
use std::u8; use std::fs::File; use std::io::prelude::*; use std::path::Path; use std::collections::HashMap; use prettytable::Table; use prettytable::format; use number_prefix::{binary_prefix, Standalone, Prefixed}; use encoding::{Encoding, DecoderTrap}; use encoding::all::GBK; use encode::{to_sha1_hex, hex_to_binar...
true
058a1c0ca34b0bd149919dda404f1ecd01e093c4
Rust
DougLau/gift
/src/decode.rs
UTF-8
31,486
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
// decode.rs // // Copyright (c) 2019-2023 Douglas Lau // //! GIF file decoding use crate::block::*; use crate::error::{Error, Result}; use crate::lzw::Decompressor; use crate::private::Step; use pix::{rgb::SRgba8, Raster, Region}; use std::cmp::Ordering; use std::io::{ErrorKind, Read}; /// An Iterator for [Block]s w...
true
4d67aa7afbef76e68bf3ca98eb866e614fd9ad6d
Rust
karanborate29/kip_practice
/three/Assignment_Three/src/main.rs
UTF-8
3,608
3.609375
4
[]
no_license
//assignment_three use std::io::{self, Write}; fn main(){ let arr = [1, 10, 20, 47, 59, 63, 75, 88, 99, 107, 120, 133, 155, 162, 176, 188, 199, 200, 210, 222]; let target: i32 = 47; linearsearch(arr,target); //Q1(a)_Calling Linear_Search binarysearch(arr, target); //Q1(b)_Calling Binary_Search ...
true
b738fb66cfc680a2d50ff06afd57c0c0cfc1967f
Rust
mzohreva/hokm
/src/gui/misc.rs
UTF-8
3,478
3
3
[]
no_license
use super::*; use sdl2::gfx::primitives::DrawRenderer; use sdl2::pixels::Color; pub struct Circle { pub cx: i32, pub cy: i32, pub radius: u32, } impl Circle { pub fn find_point(&self, angle: f32) -> (i32, i32) { let x = (self.radius as f32 * angle.cos()) as i32; let y = (self.radius a...
true
c90ccc744a18a1d70b037afa1e14657d679fe9a2
Rust
albhaf/adventofcode-2016
/rust/src/bin/3.rs
UTF-8
762
3.046875
3
[]
no_license
use std::io; fn main() { let mut valid = 0; let mut input = String::new(); loop { match io::stdin().read_line(&mut input) { Ok(_) => { if input.len() == 0 { break; } let s = input.trim(); let sides: Vec...
true
74b0828fc831aef7857e49a51bfdce58fce43138
Rust
mishun/minisat-rust
/src/util.rs
UTF-8
755
2.625
3
[ "MIT" ]
permissive
use std::process; use std::fs::File; use std::io::Read; #[cfg(not(target_os = "linux"))] pub fn mem_used_peak() -> Option<usize> { None } #[cfg(target_os = "linux")] pub fn mem_used_peak() -> Option<usize> { let mut buf = String::new(); let mut stats = File::open(&format!("/proc/{}/status", process::id())...
true
0b2e17e14fc6ea77130d89a7d7e8985cf22e54d3
Rust
marcaddeo/rs-hank
/src/plugin/hi_plugin.rs
UTF-8
1,217
2.75
3
[]
no_license
use regex::Regex; use rand; use rand::Rng; use irc::client::prelude::*; use plugin::{Plugin, PluginContext}; use errors::*; pub struct HiPlugin; impl Plugin for HiPlugin { fn will_handle(&self, command: Command) -> bool { match command { Command::PRIVMSG(_, _) => true, _ => false, ...
true
80c30cf2627902c3b3a17764a41d325a7ecf4837
Rust
EtomicBomb/pusoy
/src/card.rs
UTF-8
3,991
3.53125
4
[]
no_license
use serde::{Deserialize, Serialize}; use std::fmt; use std::str::FromStr; use self::Rank::*; use self::Suit::*; pub const ALL_RANKS: [Rank; 13] = [ Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace, Two, ]; pub const ALL_SUITS: [Suit; 4] = [Clubs, Spades, Hearts, Diamonds]; pub const THRE...
true
03f00ca04f50d7ef53204d27d6a6835a45c31e82
Rust
ApophisLee/gbc
/emu-wasm/src/lib.rs
UTF-8
3,568
2.8125
3
[]
no_license
use wasm_bindgen::prelude::*; use gbc::Gameboy as Gameboy_; use gbc::cartridge::Cartridge as Cartridge_; use gbc::joypad::{JoypadEvent, JoypadInput as JoypadInput_}; use gbc::ppu::{GameboyRgb, LCD_WIDTH, LCD_HEIGHT}; // Re-exported JopypadInput enum #[wasm_bindgen] #[derive(Clone, Copy)] pub enum JoypadInput { Up...
true
42b3ad459a46d6868d5732149b541bde910a9398
Rust
softprops/prefix
/src/git.rs
UTF-8
3,214
2.8125
3
[ "MIT" ]
permissive
use path_slash::PathBufExt; use std::{ io, path::{Path, PathBuf}, }; use tokio::process::Command; /// hooks that can be by-passed pub const NOVERIFY_HOOKS: &[&str] = &["commit-msg", "pre-commit", "pre-rebase", "pre-push"]; /// client-side hooks pub const HOOKS: &[&str] = &[ "applypatch-msg", "pre-appl...
true
229ff2d7e3ede73fac1184b213d51f0e8be9d4c6
Rust
riontdev/api-hero-rust
/src/models/hero.rs
UTF-8
2,204
2.78125
3
[]
no_license
use serde::{Serialize, Deserialize}; //use actix_web::web::Data; //use actix_web::Responder; //use actix_web::HttpResponse; //use diesel::pg::PgConnection; use diesel::prelude::*; use crate::schema::hero; use crate::db; use diesel; use crate::api_error::ApiError; use chrono::{NaiveDateTime, Utc}; //use uuid::Uuid; ...
true
dbe4b238cb349405549ce32a0deeb27fa7e7e07e
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/headers/src/common/content_length.rs
UTF-8
1,093
2.546875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use {Header, HeaderValue}; #[derive(Clone, Copy, Debug, PartialEq)] pub struct ContentLength(pub u64); impl Header for ContentLength { fn name() -> &'static ::http::header::HeaderName { &::http::header::CONTENT_LENGTH } fn decode<'i, I: Iterator<Item = &'i Hea...
true
de93b83d2e951b556e580654ad8f2b05bf8d23c6
Rust
fbenkstein/advent-of-code
/dima/src/day14.rs
UTF-8
2,168
3.453125
3
[]
no_license
use std::error::Error; use std::str; fn score(num_recipies: usize) -> usize { let mut board: Vec<u8> = Vec::with_capacity(num_recipies + 10); board.push(3); board.push(7); let mut i = 0; let mut j = 1; loop { let sum = board[i] + board[j]; let digits = sum.to_string(); ...
true
b8331846d6e05142e042b086d856abf20dfe59c0
Rust
EdGavin98/PNG-Decoder
/src/args.rs
UTF-8
899
2.546875
3
[]
no_license
use structopt::StructOpt; use std::path::PathBuf; #[derive(Debug, StructOpt)] pub struct Encode { #[structopt(short, long)] pub file: PathBuf, #[structopt(short, long)] pub chunk_name: String, #[structopt(short, long)] pub message: String, #[structopt(short, long)] pub output_file: Opti...
true
e4e7149016622504072ee46d86e4c55318e4f665
Rust
linclelinkpart5/regulus
/src/util.rs
UTF-8
2,203
3.203125
3
[]
no_license
use sampara::Frame; const DEN_THRESHOLD: f64 = 1.0e-15; pub struct Util; impl Util { #[inline] pub fn lufs(x: f64) -> f64 { -0.691 + 10.0 * x.log10() } /// Given the mean squares (powers) of an input signal and a set of /// per-channel weights, calculates the weighted loudness across all...
true
cfeff15906568ce8a25db8da3fd8cba385c2529a
Rust
findelabs/mibana
/src/tools.rs
UTF-8
758
2.890625
3
[]
no_license
use http::request::Parts; use std::collections::HashMap; use std::net::{Ipv4Addr, SocketAddr}; pub type Queries = HashMap<String, String>; pub fn queries(req: &Parts) -> Option<Queries> { let params: HashMap<String, String> = req .uri .query() .map(|v| { url::form_urlencoded::p...
true
07839ea9b651e536dbe62f04ac3fd480f8955a31
Rust
cmal/rust-practise-questions
/answer/chapter_07/fn_accepts_closure/src/main.rs
UTF-8
178
2.78125
3
[ "MIT" ]
permissive
fn accept_closure<F>(f: F) -> String where F: FnOnce() -> String { f() } fn main() { let closure = || "xxxx".to_string(); println!("{}", accept_closure(closure)); }
true
a1505b96cade245b74c32036c3b58f6c4d7001da
Rust
xiph/rav1e
/src/api/util.rs
UTF-8
8,871
2.6875
3
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2018-2021, The rav1e contributors. All rights reserved // // This source code is subject to the terms of the BSD 2 Clause License and // the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License // was not distributed with this source code in the LICENSE file, you can // obtain it at ...
true
f37ac78d8798eec02daac5f2928d863ce564bf3a
Rust
zatchl/kawaiifi
/src/ies/bss_load.rs
UTF-8
1,632
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
use super::{Field, IeError, InformationElement}; use bitvec::prelude::*; #[derive(Debug, Clone, PartialEq, Eq)] pub struct BssLoad { bits: BitVec<LocalBits, u8>, } impl BssLoad { pub const LENGTH: usize = 5; pub fn new(bytes: Vec<u8>) -> Result<BssLoad, IeError> { if bytes.len() == Self::LENGTH {...
true
d17bef19a629868b162ed913bfd53d81ed10f52a
Rust
iwburns/roml
/src/vector/vector3f.rs
UTF-8
14,351
3.40625
3
[ "MIT" ]
permissive
use vector::Vector; use vector::Vector3; use ThreeTuple; #[derive(Default)] pub struct Vector3f { pub x: f32, pub y: f32, pub z: f32, } impl Vector3<f32> for Vector3f { fn new(x: f32, y: f32, z: f32) -> Self { Vector3f { x: x, y: y, z: z } } fn cross<'a, V>(&mut self, rhs: &'a V) -> &...
true
ade2650e53edaec38841ed2fe7009e172b5450c1
Rust
marionebl/rust-book-exercises
/8_3_hashmaps/src/main.rs
UTF-8
1,575
3.59375
4
[]
no_license
use std::collections::HashMap; fn main() { let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Yellow"), 50); println!("scores: {:?}", scores); let teams = vec![String::from("Blue"), String::from("Yellow")]; let initial_scores = vec![10, 50];...
true
c7de62c369a91c2ff5026b2f3b65daa02ec0c0c2
Rust
MediocreBoris/gitgud
/equalsplits/main.rs
UTF-8
920
3.34375
3
[ "MIT" ]
permissive
use std::io; fn main(){ let mut x = String::new(); io::stdin().read_line(&mut x).expect("Failed to read line"); let x: Vec<i64> = x.split_whitespace() .map(|s| s.parse().unwrap()) .collect(); println!("{:?}", split(x)) } fn split(x: Vec<i6...
true
a4f8cdf436da69ce1c5ac142cae5065a7651b6ce
Rust
emakryo/cmpro
/src/facebook2021_r2/src/bin/a.rs
UTF-8
2,439
3.078125
3
[]
no_license
#![allow(unused_macros, unused_imports)] use std::{collections::{BTreeMap, HashMap, HashSet}, hash::Hash, iter::FromIterator}; macro_rules! dbg { ($($xs:expr),+) => { if cfg!(debug_assertions) { std::dbg!($($xs),+) } else { ($($xs),+) } } } fn main() { proco...
true
95110b5c6f3e5f64710b5927c8591cb66492b9ec
Rust
dbyr/rust-classifiers
/src/common.rs
UTF-8
888
3.46875
3
[]
no_license
use std::fs::File; pub trait Attributable { // returns a string naming the attributes of this struct // returns: attribute name string fn attribute_names() -> String; // returns this object's values in a corresponding format to attribute_names // returns: attribute values string fn attribute_v...
true
38908da1d1426e70866c2d5d01bd240249d8bdb4
Rust
ithinuel/atsam4e
/boards/duet2_v1.03_wifi/examples/usb_poll.rs
UTF-8
3,158
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Makes the pygamer appear as a USB serial port loop back device. //! Repeats back all characters sent to it, but in upper case. #![no_std] #![no_main] //use panic_halt as _; #[panic_handler] fn on_panic(info: &core::panic::PanicInfo) -> ! { atsam4e_hal::dbgprint!("Woops: {:?}", info); loop {} } use atsam4...
true
66a904546808165dedbe440d551e90d5a1159909
Rust
s3rvac/retdec-rust
/src/fileinfo.rs
UTF-8
6,730
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Access to the file-analyzing service //! ([fileinfo](https://retdec.com/api/docs/fileinfo.html)). use analysis::Analysis; use analysis::AnalysisArguments; use connection::APIArguments; use connection::APIConnectionFactory; use connection::HyperAPIConnectionFactory; use connection::ResponseVerifyingAPIConnectionFac...
true
2be7d47515baf4bb995ade6552041d588e4df64c
Rust
a5huynh/defender-game
/ports/amethyst/src/defender/config.rs
UTF-8
1,282
2.875
3
[ "MIT" ]
permissive
use serde::{ Deserialize, Serialize }; pub mod consts { pub const WIN_HEIGHT: f32 = 768.0; pub const FRAC_WIN_HEIGHT_2: f32 = WIN_HEIGHT / 2.0; pub const WIN_WIDTH: f32 = 960.0; pub const FRAC_WIN_WIDTH_2: f32 = WIN_WIDTH / 2.0; } #[derive(Debug, Default, Deserialize, Serialize)] pub struct BulletConf...
true
1de944b74d05f1512a13751c01108629b1bdd1df
Rust
nickelc/modio-rs
/src/download.rs
UTF-8
11,211
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Downloading mod files. use std::error::Error as StdError; use std::fmt; use std::path::Path; use bytes::Bytes; use futures_core::Stream; use futures_util::{SinkExt, StreamExt, TryFutureExt, TryStreamExt}; use reqwest::{Method, Response, StatusCode}; use tokio::fs::File as AsyncFile; use tokio::io::BufWriter; use t...
true
d80d4d1ff83bff6a437398db9e2e8e995d7674f2
Rust
koute/static_test
/tests/test_ok.rs
UTF-8
392
3.015625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use static_test::static_test; #[static_test] fn test_slice_get_will_always_succeed_if_length_is_known( buffer: &[u8] ) -> u8 { assume!( buffer.len() == 1 ); match buffer.get( 0 ) { Some( &value ) => value, None => static_unreachable!() } } #[static_test] fn test_multiplication( value: u8 )...
true
b16d50f4a3d87052d6a333d108880cb54e40a2d7
Rust
nvzqz/bad-rs
/src/lib.rs
UTF-8
1,258
2.65625
3
[ "MIT", "Unlicense" ]
permissive
//! A collection of (bad) ideas that you may or may not want use in your next //! big project. Courtesy of //! [Nikolai Vazquez](https://twitter.com/NikolaiVazquez). //! //! ## Installation //! //! This crate is available [on crates.io](https://crates.io/crates/bad) and can be //! used by adding the following to your p...
true
378d9fd221102aaf6a285d2f9fd380914f1ad481
Rust
augusto-mantilla/rust-exercises
/expected_variable/src/lib.rs
UTF-8
3,414
3.6875
4
[]
no_license
/* ## expected_variable ### Instructions Create a function `expected_variable` that receives two strings: one to be evaluated and the other to be compared to (expected) and returns an Option. Every comparison should be case insensitive. If the evaluated string is not in camel case or in snake case according to the `...
true
484c5315b274d063953c7b14299091fb62993582
Rust
rwtnorton/rust-fibs
/src/main.rs
UTF-8
1,332
3.234375
3
[]
no_license
extern crate pretty_env_logger; #[macro_use] extern crate log; fn main() { pretty_env_logger::init(); let vs: Vec<_> = std::env::args().skip(1).collect(); let prog_name = get_prog_name(); if vs.len() != 1 { eprintln!("Usage: {} n", prog_name); std::process::exit(1); } let n: u3...
true
a9b96152a55fcde2eb207fe204493440b29bef09
Rust
tsukuyomi-rs/izanami
/izanami-hyper/src/lib.rs
UTF-8
6,148
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use async_trait::async_trait; use futures::{ future::{poll_fn, Future}, task::{self, Poll}, }; use http::{HeaderMap, Request, Response, StatusCode}; use http_body::Body as _Body; use hyper::{ body::{Body, Chunk, Sender as BodySender}, server::{conn::AddrIncoming, Builder as ServerBuilder, Server as Hype...
true
898752e5173a3935ac3b9cca12d05a33a430a3fb
Rust
hotiket/sumorucc
/src/node.rs
UTF-8
9,016
2.890625
3
[ "MIT" ]
permissive
use std::rc::Rc; use super::ctype::CType; use super::parse_context::ParseContext; use super::tokenize::Token; #[derive(Clone)] pub enum NodeKind { // name, params(offset, type), body Defun(String, Vec<(usize, CType)>, Box<Node>), Block(Vec<Node>), // GCC拡張のstatement expression StmtExpr(Box<Node>),...
true
c4d3a79bb2859ce25e6b591b43529a1f1fb8a35a
Rust
JakeStanger/eno-number
/src/path_vec.rs
UTF-8
1,099
3.296875
3
[ "MIT" ]
permissive
use crate::settings::MAX_DISTANCE; use crate::structs::Artist; pub struct PathVec { pub paths: Vec<Vec<Artist>>, pub shortest_distance: usize, } impl PathVec { pub fn new() -> PathVec { PathVec { paths: Vec::new(), shortest_distance: MAX_DISTANCE as usize, } } ...
true
f15ae8d96d82326c1ec22b26c257694a21191d62
Rust
EFanZh/LeetCode
/src/problem_1047_remove_all_adjacent_duplicates_in_string/mod.rs
UTF-8
366
3.078125
3
[]
no_license
pub mod greedy; pub trait Solution { fn remove_duplicates(s: String) -> String; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [("abbaca", "ca"), ("azxxzy", "ay")]; for (s, expected) in test_cases { assert_eq!(S::remove_duplicates...
true
d078cfc739009fff7b1f103fd8793d33e569f89a
Rust
jamesmarva/The-Rust-Programming-Language
/code/ch10/c_10_16/src/main.rs
UTF-8
350
3.53125
4
[]
no_license
use std::fmt::{Display, Formatter, Result}; fn main() { let p = Point{ x: 3, y: 4, }; println!("{}", p); println!("{}", p.to_string()); } struct Point { x: u32, y: u32, } impl Display for Point { fn fmt(&self, f: &mut Formatter<'_>) -> Result { write!(f, "({}, {}...
true
35a4941bbe280003611de32b954bef7ecb5e8a8b
Rust
fulmicoton/suntan
/src/practice.rs
UTF-8
586
3.359375
3
[]
no_license
fn main() { println!("Time for some practice!"); let mut vec = vec![1, 2, 3, 4]; println!("powerset of {:?}?", vec); let result = powerset(&mut vec); println!("{:?}", result); } fn powerset(list: &mut Vec<i32>) -> Vec<Vec<i32>> { let mut sets: Vec<Vec<i32>> = Vec::new(); if list.len() == 0...
true
b514e09b3e86235ae69410a02c3b9322304ff26e
Rust
Aldarrion/rusty_path
/src/main.rs
UTF-8
5,716
2.734375
3
[]
no_license
use rayon::prelude::*; mod aabb; mod vec3; mod ray; mod hittable; mod camera; mod texture; extern crate rand; use rand::Rng; use camera::Camera; use hittable::*; use vec3::{Vec3}; use ray::Ray; use std::sync::Arc; use std::time::{Instant}; use texture::*; fn color(r: &Ray, world: Arc<dyn Hittable>, depth: i32) -> Ve...
true
0f031ca56c6e584ad5bb28ed3b542714f53be106
Rust
muskanmahajan37/rsass
/src/selectors.rs
UTF-8
14,991
3.171875
3
[ "Apache-2.0", "MIT" ]
permissive
//! This module contains types for the selectors of a rule. //! //! Basically, in a rule like `p.foo, .foo p { some: thing; }` there //! is a `Selectors` object which contains two `Selector` objects, one //! for `p.foo` and one for `.foo p`. //! //! This _may_ change to a something like a tree of operators with //! lea...
true
9169c88e52a628d62070a0a699d54355f5ba4c77
Rust
TerraDOOM/RMGE
/src/error.rs
UTF-8
6,995
2.765625
3
[]
no_license
use gfx_hal::{self as hal}; use std::error; use std::fmt::{self, Display, Formatter}; #[derive(Debug)] pub enum Error { InstanceCreationError(gfx_hal::UnsupportedBackend), SurfaceCreationError(gfx_hal::window::InitError), QueueGroupError(QueueGroupError), CommandPoolCreationError, FenceCreationErro...
true
41ba6aaf8a29fab9899587a74b749420d36575cf
Rust
iacsa/exercism-solutions
/rust/grade-school/src/lib.rs
UTF-8
655
3.390625
3
[ "Unlicense" ]
permissive
use std::collections::HashMap; pub struct School { map: HashMap<usize, Vec<String>>, } impl School { pub fn new() -> Self { Self { map: HashMap::new(), } } pub fn grades(&self) -> Vec<usize> { let mut grades: Vec<_> = self.map.keys().cloned().collect(); gra...
true
f62d73f12cd0518c9db02bb1aaeba5cc772e9c2b
Rust
rileygowan/rust
/the-rust-programming-language/8/8.3/practice/src/main.rs
UTF-8
4,758
3.921875
4
[]
no_license
use std::collections::HashMap; use std::io; use std::io::BufRead; fn average(numbers: &[i32]) -> f32 { numbers.iter().sum::<i32>() as f32 / numbers.len() as f32 } fn median(numbers: &mut [i32]) -> i32 { numbers.sort(); let mid = numbers.len() / 2; numbers[mid] } fn mode(numbers: &[i32]) -> i32 { ...
true
31358120979ec404e5be2f0a8171f5340de6e489
Rust
jgrazian/wgpu-raytracer
/src/material.rs
UTF-8
1,220
2.875
3
[ "MIT" ]
permissive
use crate::traits::AsBytes; #[repr(C)] #[derive(Clone, Copy, Debug)] pub struct Material { pub albedo: [f32; 3], pub type_flag: u32, pub is_light: bool, } unsafe impl bytemuck::Pod for Material {} unsafe impl bytemuck::Zeroable for Material {} impl Material { pub fn new(albedo: [f32; 3], type_flag: u3...
true
53b192cb61b8d18ff157a189dcd997ea50f235e4
Rust
logansquirel/advent_of_code
/aoc_2015/day_08/src/lib.rs
UTF-8
2,652
3.59375
4
[ "MIT" ]
permissive
pub fn part_one(input: &str) -> usize { let mut code = 0; let mut memory = 0; for line in input.trim().lines() { code += code_count(line); memory += memory_count(line); } code - memory } pub fn part_two(input: &str) -> usize { let mut encode = 0; let mut code = 0; for li...
true
9a220a6e5fef952fcb9db5b3f8d9e5266f865962
Rust
inspier/zstd-rs
/src/decoding/sequence_execution.rs
UTF-8
3,400
2.984375
3
[ "MIT" ]
permissive
use super::scratch::DecoderScratch; #[cfg(feature = "alloc")] use alloc::borrow::ToOwned; #[cfg(feature = "alloc")] use alloc::string::String; pub fn execute_sequences(scratch: &mut DecoderScratch) -> Result<(), String> { let mut literals_copy_counter = 0; let old_buffer_size = scratch.buffer.len(); let mu...
true
09b05484693a249098c702affe41b00c6cb01dc8
Rust
prisma/prisma-engines
/libs/user-facing-errors/src/common.rs
UTF-8
7,820
2.9375
3
[ "Apache-2.0" ]
permissive
use crate::UserFacingError; use serde::Serialize; use std::fmt::Display; use user_facing_error_macros::*; #[derive(Debug, UserFacingError, Serialize)] #[user_facing( code = "P1000", message = "\ Authentication failed against database server at `{database_host}`, the provided database credentials for `{database...
true
d445f2467ab42343c39f36701e461aea3859b0f2
Rust
yeliknewo/explore
/src/systems/src/dwarf.rs
UTF-8
1,743
2.59375
3
[]
no_license
pub struct System { } impl System { pub fn new() -> System { System { } } } impl ::specs::System<::utils::Delta> for System { fn run(&mut self, arg: ::specs::RunArg, time: ::utils::Delta) { use ::specs::Join; let (transforms, physicals, mut dwarves, mut l...
true