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
2878d455f041b983ae926c3f920f9ac53b574abd
Rust
juliocmalvares/skypiea
/src/filters/grayscale.rs
UTF-8
1,572
2.75
3
[ "MIT" ]
permissive
extern crate image; // use image::{GenericImageView, RgbImage}; use crate::filters::base_filter::*; use crate::io::fastbitmap::*; impl<'a> Grayscale<'a> for BaseFilter { fn apply(mut fb: &FastBitmap<'a>) -> FastBitmap<'a> { // let mut buffer: RgbImage = image::ImageBuffer::new(img.dimensions().0, img.dime...
true
ad5505ad9320a8642403eb2affdd0a1063ababff
Rust
PurpleMyst/sphrosyne
/vigem-client-c/src/gamepad_state.rs
UTF-8
2,561
2.8125
3
[ "ISC" ]
permissive
//! Contains structures and enums needed to represent a gamepad state use bitflags::bitflags; use vigem_client_c_sys as ffi; bitflags! { /// Represents an xbox 360 controller's buttons #[derive(Default)] pub struct X360Buttons: u16 { const DPAD_UP = 0x0001; const DPAD_DOWN = 0x0002; ...
true
ebbe2d319a0ccf8cf92fecdb78635a16aa44ae9c
Rust
math4tots-misc/ugh-contests
/src/hr/vertical-rooks.rs
UTF-8
734
3.078125
3
[]
no_license
//! vertical-rooks.rs //! Problem reduces to nim in a natural way. use std::io::prelude::*; fn readln() -> String { let mut line = String::new(); assert!(std::io::stdin().read_line(&mut line).is_ok()); return line; } fn ti(text: &String) -> i32 { return text.trim().parse().expect(text); } fn main() ...
true
764aa11cdbda65969af2a7756e323aedad8d23bc
Rust
agmcleod/adventofcode-2019
/16/src/main.rs
UTF-8
1,963
3.1875
3
[]
no_license
use read_input::read_text; fn get_initial(text: &String) -> Vec<i32> { text.chars() .map(|c| c.to_digit(10).unwrap() as i32) .collect() } fn fft(mut input_list: Vec<i32>) -> Vec<i32> { let pattern = vec![0, 1, 0, -1]; for _ in 0..100 { let output: Vec<i32> = (1..=input_list.len())...
true
c36809b316305372159a7daf6f2bd133e8ba866a
Rust
mrroach9/HyperDoom_rust
/backend/renderer/src/common/constants.rs
UTF-8
713
2.90625
3
[ "Apache-2.0" ]
permissive
// The error bound for comparing floating point numericals, i.e. numericals within this // error bound are considered equal. pub const EPSILON: f64 = 1e-6; // A finer error bound for comparing values with zeros. i.e. numericals with absolute value // less than this constant will be considered zero. pub const EPSILON_T...
true
90cfe6ad3b6850d9f4c644a922b27119f6b0f0ef
Rust
qinxiaoguang/rs-lc
/src/solution/l005.rs
UTF-8
2,771
3.75
4
[]
no_license
pub struct Solution {} impl Solution { // 最长回文子串 // babad => aba #![allow(dead_code)] pub fn longest_palindrome(s: String) -> String { // 首先需要将s变为#b#a#b#a#d let mut res = s.chars().map(|c| format!("#{}", c)).collect::<String>(); res = format!("{}#", res); let chars: Vec<c...
true
2b83bce0763ab457f29d22145a20726174c32e42
Rust
housleyjk/rust-smtp
/src/sender/mod.rs
UTF-8
9,172
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// Copyright 2014 Alexis Mousset. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option...
true
b40d22ced09b05415ea01077f4d927ff305a8eab
Rust
dfrankland/eyeliner
/src/settings.rs
UTF-8
5,739
3.296875
3
[]
no_license
use maplit::hashmap; use std::collections::HashMap; /// Settings referenced by features enabled through `Options`. #[derive(Clone, Debug)] pub struct AbstractSettings { /// List of HTML elements that can receive `width` attributes. /// /// Defaults to: /// /// ``` /// vec![ /// "table",...
true
6b8193523d6565e6fa9d1e84e6e4c9f700f3c1ff
Rust
amarmaduke/reducto
/src/optimal.rs
UTF-8
21,815
3.140625
3
[ "MIT" ]
permissive
use std::collections::{HashSet, HashMap, VecDeque}; use std::ops::{Index, IndexMut}; use std::fmt; use crate::tree::Tree; use crate::strategy::Strategy; #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)] pub enum AgentKind { Application, Bracket, Croissant, Duplicator, Eraser, Lambd...
true
a87f0004bb7beea67c7e3b609247355f52114d8b
Rust
enizor/rusty-pick-em
/src/routes.rs
UTF-8
10,640
2.609375
3
[]
no_license
use rocket::form::Form; use rocket::http::{Cookie, CookieJar}; use rocket::request::FlashMessage; use rocket::response::{Flash, Redirect}; use rocket_dyn_templates::Template; use rocket_sync_db_pools::{database, diesel}; use crate::games::*; use crate::models::*; use crate::schema; use crate::session::*; use chrono::p...
true
e661ce912ae47b1fed5f55436390b569493a4b14
Rust
des256/e
/old/test_triangle.rs
UTF-8
8,361
2.8125
3
[ "MIT" ]
permissive
use { e::*, std::{ rc::Rc, time::Instant, }, gpu_macros::*, }; #[derive(Vertex)] struct MyVertex { pub pos: Vec2<f32>, pub color: Vec4<f32>, } #[vertex_shader] mod my_vertex_shader { // TEST SHADER ATTEMPTING TO USE ALL FEATURES struct SomeTuple(u8,i8,f16); type So...
true
4a494f6b9fe773a166668a6c4e0efa75f883a918
Rust
garentyler/rust-experiments
/networking/trapdoor/src/main.rs
UTF-8
3,411
2.765625
3
[ "MIT" ]
permissive
use std::io::prelude::*; use std::net::{TcpStream, TcpListener}; use openssl::ssl::{SslConnector, SslMethod, SslStream}; use trapdoor::packet; fn main() { let listener = TcpListener::bind("127.0.0.1:25565").unwrap(); for stream in listener.incoming() { let mut stream = stream.unwrap(); handle_st...
true
2371e35b0f80e2cafa581b82301187057a935caf
Rust
woshilapin/advent-calendar
/2019/15_oxygen-system/src/main.rs
UTF-8
9,719
3.109375
3
[]
no_license
use intcode::{self, Program}; use std::{ collections::HashMap, env, fmt::{self, Display, Formatter}, fs::File, io::{BufRead, BufReader}, ops::{Deref, DerefMut}, sync::mpsc, thread, }; type Position = (i64, i64); #[derive(Debug, Clone)] enum Tile { Empty(usize), Wall, Oxygen...
true
34badacb6ae7c1a9d05e17470d970838ebda7043
Rust
benesch/bytes
/src/hex.rs
UTF-8
840
2.984375
3
[ "MIT" ]
permissive
use crate::{Bytes, BytesMut}; use core::fmt::{Formatter, LowerHex, Result, UpperHex}; struct BytesRef<'a>(&'a [u8]); impl<'a> LowerHex for BytesRef<'a> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { for b in self.0 { write!(f, "{:02x}", b)?; } Ok(()) } } impl<'a> Upper...
true
361b48f11142efb1dbd86610276c073c9e729379
Rust
4x7y/nurbs-rs
/src/tests/rbtree.rs
UTF-8
1,616
2.734375
3
[]
no_license
use crate::robotics::RigidBodyTree; fn setup() -> RigidBodyTree { let file = "resource/sample.urdf"; RigidBodyTree::from_urdf_file(file).expect("urdf file not found.") } fn is_all_same<T: Eq>(slice: &[T]) -> bool { slice .get(0) .map(|first| slice.iter().all(|x| x == first)) .unwra...
true
c5535d55195973a5da8e14d2c643cf2540556382
Rust
lchannng/ehframe-bpf-compiler
/src/gen.rs
UTF-8
3,448
2.78125
3
[]
no_license
use crate::{Register, UnwindTable, UnwindTableRow}; use anyhow::Result; use std::io::Write; const PRE: &str = r#" #include <stdint.h> typedef enum { UNWF_RIP=0, UNWF_RSP=1, UNWF_RBP=2, UNWF_RBX=3, UNWF_ERROR=7, } unwind_flags_t; typedef struct { uint8_t flags; uintptr_t rip, rsp, rbp, rbx...
true
5033c56108cef469024c2ad8e2564b0e24d61e37
Rust
xiaoqixian/Wonderland
/leetcode/TextEditor.rs
UTF-8
17,747
2.84375
3
[]
no_license
/********************************************** > File Name : TextEditor.rs > Author : lunar > Email : lunar_ubuntu@qq.com > Created Time : Fri Aug 12 23:33:35 2022 > Location : Shanghai > Copyright@ https://github.com/xiaoqixian **********************************************/ use std::ptr:...
true
977aab4220015e443f9349159e276fa481a42814
Rust
nappa85/HashCode2018
/src/main.rs
UTF-8
8,395
3.1875
3
[]
no_license
use std::env; use std::io::{BufReader, BufRead, Write}; use std::fs::File; use std::str::FromStr; use std::collections::HashMap; use std::cmp::{PartialEq, Ordering}; pub struct Grid { rows: u64, cols: u64, vehicles: Vec<Vehicle>, rides: Vec<Ride>, bonus: u64, steps: u64, } impl Grid { pub...
true
333ef9933691cf13c18b8d0f142db58ba047dc60
Rust
telosprotocol/TOP-chain
/src/xtopcom/xevm_engine_rs/engine/src/error.rs
UTF-8
4,489
2.921875
3
[]
no_license
use evm::{ExitError, ExitFatal}; #[derive(Debug)] pub enum EngineStateError { NotFound, DeserializationFailed, } impl AsRef<[u8]> for EngineStateError { fn as_ref(&self) -> &[u8] { match self { Self::NotFound => b"ERR_STATE_NOT_FOUND", Self::DeserializationFailed => b"ERR_S...
true
2a4a5ec30f1e3ec3b5f06331c81b3e535b04ae07
Rust
jacobhenn/buzzer
/client/src/app/buzz_keys.rs
UTF-8
6,565
3.265625
3
[]
no_license
//! The component which allows contestants to select their buzz keys, and which //! detects when contestants have pressed their buzz key. use log::debug; use mogwai::prelude::*; use util::command::Command; use utils::send_command; use web_sys::WebSocket; use crate::utils::{self, BuzzMethod, ClientState, BUZZ_KEYS}; ...
true
5eccb0c26e59a1b20c062c04acafaddeb7c0e52a
Rust
rvarago/rustollens
/src/connective.rs
UTF-8
1,600
3.296875
3
[]
no_license
use super::{ boolean::{False, True}, private::Sealed, }; /// Type-level negation (NOT). pub trait Negation: Sealed { /// Logical conclusion of the negation of `Self`. type Output; } /// Type-level conjunction (AND). pub trait Conjunction<L>: Sealed { /// Logical conclusion of the conjunction of `S...
true
28ce999aa61962c2f4c3fe65736606ee3bb5d94c
Rust
stormyyd/yeelight-bulb-controller
/src/main.rs
UTF-8
2,035
3.21875
3
[ "ISC" ]
permissive
use std::env; use std::io::{self, BufRead, BufReader, BufWriter, Write}; use std::net::{SocketAddr, TcpStream}; use std::time; use rand::Rng; use command::Command; mod command; fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 3 { println!( "Usage: {} [IP_ADDRESS...
true
b029ac154de5948770dba4f3b4f30f67bb910c67
Rust
IThawk/rust-project
/rust-master/src/test/ui/span/issue-39018.rs
UTF-8
1,127
3.5
4
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
pub fn main() { let x = "Hello " + "World!"; //~^ ERROR cannot be applied to type // Make sure that the span outputs a warning // for not having an implementation for std::ops::Add // that won't output for the above string concatenation let y = World::Hello + World::Goodbye; //~^ ERROR cann...
true
82d5a22b61de99ea1d5d90a603c835fc97834d2e
Rust
McM1k/multilayer_perceptron
/src/perceptron/activation_functions.rs
UTF-8
3,048
3.515625
4
[]
no_license
use std::vec::Vec; #[derive(Clone, Copy)] pub enum ActivationNames { Sigmoid, HyperboloidTangent, RectifiedLinearUnit, } impl ActivationNames { pub fn get_fn(self) -> fn(f64) -> f64 { match self { ActivationNames::Sigmoid => sigmoid, ActivationNames::HyperboloidTangent ...
true
cea4f15559a8a60b232adb87c0a690f71f3f0ea8
Rust
elsuizo/Rust_work
/copy-generics-buffers/src/main.rs
UTF-8
833
3.125
3
[ "MIT" ]
permissive
// NOTE(elsuizo:2020-05-27): la idea de esta funcion es que sea generica para cualquier "reader" y // cualquier "writer" y lo que hace es copiar todos lo bytes de uno al otro use std::io::{self, Read, Write, ErrorKind}; const DEFAULT_BUFFER_SIZE: usize = 8 * 1024; fn copy<R: ?Sized, W: ?Sized>(reader: &mut R, writer...
true
873136a877d17594ea5eea3b726253990f811f0a
Rust
xosdy/aoc2018
/src/day14.rs
UTF-8
2,115
3.703125
4
[ "MIT" ]
permissive
pub struct Recipes { elves: Vec<usize>, scores: Vec<u32>, } impl Recipes { pub fn tick(&mut self) { let new_recipes: u32 = self.elves.iter().map(|&e| self.scores[e]).sum(); self.scores.extend( new_recipes .to_string() .chars() .map...
true
1e2c18729ed6f52a7cb3f060fc4e4e450e35f794
Rust
AlexanderMattheis/filter
/src/system/defaults/output_filenames.rs
UTF-8
1,361
2.890625
3
[]
no_license
use crate::system::basic::{paths, strings}; pub struct ChannelOutputNames; pub const SEPARATOR: &'static str = "_"; impl ChannelOutputNames { pub const RED: &'static str = "red"; pub const GREEN: &'static str = "green"; pub const BLUE: &'static str = "blue"; pub const ALPHA: &'static str = "alpha"; ...
true
e9dd115b108379ad769e0bef1938df4feea465e7
Rust
ercoppa/rust-scripts
/elapsed_time.rs
UTF-8
456
2.9375
3
[]
no_license
use std::process::Command; use std::thread::sleep; use std::time::{Duration, Instant}; use std::io::{self, Write}; fn main() { let now = Instant::now(); // run some process let status = Command::new("/bin/bash") .arg("-c") .arg("echo RUNNING && sleep 10 && echo DONE") .status() ...
true
4f23e585d2d0428e3be490d87c784359cea7caaa
Rust
gjz010-Archive/clouddrive
/src/support/mod.rs
UTF-8
5,381
2.765625
3
[]
no_license
use std::io::ErrorKind; use std::cmp::{max, min}; use std::ops::Range; use tokio::sync::Mutex; use async_trait::async_trait; mod lru; mod memory; mod byte; pub mod seafile; use std::ops::DerefMut; pub use self::byte::ByteGranularityProvider; pub use self::lru::LRUProvider; pub use self::memory::MemoryProvider; pub use...
true
2257d03c6b9616ef3f9bc14e91730860368da176
Rust
H2CO3/mdccc
/src/lib.rs
UTF-8
2,364
2.734375
3
[ "MIT" ]
permissive
/*! # MDCCC: Markdown Compiler-Compiler-Compiler MDCCC is a Markdown to LaTeX renderer. It's not a compiler compiler compiler; it's not even a compiler compiler, but I find the expression oddly satisfying. It's also the Roman numeral for 1800. ## Usage of the library The basic idea: there's a `LaTeXIter` type, which...
true
3cfa9598421e26fe6c6a2704b9ff8a16ca005334
Rust
hml1006/amqp-parser
/src/error.rs
UTF-8
1,174
2.734375
3
[]
no_license
use std::{io, fmt}; use std::fmt::{Display, Formatter}; use std::io::Error; #[derive(Debug)] pub enum FrameDecodeErr { Incomplete, UnknowFrameType, UnknownClassType, UnknownMethodType, ParseAmqpHeaderFailed, ParseFrameFailed, Amqp(amqp_types::error::Error), Io(io::Error) } impl Display...
true
c1b5a4cef2221558e2a630467383adae2bcfd156
Rust
ennocramer/lucifer
/src/geometry/mod.rs
UTF-8
4,396
3.71875
4
[]
no_license
//! Spatial geometry and ray-intersection math use std::f32::INFINITY; use cgmath; use cgmath::{InnerSpace, Transform}; pub mod cube; pub mod disc; pub mod plane; pub mod sphere; pub use self::cube::Cube; pub use self::disc::Disc; pub use self::plane::Plane; pub use self::sphere::Sphere; /// A direction or distanc...
true
be4fb8b05b83c0665317a0ca6f65a56f703fb04b
Rust
WizardOfMenlo/AOC
/day5/src/main.rs
UTF-8
853
2.875
3
[]
no_license
use std::{collections::HashSet, fs::read_to_string}; use std::iter::FromIterator; use std::usize; fn main() { let input = read_to_string("data/input").unwrap(); let mut parsed: Vec<_> = input .lines() .map(|l| { let rows = &l[0..7].replace('F', "0").replace('B', "1"); l...
true
6cdaa0a7596149fdebce562fc9a4a068a3aa7a3b
Rust
MarcusGrass/advent_of_code_2020
/src/solutions/aoc_five.rs
UTF-8
2,499
3
3
[]
no_license
static ROWS: i32 = 128; static COLS: i32 = 8; pub fn solve_both(session: &str) { let lines = crate::util::fetch_lines(5, session); solve_first(&lines); solve_second(&lines); } fn solve_first(lines: &Vec<String>) { let mut max = 0; let coords = get_all_seat_coords(lines); for coord in &coords ...
true
6f1ca5039b5a0eba412348d2fd0361a7c5324862
Rust
clay53/from_anarchy
/from_anarchy_server/src/main.rs
UTF-8
4,734
2.625
3
[]
no_license
use std::{ borrow::Cow, collections::HashMap, io::Error as IoError, net::SocketAddr, sync::{Arc, Mutex}, thread, time::{ Duration, Instant }, }; use futures::prelude::*; use futures::{ channel::mpsc::{unbounded, UnboundedSender}, future, pin_mut, }; use async_st...
true
4aa245d1ef6d4420590c333ec433aebeee3a105a
Rust
Cupnfish/village-sim
/game_plugin/src/loading.rs
UTF-8
3,596
2.578125
3
[ "CC0-1.0" ]
permissive
mod paths; use crate::loading::paths::PATHS; use crate::GameState; use bevy::asset::LoadState; use bevy::prelude::*; use bevy_kira_audio::AudioSource; // TODO: refactor this file. This is error prone, you must remember to start loading the textures in one method and insert them in another (here) pub struct LoadingPl...
true
27873f61b4894f9c81e2c3bc8453c1e9d6906b07
Rust
yancheng199287/rquickjs-lib
/src/js_class.rs
UTF-8
1,755
2.5625
3
[]
no_license
use rquickjs::{ObjectDef, Ctx, Object, Func, class_def, Method, ClassDef}; pub trait JSClass: ClassDef { // 构造方法 // 打印当前对象的各个属性 fn to_json_string(&self); } pub mod animal { use crate::js_class::JSClass; use rquickjs::{ObjectDef, Ctx, Result, Object, Func, class_def, Method, ClassDef, RefsMarker, ...
true
cfef7eb9f18e3ec3600356cd3d8b3113b3bbc0fb
Rust
StoriqaTeam/statics
/src/main.rs
UTF-8
1,183
2.84375
3
[]
no_license
//! Statics is a microservice responsible for uploading different static assets like images, videos, etc. //! The layered structure of the app is //! //! `Application -> Controller -> Service -> HttpClient` //! //! Currently available routes: //! //! - `GET /healthcheck` - returns `"ok"` if the server is live //! - `PO...
true
4fad7479952ff15883027d975e43113f55d88d1c
Rust
super-rust-boy/super-rust-boy
/src/audio/channels/square2.rs
UTF-8
4,016
2.984375
3
[ "MIT" ]
permissive
use super::*; const MAX_LEN: u8 = 64; pub struct Square2 { // Public registers pub duty_length_reg: u8, pub vol_envelope_reg: u8, pub freq_lo_reg: u8, pub freq_hi_reg: u8, // Internal registers enabled: bool, duty_counter: DutyCycleCounter, volume: ...
true
a00f4f42855059cab7ed3d99a04385f7a5ffbeff
Rust
JamesHallowell/launchpad-pro-rs
/src/hal.rs
UTF-8
23,380
3.140625
3
[ "BSD-3-Clause" ]
permissive
use core::ops::Add; #[doc(hidden)] pub use spin::Mutex; #[cfg(target_arch = "arm")] extern "C" { fn hal_plot_led(t: u8, index: u8, red: u8, green: u8, blue: u8); fn hal_read_led(t: u8, index: u8, red: *mut u8, green: *mut u8, blue: *mut u8); fn hal_send_midi(port: u8, status: u8, data1: u8, data2: u8); ...
true
e57a64d540c3f6a9a3c08dad2f7845de6b63e6cf
Rust
angelocatalani/hexagonal_architecture
/hexagonal_pokedex/src/pokemon_bounded_context/port/service/pokemon_translator.rs
UTF-8
11,562
3.015625
3
[]
no_license
use crate::pokemon_bounded_context::domain::Pokemon; use crate::pokemon_bounded_context::port::out::{ CacheRetrieval, CacheUpdater, ShakespeareTranslator, YodaTranslator, }; pub struct PokemonTranslator<S, Y, R, U> where S: ShakespeareTranslator, Y: YodaTranslator, R: CacheRetrieval, U: CacheUpdate...
true
323058b8b064296bda223adc4cf7eb00154a665e
Rust
vanhtuan0409/exercism
/rust/dot-dsl/src/lib.rs
UTF-8
1,966
3.046875
3
[ "MIT" ]
permissive
use std::collections::HashMap; macro_rules! attributable { () => { pub fn get_attr(&self, key: &str) -> Option<&str> { self.attrs.get(key).map(|s| s.as_str()) } pub fn with_attrs(mut self, attrs: &[(&str, &str)]) -> Self { self.attrs = attrs .iter() ...
true
7b82bf93cc3a5cbdddcad11aae0816edb1201d19
Rust
jwgarber/password-hashes
/argon2/tests/phc_strings.rs
UTF-8
1,452
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Test vectors for Argon2 password hashes in the PHC string format //! //! Adapted from: <https://github.com/P-H-C/phc-winner-argon2/blob/master/src/test.c> #![cfg(all(feature = "alloc", feature = "password-hash"))] use argon2::{Argon2, PasswordHash, PasswordVerifier}; /// Valid password pub const VALID_PASSWORD: ...
true
7721d95e162d4eba3f7912a251f492a9169c55e5
Rust
flmmkch/titlefmt
/src/function/string/right/test.rs
UTF-8
999
2.875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{test, Formatter}; use std::collections::HashMap; #[test] fn test_function_right() { let formatter = Formatter::new(); { let test_metadata = test::MetadataProvider::new(HashMap::new()); let do_test = |original, at_char, expected| { let expression = formatter ...
true
2c1d96602b8b824ed0e51f5b1ea054b1f04b4f35
Rust
plurid/derive
/src/main.rs
UTF-8
2,912
2.859375
3
[ "MIT" ]
permissive
extern crate clap; use std::env; use std::fs; use std::io; use std::path::PathBuf; use clap::{App, Arg, SubCommand}; // mod deversion; // mod repository; fn main() { let app = App::new("derive") .version(env!("CARGO_PKG_VERSION")) .author(env!("CARGO_PKG_AUTHORS")) ...
true
49cebda53b5a7578467f481de9e9f1a79f754a39
Rust
joshfinnie/advent-of-code
/2021/src/days/day06.rs
UTF-8
1,163
3.484375
3
[ "MIT" ]
permissive
fn parse_input(input: &String) -> Vec<u8> { input .trim() .split(',') .map(|v| v.parse::<u8>().unwrap()) .collect() } pub fn part1(input: String) { let mut report = parse_input(&input); let days = 80; for _ in 1..=days { for i in 0..report.len() { if ...
true
2107788eec7646487e35be7299ac4b6bd9adf395
Rust
EFanZh/Introduction-to-Algorithms
/src/chapter_6_heapsort/problems/problem_6_2_analysis_of_d_ary_heaps.rs
UTF-8
3,242
3.375
3
[]
no_license
pub struct DAryHeap<T> { data: Vec<T>, d: usize, } impl<T: Ord> DAryHeap<T> { #[must_use] pub fn new(d: usize) -> Self { Self { data: Vec::new(), d } } fn parent(&self, i: usize) -> usize { (i - 1) / self.d } fn children(&self, i: usize) -> (usize, usize) { let...
true
4eadb4f7b353d63f2abaaba68d790619530d4e44
Rust
lindentree/ssvm-nodejs-starter
/src/lib.rs
UTF-8
849
3.296875
3
[]
no_license
use wasm_bindgen::prelude::*; // extern crate num_bigint as bigint; // extern crate num_traits; // use bigint::BigUint; // use num_traits::{Zero, One}; // #[wasm_bindgen] // pub fn say(s: &str) -> String { // println!("The Rust function say() received {}", s); // let r = String::from("hello "); // return r + s...
true
7bb3db848875323bad8820b7e117d9f4d375eb19
Rust
felix91gr/pathfinding
/tests/connected-components.rs
UTF-8
1,847
2.953125
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate itertools; extern crate pathfinding; use itertools::Itertools; use pathfinding::undirected::connected_components::*; use std::usize; #[test] fn basic_separate_components() { let (h, g) = separate_components(&[vec![1, 2], vec![3, 4], vec![5, 6], vec![1, 4]]); assert!([1, 2, 3, 4].into_iter().map(|...
true
34387e35b9c5618cdc7277d81e7a81e0166da9d7
Rust
nicolasjhampton/rust-server-framework
/network/src/server/utils/threadpool.rs
UTF-8
1,521
3.0625
3
[]
no_license
use std::io::{Read, Write}; use std::sync::Arc; use std::sync::Mutex; use std::sync::mpsc; use std::net::TcpStream; use super::worker::Worker; use super::message::Message; use router::Router; pub struct ThreadPool { workers: Vec<Worker>, sender: mpsc::Sender<Message> } impl ThreadPool { pub fn new(thread...
true
9778ab70ddaef4c59b2fa14d7789d106247b7004
Rust
KodrAus/sval
/src/serde/error.rs
UTF-8
1,684
2.875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::std::fmt; use serde_lib::ser; /** An error encountered during serialization. */ pub(super) struct Error(crate::Error); impl From<fmt::Error> for Error { fn from(_: fmt::Error) -> Self { Error(crate::Error::msg("error during formatting")) } } impl From<crate::Error> for Error { fn from...
true
13edd95146f27b81d74389bb42ea3c797444bb79
Rust
vaibhavantil2/third-party-api-clients
/google/calendar/src/calendar_list.rs
UTF-8
14,046
3.15625
3
[ "CC-BY-3.0", "MIT" ]
permissive
use anyhow::Result; use crate::Client; pub struct CalendarList { pub client: Client, } impl CalendarList { #[doc(hidden)] pub fn new(client: Client) -> Self { CalendarList { client } } /** * This function performs a `GET` to the `/users/me/calendarList` endpoint. * * Retur...
true
0dbb7f2ab765c48a8a39060d1f01efa62118a910
Rust
SamHDev/luna_nbt
/src/ser.rs
UTF-8
10,543
2.78125
3
[ "MIT" ]
permissive
use serde::{Serializer, Serialize}; use crate::Tag; use crate::error::NBTError; use std::collections::HashMap; use std::fmt::Display; use serde::ser::{SerializeSeq, SerializeTuple, SerializeTupleStruct, SerializeTupleVariant, SerializeMap, SerializeStruct, SerializeStructVariant}; pub struct NBTSerializer; #[allow(un...
true
ab3be1cfec270fead77922cf80c0e75304f7c832
Rust
sjinno/exercism
/triangle/src/lib.rs
UTF-8
941
3.453125
3
[]
no_license
use num::Zero; // num = "0.4" use std::ops::Add; pub struct Triangle<T> { sides: [T; 3], } impl<T> Triangle<T> where T: Add<Output = T> + Copy + PartialOrd + Zero, { pub fn build(sides: [T; 3]) -> Option<Self> { if sides.iter().any(|n| n.is_zero()) { return None; } let ...
true
39ccebb3a35409e06b2465b96f582302e7f99f77
Rust
royswale/leetcode
/src/bin/water-bottles.rs
UTF-8
446
3.390625
3
[ "MIT" ]
permissive
fn main() { assert_eq!(19, Solution::num_water_bottles(15, 4)); } struct Solution; impl Solution { pub fn num_water_bottles(mut num_bottles: i32, num_exchange: i32) -> i32 { let mut a = num_bottles; // 剩余的空瓶 while a >= num_exchange { num_bottles += 1; // 瓶数加1 a -= num_...
true
539062468fa07cfba0902a8b92e76ea085a48321
Rust
cnruby/learn-rust-by-crates
/hello-borrowing/bin-hello/src/features/rs_files/for_loop_for_next.rs
UTF-8
1,707
3.046875
3
[]
no_license
pub const FOR_NEXT_OK :&str = r#"pub fn main() { let mut instance = vec![33u8; 5]; let mut iter = instance.iter_mut(); loop { match iter.next() { Some(x) => println!("{:?}", x), None => break, } } println!("{:?}", instance); } "#; pub const FOR_NE...
true
826f734c7da138733f57fa93491a1dd9ebb181c6
Rust
CarlosJordanDev/auto-fuzz-test
/src/crate_parse.rs
UTF-8
26,309
2.609375
3
[ "MIT", "Apache-2.0" ]
permissive
use fs3::FileExt; use proc_macro2::TokenStream; use std::fs::{File, OpenOptions}; use std::io::{Error, ErrorKind, Read, Write}; use std::path::{Path, PathBuf}; use syn::{Ident, Type}; use cargo_toml::Value::String as TomlString; use cargo_toml::Value::Table as TomlTable; use toml::value::Value as TomlValue; #[derive(...
true
05142868eaa2ef58989eb99e88bfd526f0e1908a
Rust
SWi98/UWr
/Kurs Rust/Lista 6/Zadanie4/src/main.rs
UTF-8
344
3.234375
3
[]
no_license
fn comp(a: Vec<i64>, b: Vec<i64>) -> bool { let mut _a = a.iter().map(|x| x * x).collect::<Vec<i64>>(); let mut _b = b; _a.sort(); _b.sort(); _a == _b } fn main() { let a1 = vec![121, 144, 19, 161, 19, 144, 19, 11]; let a2 = vec![11*11, 121*121, 144*144, 19*19, 161*161, 19*19, 144*144, 19*1...
true
3354f21d012b451d73f696a47aaf028820e34512
Rust
JIghtuse/adventofcode-solutions
/2016/day14/otp/src/main.rs
UTF-8
3,253
3.0625
3
[]
no_license
extern crate crypto; use crypto::md5::Md5; use crypto::digest::Digest; const THREES : &'static [&'static str] = &[ "000", "111", "222", "333", "444", "555", "666", "777", "888", "999", "aaa", "bbb", "ccc", "ddd", "eee", "fff", ]; const FIVES : &'static ...
true
b487ab38aea050ccd71e5ecf36a6179dff1838bf
Rust
wildonion/katyusha
/katrust/src/commands.rs
UTF-8
770
2.578125
3
[]
no_license
use std::error::Error; use teloxide::{prelude::*, utils::command::BotCommand}; use crate::utils as botter; //-- or use utils as botter #[derive(BotCommand)] #[command(rename = "lowercase", description = "Attack with one the following commands:")] pub enum Command { #[command(description = "Take Screenshot"...
true
0f04b80f084a0ad33481e74684cf6d83864e2fe0
Rust
evanmcc/Rustler
/src/atom.rs
UTF-8
2,920
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::HashMap; use std::sync::RwLock; use std::sync::Mutex; use std::ops::DerefMut; use super::{ NifTerm, NifEnv }; use ::wrapper::nif_interface::size_t; use ::wrapper::nif_interface::{ enif_make_atom_len, enif_alloc_env, NIF_ENV, NIF_TERM }; // Atoms are a special case of a term. They can be stored a...
true
d9b18039e0cbd51f93c11f083da88f7409ae9707
Rust
oldtree2008/shaku
/shaku/examples/simple_with_macros.rs
UTF-8
1,412
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
//! A simple example of using shaku with derives and macros (see the //! simple_no_macros example for the same code, but without derives or macros). use shaku::{module, Component, HasComponent, HasProvider, Interface, Provider}; use std::fmt::Debug; use std::sync::Arc; // Traits trait SampleDependency: Interface + D...
true
6878a1ba40890f009ed114a4268136c6fdffc000
Rust
ecafkoob/ockam
/examples/rust/get_started/src/logger.rs
UTF-8
1,092
2.9375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use ockam::{hex, Any, Context, Result, Routed, Worker}; pub struct Logger; #[ockam::worker] impl Worker for Logger { type Context = Context; type Message = Any; /// This handle function takes any incoming message and print its content as a UTF-8 string /// if it's correct UTF-8 string, and in hex if ...
true
bd8d218414074e6f62949101d3461209feac34e4
Rust
Kurtoid/ktop
/src/config.rs
UTF-8
1,044
2.984375
3
[]
no_license
use clap::ArgMatches; const DEFAULT_DELAY: u64 = 5; pub struct AppConfig { pub delay: u64, pub run_once: bool, pub can_use_debugfs: bool, pub show_threads: bool } pub fn create_config_from_matches(matches: ArgMatches)-> AppConfig{ let delay_str = matches.value_of("refresh time"); let delay_tim...
true
5db7719a93057fa723fc339d933b0f64075dec7b
Rust
data-pup/intro-to-macros-presentation
/example/run_example/src/main.rs
UTF-8
316
2.546875
3
[]
no_license
extern crate awoo; #[macro_use] extern crate awoo_derive; use awoo::Awoo; struct Puppo; impl Awoo for Puppo { fn awoo() { println!("I am a Puppo! Awoo!"); } } #[derive(Awoo)] struct Doggo; #[derive(Awoo)] struct Friendo; fn main() { Puppo::awoo(); Doggo::awoo(); Friendo::awoo(); }
true
784059434f972e501540aecf947209702dac72b4
Rust
huangqian/rust-in-action
/examples/redis.rs
UTF-8
979
2.75
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] extern crate redis; use redis::Commands; #[cfg(test)] mod test { use super::*; #[test] pub fn test_hello_simple() { let client = redis::Client::open("redis://192.168.30.244/0").unwrap(); let mut conn = client.get_connection().unwrap(); // ...
true
d1957e0928e41f7cf8a48938e65d8ac0d0322375
Rust
alanpoon/hardback_server
/src/game_logic/show_draft.rs
UTF-8
3,477
2.59375
3
[]
no_license
use codec_lib::codec::*; use game_logic::board::BoardStruct; use game_logic::game_engine::GameCon; use rand::{thread_rng, Rng, SeedableRng, StdRng}; use std::collections::HashMap; pub fn go_to_shuffle<T: GameCon>(randseed: Option<&[usize]>, _board: &mut BoardStruct, ...
true
cf8c7718993045d3a7b44013692b662c52d961f2
Rust
Klades/Advent2020
/src/day9.rs
UTF-8
2,387
3.875
4
[]
no_license
use std::collections::VecDeque; pub fn part1(data: &Vec<String>) -> i64 { let mut breaker = Breaker::new(25); for number in data.iter().map(|line| line.parse::<i64>().unwrap()) { if !breaker.process(number) { return number; } } // yes this should probably actually return Result or Option but whatever return -1...
true
0e05e82a90b3240a9d47e65030d1ea754c1b44ce
Rust
pit-rpg/Viz
/src/core/perspective_camera.rs
UTF-8
3,785
2.9375
3
[]
no_license
extern crate specs; use math::{Matrix4}; use std::f32::consts::PI; use self::specs::{Component, VecStorage}; #[allow(dead_code)] #[derive(Clone, Debug)] pub struct PerspectiveCamera { pub fov: f32, pub zoom: f32, pub near: f32, pub far: f32, pub focus: f32, pub aspect: f32, pub film_gauge: f32, pub film_offs...
true
2d67722c6b95f6c412304125d5d98fc93e08123c
Rust
qiuzhanghua/rust-app
/src/handlers/mod.rs
UTF-8
5,724
3
3
[]
no_license
use serde::{Deserialize, Serialize}; use actix_web::{HttpRequest, HttpResponse, web, Error}; use handlebars::Handlebars; use actix_multipart::Multipart; use futures::StreamExt; use async_std::prelude::*; use crate::utils; use crate::db::*; use crate::db::models::User; pub async fn index(_req: HttpRequest) -> &'static ...
true
2e0f1177b3dfa1d4819c825770c8379f727b24e5
Rust
theduke/rust
/src/librustc_data_structures/snapshot_map/test.rs
UTF-8
1,546
2.796875
3
[ "MIT", "NCSA", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-3-Clause", "BSD-2-Clause", "Unlicense", "LicenseRef-scancode-other-permissive" ]
permissive
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
true
fe7cdf9a0601fb650e8fe4241dad14166fcfb2e1
Rust
royswale/leetcode
/src/bin/merge-k-sorted-lists.rs
UTF-8
2,354
3.421875
3
[ "MIT" ]
permissive
fn main() {} struct Solution; // Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } impl Solution { pub ...
true
c1bda28729184829653b6311ed0232fd8036f820
Rust
DiegoMagdaleno/fetch_me
/src/lib.rs
UTF-8
16,049
2.640625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![recursion_limit = "1024"] #[macro_use] extern crate derive_new; #[macro_use] extern crate derive_setters; #[macro_use] extern crate log; #[macro_use] extern crate thiserror; pub mod checksum; mod range; mod systems; pub use self::systems::*; use std::{ fmt::Debug, io, num::{NonZeroU16, NonZeroU32, No...
true
4bb488d5cd40c9e4b59b0e904a4018f944068c3d
Rust
rousan/rust-web-frameworks-benchmark
/hyper/src/main.rs
UTF-8
875
2.90625
3
[ "MIT" ]
permissive
use hyper::service::{make_service_fn, service_fn}; use hyper::{Body, Request, Response, Server}; use std::convert::Infallible; use std::net::SocketAddr; async fn hello_world(_req: Request<Body>) -> Result<Response<Body>, Infallible> { Ok(Response::new("Hello, World".into())) } #[tokio::main] async fn main() { ...
true
052ef5ca4665676dc0bab29672fad7589c13e51a
Rust
asnelling/psst
/psst-gui/src/widget/utils.rs
UTF-8
3,989
2.9375
3
[ "MIT" ]
permissive
use druid::{ kurbo::{Line, Shape}, widget::{prelude::*, BackgroundBrush, Painter}, Color, Data, KeyOrValue, }; pub struct Clip<S, W> { shape: S, inner: W, } impl<S, W> Clip<S, W> { pub fn new(shape: S, inner: W) -> Self { Self { shape, inner } } } impl<T: Data, S: Shape, W: Widget...
true
6dfb52ac33c8a050c58b4e3259b3ffbbef20e06c
Rust
jameysharp/rusty-tower
/src/component.rs
UTF-8
1,363
2.859375
3
[]
no_license
pub trait Emitter<T> { fn emit(&mut self, event: T); } pub trait Monitor { const MONITOR_INIT : Self; } macro_rules! monitor_state { ($monitor:ident {}) => ( pub struct $monitor; impl Monitor for $monitor { const MONITOR_INIT : $monitor = $monitor; } ); ($monitor:ident { $( $statename:ident : $statety...
true
4446b14203adfe49d518de50c616660d28058705
Rust
rigma/adventofcode
/2022/01/src/main.rs
UTF-8
619
2.9375
3
[]
no_license
use std::{ env, fs, io::{self, BufRead, BufReader}, }; fn main() -> io::Result<()> { let args: Vec<String> = env::args().collect(); let file = fs::File::open(&args[1])?; let file = BufReader::new(file); let mut stocks = Vec::new(); let mut sum = 0; for line in file.lines() { m...
true
87cb4c73e9374727bdfa1fadbf4fefbcaa052ea8
Rust
Drumato/peachili
/src/common/three_address_code/code_kind.rs
UTF-8
6,810
2.8125
3
[ "MIT" ]
permissive
use crate::common::three_address_code::function::ValueArena; use crate::common::three_address_code::ValueId; /// Codeの種類 #[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone)] pub enum CodeKind { ADD { lop: ValueId, rop: ValueId, result: ValueId, }, SUB { lop: ValueId, ...
true
b5fe367c6260f0dfcbcd77efb4291ca0ee8c24dd
Rust
antaljanosbenjamin/rust_projects
/minesweeper/src/minesweeper_logic/table.rs
UTF-8
51,060
2.703125
3
[ "MIT" ]
permissive
use super::basic_types::SizeType; use super::field_info::{FieldInfo, FieldState, FieldType}; use super::results::{FlagResult, OpenInfo, OpenResult}; use indexmap::IndexSet; use mockall::automock; use std::collections::{HashMap, HashSet}; use strum_macros::Display; static INVALID_VALUE_ERROR: &'static str = "Invalid va...
true
fd2da56dc9c9c5fe285e032667c75289e74cd2f1
Rust
cloudflare/lol-html
/src/rewriter/mod.rs
UTF-8
28,296
2.578125
3
[ "BSD-3-Clause", "CC-BY-SA-4.0" ]
permissive
mod handlers_dispatcher; mod rewrite_controller; #[macro_use] mod settings; use self::handlers_dispatcher::ContentHandlersDispatcher; use self::rewrite_controller::*; use crate::base::SharedEncoding; use crate::memory::MemoryLimitExceededError; use crate::memory::MemoryLimiter; use crate::parser::ParsingAmbiguityErro...
true
dad1177bd532c5111b905324c49a796155b15b46
Rust
enso-org/enso
/build/ci_utils/src/cache/archive.rs
UTF-8
1,447
2.671875
3
[ "AGPL-3.0-only", "Apache-2.0", "AGPL-3.0-or-later" ]
permissive
use crate::prelude::*; use crate::cache::Cache; use crate::cache::Storable; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Key<S> { pub archive_source_key: S, pub path_to_extract: Option<PathBuf>, } #[derive(Clone, Debug)] pub struct ExtractedArchive<S> { pub archive_source: S, pub ...
true
c8c41dba3b256c0943191e5f4e90b2d33b898f07
Rust
antialize/MerkelBackup
/src/server/handler.rs
UTF-8
30,455
2.578125
3
[ "MIT" ]
permissive
use base64::Engine; use hyper::header::CONTENT_LENGTH; use hyper::{Body, Method, Request, Response, StatusCode}; use rusqlite::params; use std::fmt::Write; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; use crate::config::{AccessType, Config, SMALL_SIZE}; use crate::error::{Error, ResponseFuture, Result}...
true
a2a92c0852ed3f23b7d2cd7a92270daec8609bc8
Rust
rust-lang/cargo
/crates/cargo-test-support/src/diff.rs
UTF-8
5,251
3.3125
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 simple Myers diff implementation. //! //! This focuses on being short and simple, and the expense of being //! inefficient. A key characteristic here is that this supports cargotest's //! `[..]` wildcard matching. That means things like hashing can't be used. //! Since Cargo's output tends to be small, this shoul...
true
1405e528a82bf88baaf8c681bc2dd4bc26561714
Rust
PacktPublishing/The-Complete-Rust-Programming-Reference-Guide
/Chapter08/async_channels.rs
UTF-8
361
2.96875
3
[ "MIT" ]
permissive
// async_channels.rs use std::thread; use std::sync::mpsc::channel; fn main() { let (tx, rx) = channel(); let join_handle = thread::spawn(move || { while let Ok(n) = rx.recv() { println!("Received {}", n); } }); for i in 0..10 { tx.send(i).unwrap(); } drop...
true
eee7045948ee00fd4340b774a812c6420e459384
Rust
shory152/rustmpmc
/src/mpmcq2.rs
UTF-8
12,412
3.03125
3
[ "MIT" ]
permissive
/// /// my MPMC queue /// use std::sync::atomic::{AtomicIsize, AtomicI32, Ordering, AtomicBool}; use std::mem::swap; use std::sync::{MutexGuard, Condvar, Mutex, Arc}; use crate::QueueType::MyFastQueue; /// /// my condition /// struct MyCond{ lock : Mutex<()>, cond : Condvar, } impl MyCond{ /// /// cr...
true
0b1528f43a47060d18459d88fb56274431da7c2f
Rust
cqueirolo/21C1-Stormtroopers
/redis_server/src/command/db_list_cmd/db_list_generator.rs
UTF-8
1,836
2.65625
3
[]
no_license
//! Helper function that instanciate all of the list related commands. use crate::command::command_builder::CommandBuilder; use crate::command::db_list_cmd::lindex_cmd::LindexCommand; use crate::command::db_list_cmd::llen_cmd::LLenCommand; use crate::command::db_list_cmd::lpop_cmd::LpopCommand; use crate::command::db_l...
true
f5376a9d1eb3f18416c6fa2a10e27003aab426a6
Rust
lusamreth/my_first_cli_app
/src/interface/mod.rs
UTF-8
5,010
2.71875
3
[]
no_license
use super::utility; // use std::cell::RefCell; // use std::collections::VecDeque; // use std::rc::Rc; use terminal_size::{terminal_size, Height, Width}; pub mod template_engine; pub mod text_processing; pub mod printer; pub mod components; #[derive(Debug)] pub struct TerminalSize { pub x: u16, pub y: u16, } imp...
true
dbb0c39a96128eaef4f70d320250c82d8e9decc4
Rust
caibirdme/leetcode_rust
/src/ggprob/prob_929.rs
UTF-8
794
2.90625
3
[ "MIT" ]
permissive
use std::collections::{HashSet, HashMap}; impl Solution { pub fn num_unique_emails(emails: Vec<String>) -> i32 { use std::str::from_utf8_unchecked; let mut set = HashMap::new(); for email in emails { let email = email.as_bytes(); let mut k = 0; while emai...
true
3843f7696482ede02dec7929438e26c20790944e
Rust
einoj/ray_tracing_owe
/oneweekend/src/ch4/sphere.rs
UTF-8
1,409
2.8125
3
[]
no_license
use vec3::dot; fn hit_sphere(center: vec3::Vec3, radius: f64, r: &ray::Ray) -> bool { let oc: vec3::Vec3 = r.origin() - center; let a: f64 = dot(&r.direction(), &r.direction()); let b: f64 = 2.0 * dot(&oc, &r.direction()); let c: f64 = dot(&oc, &oc) - radius*radius; let discriminant: f64 = b*b - 4...
true
0e34efc33de7e8415330615950ae93da7d8ca2e9
Rust
immunant/rstrace
/src/bin/cceq.rs
UTF-8
3,829
2.796875
3
[]
no_license
use std::fs::read_to_string; use std::iter::FromIterator; use std::path::Path; use std::process::exit; #[macro_use] extern crate serde_derive; extern crate serde_json; use serde_json::Result; #[macro_use(crate_version, crate_authors)] extern crate clap; use clap::{App, Arg}; use std::collections::HashSet; use std::er...
true
4e03d2af9475def75afc8ed9af666a4eb5b1fa99
Rust
mystor/cghelper
/examples/simple_struct.rs
UTF-8
1,443
2.890625
3
[]
no_license
#[macro_use] extern crate cghelper; use cghelper::Code; struct Struct<'a> { name: &'a str, fields: &'a [(&'a str, &'a str)], } fn gen_fields_code(fields: &[(&str, &str)]) -> Code { fields.iter().map(|&(name, ty)| { code! { "$ty $name;\n", ty: ty, name: name, ...
true
00c024f7d8c3bc27dd3b400a9161a3078f23a276
Rust
P3qch/minesweeper-tui
/src/field.rs
UTF-8
8,283
2.84375
3
[ "MIT" ]
permissive
/* MIT License Copyright (c) 2021 P3qch 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 rights to use, copy, modify, merge, publish, distrib...
true
5a702e641178dcde293fc1bfec3383c7deb65736
Rust
szhongren/rust_learn
/12_generics/3_traits.rs
UTF-8
667
3.40625
3
[]
no_license
// traits can also be generic // non-copyable types struct Empty; struct Null; // a trait generic over T trait DoubleDrop<T> { // def a method on the caller type which takes an additional single param T fn double_drop(self, _: T); } // impl doubledrop for any generic param T and caller U // <T, U>...
true
1c9f2d5bad7bb76038c7b69a010b283e03e02948
Rust
qwerty2501/experimental-wasm-aot
/src/engine/frame.rs
UTF-8
5,612
2.78125
3
[ "MIT" ]
permissive
use super::*; use parity_wasm::elements::ValueType as WasmValueType; use parity_wasm::elements::Instruction; pub struct Frame<'a,T:WasmIntType + 'a>{ pub locals:Vec<LocalValue<'a>>, pub module_instance:ModuleInstance<'a,T>, pub history:InstructionHistory<'a>, } pub struct ModuleInstance<'a,T:WasmIntType...
true
c55d3e14e95f86c48b7d9ed3636e9b7f403cab38
Rust
p0lunin/umlsm_old
/src/vert_handler.rs
UTF-8
3,188
2.6875
3
[]
no_license
use crate::process_result::ProcessResultSubstate; use crate::vertex::{StateMachineVertex, TerminationPseudoState}; use crate::{CurrentStateIs, ProcessEvent}; use frunk::coproduct::{CNil, CoproductSelector}; use frunk::{Coproduct, HCons, HNil}; use std::marker::PhantomData; pub trait VertexHandler<Vertex, Idx, Event, A...
true
f96ea8b498c96e592f3d2846369070f83596d6c3
Rust
zTgx/jlib-rs
/src/api/message/local_sign_tx.rs
UTF-8
1,146
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
use serde::{Deserialize, Serialize}; use serde::ser::{Serializer, SerializeStruct}; #[derive(Deserialize, Debug, Default)] pub struct LocalSignTx { #[serde(rename="id")] id: u64, #[serde(rename="command")] pub command: String, #[serde(rename="tx_blob")] pub tx_blob: String, } impl Serialize...
true
2ce7bb7f7f04bc6c44dff480abd4b28df2e84079
Rust
nacho-vlad/raytracer-rs
/src/scene/camera.rs
UTF-8
1,495
3.078125
3
[ "MIT" ]
permissive
use crate::vec3::Vec3; use crate::ray::Ray; pub struct Camera { pub vfov: f64, pub aspect: f64, pub look_from: Vec3, pub look_at: Vec3, pub look_up: Vec3 } impl Camera { pub fn new( look_from: Vec3, look_at: Vec3, look_up: Vec3, vfov: f64, aspect: f64) -> Camera { Camera { look_from, ...
true
666a72a7fdbaa74f3b13d41e5aff41780735cba9
Rust
andfoy/curryrs
/rust/hrgen/hs-type-parser/src/lib.rs
UTF-8
5,213
3.25
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
extern crate combine; extern crate combine_language; use combine::Parser; use std::borrow::Cow; use std::marker::PhantomData; #[derive(Debug, PartialEq, Eq)] pub enum Type { Constr(Cow<'static, str>), Var(String), App(Box<Type>, Box<Type>), } pub fn constr<S: Into<Cow<'static, str>>>(name: S) -> Type { Type::...
true
14321e236006a79ee6bc14d0206a0fb7b5a9e5fa
Rust
arn-the-long-beard/facebook-api-rs
/examples/seed/src/lib.rs
UTF-8
6,035
2.90625
3
[]
no_license
use facebook_api_rs::prelude::*; use seed::{prelude::*, *}; // ------ ------ // Init // ------ ------ // `init` describes what should happen when your app started. fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model { orders.perform_cmd(async { // Load config from some json. // You can ha...
true
9e7f6e7cf06cc9e7ae567b56850c28876a034cad
Rust
AishwaryaKaranth/av-metrics
/av_metrics/src/capi.rs
UTF-8
12,336
2.53125
3
[ "MIT" ]
permissive
#![allow(dead_code)] extern crate libc; use libc::c_char; use std::ffi::CStr; use std::fs::File; use std::os::raw::c_int; use std::path::{Path, PathBuf}; use std::ptr::null; use crate::video::*; #[derive(Debug, Clone, Copy)] enum InputType { Video(VideoContainer), Unknown, } impl InputType { pub fn det...
true