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
d070947298be9fecdba9e696e54d1e0182b81289
Rust
waynejr2/macroquad_tantan_toolbox
/src/resources.rs
UTF-8
3,769
3
3
[ "MIT" ]
permissive
use macroquad::audio::*; use macroquad::prelude::*; use std::collections::HashMap; use std::fmt::Debug; use std::hash::Hash; use std::marker::PhantomData; // THIS doesn't work on wasm builds atm due to futures::executor::block_on not being allowed in wasm pub struct DefaultFactory; impl ResourceFactory<Texture2D> for...
true
3149a8087cb5295c9583590c27b97a0deebf34c5
Rust
baitcenter/QRStorageOrganizer
/src/im_encoder/mod.rs
UTF-8
1,456
2.875
3
[]
no_license
extern crate image; extern crate qrcode; use crate::models; use bardecoder; use qrcode::QrCode; use image::Luma; use image::GrayImage; pub fn to_img(_entry: &models::QrEntry) -> GrayImage { //Luma<u8> { let code = QrCode::new(b"01234567").unwrap(); let image = code.render::<Luma<u8>>().build(); //let imag...
true
4ce5d358d8cfa89c138376ef3ed13f348a7840e8
Rust
tqdv/mcclwrap
/src/ready.rs
UTF-8
4,264
2.734375
3
[]
no_license
/*! A ready channel (spmc) ``` # use tokio::time::{delay_for, Duration} let (tx, rx) = ready::channel(); let ready = rx.clone(); tokio::spawn(async move { delay_for(Duration::from_secs(1)).await; tx.ready(); }); tokio::spawn(async move { ready.await; println!("ready!"); }); if let None = rx.await { println!("...
true
40cfa05b7717d2489492f5348e20d0de490b8771
Rust
finchers-rs/finchers
/src/output/status.rs
UTF-8
1,376
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
#![allow(missing_docs)] use http::{Request, Response, StatusCode}; use super::IntoResponse; impl IntoResponse for StatusCode { type Body = &'static [u8]; #[inline] fn into_response(self, _: &Request<()>) -> Response<Self::Body> { let mut response = Response::new(&[] as &[u8]); *response....
true
268f192a4782f0cac088897a0d4ea0c620776260
Rust
voldyman/orbtk
/src/properties/tests/rect.rs
UTF-8
2,352
3.1875
3
[ "MIT" ]
permissive
use super::*; #[test] fn test_point() { let rect = Rect::new(5, 8, 0, 0); assert_eq!(rect.point().x, 5); assert_eq!(rect.point().y, 8); } #[test] fn test_contains() { let rect = Rect::new(5, 8, 100, 80); let inner_point = Point::new(50, 50); let outer_point_one = Point::new(0, 0); let oute...
true
b1fa47bf3928e7a1e1f8dae273f9187d34042bc0
Rust
tony84727/game-of-life
/src/camera.rs
UTF-8
1,344
2.609375
3
[]
no_license
use amethyst::{ ecs::{Component, DenseVecStorage, Join, Read, ReadStorage, System, WriteStorage}, input::{InputHandler, StringBindings}, renderer::camera::Projection, }; use amethyst_rendy::Camera; pub struct CameraZoomSystem { scale: f32, } impl CameraZoomSystem { pub fn new() -> CameraZoomSystem...
true
f9c9e4c1ce9a042202f448559597d14c41dd6969
Rust
rust-bakery/nom
/benchmarks/benches/json_streaming.rs
UTF-8
5,612
2.90625
3
[ "MIT", "CC0-1.0" ]
permissive
#[macro_use] extern crate criterion; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; use criterion::Criterion; use nom::{ branch::alt, bytes::streaming::{tag, take}, character::streaming::{anychar, char, multispace0, none_of}, combinator::{map, map_opt, map_res, value, verif...
true
f56b272bd42a523a7718e25768426d09f828de01
Rust
PoeBlu/nebulet
/src/common/table.rs
UTF-8
2,251
3.421875
3
[ "MIT" ]
permissive
use alloc::vec::{Vec, Drain}; use core::iter::FilterMap; use core::ops::{Index, IndexMut, RangeBounds}; pub type TableIndex = usize; #[derive(Debug)] pub struct Table<T> { objects: Vec<Option<T>>, free_list: Vec<usize>, len: usize, } impl<T> Table<T> { pub fn new() -> Self { Ta...
true
9d26532b2d2fa11a5f9f7ab2a684091521f1db4d
Rust
mriise/humanize-rs
/src/duration/tests.rs
UTF-8
2,569
3.09375
3
[ "MIT" ]
permissive
use super::parse; use std::time::Duration; use ParseError; #[test] fn test_parse_duration_units() { assert_eq!(parse("1d"), Ok(Duration::from_secs(86400))); assert_eq!(parse("1h"), Ok(Duration::from_secs(3600))); assert_eq!(parse("1m"), Ok(Duration::from_secs(60))); assert_eq!(parse("1s"), Ok(Duration:...
true
9613bcfeb607d80d263aa05a05404747af36055a
Rust
chrisvittal/aoc-2017
/src/bin/day24.rs
UTF-8
1,440
3.140625
3
[ "MIT" ]
permissive
extern crate aoc; use std::str::FromStr; use std::collections::HashSet; #[derive(Debug,Clone,Copy)] struct Component(u32,u32); struct Answer { pt1: u32, pt2: (usize, u32) } impl FromStr for Component { type Err = (); fn from_str(s: &str) -> Result<Self, ()> { let mut s = s.split("/").map(|d...
true
c4a86192caae3a1230a232dd1b9bd315b094d682
Rust
nagyf/write-yourself-a-git
/src/repository/object.rs
UTF-8
1,292
3.609375
4
[]
no_license
pub trait Serializable { fn serialize(&self) -> &[u8]; fn deserialize(input: &[u8]) -> Self; } #[derive(Copy, Clone, Debug)] pub enum Type { Commit, Tree, Tag, Blob, } pub struct GitObject { pub object_type: Type, pub data: Vec<u8> } impl Serializable for GitObject { fn serialize(...
true
ffa7d0977d677c2b237d92c184ad478f245b4041
Rust
Anaisdg/flux
/libflux/flux-core/src/parser/tests/errors.rs
UTF-8
40,411
2.546875
3
[ "MIT" ]
permissive
use pretty_assertions::assert_eq; use super::*; use crate::ast::tests::Locator; #[test] fn function_call_with_unbalanced_braces() { let mut p = Parser::new(r#"from() |> range() |> map(fn: (r) => { return r._value )"#); let parsed = p.parse_file("".to_string()); let loc = Locator::new(&p.source[..]); a...
true
98789599f094fe2ce5cb000f25c88911d7ca67ec
Rust
aryan9600/kv-store
/src/pubsub.rs
UTF-8
886
2.828125
3
[]
no_license
use log::error; use nats::{Connection, Subscription}; use rocket::serde::{Deserialize, Serialize}; use crate::Result; /// Publish an action to a subject in the NATS server. pub fn publish_action<'de, T>(conn: &Connection, subject: &str, action: Box<T>) -> Result<()> where T: Serialize + Deserialize<'de>, { co...
true
311fa3c6076b198c5924aefe4e942d027a3edb44
Rust
ptorru/reticle
/src/langs/asm/src/helpers.rs
UTF-8
2,654
2.671875
3
[ "Apache-2.0" ]
permissive
use crate::ast::*; impl Loc { pub fn prim(&self) -> &Prim { &self.prim } pub fn x(&self) -> &ExprCoord { &self.x } pub fn y(&self) -> &ExprCoord { &self.y } pub fn is_lut(&self) -> bool { matches!(self.prim, Prim::Lut) } pub fn is_dsp(&self) -> bool {...
true
afc8640675555d5020fcc4a29269694afca73bd0
Rust
caio/cantine
/tique/src/conditional_collector/traits.rs
UTF-8
2,654
2.953125
3
[ "MIT" ]
permissive
use std::cmp::Ordering; use tantivy::{DocAddress, DocId, SegmentOrdinal, SegmentReader}; use super::topk::Scored; /// A trait that allows defining arbitrary conditions to be checked /// before considering a matching document for inclusion in the /// top results. pub trait ConditionForSegment<T>: Clone { /// The ...
true
8a7af253a23eee79c59261f43ed5075896d92410
Rust
soojade/guessing
/src/main.rs
UTF-8
1,406
3.984375
4
[]
no_license
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("数字猜谜游戏!"); let secret_number = rand::thread_rng().gen_range(1,101); loop { println!("请输入你要猜的数字."); let mut guess = String::new();// 标准库提供的String字符串类型,是可增长 的utf-8的文本。 :: 关联String本身而不是实例,即静态方法。 ...
true
5ea4fd1282a8e796bc80e97ef82d270e86411215
Rust
txstate-etc/redirector
/src/main.rs
UTF-8
2,021
2.765625
3
[ "MIT" ]
permissive
#[macro_use] extern crate lazy_static; use std::env; use std::convert::Infallible; use std::net::SocketAddr; use hyper::{Body, Request, Response, Server, StatusCode}; use hyper::service::{make_service_fn, service_fn}; //const LOCATION: &'static str = "https://edac.io"; // example: LOCATION=https://edac.io lazy_static!...
true
88977a7a4b3c5e4826c7c67b7f07eb66bf5cbfc6
Rust
pavel1269/advent-of-code
/2020/src/day14.rs
UTF-8
838
2.703125
3
[]
no_license
#[path = "day14/mod.rs"] mod day14; use day14::*; pub fn get_part1_result() -> i64 { let input = get_challenge_input(); let state = run_program(input, Version::V1); let result = sum_memory(&state); return result as i64; } pub fn get_part2_result() -> i64 { let input = get_challenge_input(); ...
true
3d8bbbcfa11e57f2e026ee0b46bded3713e0cdb5
Rust
amanusk/cpu-rs
/cpu-freq/src/lib.rs
UTF-8
3,579
3.625
4
[ "Apache-2.0" ]
permissive
//! A crate to obtain CPU frequency information //! //! The crates attempts to obtain the information with as little permissions as //! possible, in the fastest way possible, while still returning a result. //! //! ## Examples //! //! Fetch CPU frequency //! //! ``` //! let cpus = cpu_freq::get(); //! ``` #[derive(Clon...
true
01e6ead483c237a26ef001f4576426c2bcd60014
Rust
Delamare2112/AdventOfCode2017
/day3/src/main.rs
UTF-8
3,719
3.453125
3
[]
no_license
const T1: usize = 1; const T2: usize = 12; const T3: usize = 23; const T4: usize = 1024; const I1: usize = 361527; fn get_manhattan_distance(loc: usize) -> usize { let loc = loc as f32; // essentially this is the length of a square in the spiral. let mut base = loc.sqrt().ceil(); if base % 2f32 == 0f3...
true
9def7483ad07d44749a2579769b566427131a779
Rust
ZygimantasGudanis/learning-rust
/project_1/src/sorting/quick_sort.rs
UTF-8
752
3.421875
3
[]
no_license
pub fn quick_sort(vector: &mut [i32], low: usize, high: usize) -> &mut [i32]{ let mut vector_copy = vector; if low < high { let p = partition(vector_copy, low, high); vector_copy = quick_sort(p.1, low, p.0.saturating_sub(1)); vector_copy = quick_sort(vector_copy, p.0 + 1, high);...
true
5e87550629cecd609cb351af637c9a49ac441ed7
Rust
Kreyren/piston-examples
/examples/texture_swap.rs
UTF-8
1,856
2.546875
3
[ "MIT" ]
permissive
extern crate rand; extern crate piston_window; extern crate image as im; use piston_window::*; fn main() { let texture_count = 1024; let frames = 200; let size = 32.0; let mut window: PistonWindow = WindowSettings::new("piston", [1024; 2]).build().unwrap(); let mut texture_context = TextureConte...
true
692924e7797083b771cab13653d49723e2e33043
Rust
emabee/rust-hdbconnect
/hdbconnect_impl/src/protocol/parts/write_lob_request.rs
UTF-8
1,792
2.6875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::HdbResult; #[cfg(feature = "sync")] use byteorder::{LittleEndian, WriteBytesExt}; #[derive(Debug)] pub struct WriteLobRequest<'a> { locator_id: u64, offset: i64, buf: &'a [u8], last_data: bool, } impl<'a> WriteLobRequest<'a> { pub fn new(locator_id: u64, offset: i64, buf: &[u8], last_dat...
true
6df8fdc498f0222d2d35d5a81e46352246a25865
Rust
dashaw92/dailyprogrammer
/275e/src/main.rs
UTF-8
2,344
3.75
4
[]
no_license
fn main() { let tests = vec![("Spenglerium", "Ee"), ("Zeddemorium", "Zr"), ("Venkmine", "Kn"), ("Stantzon", "Zt"), ("Melintzum", "Nn"), ("Tullium", "Ty"), ]; println!("Element sy...
true
0c6a48ed5d592c2ad53b81b3396e23b99a46d2ce
Rust
jonasdn/crazyflie-link-rs
/crazyflie-link/src/context.rs
UTF-8
2,360
2.734375
3
[]
no_license
use crate::error::{Error, Result}; use crate::Connection; use crate::RadioThread; use crazyradio::Channel; use std::sync::{Arc, Mutex, Weak}; use url::Url; pub struct LinkContext { radios: Vec<Mutex<Weak<RadioThread>>>, } impl LinkContext { pub fn new() -> Self { Self { radios: vec![Mutex:...
true
e9722b6d90eec107ef4b43d344e99fd1008dbc45
Rust
wuggen/gramit
/src/vec.rs
UTF-8
21,291
3.671875
4
[ "MIT" ]
permissive
//! Two, three, and four-dimensional real vectors with `f32` components. //! //! This module defines a trait [`Vector`] for generic mathematical vectors, as well as three //! default vector types useful for graphics programming: [`Vec2`], [`Vec3`], and [`Vec4`], vectors //! in the 2, 3, and 4 dimensional real spaces re...
true
f1aa6ce47461159e4f0f6553290be849ff17aef4
Rust
00mjk/accord
/src/validators/eq_either.rs
UTF-8
3,205
4.0625
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fmt::Display; /// Enforce that `T` must equal `value`. pub fn eq<T: 'static>(value: T) -> Box<Fn(&T) -> ::ValidatorResult> where T: PartialEq + Display { Box::new(move |s: &T| { if *s == value { Ok(()) } else { Err(::Invalid { msg: "Does not equ...
true
83eeeab8d219663a56378a06bcfb6b4be201500d
Rust
praetp/rustysnake
/src/view/unicornhd.rs
UTF-8
2,963
2.734375
3
[ "MIT" ]
permissive
use crate::model::game::{GameState, SnakeGame}; use self::rgb::*; use self::unicorn_hat_hd::UnicornHatHd; use super::snakedisplay::SnakeDisplay; use image::{ImageBuffer, Pixel, Rgb}; use rusttype::Font; use rusttype::Scale; extern crate rgb; extern crate unicorn_hat_hd; pub static GREEN: RGB8 = RGB8 { r: 0, g: 255, b...
true
3f4e5bd9f1abfbd819255bed7047be84ea353ac7
Rust
genomeannotation/yotools
/hetsep/src/main.rs
UTF-8
4,020
2.828125
3
[]
no_license
#![feature(convert)] use std::collections::{HashMap, HashSet}; use std::fs::File; use std::io::{ BufRead, BufReader, BufWriter, Write, }; use std::str; fn main() { let args: Vec<String> = std::env::args().take(3).collect(); if args.len() < 3 { println!("usage: hetsep <input_fasta> <out...
true
87d8b9df695bdd6025ebb871387fff8db007cd2c
Rust
ChristopherLR/web-graphics
/src/helpers.rs
UTF-8
2,504
2.609375
3
[]
no_license
use web_sys::*; use web_sys::WebGl2RenderingContext as GL; use wasm_bindgen::JsCast; use js_sys::WebAssembly; use js_sys::Object; use js_sys::{ Float32Array, Float64Array, Uint16Array }; use std::mem::size_of; pub fn link_program(gl: &GL, vert_src: &str, frag_src: &str) -> Result<WebGlProgram, String> { let program...
true
ba1436410831a95ac96500a50ea6c5532183af6d
Rust
csirkeee/advent2020
/day3a/src/main.rs
UTF-8
843
2.96875
3
[]
no_license
use std::error::Error; use std::io; use std::io::BufRead; fn main() -> Result<(), Box<dyn Error>> { let stdin = io::stdin(); let mut treemap: Vec<Vec<bool>> = Vec::new(); for line_result in stdin.lock().lines() { if let Ok(line) = line_result { let line = line.trim(); if l...
true
40f39a276ed904d890ca6f4136d7d85e5a3c4837
Rust
gridbugs/advent-of-code-2019
/day6-1/src/main.rs
UTF-8
2,100
3.46875
3
[]
no_license
use std::collections::HashMap; use std::io::BufRead; type NodeName = String; #[derive(Default)] struct DirectedGraph { edges: HashMap<NodeName, Vec<NodeName>>, } #[derive(Default)] struct Count { num_nodes: usize, num_orbits: usize, } impl std::iter::Sum for Count { fn sum<I>(iter: I) -> Self wh...
true
9990d1568494b5a99cba50c214330f731bcf85f5
Rust
dopitz/vulkanism
/nobs-vulkanism-headless/src/cmd/commands/draw/draw.rs
UTF-8
2,495
2.734375
3
[ "MIT" ]
permissive
use super::BindVertexBuffers; use super::BindVertexBuffersManaged; use super::DrawIndexed; use super::DrawIndirect; use super::DrawVertices; use crate::cmd::stream::*; #[derive(Debug, Clone, Copy)] pub enum DrawKind { Vertices(DrawVertices), Indexed(DrawIndexed), Indirect(DrawIndirect), } impl Default for DrawK...
true
f92fea847c82c1f6305a1d2ea74361249152a522
Rust
Infinity-OS/infinity
/src/context/context.rs
UTF-8
6,303
2.890625
3
[ "MIT" ]
permissive
//! This file contains the implementation of the context concept. use ::core::sync::atomic::AtomicUsize; use alloc::boxed::Box; use alloc::arc::Arc; use collections::Vec; use super::File; use scheme::{SchemeNamespace, FileHandle}; use spin::Mutex; use arch::memory::MemoryController; use super::memory::{Memory, Shared...
true
df8cb2161cf704b324e92f6c5538f95a33f19dd4
Rust
cookiemon/cargo-flash
/src/main.rs
UTF-8
4,561
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
use cargo_metadata::Message; use std::env; use std::fmt; use std::io; use std::path::{Path, PathBuf}; use std::process::{self, Command, ExitStatus, Stdio}; // Source: https://www.olimex.com/Products/ARM/JTAG/_resources/Manual_PROGRAMMER.pdf // Removed arm7_9 dcc_downloads enable because it won't work on stm32 // and s...
true
ed5ce9c5fba59ebd1922294888faefabb5315414
Rust
It4innovations/hyperqueue
/crates/tako/src/internal/worker/resources/pool.rs
UTF-8
9,085
2.84375
3
[ "MIT" ]
permissive
use crate::internal::common::resources::descriptor::ResourceDescriptorKind; use crate::internal::common::resources::{ AllocationValue, ResourceAmount, ResourceId, ResourceIndex, }; use crate::internal::common::Map; use crate::internal::worker::resources::counts::ResourceCount; use crate::internal::worker::resources...
true
c80daad1d180783f2b00448ddb6014aee894b178
Rust
mgtlake/AdventOfCode2018
/day_2/src/main.rs
UTF-8
1,622
3.390625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::env; use std::fs::File; use std::io::BufRead; use std::io::BufReader; extern crate itertools; use itertools::Itertools; fn main() { let args: Vec<String> = env::args().collect(); let filename = &args[1]; let file = File::open(filename).expect("Could not read file")...
true
3de21ab7857501854c0960b28b77a00893162b97
Rust
bketelsen/iron-carrier
/src/lib.rs
UTF-8
3,933
2.78125
3
[ "MIT" ]
permissive
#![warn(missing_docs)] #![warn(missing_doc_code_examples)] //! Keep your files in sync! //! //! Synchronize your files in differents machines on the same network use serde::{Deserialize, Serialize}; use std::{error::Error, fmt::Display}; pub mod config; mod crypto; mod deletion_tracker; mod fs; mod network; pub mod ...
true
26918eafdc0dd258533f526bae8a3aab687eb165
Rust
jesusjbr/advent-of-code-2020
/src/day16.rs
UTF-8
5,626
3.1875
3
[]
no_license
use std::collections::HashSet; use std::ops::RangeInclusive; fn parse_input(input: &str) -> (&str, &str, &str) { let (rules, rest) = ( input.split("your ticket:").nth(0).unwrap(), input.split("your ticket:").nth(1).unwrap(), ); let (your_ticket, nearby_tickets) = ( rest.split("near...
true
435741e2c274cdc594a9df2ca029adb9b6d18601
Rust
nimiq/core-rs-albatross
/blockchain-interface/src/abstract_blockchain.rs
UTF-8
4,044
2.53125
3
[ "Apache-2.0" ]
permissive
use futures::stream::BoxStream; use nimiq_block::{Block, BlockType, MacroBlock}; use nimiq_hash::Blake2bHash; use nimiq_primitives::{ networks::NetworkId, policy::Policy, slots_allocation::{Validator, Validators}, }; use crate::{ error::{BlockchainError, BlockchainEvent, Direction}, ChainInfo, Fork...
true
10a4a641f9d90afdf6db81710f156d7b8d2decd0
Rust
NoSequel/rfetch
/src/os.rs
UTF-8
2,824
3.046875
3
[]
no_license
use std::fs; use std::fs::File; use std::process::{Command, Stdio}; pub fn get_system(systems: Vec<System>) -> Option<System> { let file_contents = fs::read_to_string("/etc/os-release"); if let Ok(contents) = file_contents { for system in systems { if contents.contains(system.os_name.as_s...
true
cb6ed13f9a35a3c35d24f6c3db8ce53deb2662f8
Rust
TTcheng/LearnRust
/smart_pointers/src/lib.rs
UTF-8
2,309
3.703125
4
[]
no_license
/// RefCell<T> 和内部可变性模式 /// 内部可变性(Interior mutability)是 Rust 中的一个设计模式,它允许你即使在有不可变引用时改变数据,这通常是借用 /// 规则所不允许的。为了改变数据,该模式在数据结构中使用 unsafe 代码来模糊 Rust 通常的可变性和借用规则。我们还未讲 /// 到不安全代码;第十九章会学习它们。当可以确保代码在运行时会遵守借用规则,即使编译器不能保证的情况,可以选择使用那 /// 些运用内部可变性模式的类型。所涉及的 unsafe 代码将被封装进安全的 API 中,而外部类型仍然是不可变的。 /// 通过 RefCell<T> 在运行时检查借用规则 pub ...
true
95675dbf29f86ff8244acf79525fa0188b7f6b01
Rust
facebookexperimental/MIRAI
/checker/tests/run-pass/box_struct.rs
UTF-8
521
2.609375
3
[ "MIT" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. // // A test that uses paths containing base addresses. use mirai_annotations::*; pub struct Foo { pub x: i32, pub y: i64, } pub...
true
e0c3f3e32a91aa0dd166e047cee95282773b511d
Rust
google/tock-on-titan
/third_party/clap/src/completions/fish.rs
UTF-8
3,429
2.84375
3
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "MIT" ]
permissive
// Std use std::io::Write; // Internal use app::parser::Parser; pub struct FishGen<'a, 'b> where 'a: 'b, { p: &'b Parser<'a, 'b>, } impl<'a, 'b> FishGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { FishGen { p: p } } pub fn generate_to<W: Write>(&self, buf: &mut W) { let command = s...
true
82325c8002d308292cb25a27d45255d349c7de0f
Rust
mitsuhiko/covidcotra
/src/utils.rs
UTF-8
878
2.734375
3
[ "Apache-2.0" ]
permissive
pub mod base64 { use serde::private::de::{Content, ContentDeserializer}; use serde::{de::Deserializer, de::Error, ser::Serializer, Deserialize}; pub fn serialize<T, S>(buffer: &T, serializer: S) -> Result<S::Ok, S::Error> where T: AsRef<[u8]> + ?Sized, S: Serializer, { seria...
true
101295ae71bfed4f1dffb72d5d25c9fb104c68ad
Rust
iCodeIN/listener-rs
/src/sync.rs
UTF-8
2,070
3.265625
3
[]
no_license
//! Synchronized event handler implementation. use std::sync::{Arc, RwLock}; use crate::{EventAction, EventListener}; use crate::args::{EventArgs, EventArgsOwned, EventArgsRef}; /// A synchronized event handler. pub struct EventHandler<T: 'static> { listeners: Arc<RwLock<Vec<Box<dyn EventListener<T>>>>>, } impl<T:...
true
095406582b37ddb1b9817d4cb451491104402a09
Rust
nithinphilips/xsv
/src/cmd/trim.rs
UTF-8
1,630
3.0625
3
[ "MIT", "Unlicense" ]
permissive
use CliResult; use config::{Config, Delimiter}; use util; static USAGE: &'static str = " Trims the fields of CSV Usage: xsv trim [options] [<input>] xsv trim --help Common options: -h, --help Display this message -o, --output <file> Write output to <file> instead of stdout. -n, --n...
true
d0180b6a5ee5d0f29e1e2bad4954000ff6b0f76e
Rust
quilt/dahe
/src/sign.rs
UTF-8
2,613
2.625
3
[]
no_license
use crate::config::Config; use crate::hex::HexData; use anyhow::Result; use ethereum_types::{Address, H256}; use ethers::core::k256::{ ecdsa::{recoverable::Signature as RecoverableSignature, signature::Signer, SigningKey}, elliptic_curve::FieldBytes, Secp256k1, }; use sha3::{Digest, Keccak256}; use std::fmt...
true
26e83bfa9d72c13006cef3364100ee3bd33eb22d
Rust
volker48/advent-of-code
/2020/src/day3.rs
UTF-8
1,200
3.53125
4
[]
no_license
pub fn part1(down: usize, right: usize) -> usize { let raw_input = include_str!("day3_input.txt"); return traverse(raw_input, down, right); } fn traverse(raw_input: &str, down: usize, right: usize) -> usize { let mut tree_count = 0; let path = &mut raw_input.lines().map(|line| line.chars().cycle()).ski...
true
22ea8ac9dd5ab22e861577d87823b0cea5f86477
Rust
dxking/onefetch
/src/onefetch/utils.rs
UTF-8
1,422
3.296875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use byte_unit::Byte; use chrono::{FixedOffset, TimeZone}; use chrono_humanize::HumanTime; use colored::Color; use git2::Time; pub fn num_to_color(num: &str) -> Option<Color> { let color = match num { "0" => Color::Black, "1" => Color::Red, "2" => Color::Green, "3" => Color::Yellow, ...
true
8c9ddc6f861e69cd3f39d8e5ed476e9bd82f5842
Rust
clucompany/cluLockFile
/src/state/move_active_state.rs
UTF-8
2,023
3.140625
3
[ "Apache-2.0" ]
permissive
use crate::state::ActiveLockState; use std::fmt::Display; use std::fmt; #[derive(Debug, Clone, PartialEq, PartialOrd)] pub enum MoveActiveLockState<T> { AlwaysOn(T), AlwaysOff, On(T), Off, } impl<T> MoveActiveLockState<T> { #[inline] pub const fn always_on(t: T) -> Self { Self::AlwaysOn(t) } #[inline] ...
true
4acccb8df750e3b85c21f7e0b6e29c4db8d76543
Rust
RonSheely/logicsim
/src/circuits/bus_multiplexer.rs
UTF-8
2,119
2.984375
3
[ "MIT" ]
permissive
use super::decoder; use crate::graph::*; fn mkname(name: String) -> String { format!("BUSMUX:{}", name) } /// Returns one of the `inputs` selected by `address`. /// Conceptually it is a combination of [multiplexers](https://en.wikipedia.org/wiki/Multiplexer), one for each I/O bit. /// /// The output width will be...
true
33d6bac656f10f69db295f4a0f43bbaf2ba8051b
Rust
ohyo-io/wampire
/src/messages/types/value.rs
UTF-8
10,047
3.3125
3
[ "MPL-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{collections::HashMap, fmt}; use itertools::Itertools; use crate::CallResult; use super::{CallError, Reason}; /// Alias for HashMap of [Value]'s pub type Dict = HashMap<String, Value>; /// Alias for Vec of [Value]'s pub type List = Vec<Value>; // TODO properly implement Hash and Eq /// Represents URI #[...
true
418c3e539cdf1a9737f2b05ede8ed723e662fcf3
Rust
OrbitalStation/qas
/qas-macro/src/c/comment.rs
UTF-8
743
3.109375
3
[]
no_license
pub struct Comment { pub begin: &'static str, pub end: &'static str, pub save_end: bool, } impl Comment { pub fn uncomment(code: &mut String, comments: &[Self]) { let mut i = 0; while i < code.len() { for comment in comments { if code.chars().skip(i).collect:...
true
c9b5fde5aaafe6bd953568549f81e35ad0e6794f
Rust
Coutlaw/leetcode_solutions
/lib/i32_reverse/src/lib.rs
UTF-8
1,687
3.703125
4
[]
no_license
/* Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the purpose...
true
eedc874b25efbec713deb78721ac008e830582e5
Rust
mdg/leema
/src/leema/parser.rs
UTF-8
64,916
2.671875
3
[ "Apache-2.0" ]
permissive
use crate::leema::ast2; use crate::leema::ast2::{ Ast, AstNode, AstResult, Case, DataType, ModAction, ModTree, Xlist, }; use crate::leema::failure::Lresult; use crate::leema::lstr::Lstr; use crate::leema::pratt; use crate::leema::struple::StrupleItem; use crate::leema::val::Val; use pest::iterators::Pair; use pest...
true
06a0883df8603bb9c7611c29dfcd62874fe82050
Rust
nickbabcock/collectd-rust-plugin
/src/de/level.rs
UTF-8
1,080
3.03125
3
[ "MIT" ]
permissive
use crate::api::LogLevel; use serde::de::{self, Deserialize, Deserializer, Visitor}; use std::fmt; struct LogLevelVisitor; impl<'de> Visitor<'de> for LogLevelVisitor { type Value = LogLevel; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("ERROR | WARN | I...
true
8e89005f7b5af43bb40adb92b633679528f7be71
Rust
alex-eg/rust-whatever
/string-palindroms.rs
UTF-8
734
3.40625
3
[]
no_license
use std::io; fn reverse(s: &~str) -> ~str { s.chars_rev().collect() } fn get_palindroms(s: ~str) -> ~[~str] { let mut words = ~[]; for q in s.words() { words.push(q.to_owned()); } let mut result = ~[]; let mut p = words.iter().filter(|&x| *x == reverse(x)); for q in p { res...
true
4aa505bf8195f5b9306205e71926117bad4c92e0
Rust
lumeohq/onvif-rs
/onvif/src/utils/display_list.rs
UTF-8
549
3.171875
3
[ "MIT" ]
permissive
use std::fmt::{Debug, Display, Formatter, Write}; pub struct DisplayList<'a, T>(pub &'a [T]); impl<T: Display> Debug for DisplayList<'_, T> { fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result { formatter.write_char('[')?; let mut peekable = self.0.iter().peekable(); while ...
true
87c86e028df7b3f3973ca4efeb78405aa496290f
Rust
SolarLiner/wavr-audio
/wavr-engine/src/context.rs
UTF-8
3,782
3.015625
3
[ "MIT" ]
permissive
/* * Copyright (c) 2020 the Wavr Audio project. * This source file, as well as the binaries generated by it, * are licensed under MIT. */ //! Module implementing the `AudioContext` structure, keeping track of the state //! of the processing and timestamp of the current audio frame. //! //! You will most likely not ...
true
82b9d0555cf67f141edf9bc8563c58da20ee7bf7
Rust
inflation/raytracer
/src/bvh.rs
UTF-8
3,101
2.796875
3
[]
no_license
use rand::Rng; use crate::prelude::*; use crate::hittable_list::*; use std::sync::Arc; #[derive(Debug)] pub struct BVHNode { left: Arc<dyn Hittable>, right: Arc<dyn Hittable>, bbox: AABB, } impl BVHNode { pub fn new( objects: &mut Vec<Arc<dyn Hittable>>, start: usize, end: u...
true
1da13006d942e9ff45b824892037852ec2d2af3e
Rust
openstax/math-editor-sprint
/übertool/src/format/mathml/opdict.rs
UTF-8
119,763
2.578125
3
[]
no_license
//! MathML Operator Dictionary use ast::OperatorForm; pub struct Op { pub character: &'static str, pub form: OperatorForm, pub priority: u32, pub lspace: u8, pub rspace: u8, pub fence: bool, pub stretchy: bool, pub symmetric: bool, pub largeop: bool, pub movablelimits: bool, pub separator: bool,...
true
14ace84b3eaf409d21fabefcb7faf8fd5729b191
Rust
FaneTheEternal/cubism-rs
/src/json/pose.rs
UTF-8
1,549
2.859375
3
[ "Apache-2.0", "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use std::str::FromStr; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(rename_all = "PascalCase")] pub struct Pose3 { #[serde(rename = "Type")] pub ty: String, pub groups: Vec<PoseGroup>, #[serde(default = "Pose3::fade_in_time_default")] pub fade_in_tim...
true
f760d47f8f2ce571fa64de7f433381be8ed5aacf
Rust
elauffenburger/sixty-five-oh-too
/src/cpu/instr/store.rs
UTF-8
4,000
2.78125
3
[]
no_license
use super::super::super::cpu; use super::Cpu; use super::InstrResult; use super::super::addr; use self::addr::AddrResult; use std::fmt; pub mod sta { use super::cpu; use super::Cpu; use super::InstrResult; use super::addr; use self::addr::AddrResult; pub fn zero_page(cpu: &mut Cpu) -> Box<Ins...
true
d97d2aaacf08c53a2dfeb5f5306bbcc7a6a5aaa9
Rust
isgasho/random-access-memory
/tests/test.rs
UTF-8
1,382
3
3
[ "Apache-2.0", "MIT" ]
permissive
use random_access_memory as ram; use random_access_storage::RandomAccess; #[async_std::test] async fn can_call_new() { let _file = ram::RandomAccessMemory::default(); } #[async_std::test] async fn can_open_buffer() { let mut file = ram::RandomAccessMemory::default(); file.write(0, b"hello").await.unwrap(); } #...
true
e7632514471d64dc17e154fde9a92cc920ea3864
Rust
jlhsmall/RayTracer
/src/hittablelist.rs
UTF-8
1,926
2.828125
3
[ "MIT" ]
permissive
pub use crate::aabb::AABB; pub use crate::object::{HitRecord, Hittable}; pub use crate::oneweekend::rand_int; pub use crate::ray::Ray; pub use crate::vec3::Vec3; pub use std::sync::Arc; pub struct HittableList { pub objects: Vec<Arc<dyn Hittable>>, } impl HittableList { pub fn new(objects: Vec<Arc<dyn Hittable>...
true
886dd6b797d90e587a21735a9c8b39a475144ef9
Rust
Ducolnd/ludwig-world-3d
/src/render/meshing/chunkmeshing.rs
UTF-8
5,012
2.9375
3
[ "MIT" ]
permissive
use crate::render::{ vertexarray::VertexArray, shapes::shapes::Quad, meshing::meshing::*, }; use crate::world::{ chunk::chunk::{Chunk, index_to_coord}, chunk::chunkmanager::ChunkManager, constants::*, block::blocks::{get_block, BlockID, Blocks, Sides}, chunk::pos::*, }; pub struct Chunk...
true
4b6d0d427b9e24590e937fe44df0071366d8c69c
Rust
rocurley/jex
/src/layout.rs
UTF-8
2,084
2.609375
3
[ "MIT" ]
permissive
use tui::layout::{Constraint, Direction, Layout, Rect}; #[derive(Clone, Copy, Debug)] pub struct JexLayout { pub tree: Option<Rect>, pub left: Rect, pub right: Rect, pub query: Rect, } impl JexLayout { pub fn new(size: Rect, show_tree: bool) -> JexLayout { let vchunks = Layout::default() ...
true
48c52fae342efda2dbb448b5ca0dde4f1b235612
Rust
ForgottenMaster/aoc-2020
/src/bin/day03.rs
UTF-8
732
2.71875
3
[]
no_license
use { aoc::{ io::file::get_file_contents, toboggan::map::{Map, Space}, }, std::io::Result, }; fn main() -> Result<()> { let map = get_file_contents("data/day03.txt")?.parse::<Map>()?; println!( "Part 1 = {}", map.follow_route(3, 1) .filter(|space| { **sp...
true
de2ec8948c90f5af90b20d67e7113ce750802ffb
Rust
brodly/rust_exercises
/temperature_convert/src/main.rs
UTF-8
1,582
3.890625
4
[]
no_license
use std::io; fn main() { loop { println!("Press 1 for C to F"); println!("Press 2 for F to C"); let mut convert_to = String::new(); io::stdin().read_line(&mut convert_to) .expect("Failed to read line"); let convert_to: u32 = match convert_to.trim().parse() { ...
true
847789dc6c27568e798b942f730ff4c4b74c6627
Rust
alistairbill/bluenrg1
/src/spi.rs
UTF-8
3,981
2.5625
3
[]
no_license
#[doc = r" Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Control Register 0"] pub cr0: CR0, #[doc = "0x04 - Control Register 1"] pub cr1: CR1, #[doc = "0x08 - Data Register"] pub dr: DR, #[doc = "0x0c - Status Register"] pub sr: SR, _reserved0: [u8; 3usize], ...
true
2afe5a5ebfd580dcfb1539d763c71fc6747c81f5
Rust
duhongbo123/crdb-changefeed-publisher
/src/queues.rs
UTF-8
1,616
2.53125
3
[ "MIT" ]
permissive
use crate::Error; use crate::RABBITMQ_MESSAGES_SENT_COUNTER; use async_trait::async_trait; use lapin::{ options::{BasicPublishOptions, QueueDeclareOptions}, types::FieldTable, BasicProperties, Channel, Connection, ConnectionProperties, }; use tokio_amqp::LapinTokioExt; #[async_trait] pub trait MessageQueu...
true
c13b85f6030361c13fc21d67893d91eb9300be0a
Rust
mitsuhiko/minijinja
/examples/eval-to-state/src/main.rs
UTF-8
1,301
2.578125
3
[ "Apache-2.0" ]
permissive
use minijinja::{args, context, Environment}; fn main() { let mut env = Environment::new(); env.add_template("layout.html", include_str!("templates/layout.html")) .unwrap(); env.add_template("index.html", include_str!("templates/index.html")) .unwrap(); let template = env.get_template("...
true
7303534d0573be9c7d2e1d936b45580a8a97bbfd
Rust
LiamMehle/playground
/rust/examples/net_tcp_read.rs
UTF-8
2,563
3.546875
4
[]
no_license
use std::{net, thread}; // the whole thing revolves around networking and threading control const EXPECTED_ADDR: &str = "127.0.0.1:6969"; // yep, not a typo. I am verry mature. // fixed size buffers are both more technically challenging and far, far faster // works with any non-zero buffer size const READ_BUFF_SIZE: u...
true
c13a6a03e7f70a33318c788e18065c675b0876b4
Rust
phyber/jail_exporter
/src/main.rs
UTF-8
3,552
2.546875
3
[ "MIT" ]
permissive
//! //! `jail_exporter` //! //! An exporter for Prometheus, exporting jail metrics as reported by rctl(8). //! #![forbid(unsafe_code)] #![deny(missing_docs)] #![allow(clippy::module_name_repetitions)] #![allow(clippy::redundant_field_names)] use tracing::debug; use users::UsersCache; #[cfg(feature = "auth")] use std::...
true
667c1829a9a525d93c9110c5cf1218b748172a4a
Rust
AlexHart/rust-book
/ownership/src/main.rs
UTF-8
967
4.03125
4
[]
no_license
fn main() { let s = String::from("Hello"); let mut s2 = String::from(s); s2.push_str(", world!"); println!("{}", s2); free_string_memory(); free_string_memory_with_clone(); let ss = String::from("hello"); let s_res = takes_ownership(ss); println!("{}", s_res); let (ss2, len) =...
true
1c07c2ddcc8c769de5bd5c3f58f62b5cfb72084d
Rust
jedisct1/rust-ed25519-compact
/src/x25519.rs
UTF-8
10,337
2.8125
3
[ "MIT" ]
permissive
use core::ops::{Deref, DerefMut}; use super::common::*; use super::error::Error; use super::field25519::*; const POINT_BYTES: usize = 32; /// Non-uniform output of a scalar multiplication. /// This represents a point on the curve, and should not be used directly as a /// cipher key. #[derive(Clone, Debug, Eq, Partia...
true
cc9f81601da1e1e7c40ad41eb871043fcd77c2c7
Rust
Measter/roguelike_tutorial_rs
/week_03/src/rectangle.rs
UTF-8
944
3.453125
3
[ "MIT" ]
permissive
use point::Point; #[derive(Debug, Hash, Eq, PartialEq)] pub struct Rectangle { pub top_left: Point<i8>, pub bottom_right: Point<i8>, } impl Rectangle { pub fn new(top_left: Point<i8>, (width, height): (u8, u8)) -> Rectangle { Rectangle { top_left: top_left, bottom_right: Po...
true
3fd241d01d7f56169d5261cf364a847a5b1763bd
Rust
Matthias-Fauconneau/iced
/native/src/widget/image.rs
UTF-8
6,604
3.453125
3
[ "MIT" ]
permissive
//! Display images in your user interface. use crate::{layout, Element, Hasher, Layout, Length, Point, Size, Widget}; use std::{ hash::{Hash, Hasher as _}, path::PathBuf, sync::Arc, }; /// A frame that displays an image while keeping aspect ratio. /// /// # Example /// /// ``` /// # use iced_native::Image...
true
fa4e780334a58c26119d91c6da88c4035536bdae
Rust
byron7cueva/learn-rust
/intermedio/first-project/src/stack_heap.rs
UTF-8
5,089
3.78125
4
[]
no_license
// Con el signo de admiracion !, ejemplo: println!(), estas son macros // Las macros permiten definir un lenguaje a un dominio especifico #[derive(Debug)] struct DougsStruct { a: i32, b: f64, c: String } fn main () { let entero: u8 = 5; // Imprimir en formato del apuntador println!("La direccion del ente...
true
9b10040dd0dd17e4692bc7eaeb85bbe11ff54408
Rust
simvux/aoc-2019
/6/both/src/main.rs
UTF-8
1,403
3.359375
3
[]
no_license
use std::collections::HashMap; use std::io; use std::io::BufRead; fn main() { let mut objects = HashMap::new(); for line in io::stdin().lock().lines() { let line = line.unwrap(); let mut spl = line.split(')'); let left = spl.next().unwrap(); let right = spl.next().unwrap(); ...
true
c1ae749620313cf3a178f65cd4107351e957ffe8
Rust
bwindels/rust-exif-parser
/src/component.rs
UTF-8
2,089
2.890625
3
[]
no_license
use std::iter::Iterator; use ::cursor::{Cursor, ByteSwappable}; use ::error::ParseResult; use std::marker::{Sized, PhantomData}; pub trait ExifValueReader { fn read_exif_value(cursor: &mut Cursor) -> ParseResult<Self> where Self: Sized + Copy; } impl ExifValueReader for (u32, u32) { fn read_exif_value(cursor: &mu...
true
40cc310f2e4067c9d6fc05dc139b43b93c0719a2
Rust
dmgolembiowski/tql
/tql_macros/src/stable.rs
UTF-8
10,310
2.640625
3
[ "MIT" ]
permissive
//! Workaround to make get the hygiene right on stable. use proc_macro2::TokenStream; use syn::{ Expr, Ident, }; use ast::{ Aggregate, Assignment, AssignmentOperator, FilterExpression, FilterValue, Groups, Join, Limit, LogicalOperator, MethodCall, Order, Query, ...
true
4ae60812058cb3ddb29afcc4eacf866832f62650
Rust
Devolutions/gfwx-rs
/src/header/builder.rs
UTF-8
2,271
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
use super::{Encoder, Filter, Header, HeaderErr, Intent, Quantization}; use std::fmt::Display; pub struct HeaderBuilder { pub width: u32, pub height: u32, pub layers: u16, pub channels: u16, pub quality: u16, pub chroma_scale: u8, pub block_size: u8, pub filter: Filter, pub encoder: ...
true
0c8ff7092ad77088fca531c2f02aace7874a39ca
Rust
ZeProf10T/Subnet-calculator
/src/show.rs
UTF-8
3,710
3.078125
3
[ "MIT" ]
permissive
use std::net::Ipv4Addr; use std::net::Ipv6Addr; use std::error::Error; use crate::ipv4; use crate::ipv6; pub fn quatre(ip: Ipv4Addr, mask: Ipv4Addr, subnet_mask: Option<Ipv4Addr>) { let network = ipv4::address::network(&ip, &mask); let wildcard = ipv4::address::wildcard(&mask); let broadcast = ipv4::addr...
true
9fd873f12755506af15b2d0ad4bd5907a7b42b3f
Rust
tikhono/CryptoHackPals
/hacks/diffie_hellman/diffie_hellman_starter_2/src/lib.rs
UTF-8
656
3.28125
3
[]
no_license
use num::bigint::BigInt; pub fn order(g: BigInt, p: u32) -> u32 { for i in 2..p { if g.modpow(&BigInt::from(i), &BigInt::from(p)) == g { return i; } } p } pub fn generator(p: u32) -> u32 { for g in 2..p { //Generator couldn't be 0 or 1 if order(BigInt::from(...
true
6113b681474228b6f414817e9cbd45a5c8779e6c
Rust
SASUKE40/yukino-dev
/core/src/err/query.rs
UTF-8
1,123
2.6875
3
[ "MIT" ]
permissive
use crate::err::YukinoError; use query_builder::DatabaseType; use query_builder::Expr; use std::error::Error; use std::fmt::{Debug, Display, Formatter, Result as FmtResult}; use thiserror::Error; pub type ExprResult<T> = Result<T, ExprError>; #[derive(Debug)] pub struct ExprError { expr: String, msg: String, ...
true
59382b2c080a763c518d3c7f823a7ac4759490d5
Rust
driftluo/AlgorithmPractice
/BinaryTree/Rust/binarytree/src/main.rs
UTF-8
2,628
3.8125
4
[ "MIT" ]
permissive
type TreeNode<K, V> = Option<Box<Node<K, V>>>; #[derive(Debug)] struct Node<K, V: std::fmt::Display> { left: TreeNode<K, V>, right: TreeNode<K, V>, key: K, value: V, } trait BinaryTree<K, V> { fn pre_order(&self); fn in_order(&self); fn pos_order(&self); } trait BinarySerchTree<K:PartialO...
true
df9d67ebf33bc8ea394cb16fa48cf9dc30c98ce6
Rust
dnsl48/fraction
/src/fraction/ops/mul_assign.rs
UTF-8
7,760
3.125
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::fraction::{GenericFraction, Sign}; use crate::{Integer, Ratio, Zero}; use std::mem; use std::ops::{Mul, MulAssign}; impl<T, O> MulAssign<O> for GenericFraction<T> where T: Clone + Integer, O: Into<GenericFraction<T>>, { fn mul_assign(&mut self, other: O) { let other = other.into(); ...
true
43e06affd3abd0130b950191bdfc1c0f9ff4151d
Rust
christopherjreid/advent-of-code-2020-rust
/src/days_of_advent/day02/policies/range_password_policy.rs
UTF-8
1,326
3.5
4
[]
no_license
use super::validates_password::ValidatesPassword; pub struct RangePasswordPolicy { pub range: std::ops::RangeInclusive<usize>, pub character: char } impl ValidatesPassword for RangePasswordPolicy { fn is_password_valid(&self, password: &str) -> bool { let num_matches = password.matches(self.charac...
true
201b01fc448d5d280c4f2fbb3bd0eb2806a4f1c4
Rust
tommcgurl/learn-rust-live
/projects/chapter-14-cargo-and-crates/add/add-two/src/lib.rs
UTF-8
214
4.34375
4
[]
no_license
/// Function that adds 1 to the number provided. /// /// # Examples /// ``` /// let num = 115; /// let answer = add_two::add_two(num); /// assert_eq!(117, answer) /// ``` pub fn add_two(x: i32) -> i32 { x + 2 }
true
91a02417db41d0e0381550e9bf07c3b08990c23e
Rust
vmanucharyan/nprs
/src/train.rs
UTF-8
618
2.890625
3
[]
no_license
extern crate rusty_machine; use rusty_machine::learning::logistic_reg::LogisticRegressor; use rusty_machine::learning::SupModel; use rusty_machine::linalg::matrix::Matrix; use rusty_machine::linalg::vector::Vector; fn main() { let inputs = Matrix::new(4,1,vec![1.0,3.0,5.0,7.0]); let targets = Vector::new(vec!...
true
312c4d09dd557314547fde6b96499d436c86e51d
Rust
danbruder/poppy
/src/config.rs
UTF-8
1,290
2.765625
3
[]
no_license
use std::env; use std::fs; use std::path::PathBuf; lazy_static! { pub static ref DATABASE_URL: String = env::var("DATABASE_URL").expect("must set DATABASE_URL"); pub static ref FILES_DIR: String = env::var("FILES_DIR").expect("must set FILES_DIR"); pub static ref DATABASE_PATH: String = env::var("D...
true
848d9bbf4355d7159fc4cf207cd211f2700c36ef
Rust
NLnetLabs/rpki-rs
/src/rtr/mod.rs
UTF-8
1,667
2.65625
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! RTR: the RPKI to Router Protocol. //! //! RPKI, the Resource Public Key Infrastructure, is a distributed database of //! signed statements by entities that participate in Internet routing. A //! typical setup to facilitate this information when making routing decisions //! first collects and validates all statement...
true
631939f5773493eefdb5449bf4289dafa8bd0d98
Rust
danielhenrymantilla/stackbox.rs
/src/dyn_traits/mod.rs
UTF-8
3,917
3.234375
3
[ "Apache-2.0", "Zlib", "MIT" ]
permissive
//! Hand-rolled implementations of pervasive `StackBox<dyn …>` types. //! //! ### Explanation //! //! Given the baked-into-the-language nature of trait objects, receiver types, //! and auto-generated vtables, things like `StackBox<'_, dyn Any>` _& co._ //! Do Not Work™. //! //! So we need to hand-roll those, and this i...
true
5bb1541715e471b6702c2961a7d87941d734efe6
Rust
peterzheng98/raytracer.rs
/src/tracer/pdf/rect.rs
UTF-8
2,607
2.9375
3
[ "MIT" ]
permissive
use crate::tracer::{HitRecord, Ray, Vec3, AABB}; use super::PDFHitable; use rand::rngs::SmallRng; use rand::{Rng, SeedableRng}; use std::f32::consts::PI; pub struct RectXZArea { pub x0: f32, pub x1: f32, pub z0: f32, pub z1: f32, pub k: f32, mu_x: f32, mu_z: f32, s_x: f32, s_z: f32,...
true
b47b5fc6afe0c9f88907f7887dc9df9cd3a091f1
Rust
jmc-figueira/oxdz
/src/module/mod.rs
UTF-8
1,867
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
pub mod event; pub mod sample; pub use self::sample::Sample; use std::any::Any; use std::marker::{Sync, Send}; use util::MemOpExt; // Module pub struct Module { pub format_id : &'static str, // format identifier pub description: String, // format description pub creator : String, ...
true
03ad3a33410ec1c1ef89b690acfeb01633497869
Rust
antstorm/euler
/16.rs
UTF-8
573
3.71875
4
[]
no_license
// 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. // What is the sum of the digits of the number 2^1000? fn solve(power: u32) -> u64 { let mut result = vec!(1); for _ in 1..(power + 1) { let mut extra = false; for i in 0..result.len() { let x = result[i] * 2; result[i] = x ...
true
4ddc89d7299a31c514b0195b2a1323871af75cbb
Rust
bittersweetpuff/raytracing
/src/main.rs
UTF-8
602
2.875
3
[]
no_license
mod vec3; pub use vec3::{cross, dot, unit_vector, Vec3}; mod color; pub use color::{write_color, Color}; fn main() { //Image let image_width = 256; let image_height = 256; //Render println!("P3\n{} {}\n255\n", image_width, image_height); for j in 0..image_height { for i in 0..image_...
true
bd80ef4f8f3100a79dd2e4eeb0952abec9451d8d
Rust
w23/alacritty
/alacritty/src/url.rs
UTF-8
7,578
2.609375
3
[ "Apache-2.0" ]
permissive
use std::cmp::min; use std::mem; use crossfont::Metrics; use glutin::event::{ElementState, ModifiersState}; use urlocator::{UrlLocation, UrlLocator}; use alacritty_terminal::index::{Column, Point}; use alacritty_terminal::term::cell::Flags; use alacritty_terminal::term::color::Rgb; use alacritty_terminal::term::{Rend...
true