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
af40ce6b70f03b4b3079e57c11dac1bf197068d1
Rust
lizhuohua/impulse-engine-rust-wasm
/src/rand.rs
UTF-8
344
2.75
3
[]
no_license
use rand::rngs::OsRng; use rand::RngCore; pub struct Rng { rng: OsRng, } impl Rng { pub fn new() -> Self { Self { rng: OsRng::new().unwrap(), } } pub fn gen_range(&mut self, min: i32, max: i32) -> i32 { let r = self.rng.next_u32(); (r % (max - min + 1) as u3...
true
4db2204267af3a6c4370065ae9cc850edc4f8b1e
Rust
supernothing/clamav-rest
/src/main.rs
UTF-8
2,465
2.515625
3
[ "MIT" ]
permissive
use actix_web::{web, App, HttpServer, Responder, middleware, Error, FromRequest}; use clamav; use clamav::{db, engine, scan_settings}; use std::sync::{Arc}; use awmp; use std::process::Command; use serde_derive::Serialize; #[derive(Clone)] pub struct Scanner { scanner: Arc<engine::Engine>, settings: Arc<scan_s...
true
7769aef6a912e07db3270eed38f048c8747b344d
Rust
tomaka/send_wrapper
/src/lib.rs
UTF-8
8,133
3.125
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2017 Thomas Keh. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to ...
true
27942eb8b2570141e5c893c0f58ff5dbf063da3b
Rust
mnts26/aws-sdk-rust
/sdk/cognitosync/src/client.rs
UTF-8
61,143
2.53125
3
[ "Apache-2.0" ]
permissive
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[derive(Debug)] pub(crate) struct Handle< C = smithy_client::erase::DynConnector, M = aws_hyper::AwsMiddleware, R = smithy_client::retry::Standard, > { client: smithy_client::Client<C, M, R>, conf: crate::Config, } //...
true
bb0c78059bde1e4ab17152aae3c6c5d2ebe6f598
Rust
jgouly/keyboard-app
/src/state.rs
UTF-8
1,552
3.15625
3
[]
no_license
use matrix::Matrix; #[derive(Copy, Clone)] #[cfg_attr(test, derive(Debug))] #[derive(PartialEq)] pub enum KeyState { None, Pressed, Held, Released, } impl Default for KeyState { fn default() -> KeyState { KeyState::None } } pub fn process_key_state<RM, SM>(result: &RM, previous_result: &RM) -> SM whe...
true
1ef4c9c54fe3b411b4a1da3e5d571306783eabd0
Rust
edutilos6666/RustProject
/Runner.rs
UTF-8
3,150
2.78125
3
[]
no_license
//use std::{i8,i16,i32,i64,u8,u16,u32,u64, isize, usize, f32, f64}; use std::io::stdin; mod OperatorsExample; mod DataTypesExample; mod DecisionMakingExample; mod LoopExample; mod StringExample; mod IOExample; mod ContainerDataTypesExample; mod FunctionExample; mod StructExample; mod TraitExample; mod EnumExample; mod...
true
eb08863daff76ff530a7fd846e4b94cc41906cae
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0523.continuous-subarray-sum/continuous-subarray-sum_test.go
UTF-8
803
2.65625
3
[ "MIT" ]
permissive
package problem0523 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { nums []int k int ans bool }{ { []int{1, 2}, 4, false, }, { []int{0, 0}, 0, true, }, { []int{23, 2, 4, 6, 7}, 6, true, }, { []int{1, 2, 3, 4}, 5,...
true
bcc35c7b2ebcae4c66e18454420869640956e64d
Rust
jodal/garmon
/src/main.rs
UTF-8
603
2.546875
3
[]
no_license
use std::{thread, time::Duration}; use garmon::components::{hcsr04::HcSr04, led::Led}; use gpio_cdev::Chip; fn main() -> Result<(), Box<dyn std::error::Error>> { println!("{}", garmon::PROGRAM_NAME); let mut chip = Chip::new("/dev/gpiochip0")?; let led = Led::new(chip.get_line(16)?)?; let hc_sr04 = H...
true
0294077176e79c830db2b35de0aa751117224c21
Rust
beningodfrey4/rusting
/references/src/main.rs
UTF-8
1,062
3.609375
4
[ "MIT" ]
permissive
fn main() { let l = calculate_length(&String::from("test")); println!("{}", l); let mut x = String::from("test"); change(&mut x); // no ownership transferred to change, so no move and drop, but a pointer to this reference is created locally. let _y = &x; let _z = &x; //allowed as _y and _...
true
99862d6a8397306e20cef775dd0b5f30a71115a4
Rust
jamesmarva/Head-First-Rust
/ch21/s2/d1/src/main.rs
UTF-8
217
3.078125
3
[]
no_license
fn main() { } fn compare_option<T>(first: Option<T>, second: Option<T>) -> bool { match(first, second) { (Some(..), Some(..)) => true, (None, None) => true, _ => false, } }
true
38e48b86f73a302a718853368ae53ad05090b7f7
Rust
Brent-A/AdventOfCode2019
/day/02/intcode/src/main.rs
UTF-8
5,587
3.0625
3
[ "MIT" ]
permissive
#[cfg(test)] mod test { use super::*; #[test] fn example1() { let mut program = [1,0,0,0,99]; execute(&mut program); assert_eq!([2,0,0,0,99], program); } #[test] fn example2() { let mut program = [2,3,0,3,99]; execute(&mut program); assert_eq!([2...
true
097a15a66bdf7d7e3f95fd90d0a88b367c638a56
Rust
andrewarrow/tinted_paradise
/src/server.rs
UTF-8
1,050
2.796875
3
[]
no_license
use std::net::{TcpStream}; use std::io::Write; use std::io::Read; use std::str; use std::collections::HashMap; use auth; #[derive(Debug)] pub struct Paradise { cstream: TcpStream, map: HashMap<String, fn()> } impl Paradise { pub fn new(stream: TcpStream, map: &HashMap<String, fn()>) -> Paradise { Paradise ...
true
c4bbe7afe953723cb5b676c7c691d331a3916677
Rust
TianyiShi2001/nom-pdb
/src/title_section/expdta.rs
UTF-8
1,703
2.796875
3
[ "MIT" ]
permissive
// Copyright (c) 2020 Tianyi Shi // // This software is released under the MIT License. // https://opensource.org/licenses/MIT //! Parses EXPDTA records which is a continuation type of record which may span multi-lines. //! Record contains list of `;` seperated experimental techniques. If seuccesfull returns //! [Reco...
true
3cfcc5ab3279c718ecbe39298a10f1419c3bdd41
Rust
hexagram30/eco
/examples/tile.rs
UTF-8
1,041
2.84375
3
[ "Apache-2.0" ]
permissive
use hxgm30eco::tile::{NormalDistTile, TileOptions}; pub fn main() { let opts = TileOptions { parent_x: 108, parent_y: 54, width: 10, height: 10, max_value: 10.0, min_value: 0.0, mean: 5.0, std_dev: 2.0, }; let t = NormalDistTile::new(opts); ...
true
f8eeb63335a1de30ce890fc839f61a6ba0af5605
Rust
EFanZh/LeetCode
/src/problem_0557_reverse_words_in_a_string_iii/iterative.rs
UTF-8
722
2.828125
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn reverse_words(s: String) -> String { let mut s = s.into_bytes(); s.split_mut(|&c| c == b' ').for_each(<[_]>::reverse); Stri...
true
51fb42a207695c391ed0070e498aae06d0f5fe58
Rust
menski/foobar
/src/lib.rs
UTF-8
1,686
2.609375
3
[ "MIT" ]
permissive
#[macro_use] extern crate derive_builder; #[macro_use] extern crate error_chain; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_json; extern crate chrono; pub mod errors; pub mod protocol; pub mod widgets; use errors::*; use std::fmt; use std::thread::sleep; use std::time::Duration; p...
true
a38d676a7b2ad5721cb7749929be637296dbd5b9
Rust
tokio-rs/axum
/examples/tracing-aka-logging/src/main.rs
UTF-8
3,475
2.796875
3
[]
no_license
//! Run with //! //! ```not_rust //! cargo run -p example-tracing-aka-logging //! ``` use axum::{ body::Bytes, extract::MatchedPath, http::{HeaderMap, Request}, response::{Html, Response}, routing::get, Router, }; use std::time::Duration; use tokio::net::TcpListener; use tower_http::{classify::...
true
82f800c83c4288cde773aff2d495972a6906697c
Rust
sammyne/mastering-rustls
/mutual-auth/client/src/main.rs
UTF-8
2,330
2.765625
3
[]
no_license
use std::fs; use std::io::{self, Read, Write}; use std::net::TcpStream; use std::sync::Arc; use rustls::{self, Session}; fn read_certs(path: &str) -> Result<Vec<rustls::Certificate>, String> { let data = match fs::File::open(path) { Ok(v) => v, Err(err) => return Err(err.to_string()), }; ...
true
cd25ca9508da25f4184e9cac284d7eb0dd35dea7
Rust
jb-abbadie/matasano_rust
/src/challenge.rs
UTF-8
4,478
2.9375
3
[]
no_license
extern crate base64; extern crate hex; use crypto; use std::f64; use std::fs::File; use std::io::prelude::*; pub fn challenge_1() { let input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"; let hex_string = hex::decode(input).expect("ok"); let b64_stri...
true
bcfae59e8812e10ba69f58091a59ab704f353f33
Rust
kanerogers/basis-universal-rs
/basis-universal/src/encoding/compressor_params.rs
UTF-8
10,380
2.859375
3
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "CC0-1.0", "Apache-2.0", "BSD-2-Clause" ]
permissive
use super::*; use crate::{BasisTextureFormat, UserData}; use basis_universal_sys as sys; pub use basis_universal_sys::ColorU8; /// The color space the image to be compressed is encoded in. Using the correct color space will #[derive(Debug, Copy, Clone)] pub enum ColorSpace { /// Used for normal maps or other "data...
true
22413518120d27cd7074724c35b3695b319149f2
Rust
Nukesor/collatz_conjecture
/src/algorithms/fixed_vector.rs
UTF-8
3,824
3.046875
3
[]
no_license
use std::time::Instant; use color_eyre::eyre::Result; use crossbeam::channel::Receiver; use num_format::{Locale, ToFormattedString}; use crate::{BATCH_SIZE, DEFAULT_MAX_PROVEN_NUMBER, REPORTING_SIZE, THREAD_COUNT}; /// We have to implement our own non-moving vector, since the backlog is by far the slowest part of //...
true
5fcaf6165236ff797e051fa5f9fa3224e834db19
Rust
divinerapier/crack-the-coding-interview
/linked-list/src/main.rs
UTF-8
517
2.96875
3
[]
no_license
#![feature(box_into_raw_non_null)] pub mod linkedlist; fn main() { println!("Hello, world!"); } impl<T> linkedlist::LinkedList<T> where T: std::cmp::Eq + std::hash::Hash, { // fn remove_duplicates(&self) { // let set: std::collections::HashSet<T> = std::collections::HashSet::new(); // let...
true
4a005aae80c84082ef95cc7be098e8f18a4dcd16
Rust
magnusmanske/gulp
/src/list.rs
UTF-8
14,202
2.75
3
[]
no_license
use std::collections::HashMap; use std::collections::HashSet; use std::sync::Arc; use serde::Serialize; use mysql_async::{prelude::*, Conn}; use serde_json::json; use crate::app_state::AppState; use crate::data_source::{DataSource, CellSet}; use crate::header::*; use crate::cell::*; use crate::row::*; use crate::GulpEr...
true
d4a4cd9217acadb627e713d8d4cb4e955e68e89e
Rust
Thaelz/ranaz
/ranaz/src/main.rs
UTF-8
3,171
2.8125
3
[]
no_license
#[macro_use] extern crate clap; pub mod utils; pub mod markov; pub mod fourier; use clap::App; use std::fs::File; use std::io::prelude::*; /* Statistical basic analisys * -> bits (1 and 0 count) * -> dibits (00, 01, 10, 11 count) * -> bytes (hex : 00 to ff count) * -> word, 4-bytes word * We try to do...
true
28b48243d40bc828abf288a10af29f27e883b508
Rust
krobelus/rate
/rate-common/src/memory.rs
UTF-8
1,835
3.5
4
[ "MIT" ]
permissive
//! General purpose data structures //! //! These are simply `std::vec::Vec` wrappers tuned for a specific purpose, //! so they are harder to misuse, or more efficient. //! //! For example: //! //! - The first template argument in `Array<I, T>` and `StackMapping<I, T>` //! requires to specify a type that will be used...
true
d4a8fce1d4ca92dfd88a4b2a3a55c852e7fc945d
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/structs-enums/enum-discrim-manual-sizing.rs
UTF-8
1,977
2.671875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![allow(dead_code)] use std::mem::{size_of, align_of}; #[repr(i8)] enum Ei8 { Ai8 = 0, Bi8 = 1 } #[repr(u8)] enum Eu8 { Au8 = 0, Bu8 = 1 } #[repr(i16)] enum Ei16 { Ai16 = 0, Bi16 = 1 } #[repr(u16)] enum Eu16 { Au16 = 0, Bu16 = 1 } #[repr(i32)] enum Ei32 { Ai32 = 0,...
true
0c1167be410a4284fb7aa0200ee22cbcd3c66d2b
Rust
prz23/zinc
/zinc-types/src/request/initialize.rs
UTF-8
1,310
2.71875
3
[ "Apache-2.0" ]
permissive
//! //! The contract resource `initialize` POST request. //! use std::iter::IntoIterator; use serde::Deserialize; use serde::Serialize; use zksync_types::Address; use crate::transaction::Transaction; /// /// The contract resource `initialize` POST request query. /// #[derive(Debug, Deserialize)] pub struct Query {...
true
164f5874cc68a909bc3036ed7636c1200114a5e7
Rust
joseluis/spaceindex
/spaceindex/src/geometry/region.rs
UTF-8
6,395
3.1875
3
[ "MIT", "Apache-2.0" ]
permissive
use geo::bounding_rect::BoundingRect; use std::borrow::Cow; use crate::geometry::point::IntoPoint; use crate::geometry::{ check_dimensions_match, min_distance_point_region, min_distance_region, LineSegment, Point, Shape, Shapelike, ShapelikeError, }; #[derive(Debug, Clone, PartialEq)] pub struct Region { ...
true
8fc7a7d05fcd44963b13a029eaa26cf422c40cb6
Rust
peter-signal/dtls
/src/curve/named_curve.rs
UTF-8
2,352
3.078125
3
[ "MIT" ]
permissive
use rand_core::OsRng; // requires 'getrandom' feature use util::Error; use crate::errors::*; // https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-8 #[derive(Copy, Clone, PartialEq, Debug)] pub enum NamedCurve { P256 = 0x0017, P384 = 0x0018, X25519 = 0x001d, Unsupported...
true
478fde5b317d5eb88bb7d55f57eba587c2a8e985
Rust
markjansnl/aoc2020
/aoc13/src/bin/b.rs
UTF-8
1,608
2.859375
3
[]
no_license
use num::integer::*; use aoc13::{input, *}; fn main() { println!("{}", earliest_timestamp(input::USER)); } fn earliest_timestamp(input: &str) -> usize { let schedules = parse_input(input).1; let busses: Vec<(usize, usize)> = schedules .iter() .enumerate() .filter_map(|(index, sche...
true
a0c4f1677b06e646e38a8c4ea265ee36ffbaf265
Rust
ArnaudValensi/rust-opengl-game-engine
/src/voxel/voxel_mesh_builder.rs
UTF-8
1,339
2.859375
3
[]
no_license
use mesh_data::MeshData; use super::chunk::Chunk; use super::direction::Direction; use super::position::Position; use super::voxel_geometry::{add_quad_triangles, create_vertex_position_face}; pub fn build_mesh(chunk: &Chunk) -> MeshData { // TODO: Instanciate mesh_data with_capacity. let mut mesh_data = MeshDa...
true
f9d7b5bf1f8607518f2c6edb12fcad4f95cabbd3
Rust
Techcable/mcp-database
/src/utils.rs
UTF-8
1,503
2.59375
3
[]
no_license
use std::{fmt, slice, mem}; use std::marker::PhantomData; use serde::de::{self, Deserializer, Deserialize, Visitor}; pub unsafe trait TransmuteFixedBytes {} #[inline] pub fn deserialize_borrowed_list<'de, T, D>(deserializer: D) -> Result<T, D::Error> where T: TransmuteFixedBytes, D: Deserializer<'de> { struct...
true
7d7162f616799057a97bcaadf14dd4f33cde7344
Rust
spacebox-org/spacebox
/src/fs/scan.rs
UTF-8
1,832
3.46875
3
[ "MIT" ]
permissive
use std::path::{Path}; use std::fs; pub enum FileChange<P: AsRef<Path>> { Creation(P), Deletion(P), Modification(P), } /// Scans a given directory recursively for changes in files by comparing them against /// a database of known hashes of the files. /// /// If a file is not found in the database of know...
true
8c4c575b012c96bb2f323e1d1df361159a50da44
Rust
amazingefren/rust-notes
/concepts/vectors/src/main.rs
UTF-8
3,614
3.640625
4
[ "MIT" ]
permissive
#![allow(dead_code)] use std::collections::HashMap; fn main() { let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Yellow"), 50); scores.insert(String::from("Blue"), 30); scores.entry(String::from("Red")).or_insert(0); // let teams = vec![String...
true
02828d90fbb621fbe7b40a7c97bcbc4d71c4c599
Rust
knknkn1162/sutramaking-rustbyexample
/src/primitives/arr_slice.rs
UTF-8
748
3.453125
3
[]
no_license
use std::mem; fn analyze_slice(slice: &[i32]) { println!("first element of the slice : {}", slice[0]); println!("the slice has {} elements", slice.len()); } pub fn test() { let xs: [i32; 5] = [1,2,3,4,5]; let ys: [i32; 500] = [0;500]; println!("first element of the array: {}", xs[0]); printl...
true
f19ba0ecb5514d1a357a6af54badb0c812a98b18
Rust
zoispag/amka-rs
/src/lib.rs
UTF-8
2,394
3.375
3
[ "MIT" ]
permissive
/*! A validator for greek social security number (AMKA) More information is available on [AMKA.gr](https://www.amka.gr/tieinai.html). */ use chrono::format::ParseError; use chrono::NaiveDate; use luhn; fn is_string_numeric(str: String) -> bool { for c in str.chars() { if !c.is_numeric() { retu...
true
766f6ea9473e64115e9c8fa80d6d41594b2d281c
Rust
Ninjani/advent-of-code-2018
/src/day9.rs
UTF-8
6,035
2.734375
3
[]
no_license
#![allow(dead_code)] use hashbrown::HashMap; use itertools::Itertools; #[aoc_generator(day9)] pub fn generate_day9(input: &str) -> Box<(usize, usize)> { let parts: Vec<_> = input.split_whitespace().collect(); Box::new((parts[0].parse().unwrap(), parts[6].parse().unwrap())) } #[allow(dead_code)] fn get_circula...
true
1b12cfa0940e80207e6e1a1ad98a78e9587aa501
Rust
uutils/coreutils
/src/uu/test/src/parser.rs
UTF-8
15,254
3.03125
3
[ "MIT", "GPL-1.0-or-later", "GPL-3.0-or-later" ]
permissive
// This file is part of the uutils coreutils package. // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. // spell-checker:ignore (grammar) BOOLOP STRLEN FILETEST FILEOP INTOP STRINGOP ; (vars) LParen StrlenOp use std::ffi::{OsStr, OsString...
true
e159984aa9b829c1a3da446f969cedb8e0fc27d0
Rust
mescam/aoc2020
/day6/day6.rs
UTF-8
1,333
3.265625
3
[]
no_license
use std::fs; use std::collections::HashSet; use std::iter::FromIterator; fn parse(content: &String) -> Vec<HashSet<char>> { let mut vec: Vec<HashSet<char>> = Vec::new(); let groups_it = content .split("\n\n"); for group in groups_it { let mut ans: HashSet<char> = HashSet::new(); let me...
true
84d7e055e5025c2e9c93d9c0870fe35e7af67da6
Rust
aDotInTheVoid/noria
/server/mir/src/rewrite.rs
UTF-8
6,327
2.796875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::column::Column; use crate::query::MirQuery; use crate::MirNodeRef; use std::collections::HashMap; fn has_column(n: &MirNodeRef, column: &Column) -> bool { if n.borrow().columns().contains(column) { return true; } else { for a in n.borrow().ancestors() { if has_column(a, c...
true
9cee99edb93e6811a153d2e2e2e3bed5a3ba9f0e
Rust
rome/tools
/crates/rome_js_syntax/src/jsx_ext.rs
UTF-8
17,119
3.15625
3
[ "MIT" ]
permissive
use std::collections::HashSet; use crate::{ inner_string_text, static_value::StaticValue, AnyJsxAttribute, AnyJsxAttributeName, AnyJsxAttributeValue, AnyJsxChild, AnyJsxElementName, JsSyntaxToken, JsxAttribute, JsxAttributeList, JsxElement, JsxName, JsxOpeningElement, JsxSelfClosingElement, JsxString, }; u...
true
1d6fc2619357434b74d5e09988415850102df076
Rust
mikedilger/sarek
/src/lib.rs
UTF-8
5,025
2.546875
3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate vks; extern crate winit; extern crate image as imageformat; extern crate libc; #[cfg(windows)] extern crate user32; #[cfg(windows)] extern crate winapi; #[macro_use] extern crate bitflags; // Include our macros early include!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/macros.rs")); pub mod error; pub use...
true
9bfa561947be56bc82628a122d2c81b90afe6f11
Rust
foresterre/sic
/crates/sic_image_engine/src/operations/diff.rs
UTF-8
4,419
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "OFL-1.1", "Apache-2.0", "BSD-2-Clause", "CC0-1.0", "Unlicense", "Unicode-DFS-2016", "BSD-3-Clause" ]
permissive
use crate::errors::SicImageEngineError; use crate::operations::ImageOperation; use crate::wrapper::image_path::ImageFromPath; use rayon::iter::{IndexedParallelIterator, IntoParallelRefMutIterator, ParallelIterator}; use sic_core::image::{DynamicImage, GenericImageView, ImageBuffer, Rgba, RgbaImage}; use sic_core::{imag...
true
2dd58b7c562ae2949b02990ec35058365e82b12d
Rust
nicholasnjihian/Code-Wars-Squares-in-a-true-rectangle-challenge-
/src/main.rs
UTF-8
713
3.21875
3
[]
no_license
fn get_squares(rect_len: i32, rect_width: i32) -> Option<Vec<i32>> { let mut area: i32 = rect_len * rect_width; let mut v: Vec<i32> = Vec::new(); loop { let (r, d): (i32, i32) = iterate_through_vals(area); v.push(r); if d == 0_i32 { break; } area = d; ...
true
c7faf74ec87b2389b868b0486745295122a3e8d7
Rust
club-code/CodingChallenges
/advent-of-code/2020/rust/day8/src/bin/part2.rs
UTF-8
1,536
3.34375
3
[]
no_license
use anyhow::Result; use day8::{parse_instructions, Evaluator, Instruction, Operation}; /// Solves part 2 by traversing all the instructions, inverting `nop`s and `jmp`s, /// and checking if that fixes the code by trying executing it until a loop. fn main() -> Result<()> { let inss = parse_instructions()?; for...
true
8c7cc37702271e041265f9aca89b9bfa3a9968ca
Rust
hopkings2008/nalgebra
/src/third_party/glam/glam_similarity.rs
UTF-8
1,436
2.84375
3
[ "Apache-2.0" ]
permissive
use crate::{Similarity2, Similarity3}; use glam::{DMat3, DMat4, Mat3, Mat4}; impl From<Similarity2<f32>> for Mat3 { fn from(iso: Similarity2<f32>) -> Mat3 { iso.to_homogeneous().into() } } impl From<Similarity3<f32>> for Mat4 { fn from(iso: Similarity3<f32>) -> Mat4 { iso.to_homogeneous().i...
true
0085d594898aa9b7efb6a3ca2566fbdf3ff9bfc1
Rust
sammyne/encoding-rs
/crates/binary/src/lib.rs
UTF-8
908
2.953125
3
[]
no_license
//! Implementation of simple translation between numbers and byte //! sequences and encoding and decoding of varints. //! //! Numbers are translated by reading and writing fixed-size values. //! A fixed-size value is either a fixed-size arithmetic //! type (bool, i8, u8, i16, f32, ...) //! or an array or struct contain...
true
45e863628729fc5f691453a9c7a8d1a1e3c91c07
Rust
Krout0n/vecmat-rs
/src/complex/complex_.rs
UTF-8
11,769
3.21875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ matrix::Matrix2x2, traits::{Conj, Dot, NormL1, NormL2, Normalize}, vector::Vector2, }; use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign}; use num_complex::{Complex as NumComplex, ParseComplexError}; use num_traits::{Float, Num, One, Zero, Inv}; /// Compl...
true
78b04221969f268da8ec3751a2f25819f8880949
Rust
jihokoo/rustful
/src/cache.rs
UTF-8
7,422
3.359375
3
[ "MIT" ]
permissive
//!Traits and implementations for cached resources. #![stable] use std::io::{File, IoResult}; use std::io::fs::PathExtensions; use std::sync::{RwLock, RwLockReadGuard}; use time; use time::Timespec; ///A trait for cache storage. #[unstable] pub trait Cache { ///Free all the unused cached resources. fn free_...
true
6f81edae64e4c56feb9f251d917c897811e6e6bc
Rust
joseluis/spaceindex
/spaceindex/src/geometry/tests.rs
UTF-8
3,350
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
use rand::Rng; use crate::geometry::point::IntoPoint; use crate::geometry::region::IntoRegion; use crate::geometry::{LineSegment, Point, Region, Shape, Shapelike, ShapelikeError}; use crate::rtree::RTree; #[test] fn test_line_intersections() { let p1 = Point::new(vec![1.0, 0.0]); let p2 = Point::new(vec![3.0,...
true
acda49b49cbbead8cc5837ad684cd16c67a81d8a
Rust
jinjagit/Rust
/threadpool/src/lib.rs
UTF-8
1,906
3.5
4
[]
no_license
// from tutorial: https://www.youtube.com/watch?v=2mwwYbBRJSo use std::sync::mpsc::{channel, Sender}; use std::sync::Mutex; use std::sync::Arc; pub struct ThreadPool { _handles: Vec<std::thread::JoinHandle<()>>, tx: Sender<Box<dyn FnMut() + Send>>, } impl ThreadPool { pub fn new(num_threads: u8) -> Self ...
true
20fc7eccf165af55bd691ae773b94a37cc24c950
Rust
toshuno/solved_problems
/aribon/gcj/3_7_1.rs
UTF-8
2,386
2.75
3
[]
no_license
#[allow(unused_imports)] use std::cmp::{max, min, Ordering}; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::io::prelude::BufRead; #[allow(unused_imports)] use std::io::{stdin, stdout, BufReader, BufWriter, Write}; #[allow(un...
true
3008c6537eca80826ec6dd06f8100a61c09b299c
Rust
devsnek/slither
/src/intrinsics/array_iterator_prototype.rs
UTF-8
1,528
2.59375
3
[ "MIT" ]
permissive
use crate::agent::Agent; use crate::value::{Args, ObjectKey, Value, ValueType}; fn next(args: Args) -> Result<Value, Value> { let o = args.this(); if o.type_of() != ValueType::Object { return Err(Value::new_error(args.agent(), "invalid receiver")); } let a = o.get_slot("iterated object"); i...
true
f8ef1a6f22d61578eacf0159ed9a7eb92147a529
Rust
dotanavi/dotamoji
/src/search_cache/no_cache.rs
UTF-8
771
2.578125
3
[]
no_license
use super::{SearchCache, SearchCache2}; #[derive(Serialize, Deserialize)] pub struct NoCache; impl SearchCache for NoCache { #[inline] fn new(_size: usize) -> Self { NoCache } #[inline] fn extend(&mut self, _size: usize) {} #[inline] fn mark(&mut self, _index: usize) {} #[in...
true
c2003f2c966540fff8f3962dac79dad6e34452e7
Rust
wschella/rstat
/src/univariate/beta.rs
UTF-8
3,836
2.890625
3
[ "MIT" ]
permissive
use crate::{ consts::{ONE_THIRD, TWO_THIRDS}, prelude::*, }; use rand; use spaces::real::Interval; use std::fmt; shape_params! { Params<f64> { alpha, beta } } new_dist!(Beta<Params>); macro_rules! get_params { ($self:ident) => { ($self.0.alpha.0, $self.0.beta.0) } } impl Beta { pub fn new(alpha:...
true
9d084e8e9ce0652e39c6143b894376b911f10aa7
Rust
kazzix14/keybox
/src/lib.rs
UTF-8
2,570
3.546875
4
[]
no_license
use bs58; use itertools::Itertools; use sha3::{digest::*, Shake256}; // Bitcoin style // 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz pub struct KeyGenerator { password_digest: String, hasher: Shake256, } impl KeyGenerator { pub fn new(password: String) -> Self { let mut hasher = Sh...
true
7de5443bfa98c6e406879135ee940b9cb1583e89
Rust
aashah/advent_of_code
/2016/day6/src/main.rs
UTF-8
428
2.9375
3
[]
no_license
use std::fs::File; use std::io::prelude::*; extern crate day6; fn main() { let mut file = File::open("src/input.txt").expect("Could not open src/input.txt"); let mut input = String::new(); file.read_to_string(&mut input) .expect("Could not read file"); let input = input.trim(); println!("T...
true
eb8be1b3522021a9dfa44bbb1a72ef32352ffaed
Rust
klaxit/heroku_rs
/examples/src/custom_examples.rs
UTF-8
1,882
2.90625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
extern crate heroku_rs; use super::print_response; use heroku_rs::endpoints::custom; use heroku_rs::framework::apiclient::HerokuApiClient; use heroku_rs::framework::endpoint::Method; use serde::Serialize; pub fn run<ApiClientType: HerokuApiClient>(api_client: &ApiClientType) { let app_name = String::from("heroku-r...
true
c3ce8a7aaf410fe651dbe0c1c6289f79081e9fe5
Rust
pmuens/crawler
/src/logging.rs
UTF-8
605
2.765625
3
[]
no_license
use chrono::DateTime; use chrono::Utc; use std::time::SystemTime; pub fn formatted_now() -> String { let system_time = SystemTime::now(); let date_time: DateTime<Utc> = system_time.into(); date_time.format("%d/%m/%Y %T").to_string() } #[allow(unused_macros)] macro_rules! log { ($msg:expr) => { ...
true
dd13394f16f31d52818162364d3c8a1c2ed87af9
Rust
xixixao/orbtk
/crates/widgets/src/behaviors/selection_behavior.rs
UTF-8
2,222
2.796875
3
[ "MIT" ]
permissive
use crate::{api::prelude::*, proc_macros::*}; /// The `SelectionBehaviorState` handles the `SelectionBehavior` widget. #[derive(Default, AsAny)] pub struct SelectionBehaviorState { toggle_selection: bool, selected: bool, } impl SelectionBehaviorState { fn toggle_selection(&mut self) { self.toggle_...
true
8eee8760d627c9ed0ccd949720df18ad5cacf1ed
Rust
totechite/chibidb
/src/storage/catalog.rs
UTF-8
1,873
2.734375
3
[ "MIT" ]
permissive
use std::env; use crate::storage::util::Scheme; use std::fs::{File, ReadDir, read_dir, create_dir}; use std::io::{BufWriter, IntoInnerError, Error, Write, Read}; use std::env::VarError; use std::collections::{HashSet, HashMap}; use serde_json::Deserializer; use std::path::{Path, PathBuf}; use crate::storage::magic_numb...
true
ddec50e1728e61e8d913a1b87492d40914a130dd
Rust
HdrHistogram/HdrHistogram_rust
/tests/data_access.rs
UTF-8
18,642
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Tests from HistogramDataAccessTest.java use hdrhistogram::Histogram; macro_rules! assert_near { ($a:expr, $b:expr, $tolerance:expr) => {{ let a = $a as f64; let b = $b as f64; let tol = $tolerance as f64; assert!( (a - b).abs() <= b * tol, "assertion fai...
true
d5a55ee02cdc992bb260226ac341039303346837
Rust
bhechinger/tunnel_manager
/src/storage/permissions.rs
UTF-8
4,866
2.796875
3
[]
no_license
use diesel::prelude::*; use diesel::r2d2::{ConnectionManager, Pool}; use tonic::Status; use tracing::instrument; use crate::api::permission_request::IdOrName; use crate::api::PermissionData; use crate::schema::permissions; use crate::schema::permissions::dsl::*; use crate::storage::helpers::sql_err_to_grpc_error; #[d...
true
a02368712c389c07c718d952bb7866092ed29966
Rust
halzy/twitch_api2
/src/helix/subscriptions/get_broadcaster_subscriptions.rs
UTF-8
5,839
3.28125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Get all of a broadcaster’s subscriptions. //! [`get-broadcaster-subscriptions`](https://dev.twitch.tv/docs/api/reference#get-broadcaster-subscriptions) //! //! # Accessing the endpoint //! //! ## Request: [GetBroadcasterSubscriptionsRequest] //! //! To use this endpoint, construct a [`GetBroadcasterSubscriptionsReq...
true
6618dd7f226de699f8ab8c619a359e826b3631a2
Rust
mgbatchelor/rust-playground
/chapter2/operators.rs
UTF-8
526
3.171875
3
[]
no_license
fn main() { println!("1 + 2 = {}", 1u32 + 2); println!("1 - 2 = {}", 1i32 - 2); println!("true && true = {}", true && true); println!("true || false = {}", true || false); println!("!true = {}", !true); println!("0011 AND 0101 = {:04b}", 0b0011 & 0b0101); println!("0011 OR 0101 = {:04b}", ...
true
f496557b891bcc32549f324886ce2833db802706
Rust
AcrylicShrimp/mazemaze
/src/network/handler.rs
UTF-8
5,983
2.90625
3
[]
no_license
extern crate byteorder; use byteorder::ReadBytesExt; pub enum Context { WorldReceive { width: u32, height: u32, data: Option<Vec<u8>>, player: Option<u32>, }, PlayerReceive, PlayerIdReceive, MoveReceive, } pub struct Handler { status: Option<u16>, context: Option<Context>, } impl Handler { pub fn ne...
true
58f194356a75e7b899c981cca6f145c933583db8
Rust
ra192/card-api-rust
/src/main.rs
UTF-8
2,313
2.515625
3
[]
no_license
mod db; mod token; mod merchant; mod transaction; mod account; mod card; mod customer; use warp::Filter; use crate::db::{create_pool, DBPool}; use std::convert::Infallible; use serde::{Serialize}; extern crate pretty_env_logger; #[macro_use] extern crate log; use std::env; fn with_db(db_pool: DBPool) -> impl Filter...
true
ca6d87f1da78e877065864c1802f73bc1bf8533b
Rust
luojia65/coruscant
/coruscant-nbt/examples/nbt-tag-enum.rs
UTF-8
631
2.9375
3
[ "MIT" ]
permissive
use serde::Serialize; #[derive(Serialize)] #[serde(tag = "type")] enum Message { Request { id: &'static str, method: &'static str, params: i8, }, Response { id: &'static str, result: i8, }, } fn main() { let data = Message::Request { id: "...", ...
true
aee6dd57988e74bd1ae4dcaa0a38fa6839e43ad8
Rust
AndrewMendezLacambra/rust-programming-contest-solutions
/atcoder/agc009_b.rs
UTF-8
1,829
2.90625
3
[]
no_license
/// Thank you tanakh!!! /// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mu...
true
a5b923e2f218d38b410d200bb13ddf8fd681138d
Rust
henrikpersson/potatis
/nes/src/ppu/state.rs
UTF-8
1,426
3.203125
3
[ "MIT" ]
permissive
#[derive(Default, PartialEq, Eq, Copy, Clone)] pub(crate) enum Phase { PreRender, #[default] Render, PostRender, EnteringVblank, Vblank, } pub(crate) enum Rendering { Enabled, Disabled, } #[derive(Default)] pub(crate) struct State { phase: Phase, cycle: usize, scanline: usize, clock: usize, ...
true
03e6e460a35fafad34d41698d74088a6dba3db03
Rust
Parabellum1905y/doublelinkedlist
/src/element.rs
UTF-8
1,051
3.609375
4
[]
no_license
#[derive(Clone)] pub struct Element { value: String, next: Option<Box<Element>>, prev: Option<Box<Element>> } impl Element { pub fn new(value: String) -> Element { Element { value: value, next: None, prev: None } } pub fn from_existing(value:...
true
3414f0ef222bf2524b6b6450dd10a3d50277386f
Rust
selatotal/entendendo-algoritmos
/04.quicksort/rust/quicksort/src/main.rs
UTF-8
616
3.3125
3
[ "MIT" ]
permissive
fn quicksort(arr: &mut Vec<i64>) -> Vec<i64> { if arr.len() < 2 { return arr.clone(); } let pivot = arr.remove(0); let mut lowers:Vec<i64> = arr.clone().into_iter().filter(|&v| v <= pivot).collect(); let mut greaters:Vec<i64> = arr.clone().into_iter().filter(|&v| v > pivot).collect(); l...
true
7e30510fafdd8dfa974c060a02d8347363eb916a
Rust
jakeswenson/stoken
/src/tokens/aes.rs
UTF-8
574
2.75
3
[]
no_license
use crypto::buffer::{RefReadBuffer, RefWriteBuffer}; use crypto::{aes, aes::KeySize, blockmodes::NoPadding}; pub const KEY_SIZE: usize = 16; pub const BLOCK_SIZE: usize = 16; pub fn encrypt(key: &[u8], data: &[u8]) -> [u8; BLOCK_SIZE] { let mut output_array = [0u8; BLOCK_SIZE]; let mut input = RefReadBuffer::...
true
e1c529f59c8afae83b1d12cbf1cad83ff82d30c6
Rust
rustysec/parselnk-rs
/src/lib.rs
UTF-8
7,332
3.234375
3
[]
no_license
//! Parse windows .lnk files using only safe rust. Windows lnk files //! describe links to data objects as defined by //! [this specification](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-shllink/16cb4ca1-9339-4d0c-a68d-bf1d6cc0f943). //! //! # Examples //! //! You can process the `Lnk` data from a m...
true
76dbea47ba2a99027702162ef424abf213bc45f6
Rust
dev-chee/ash
/ash/src/entry.rs
UTF-8
8,001
2.6875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::instance::Instance; use crate::prelude::*; use crate::vk; use crate::RawPtr; use std::error::Error; use std::ffi::CStr; use std::fmt; use std::mem; use std::os::raw::c_char; use std::os::raw::c_void; use std::ptr; /// Holds a custom type `L` to load symbols from (usually a handle to a `dlopen`ed library), /...
true
72c6cc5310a55f3b6e7c0c6cbdc009a35d02769f
Rust
neonphog/must_future
/src/lib.rs
UTF-8
5,174
3.078125
3
[ "Apache-2.0" ]
permissive
#![deny(warnings)] #![deny(missing_docs)] #![deny(unused_must_use)] //! BoxFutures cannot be marked `#[must_use]` because they are just type //! definitions. This newtype struct wraps a BoxFuture with something that //! can be marked `#[must_use]`. //! //! # Will Not Compile: //! //! ```compile_fail //! #![deny(unused_...
true
86f4f70714d52d02296238c8bd8cdf29046dbf12
Rust
ShisoftResearch/pmem-alloc
/src/mmap.rs
UTF-8
4,384
2.75
3
[ "MIT" ]
permissive
use libc::*; use std::{ptr, io}; use crate::Ptr; use std::ffi::c_void; use std::path::Path; use std::fs::{File, OpenOptions}; use std::ptr::{null, null_mut}; use std::os::unix::io::IntoRawFd; use errno::errno; use crate::utils::{BLOCK_SIZE, PAGE_SIZE, BLOCK_MASK}; const DEFAULT_PROT: c_int = PROT_READ | PROT_WRITE; p...
true
cb5da4c569c738f530759d5fd529fd0c40b3d921
Rust
rust-lang/rust-bindgen
/bindgen-tests/tests/quickchecking/src/lib.rs
UTF-8
3,821
2.9375
3
[ "BSD-3-Clause" ]
permissive
//! A library to generate __fuzzed__ C headers for use with `quickcheck` //! //! ## Example //! //! ```rust //! extern crate quickcheck; //! extern crate quickchecking; //! use quickcheck::{Arbitrary, Gen}; //! use quickchecking::fuzzers; //! //! fn main() { //! let generate_range: usize = 10; // Determines things ...
true
ddeb5175e61682b1d437d80d1d988871d3fe8391
Rust
boltlabs-inc/tezedge-client
/ledger_api/src/ledger_request.rs
UTF-8
1,852
2.8125
3
[ "MIT" ]
permissive
use ledger_apdu::APDUCommand; use crate::{Ledger, LedgerError, LedgerResponse}; pub type ResultHandler<T> = dyn Fn(&mut Ledger, Vec<u8>) -> Result<T, LedgerError>; pub struct LedgerRequestData<T> { pub command: APDUCommand, pub handler: Box<ResultHandler<T>>, } impl<T> LedgerRequestData<T> where T: 'sta...
true
16c29be0e05f30d3771303512e743336c9e38a78
Rust
CuriouslyCurious/gw2api
/src/v2/pvp/heroes.rs
UTF-8
6,575
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
use serde::Deserialize; use crate::client::Client; use crate::error::ApiError; use crate::utils::ids_to_string; const ENDPOINT_URL: &str = "/v2/pvp/heroes"; /// A hero used in the Stronghold game structured PvP game type. #[derive(Debug, Deserialize, PartialEq)] pub struct Hero { /// id of the hero. pub id: ...
true
1dd78e220ba5e3a7739fb46cf5aa1050eec8ae3e
Rust
rettgerst/exercism-rust
/matching-brackets/src/lib.rs
UTF-8
1,301
3.390625
3
[]
no_license
pub fn brackets_are_balanced(string: &str) -> bool { let mut brackets = vec![]; for char in string.chars() { match char { '(' => brackets.push(char), '[' => brackets.push(char), '{' => brackets.push(char), '}' => { if brackets.len() == 0 {...
true
05957a375ba4e0c1ac1bd21ac8675dce036a9203
Rust
sgmarz/raytrace
/src/threadpool.rs
UTF-8
3,316
2.8125
3
[ "MIT" ]
permissive
use crate::camera::Camera; use crate::hitable::HitList; use crate::random::random_f64; use crate::vector::Vec3; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::Arc; use std::thread::{spawn, JoinHandle}; use std::vec::Vec; pub struct ControlPacket { pub row: u32, pub col: u32, pub camera: Arc<Camera...
true
1feb1e6251ef16a115424acda38c1adba0f52d2b
Rust
rust-lang/glacier
/fixed/77218.rs
UTF-8
231
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
pub struct Cache { data: Vec<i32>, } pub fn list_data(cache: &Cache, key: usize) { for reference in vec![1, 2, 3] { if /*let*/ Some(reference) = cache.data.get(key) { unimplemented!() } } }
true
b3606f7a5bbe942c8f105367ca6bfbb96a6f652f
Rust
uchenma/Assignment1_DiningConciergeAgent
/shared-types/src/lib.rs
UTF-8
1,808
2.578125
3
[]
no_license
use dynomite::{Attributes, Item}; use serde::{Deserialize, Serialize}; #[derive(Attributes, Deserialize, Serialize, Debug, Clone)] pub struct YelpCategory { pub alias: String, pub title: String, } #[derive(Attributes, Deserialize, Serialize, Debug, Clone)] pub struct YelpAddress { #[serde(default)] city...
true
5a50f475940b9d4187f81b8f3a0dd0ae65c36d8c
Rust
peteralieber/rustrays
/src/main.rs
UTF-8
666
2.640625
3
[]
no_license
use rustrays::util::*; use rustrays::*; use log::*; fn main() { //set_max_level(LevelFilter::Info); //println!("RustRays!"); //output_color_gradient(); //output_blue_white_gradient(); //output_sphere_on_sphere(); output_metal_spheres(); let v1 = vectors::Vector3 {x:1.0,y:1.0,z:1.0}; ...
true
194669ea58db606647b219069f6c046b71fe201f
Rust
magiclen/random-integer
/src/lib.rs
UTF-8
2,995
3.390625
3
[ "MIT" ]
permissive
/*! # Random Integer Generate a random integer between two integer numbers (including the two integer numbers). ## Example ```rust extern crate random_integer; let rnd = random_integer::random_u8(224, 255); println!("{}", rnd); ``` */ #![no_std] extern crate core; pub extern crate rand; use core::cmp::Ordering; ...
true
87a9a13ca12f763a7cdb34c932f953ab841047f0
Rust
alerdenisov/unrust
/src/world/fps.rs
UTF-8
2,133
2.71875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use uni_app::now; use std; use std::collections::VecDeque; pub struct DeltaTimeStats { pub dt_max: f64, pub dt_min: f64, pub dt_avg: f64, pub dt_history: VecDeque<f64>, } impl DeltaTimeStats { fn new() -> DeltaTimeStats { DeltaTimeStats { dt_max: std::f64::MIN, dt_...
true
89a50e71da170c21ff3ddc6546568789dbb77591
Rust
jroimartin/expos
/expos/src/main.rs
UTF-8
1,702
2.6875
3
[]
no_license
//! expOS is a tiny Operating System focused on experimentation. #![no_std] #![cfg_attr(not(test), no_main)] #![feature(panic_info_message)] use range::RangeSet; use uefi::acpi; #[cfg(not(test))] mod panic; mod serial; struct BootInfo { available_memory: RangeSet, acpi_madt: acpi::Madt, } /// UEFI entry p...
true
c968daa7cc804355f6e0c423edc9d6f96f20109a
Rust
ocstl/project_euler
/src/bin/problem68.rs
UTF-8
2,670
3.21875
3
[]
no_license
use permutohedron::LexicalPermutation; use std::convert::TryFrom; use std::error::Error; use std::fmt; const NODES: u32 = 10; #[derive(Debug)] struct MagicRingError; impl fmt::Display for MagicRingError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Invalid magic ring.") } } imp...
true
85f8f3389fc5f48f523c472626ee5bfef79e38c2
Rust
ExternalReality/dynamic-split
/.circleci/test-lib/tests/dummy_test.rs
UTF-8
210
2.65625
3
[ "MIT" ]
permissive
use std::{thread, time}; use rand::Rng; #[test] fn sample_test() { let mut rng = rand::thread_rng(); let seconds = time::Duration::new(rng.gen_range(0,10),0); thread::sleep(seconds); assert!(true); }
true
3d74a395b048468b5e6c6ed499d575314b415e96
Rust
park66665/auxtools
/dm/src/string.rs
UTF-8
1,645
3.28125
3
[ "MIT" ]
permissive
use super::raw_types; use super::value::Value; use std::ffi::CStr; use std::fmt; /// A wrapper around [Values](struct.Value.html) that make working with strings a little easier pub struct StringRef { pub value: Value, } impl StringRef { pub fn new(string: &str) -> Self { StringRef { value: Value::from_string(s...
true
fb9731469fe47f8220fe5d1b667a2919483c5cc6
Rust
SidneyArmitage/png
/src/process/chunks/ihdr.rs
UTF-8
2,149
3.1875
3
[]
no_license
use super::super::*; #[cfg(test)] mod tests { use super::*; #[test] fn test_success() { let mut options = Options::new(); let out = process(&[0, 0, 0, 0x20, 0, 0, 0, 0x20, 0x10, 0x06, 0, 0, 0], 17, &mut options); assert_eq!(out, Ok(())); assert_eq!(options.bit_depth, 16); assert_eq!(optio...
true
e98e56b4ce8b0895a9bcb87e3babe0fa65abe8f5
Rust
steveklabnik/stdsimd
/coresimd/ppsv/codegen/cos.rs
UTF-8
1,892
2.515625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Exact vector cos #![allow(dead_code)] use coresimd::simd::*; #[allow(improper_ctypes)] extern "C" { #[link_name = "llvm.cos.f32"] fn cos_f32(x: f32) -> f32; #[link_name = "llvm.cos.f64"] fn cos_f64(x: f64) -> f64; #[link_name = "llvm.cos.v2f32"] fn cos_v2f32(x: f32x2) -> f32x2; #[link_...
true
ffe29abe33c5549eb66c74d2daa7d9ae44a0f3c1
Rust
sismeon/Regalia
/src/request.rs
UTF-8
162
2.59375
3
[]
no_license
pub mod request { enum HTTPMethod { GET, POST, PUT, DELETE } struct HTTPRequest { method: HTTPMethod, } }
true
63960f523645ab2cf7a156f6ebc3f8e68a6f3828
Rust
McM1k/multilayer_perceptron
/src/reader.rs
UTF-8
518
2.8125
3
[]
no_license
use super::cell::Cell; use csv::ReaderBuilder; use std::result::Result; use std::result::Result::*; use std::vec::Vec; pub fn get_raw_data(path: &str) -> Result<Vec<Cell>, &str> { let mut raw_data: Vec<Cell> = Vec::new(); let mut rdr = ReaderBuilder::new() .has_headers(false) .from_path(path) ...
true
162caf9e95bd57734217dc9d7bde65a2ae790498
Rust
Lolirofle/lolpranz
/src/glfw_game.rs
UTF-8
2,333
2.640625
3
[]
no_license
use glfw::{Context,Window}; use glfw; use std::time::Duration; use tdgl::game::Game; use tdgl::game::gameloop; use tdgl::graphics::renderer::Renderer; pub struct GlfwGame<'g,Exit,G> where G: Game<glfw::WindowEvent,(),Exit> + 'g { glfw: glfw::Glfw, pub window: (glfw::Window,Receiver<(f64,glfw::WindowEvent)>), game:...
true
093e2bdd1f7d719e34b48d143d0b1583587892a8
Rust
happyspace/rust-bucket
/misc/src/rust/panic.rs
UTF-8
954
3.796875
4
[]
no_license
pub fn divide_non_zero_result(a: u32, b: u32) -> u32 { if b == 0 { panic!("Divide-by-zero error"); } else if a < b { panic!("Integer division = 0!"); } a / b } pub fn sqrt(number: f64) -> Result<f64, String> { if number >= 0.0 { Ok(number.powf(0.5)) } else { Err...
true
0ccf0a7e5097b6d1728fc7b739083224c7806286
Rust
sbaldwin621/adventofcode2020
/day16/train_ticket2/src/notes.rs
UTF-8
7,814
2.546875
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::error::Error; use std::fmt::Display; use std::ops::{Index, Range}; use std::slice::Iter; use std::str::FromStr; use nom::bitvec::index; use crate::parser::parse_notes; #[derive(Debug)] pub struct Notes { ruleset: Ruleset, my_ticket: Ticket, nearby_tickets...
true
457afb49a5ce37d137d9d35830f49766f8e4c96d
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_1309/src/main.rs
UTF-8
168
2.546875
3
[ "MIT" ]
permissive
use leetcode_1309::solution1::Solution; fn main() { let s = "10#11#12".to_string(); let result = Solution::freq_alphabets(s); println!("result = {}", result); }
true
5b204f724d1ea79741662d328780ca36f8e7dae0
Rust
mazur/advent-of-code-2020
/src/day07/mod.rs
UTF-8
5,141
3.421875
3
[]
no_license
use std::collections::HashMap; use itertools::Itertools; pub fn run() { let system = BagSystem::build_from_rules(include_str!("input.txt")); let can_contain_shiny_gold = system.count_contains("shiny gold"); let shiny_gold_requires_contain = system.count_required_bags("shiny gold"); println!("Day07 - P...
true