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
fa2937b7794209b94626b4f4d47701507457cada
Rust
stainlessio/plantcam
/src/main.rs
UTF-8
3,614
2.6875
3
[ "MIT" ]
permissive
#![feature(conservative_impl_trait)] #![allow(dead_code)] #![allow(unused_imports)] extern crate camera_capture; extern crate clap; extern crate chrono; extern crate tokio_timer; extern crate futures; extern crate image; use std::path::Path; use std::fs::File; use clap::{App, Arg}; use chrono::prelude::*; use std::tim...
true
1c67958cb0adbbc18e05f27dee5a35e35f0ad2b4
Rust
r-asou/databend
/common/datavalues/src/arrays/ops/scatter_test.rs
UTF-8
4,493
2.640625
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
true
15e042b8aa570ae5cc01d595f12c85e7867b3a2e
Rust
TauGames/mlua
/examples/async_http_reqwest.rs
UTF-8
1,091
2.53125
3
[ "MIT" ]
permissive
use mlua::{chunk, ExternalResult, Lua, LuaSerdeExt, Result}; #[tokio::main] async fn main() -> Result<()> { let lua = Lua::new(); let null = lua.null(); let fetch_json = lua.create_async_function(|lua, uri: String| async move { let resp = reqwest::get(&uri) .await .and_the...
true
4fa1d0fe2efb0bc2f6763f08f133239eb648c952
Rust
shepmaster/jetscii
/src/fallback.rs
UTF-8
897
3.1875
3
[ "Apache-2.0", "MIT" ]
permissive
// TODO: Try boxing the closure to see if we can hide the type // TODO: Or maybe use a function pointer? pub struct Bytes<F> where F: Fn(u8) -> bool, { fallback: F, } impl<F> Bytes<F> where F: Fn(u8) -> bool, { pub /* const */ fn new(fallback: F) -> Self { Bytes { fallback } } pub fn ...
true
72ef19c532b2303e3bc99ab123e79e3a04e62bc7
Rust
psobczak/sun_time_calculator
/src/coordinate.rs
UTF-8
1,403
3.6875
4
[]
no_license
use std::fmt; #[derive(Debug)] pub struct Coordinate { pub degrees: i16, pub minutes: u16, pub seconds: u16, pub direction: Direction, } impl fmt::Display for Coordinate { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!( f, "{}°{}′{}′′{:?}", ...
true
6a1da9303fb0d083dfb0bae6fbf5e7615a43d94d
Rust
AustinJ235/vulkano
/vulkano/src/pipeline/graphics/depth_stencil.rs
UTF-8
11,844
2.859375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// Copyright (c) 2016 The vulkano developers // Licensed under the Apache License, Version 2.0 // <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT // license <LICENSE-MIT or https://opensource.org/licenses/MIT>, // at your option. All files in the project carrying such // notice may not be ...
true
2baa3f7e43a4be488ab31f08ee80c50989292476
Rust
mesalock-linux/parity-wasm-sgx
/sgx/parity-wasm-sgx-test/enclave/src/elements/reloc_section.rs
UTF-8
741
2.734375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use parity_wasm::elements::{Section, deserialize_file}; use parity_wasm::elements::RelocationEntry; //#[test] pub fn reloc_section() { let module = deserialize_file("./res/cases/v1/relocatable.wasm").expect("Module should be deserialized") .parse_reloc().expect("Reloc section should be deserialized"); let mut fo...
true
b6a8929077d47f438868655a2b401661b224e6af
Rust
suyanlong/collectd-rust-plugin
/src/de/mod.rs
UTF-8
16,061
3.015625
3
[ "MIT" ]
permissive
use std::fmt::{self, Display}; use serde::de::{self, Deserialize, DeserializeSeed, MapAccess, SeqAccess, Visitor}; use api::{ConfigItem, ConfigValue}; pub type Result<T> = ::std::result::Result<T, Error>; #[derive(Fail, Debug)] pub enum DeError { #[fail(display = "No more values left, this should never happen")] ...
true
8773cba8dca22ff138da852dc2ec6b139ca093f4
Rust
Gilnaa/rusty3bar
/src/i3.rs
UTF-8
3,444
3.546875
4
[ "Apache-2.0" ]
permissive
//! Structures describing the primitives used to communicate with i3bar. use super::color::*; /// A single display block data sent to i3bar. #[derive(Debug, Clone, Serialize)] pub struct Block { #[serde(skip_serializing_if = "Option::is_none")] pub name: Option<String>, #[serde(skip_serializing_if = "Opt...
true
c2b9d874c9b311fe8e82d968df94a8ed4c9621e4
Rust
moshg/rust-std-ja
/src/test/run-pass/impl-trait/nesting.rs
UTF-8
706
2.53125
3
[ "MIT", "Apache-2.0", "BSD-3-Clause", "NCSA", "LicenseRef-scancode-other-permissive", "BSD-2-Clause" ]
permissive
// Copyright 2018 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
33f0e8f9ef0492c9bef87031f70c12fa8f2ef3a8
Rust
cGuille/adventofcode
/src/bin/2020-day4-part2.rs
UTF-8
4,560
3.171875
3
[]
no_license
use std::num::ParseIntError; fn main() { let batch = include_str!("../../input/2020-day4.txt"); let valid_passport_count = batch .split("\n\n") .map(|s| Passport::from(s)) .filter(|p| p.is_valid()) .count(); println!("{}", valid_passport_count); } #[derive(Debug, Default)...
true
9c4f4cef648b732349acf0dfe7763c69576dd7c5
Rust
HarrisonMc555/exercism
/rust/rotational-cipher/src/lib.rs
UTF-8
1,070
3.21875
3
[]
no_license
use lazy_static::lazy_static; pub fn rotate(input: &str, key: i8) -> String { input.chars().map(|c| rotate_char(c, key)).collect() } lazy_static! { static ref UPPERCASE_LETTERS: Vec<char> = (b'A'..=b'Z').map(char::from).collect(); static ref LOWERCASE_LETTERS: Vec<char> = (b'a'..=b'z').map(char::from).col...
true
abf97d0ad52e4d2ec76aaa14466fe63aa8bc161b
Rust
emilio/rustc-perf
/collector/benchmarks/crates.io/src/local_upload.rs
UTF-8
1,115
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
//! This module implements middleware to serve crates and readmes //! from the `local_uploads/` directory. This is only used in //! development environments. use std::error::Error; use conduit::{Handler, Request, Response}; use conduit_static::Static; use conduit_middleware::AroundMiddleware; // Can't derive debug be...
true
08048e8fe6d4224059e99b80cfc68c9e54c272d4
Rust
erickt/lmath-rs
/src/funs/exponential.rs
UTF-8
5,244
3.25
3
[ "Apache-2.0" ]
permissive
/** * Exponential Functions * * This module corresponds to Section 8.2 of the [GLSL 4.30.6 specification] * (http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf). */ use numeric::funs::*; use numeric::traits::*; use vec::{Vector, Vec2, Vec3, Vec4}; // Exp pub trait ExpVector<T>: Vector<T> { pure fn p...
true
c14eaaa6e0c3561fb472b9a2cc82436bb4d1cad3
Rust
ttys3/chartered
/chartered-git/src/git/codec.rs
UTF-8
3,916
2.78125
3
[]
no_license
#![allow(clippy::module_name_repetitions)] use bytes::{Buf, Bytes, BytesMut}; use tokio_util::codec; use super::PktLine; pub struct Encoder { // buf: BytesMut, } impl codec::Encoder<PktLine<'_>> for Encoder { type Error = anyhow::Error; fn encode(&mut self, item: PktLine<'_>, dst: &mut BytesMut) -> Res...
true
c0c268b4c0f1278d7a5b4a8eaaa9d7b77f60ba22
Rust
3Hren/rust-metrics
/src/counter.rs
UTF-8
1,265
3.390625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate num; use metric::{Metric, MetricValue}; #[derive(Copy, Clone, Debug)] pub struct StdCounter { pub value: i64 } pub trait Counter{ fn clear(&mut self); fn dec(&mut self, value: i64); fn inc(&mut self, value: i64); fn snapshot(self) -> Self; } impl Counter for StdCounter { fn c...
true
d8ebcd5c52623e6f41f30e1c6008dd00d95b9793
Rust
jespino/rz80
/src/cpu/tests.rs
UTF-8
28,630
2.71875
3
[]
no_license
#![cfg(test)] use cpu::Z80; use ops::opcodes::Opcode; use ops::opcodes::Reg; use ops::opcodes::BigReg; #[test] fn test_run_ldrr() { let mut cpu = Z80::new(); cpu.regs[Reg::H] = 0x8A; cpu.regs[Reg::E] = 0x10; cpu.run_op(Opcode::LDRR(Reg::H, Reg::E)); assert_eq!(cpu.regs[Reg::H], 0x10); assert_e...
true
d1f8b6251ccda11bc2547f9da58f0f48be659aa0
Rust
wkcn/weekly_challenge_for_algorithm
/week12_array2/57-insert-interval.rs
UTF-8
2,957
3.546875
4
[]
no_license
pub struct Solution {} impl Solution { pub fn insert_2(intervals: Vec<Vec<i32>>, new_interval: Vec<i32>) -> Vec<Vec<i32>> { // 分情况调试,比较复杂 let mut ans: Vec<Vec<i32> > = Vec::new(); let mut new_interval = new_interval; let mut finished = false; for it in intervals.iter() { ...
true
5a504c4cb9304728c8bfb792f1e5430bd53990be
Rust
thomaswhiteway/aoc-2019-rust
/23/src/main.rs
UTF-8
4,208
2.8125
3
[]
no_license
use std::io::stdin; use std::cell::{Cell, RefCell}; use std::collections::VecDeque; mod display; mod process; mod program; mod utils; use process::{Input, Output, Process, run_to_completion}; use program::Program; use std::rc::Rc; #[derive(Debug)] struct Error(String); impl<T: ToString> From<T> for Error { fn f...
true
4060f640aa6e1b0f03b7e3d808c8a404d7f78749
Rust
fukatani/rust-ant-book
/src/baby_step_giant_step.rs
UTF-8
1,400
3.265625
3
[]
no_license
// n ^ p mod m fn pow_m(n: i64, mut p: i64, m: i64) -> i64 { let mut r = n; let mut ret = 1; while p > 0 { if p % 2 == 0 { r = r * r % m; p /= 2; } else { ret = ret * r % m; p -= 1; } } ret } fn gcd(a: i64, b: i64) -> i64 { ...
true
51deaee89650ae9e9f91e1a1b54e6e9cb3a59a43
Rust
michbuett/arena-rl
/src/ui/text.rs
UTF-8
10,823
2.734375
3
[ "MIT" ]
permissive
use std::cmp::max; use std::collections::HashMap; use std::string::ToString; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::{BlendMode, Canvas, Texture, TextureCreator, WindowCanvas}; use sdl2::surface::Surface; use sdl2::ttf::Font as Sdl2Font; use sdl2::video::WindowContext; use crate::ui::types::{...
true
a88b250a5fef180327c3e8cd7201fdf518b994cd
Rust
minioin/rustastic-smtp
/src/server/handler.rs
UTF-8
11,696
2.625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2014 The Rustastic SMTP Developers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable la...
true
9a4e59c96ee9b96c044e87e92d0c25d647d3ebe5
Rust
sidmohanty11/100daysofcode
/learning_rust/src/functions.rs
UTF-8
376
3.8125
4
[]
no_license
pub fn run(){ greet("Hi","Sid"); let get_sum = add(5,5); println!("{}", get_sum); //closures let add_nums = |n1:i32, n2:i32| n1+n2; println!("closure sum, {}", add_nums(3,3)); } fn greet(greeting: &str, name: &str){ println!("{} {}, nice to meet you!", greeting,name); } fn add(n1:i32,n2:i...
true
cd3a4a45f511c3845e6809a73f44947aa94fb700
Rust
mesalock-linux/crates-io
/vendor/devise_core/src/spanned.rs
UTF-8
692
2.671875
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT" ]
permissive
use proc_macro::Span; use quote::ToTokens; pub trait Spanned { fn span(&self) -> Span; } // FIXME: Remove this once proc_macro's stabilize. impl<T: ToTokens> Spanned for T { fn span(&self) -> Span { let token_stream = self.into_token_stream(); let mut iter = token_stream.into_iter(); ...
true
1ea3b6d1355c46c03ff395db5739ddc0e1095d14
Rust
r-asou/databend
/common/io/src/binary_de.rs
UTF-8
1,720
2.6875
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
true
eb534e94881a9d7d9216be7561704f70fdce9ffe
Rust
zayenz/advent-of-code-2019
/day8-1/src/main.rs
UTF-8
1,762
2.6875
3
[ "MIT" ]
permissive
#![allow(dead_code, unused_imports, clippy::ptr_arg)] use failure::bail; use failure::err_msg; use failure::Error; use itertools::*; use rayon::prelude::*; use strum_macros::EnumString; use std::char; use std::cmp::{max, min}; use std::collections::{HashMap, HashSet, VecDeque}; use std::fmt; use std::io::BufRead; use...
true
e06e7cd9767d8c3ef2bf4203f43fb02db8a7b8e0
Rust
mrnix/rust_d3_geo
/src/clip/rejoin/intersection.rs
UTF-8
1,491
2.9375
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use derivative::Derivative; use geo::CoordFloat; use num_traits::{Float, FloatConst}; use crate::clip::line_elem::LineElem; #[derive(Derivative)] #[derivative(Debug)] #[derive(Clone)] pub struct Intersection<T> where T: CoordFloat + FloatConst, { pub x: LineElem<T>, ...
true
06047e42bb64402c7b921ff60d3f1a91df31d950
Rust
BroderickCarlin/embedded-graphics
/embedded-graphics/src/primitives/arc/points.rs
UTF-8
1,800
3.21875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ geometry::Point, primitives::{ arc::{Arc, PlaneSectorIterator}, circle::DistanceIterator, OffsetOutline, }, }; /// Iterator over all points on the arc line. #[derive(Copy, Clone, PartialEq, PartialOrd, Debug)] pub struct Points { iter: DistanceIterator<PlaneSectorIt...
true
9824cf42a354bf87a1771b48820655206d621e1f
Rust
matze/proj-to-dot
/src/main.rs
UTF-8
3,087
2.75
3
[]
no_license
use anyhow::{anyhow, Result}; use log::debug; use std::cell::RefCell; use std::fs::File; use std::io::prelude::*; use std::path::{Path, PathBuf}; use structopt::StructOpt; use tree_sitter::{Language, Parser, Query, QueryCursor}; #[derive(StructOpt)] struct Opt { #[structopt(long, parse(from_os_str))] root: Pat...
true
ffe8849e2812d9180c9032a975d748314a0a2627
Rust
cLazyZombie/raytrace-rs
/src/color.rs
UTF-8
2,791
3.734375
4
[]
no_license
use std::ops::{Add, AddAssign, Mul, Sub}; #[derive(Debug, Copy, Clone)] pub struct Color { pub red: f32, pub green: f32, pub blue: f32, } impl Color { pub const BLACK: Color = Color { red: 0.0, green: 0.0, blue: 0.0, }; pub const WHITE: Color = Color { red: 1.0...
true
d9c1d8e539e0ca130e783400462b1eda31fb15a7
Rust
dcalled1/abaq_api
/abaq_methods/src/root_finding/register.rs
UTF-8
1,314
3.09375
3
[]
no_license
use std::fmt; use serde::Serialize; #[derive(Serialize)] pub struct Log { vars: Vec<f64>, i: u32 } #[derive(Serialize)] pub struct Logbook { head: Vec<String>, regs: Vec<Log>, } impl Log { fn new(i: u32, vars: Vec<f64>) -> Log { Log{i, vars} } } impl Logbook { pub(crate) fn new(n...
true
d4dd74cd8fe9dfe9bfaaccf7519fd7cec34e5d24
Rust
OrbitalStation/qas
/qas-macro/src/lib.rs
UTF-8
742
2.75
3
[]
no_license
//! //! Helper crate to provide macro `qas` //! mod c; mod string_ext; pub(crate) use string_ext::*; use proc_macro::TokenStream; #[proc_macro] pub fn qas(path: TokenStream) -> TokenStream { let path = path.to_string(); let path = path.trim(); assert!(path[..1].chars().next().unwrap() == '"' && path[pa...
true
87de5c7fdb59c6751d2ed28fb2bcc931b7f9329c
Rust
wmmxk/OOP_Rust
/ref_recursive/box_node.rs
UTF-8
253
3.109375
3
[]
no_license
#[derive(Debug)] struct Node { next: Option<Box<Node>>, data: i32, } impl Node { fn new_link(key:i32) -> Option<Box<Node>> { Some(Box::new(Node{next:None,data:key })) } } fn main(){ let key = 3; println!("{:?}", Node::new_link(key)); }
true
b898b7dba762ecd2e1298b978d04642299ea6b97
Rust
GreenPix/flat-tree
/src/buffer.rs
UTF-8
6,219
3.34375
3
[]
no_license
use std::ops::Deref; use std::ops::DerefMut; use std::mem; use std::marker::PhantomData; use std::ptr; // Next sibling meaning: // * -1 : No sibling, but some children // * 0 : No sibling and no children // * 1 : siblings, but no children // * > 1 : siblings and children #[derive(Debug)] pub struct TreeNode<T> {...
true
989216d065cd69b9d80b45d8aa9ad4d73d65dbfc
Rust
JustinUnger/rust
/joiner/increment.rs
UTF-8
333
3.15625
3
[]
no_license
fn main() { let p = vec![1,2,3]; let q = increment(p); println!("{:?}", q); let mut p = vec![1,2,3]; incrementMut(&mut p); println!("{:?}", p); } fn increment(v: Vec<isize>) -> Vec<isize> { let mut nv = vec![]; for x in v { nv.push(x+1); } nv } fn incrementMut(v: &mut Vec<isize>) { for x in v { *x = *...
true
93d6873c8f25cb150273791176f73501c25df65d
Rust
JamesMcGuigan/ecosystem-research
/rust/rust-crash-course/src/lifetimes.rs
UTF-8
1,172
3.609375
4
[ "MIT" ]
permissive
// YouTube - Rust Lifetimes: https://www.youtube.com/watch?v=1QoT9fmPYr8&ab_channel=DougMilford #[allow(unused_assignments, unused_mut)] pub fn run() { //// Scope let mut a1 = 1; let mut a2 = &1; { let b = 2; a1 = b; // This is valid because ownership transfers to a, thus deleting b ...
true
c5cc78525a4a5b12d11838e3de47e7997adc4a2a
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0825.friends-of-appropriate-ages/friends-of-appropriate-ages.go
UTF-8
826
3.265625
3
[ "MIT" ]
permissive
package problem0825 func numFriendRequests(ages []int) int { count := [121]int{} for i := range ages { count[ages[i]]++ } sums := [121]int{} sum := 0 res := 0 for a := range count { sum += count[a] sums[a] = sum if a <= 14 || count[a] == 0 { // 此时 a/2+7 >= a continue } b := a/2 + 7 res +...
true
a96b8ee4a0afe2e053a2a69958a35d6cc68a09dc
Rust
spaarmann/cluster-editing
/src/critical_cliques.rs
UTF-8
19,527
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ graph::{GraphWeight, IndexMap}, Graph, Weight, }; #[derive(Debug, Clone, Default)] pub struct CritClique { pub vertices: Vec<usize>, } pub struct CritCliqueGraph { pub cliques: Vec<CritClique>, pub graph: Graph<Weight>, } impl CritCliqueGraph { pub fn to_petgraph(&self) -> petgra...
true
bb45b7af748dede2ac3d32e7eea655f6b0b402c0
Rust
arizuk/programming-contest-solutions
/atcoder/ABC070/D/main.rs
UTF-8
3,061
2.796875
3
[]
no_license
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read...
true
555dc85a1a133a643097a69c715043f48182906d
Rust
nerosnm/punch-clock
/src/main.rs
UTF-8
8,809
2.578125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
mod opt; use chrono::{prelude::*, Duration}; use directories::ProjectDirs; use opt::Opt; use punch_clock::{ sheet::{SheetError, SheetStatus}, Period, Sheet, }; use structopt::StructOpt; const SAME_DAY_FORMAT: &str = "%H:%M:%S"; const DIFF_DAY_FORMAT: &str = "%H:%M:%S on %e %b"; fn main() { let opt = Opt:...
true
e340e382b9950b8c40ee2ab4977fec139d653b41
Rust
mankyKitty/arcade-rs
/src/views/main_menu.rs
UTF-8
4,998
2.625
3
[]
no_license
use ::phi::{Phi, View, ViewAction}; use ::phi::data::Rectangle; use ::phi::gfx::{Sprite, CopySprite}; use ::views::shared::Background; use ::sdl2::pixels::Color; pub struct MainMenuView { actions: Vec<Action>, selected: i8, //? Use an i8 (0..) so we don't decrement below 0 elapsed: f64, bg_back: Background, b...
true
95c6c98cbe5f4bc3f84be2a871fc3707e59f3f6e
Rust
danielpclark/rutie
/examples/rutie_rust_example/src/main.rs
UTF-8
576
3.25
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate rutie; use rutie::{Object, RString, VM}; fn try_it(s: &str) -> String { let a = RString::new_utf8(s); // Send returns an AnyObject type let b = unsafe { a.send("reverse", &[]) }; // We must try to convert the AnyObject // type back to our usable type. match b.try_convert_to::<RS...
true
1ea94b1a9f623a6c64f817dc5dc937213294f6f4
Rust
mesalock-linux/crates-sgx
/vendor/iovec/src/unix.rs
UTF-8
1,605
3.4375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! IoVec extensions for Unix platforms. //! //! These functions provide conversions to unix specific representations of the //! vectored data. //! //! # Examples //! //! ``` //! use iovec::IoVec; //! use iovec::unix; //! //! let a = b"hello".to_vec(); //! let b = b"world".to_vec(); //! //! let bufs: &[&IoVec] = &[(&a[...
true
3ca2e13134a0cf382b71b208b405708f9c60a63b
Rust
abusch/flexi_logger
/src/flexi_error.rs
UTF-8
1,668
3.109375
3
[]
no_license
use log; use std::fmt; use std::io; use std::error::Error; /// Describes errors in the initialization of `flexi_logger`. #[derive(Debug)] pub enum FlexiLoggerError { /// Log file cannot be written because the specified path is not a directory. BadDirectory, /// Log cannot be written because the configured...
true
0c860f737783e2a8f9122f6d9cbf0b08e974f8c0
Rust
mikeyhew/chalk
/src/macros.rs
UTF-8
1,289
2.734375
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
use std::cell::Cell; lazy_static! { pub static ref DEBUG_ENABLED: bool = { use std::env; env::var("CHALK_DEBUG").is_ok() }; } thread_local! { pub static INDENT: Cell<usize> = Cell::new(0); } macro_rules! debug { ($($t:tt)*) => { if *::macros::DEBUG_ENABLED { ::macr...
true
2033edf6312554597614a47ceaf98b59729f6cf3
Rust
goodhel/rust-actix
/src/client/client.rs
UTF-8
1,994
2.921875
3
[]
no_license
use actix_web::{web, HttpResponse, Error}; use serde::{Serialize, Deserialize}; use lettre::transport::smtp::{authentication::Credentials}; use lettre::{Message, SmtpTransport, Transport}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Email { nama: String, message: String, email: String, n...
true
3c455bb0d87df418b9c8e5e1099dfbdfcf7f5a8f
Rust
RazrFalcon/tiny-skia
/path/src/floating_point.rs
UTF-8
4,295
3.046875
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2006 The Android Open Source Project // Copyright 2020 Yevhenii Reizner // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use crate::scalar::Scalar; pub use strict_num::{FiniteF32, NonZeroPositiveF32, NormalizedF32}; #[cfg(all(not(feature = "std")...
true
7cdaef7ff61fdbba243fe589186f7dfee3ab6ccf
Rust
ootsby-forks/learning_game_design_patterns
/playgrounds/object_pool/object_pool_rust/src/lib.rs
UTF-8
1,360
2.75
3
[]
no_license
mod particle; mod particle_pool; use ggez::event::EventHandler; use ggez::graphics::{Color, BLACK}; use ggez::nalgebra::Point2; use ggez::{graphics, Context, GameResult}; use particle::Particle; use particle_pool::ParticlePool; use rand::prelude::*; pub struct GameState { particle_pool: ParticlePool, center_o...
true
3cbafd04ec7dc699b7926f8788ce229ff3d2f645
Rust
kurodenjiro/tinychain
/host/src/object/instance.rs
UTF-8
4,675
2.890625
3
[ "Apache-2.0" ]
permissive
//! User-defined instance implementation. use std::convert::{TryFrom, TryInto}; use std::fmt; use std::ops::Deref; use async_trait::async_trait; use destream::{en, EncodeMap}; use log::debug; use safecast::TryCastFrom; use tc_error::*; use tc_transact::IntoView; use tc_value::Value; use tcgeneric::Map; use crate::f...
true
dca3429f0ae6799a05a12245658afe8f05c0402e
Rust
SrimantaBarua/bed_old
/src/types/color.rs
UTF-8
1,279
3.296875
3
[]
no_license
// (C) 2020 Srimanta Barua <srimanta.barua1@gmail.com> #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub(crate) struct Color { pub(crate) r: u8, pub(crate) g: u8, pub(crate) b: u8, pub(crate) a: u8, } impl Color { pub(crate) const fn new(r: u8, g: u8, b: u8, a: u8) -> Color { Color { ...
true
91df7d7d777bd9bd6c689e7ae1e72465b169c76b
Rust
cppcoffee/klib
/src/main.rs
UTF-8
1,942
2.921875
3
[]
no_license
use std::collections::HashMap; use std::fs::OpenOptions; use std::io::Write; use std::path::PathBuf; use structopt::StructOpt; use klib::errors::Result; use klib::github::sync_repo; use klib::notes::parse_kindle_notes; /// default input path. const KIND_PATH: &str = "/Volumes/Kindle/documents/My Clippings.txt"; #[d...
true
a657de10972757ab666b6d58001d44492a5bf2bf
Rust
songlinshu/winsafe
/src/gui/native_controls/list_view_items.rs
UTF-8
11,574
3.03125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::cell::Cell; use std::ptr::NonNull; use crate::aliases::WinResult; use crate::co; use crate::handles::HWND; use crate::msg::lvm; use crate::structs::{LVFINDINFO, LVHITTESTINFO, LVITEM, RECT}; use crate::various::WString; /// Exposes item methods of a [`ListView`](crate::gui::ListView) control. /// ...
true
a7da74bfed5574e2afd506bd0e977916bf5847da
Rust
gridbugs/apocalypse-post
/src/colour/rgb24.rs
UTF-8
686
3.296875
3
[ "MIT" ]
permissive
#[derive(Clone, Copy, Debug)] pub struct Rgb24 { pub red: u8, pub green: u8, pub blue: u8, } impl Rgb24 { pub fn new(red: u8, green: u8, blue: u8) -> Self { Rgb24 { red: red, green: green, blue: blue, } } pub fn red(self) -> u8 { self...
true
b353018bc1d34fd9e29355be4254cd396d0c7bb9
Rust
alexbergeron/aoc-2018
/day04-1/src/main.rs
UTF-8
2,562
3.15625
3
[]
no_license
extern crate regex; use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; use regex::Regex; fn main() { let args: Vec<String> = env::args().collect(); let filename = &args[1]; let answer = get_answer(filename); println!("{}", answer); } fn get_answer(filename: &s...
true
93691e8f7b4b96e3affb6442d6931e5354105caa
Rust
dpchamps/advent-of-code-2019
/src/bin/day-9.rs
UTF-8
1,116
3.265625
3
[]
no_license
use adventofcode::int_code_computer::IntCodeMachine; fn part_one() -> Vec<i64>{ let program = IntCodeMachine::read_file_into_program("day-9-part-1-input"); let input = vec![1]; let mut machine = IntCodeMachine::new(&program, Some(&input)); machine.run(); machine.output.clone() } fn part_two() ->...
true
79f2055661298c267f928c995299ad1781676717
Rust
ruizmarlon/habitat
/components/pkg-export-helm/src/chartfile.rs
UTF-8
3,583
2.609375
3
[ "Apache-2.0" ]
permissive
use clap; use failure::SyncFailure; use handlebars::Handlebars; use serde_json; use crate::{export_docker::Result, hcore::package::PackageIdent}; use crate::maintainer::Maintainer; pub const DEFAULT_VERSION: &str = "0.0.1"; // Helm chart file template const CHARTFILE: &str = include_str!("../defaults/He...
true
aae02d339da8a02e94b629a61cb010da0ba99570
Rust
fsabado/feeless
/src/units/rai.rs
UTF-8
9,127
3.234375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use super::{MicroNano, Nano}; use crate::units::{Cents, UnboundedRai}; use crate::{expect_len, to_hex}; use anyhow::Context; use bigdecimal::BigDecimal; use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use std::cmp::Ordering; use std::convert::TryFrom; use std::fmt::Display; use std::str::FromStr; //...
true
a3c317984836d4e94efb3344cd53f8d67a0a36bb
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/structs-enums/rec-tup.rs
UTF-8
759
2.921875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![allow(non_camel_case_types)] #[derive(Copy, Clone)] struct Point {x: isize, y: isize} type rect = (Point, Point); fn fst(r: rect) -> Point { let (fst, _) = r; return fst; } fn snd(r: rect) -> Point { let (_, snd) = r; return snd; } fn f(r: rect, x1: isize, y1: isize, x2: isize, y2: isize) { asse...
true
eb84d70825a1924909bcb61e2d08d34357320d41
Rust
jdeeny/oxigen
/oxigen/src/selection.rs
UTF-8
6,083
3.359375
3
[ "MIT", "Apache-2.0" ]
permissive
//! This module contains the Selection trait and the provided selection functions. use rand::distributions::{Standard, Uniform}; use rand::prelude::*; use rayon::prelude::*; use std::ops::Range; use std::sync::mpsc::channel; use SelectionFunctions::*; /// This trait defines the select function used to select individu...
true
e90b28957c07d44ad6e31b888efdb8dccf71c8e8
Rust
gushernobindsme/rust-typical90
/q-004/tests/sample_inputs.rs
UTF-8
2,420
2.515625
3
[]
no_license
use cli_test_dir::*; const BIN: &'static str = "./main"; #[test] fn sample1() { let testdir = TestDir::new(BIN, ""); let output = testdir .cmd() .output_with_stdin( r#"3 3 1 1 1 1 1 1 1 1 1 "#, ) .tee_output() .expect_success(); assert_eq!( outpu...
true
f73b547adbf3e812d285f57c36b9ab70a24aea99
Rust
arturkow2000/pxeserver
/src/dhcp/packet/options.rs
UTF-8
4,488
2.6875
3
[]
no_license
use std::convert::{TryFrom, TryInto}; use std::fmt; use std::io::{self, Write}; use std::net::Ipv4Addr; use byteorder::{NetworkEndian, WriteBytesExt}; use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error("invalid message type len={len} type={type_raw:?}")] InvalidMessageType { len: u8, type_...
true
3fd187e8f6925026269b8ac5fcff1817d6acda7c
Rust
wmmxk/OOP_Rust
/pointer/pass_box/main.rs
UTF-8
345
3.296875
3
[]
no_license
//source: https://stackoverflow.com/questions/27305585/difference-between-pass-by-reference-and-by-box fn f1(x: &mut i32) { *x =5; } fn f2(mut x: Box<i32>) { *x =5; } fn main() { let mut s_a = 3; let mut h_a = Box::new(4); f1(&mut s_a); println!("{}", s_a); f1(&mut s_a); f2(h_a); // ...
true
7ef106a7a72a7df8caefdd7168e5b694fd6220aa
Rust
kiedtl/th
/mg/src/cellular.rs
UTF-8
4,264
2.90625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::vec::Vec; use serde::Deserialize; use rand::prelude::*; use lib::dun_s1::*; #[derive(Copy, Clone, Debug, Deserialize)] pub enum JobType { RandomFill, Generation(bool), // allow_islands FloorBar(usize), // height } #[derive(Clone, Debug, Deserialize)] pub struct CellularAutomataOptions { o...
true
3e145a22b707203ffcaa5230ad2f31eae9a37045
Rust
edsky/muhe
/src/heap.rs
UTF-8
2,958
3.25
3
[ "Unlicense" ]
permissive
use std::cell::{Cell, RefCell}; use crate::utils::align; use std::collections::HashMap; /* * 实现自定义 简单堆管理/ TODO: 使用 mimalloc */ pub struct Heap { start_address: u32, end_address: u32, current_alloc: Cell<u32>, current_use: Cell<u32>, chunks: RefCell<HashMap<u32, (u32, bool)>>, // 地址 <-> (大小, 使用...
true
f33c8d46741c525339d493993d2205622523ca45
Rust
fndrd1d1/enforcer
/src/clean.rs
UTF-8
5,602
3.234375
3
[ "MIT" ]
permissive
use std::str::Chars; #[derive(Clone, PartialEq)] pub enum TabStrategy { Untabify, Tabify, } fn to_spaces(line: Chars, width: u8) -> String { let mut result: Vec<char> = Vec::new(); let mut column: u8 = 0; for c in line { match c { '\t' => { let spaces = width - ...
true
b72a49d38ee7deb84a2cd53fa00fcb11f04bdfd2
Rust
lzw5399/rust-rookie
/b_data-structure/src/main.rs
UTF-8
493
3.328125
3
[]
no_license
fn main() { const TEST_CONST: u32 = 2; println!("const is {}", TEST_CONST); // float let b = 666.555; // bool let bol = true; // char let cha = 'a'; // string let str = String::new(); // tuple let tup: (i32, &str, bool) = (233, "emm", true); let (a, b, c) = tup; ...
true
77f327c17d02ea6fd12704f2750ed2161aaebae9
Rust
IThawk/rust-project
/rust-master/src/test/ui/borrowck/borrowck-ref-mut-of-imm.rs
UTF-8
193
2.78125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn destructure(x: Option<isize>) -> isize { match x { None => 0, Some(ref mut v) => *v //~ ERROR cannot borrow } } fn main() { assert_eq!(destructure(Some(22)), 22); }
true
d08b29155937a0b42976d1beed0a81b12eeb0f67
Rust
eropsyren/lc3_core
/src/instr/ops/trap/traps/halt/mod.rs
UTF-8
365
3.046875
3
[ "MIT" ]
permissive
use crate::controller::Controller; pub fn halt(controller: &mut Controller) { controller.stop(); } #[cfg(test)] mod tests { use super::halt; use crate::controller::Controller; #[test] fn test_halt() { let mut controller = Controller::new(); halt(&mut controller); assert_...
true
ef0aeb48ca66373f75b338ed72df48471d8b49ca
Rust
jstuczyn/AoC19
/day5/src/main.rs
UTF-8
15,407
3.15625
3
[ "Apache-2.0" ]
permissive
mod utils; use std::convert::TryFrom; use std::fs; const ADD_OP_CODE: isize = 1; const MUL_OP_CODE: isize = 2; const INPUT_OP_CODE: isize = 3; const OUTPUT_OP_CODE: isize = 4; const JMP_TRUE_OP_CODE: isize = 5; const JMP_FALSE_OP_CODE: isize = 6; const LESS_THAN_OP_CODE: isize = 7; const EQUALS_OP_CODE: isize = 8; co...
true
a27c9a7d989d03731b7ba27e77af010b1f81c5d4
Rust
polyhorn/polyhorn
/crates/polyhorn-android-sys/src/bitmap.rs
UTF-8
846
2.65625
3
[ "MIT" ]
permissive
use jni::objects::JValue; use super::{Env, Object, Reference}; pub struct Bitmap { reference: Reference, } impl Bitmap { pub fn width(&self, env: &Env) -> i32 { unsafe { match env.call_method(self.reference.as_object(), "getWidth", "()I", &[]) { JValue::Int(value) => value...
true
db909509218b3ea0953d2bbb5386c008ced24ed7
Rust
TomasArrachea/ejercicios-rust
/guia 2/diff/src/main.rs
UTF-8
1,655
3.453125
3
[]
no_license
use std::cmp::max; use std::fs::File; use std::io::{BufRead, BufReader}; fn main() { let lineas_1 = read_file_lines("1.txt"); let lineas_2 = read_file_lines("2.txt"); let grilla = lcs(&lineas_1, &lineas_2); print_diff(&grilla, lineas_1.len(), lineas_2.len(), &lineas_1, &lineas_2); } fn read_file_lines(ruta: &str)...
true
b9d2198574d57ff26bd6ef49286df912e86f0798
Rust
modulitos/aoc2020
/src/exercises/day_07/solution.rs
UTF-8
10,543
3.09375
3
[ "MIT" ]
permissive
use std::io::{BufRead, BufReader, Read}; use crate::convert_path_buf; use crate::{Error, Result}; use regex::Regex; use std::boxed::Box; use std::path::PathBuf; use crate::vec_ext::VecExt; use std::collections::{HashMap, HashSet}; use std::convert::TryFrom; use std::iter::FromIterator; use std::ops::Deref; use std::s...
true
7a68db9e12ea8138d4d5eaf90e40811acf44afed
Rust
gnoliyil/fuchsia
/src/storage/stress-tests/fvm/volume_actor.rs
UTF-8
9,481
2.640625
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2021 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { crate::volume::VolumeConnection, crate::vslice::{VSliceRange, VSliceRanges}, async_trait::async_trait, fuchsia_zircon::Status, ra...
true
3f0ca8295aadd13758748592b23c1e3621cfc709
Rust
cgaebel/mio
/src/server.rs
UTF-8
10,885
2.828125
3
[]
no_license
//! A generic MIO server. use error::{MioResult, MioError}; use handler::Handler; use io::{Ready, IoHandle, IoReader, IoWriter, IoAcceptor}; use iobuf::{Iobuf, RWIobuf}; use reactor::Reactor; use socket::{TcpSocket, TcpAcceptor, SockAddr}; use std::cell::RefCell; use std::collections::{Deque, RingBuf}; use std::rc::Rc;...
true
2831631e2d4ae53afa4e14b4b9c3e67db55791e1
Rust
Metadiff/gir
/gir_core/src/ops/nonl.rs
UTF-8
1,316
2.515625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use ops::interface::*; use primitives::*; use graph::*; use errors::*; use api::ids; #[derive(Debug, Clone)] pub struct Tanh {} impl Operator for Tanh { #[allow(unused_variables, unused_mut)] fn reverse_diff(&self, g: &mut Graph, x: usize, dx: usize, flow_tree: &Vec<bool>) -> Result<Vec<(...
true
9c75faf876913fe435c496327072b8cf611da680
Rust
not-fl3/macroquad
/examples/basic_shapes.rs
UTF-8
441
2.546875
3
[ "Apache-2.0", "MIT" ]
permissive
use macroquad::prelude::*; #[macroquad::main("BasicShapes")] async fn main() { loop { clear_background(LIGHTGRAY); draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE); draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN); draw_circle(screen_width() - 30.0, screen_heig...
true
79a49651a905eb85c62d2a5eccbce67570fd7e31
Rust
shikharvashistha/oak
/experimental/oak_async/src/io.rs
UTF-8
5,545
2.65625
3
[ "Apache-2.0" ]
permissive
// // Copyright 2020 The Project Oak Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law o...
true
805b8d8e9530d281d42cded92b6d1fdbbb30d87a
Rust
RystaC/browseRT
/raytrace/vector/src/lib.rs
UTF-8
2,770
3.515625
4
[]
no_license
use std::ops; #[derive(Clone, Copy, Debug, PartialEq)] pub struct Vector { x: f64, y: f64, z: f64, } impl Vector { // constructors pub fn new() -> Self { Self { x: 0.0, y: 0.0, z: 0.0 } } pub fn from_val(x: f64, y: f64, z: f64) -> Self { Self { x, y, z } } pub fn ...
true
523be81236bfbde8cbe7b8c8812dc9c23d74b218
Rust
garentyler/rust-experiments
/networking/server_and_client/server.rs
UTF-8
2,178
3.0625
3
[ "MIT" ]
permissive
use std::net::TcpStream; use std::net::TcpListener; fn main() { let listener = TcpListener::bind("127.0.0.1:25565").unwrap(); for stream in listener.incoming() { let mut stream = stream.unwrap(); handle_stream(stream); } } fn handle_stream(mut stream: TcpStream) { read_packet(&stream); }...
true
a8860a9cce701a4ea521b65f37debd1761a7ce50
Rust
automanyang/servant-macro
/tests/03_notify.rs
UTF-8
1,969
2.921875
3
[ "MIT" ]
permissive
// -- hello.rs -- #[macro_use] mod utilities; // -- // these code are been tested. #[servant::notify_interface] pub trait Bar { fn f1(&self, count: i32); fn f2(&self, msg: String); fn f3(&mut self, count: usize, f: f64, b: Option<bool>, s: Vec<String>); } // -- struct BarEntity; impl BarEntity { co...
true
ae7e22aef890fdafc4c1e25946a0ec1897101975
Rust
Nimaoth/EPLScript
/src/value.rs
UTF-8
980
3.328125
3
[ "MIT" ]
permissive
#![allow(non_snake_case)] #![allow(dead_code)] #![allow(unused_macros)] use std::ops; #[derive(Debug)] pub enum Value { None, Int(i64), Float(f64), Char(char), String(String) } macro_rules! arif { ($lhs:expr, $rhs:expr, $op:tt) => { match ($lhs, $rhs) { (Int(a), Int(b)) =>...
true
33999a585205c69f54991d7e7ef1be46dd3f35d6
Rust
Ru5ty0ne/jsonschema-rs
/jsonschema/src/keywords/any_of.rs
UTF-8
2,912
2.828125
3
[ "MIT" ]
permissive
use crate::{ compilation::{compile_validators, context::CompilationContext, JSONSchema}, error::{error, no_error, ErrorIterator, ValidationError}, paths::InstancePath, validator::{format_vec_of_validators, Validate, Validators}, }; use serde_json::{Map, Value}; use super::CompilationResult; use crate::...
true
044da1a09febe41784e2cf75b4c09cb21e03ed34
Rust
aethertap/audio
/audio/src/tests/io.rs
UTF-8
1,670
2.90625
3
[ "MIT", "Apache-2.0" ]
permissive
#[test] fn test_read_write() { use crate::io::{Read, ReadWrite, Write}; use crate::{Buf as _, ReadBuf as _, WriteBuf as _}; let from = crate::interleaved![[1.0f32, 2.0f32, 3.0f32, 4.0f32]; 2]; let to = crate::interleaved![[0.0f32; 4]; 2]; // Make `to` into a ReadWrite adapter. let mut to = Rea...
true
72945d846cd4e1eede28fee9f1d4020c9a36be6f
Rust
artichoke/rand_mt
/tests/ruby_reproducibility.rs
UTF-8
2,882
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
// tests/ruby_reproducibility.rs // // Copyright (c) 2015,2017 rust-mersenne-twister developers // Copyright (c) 2020 Ryan Lopopolo <rjl@hyperbo.la> // // 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://opensou...
true
8fa8e3954c513c926e9d9c98150bac145b24e2f5
Rust
sile/libflate
/src/huffman.rs
UTF-8
11,154
2.984375
3
[ "MIT" ]
permissive
//! Length-limited Huffman Codes. use crate::bit; use alloc::{vec, vec::Vec}; use core::cmp; use core2::io; const MAX_BITWIDTH: u8 = 15; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Code { pub width: u8, pub bits: u16, } impl Code { pub fn new(width: u8, bits: u16) -> Self { debug_assert!(wid...
true
e782fd9d7c1911772d4a2acda4447ab66b29cef8
Rust
erikjohnston/casniam
/src/stores/mod.rs
UTF-8
8,180
2.734375
3
[]
no_license
use std::collections::BTreeSet; use std::mem::swap; use std::{fmt::Debug, sync::Arc}; use async_trait::async_trait; use failure::Error; use futures::FutureExt; use crate::protocol::{Event, RoomState, RoomVersion}; pub mod backed; pub mod memory; pub mod postgres; // Ideally this trait would have lots of generic par...
true
798cbb91156da78dbc5e7a2133c28e64c78844e8
Rust
clap-rs/clap
/tests/builder/app_settings.rs
UTF-8
34,599
2.8125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::ffi::OsString; use super::utils; use clap::{arg, error::ErrorKind, Arg, ArgAction, Command}; static ALLOW_EXT_SC: &str = "\ Usage: clap-test [COMMAND] Options: -h, --help Print help -V, --version Print version "; static DONT_COLLAPSE_ARGS: &str = "\ Usage: clap-test [arg1] [arg2] [arg3] Argument...
true
f8beb5ddb6130e976267a8023a2458a4bbdd0efb
Rust
ReeceStevens/wfdb-rust
/tests/mit_dataset_test.rs
UTF-8
1,155
2.71875
3
[]
no_license
/// Tests using the MIT ECG database samples. /// /// Note: in order to run these integration tests, the datasets referenced here must be downloaded /// and put in the data directory. The datasets used for testing here were downloaded from /// PhysioNet and can be found at https://physionet.org/content/mitdb/1.0.0/. ex...
true
1d4d6542a1f5d5477308db713740aa0df469bd3e
Rust
cLazyZombie/advent-of-code-2020
/day5/src/main.rs
UTF-8
1,365
3.640625
4
[]
no_license
fn main() { let input = include_str!("input.txt"); let mut highest = -1; let mut seats = Vec::new(); for line in input.lines() { let line = line.trim(); if line.len() != 10 { continue; } let seat_number = get_seat_number(line); if seat_number > hig...
true
54f5ccc23a7ebe71dc107ec326f4327bb393a096
Rust
critiqjo/apac-utils
/gym-sprouts/src/main.rs
UTF-8
1,261
3.265625
3
[]
no_license
use std::io::{self, BufRead}; fn mod_exp(n: u64, mut p: u64, k: u64) -> u64 { // n^p mod k if p == 0 { return 1; } let mut powers: Vec<u64> = vec![]; let mut t = n % k; while p > 0 { if p % 2 == 1 { powers.push(t); } t = (t * t) % k; p /= 2; } let mut...
true
bac209d3d6f9a044d5500688a5691b4dda59337f
Rust
BigAngryDinosaur/rs-classical
/src/fib.rs
UTF-8
352
3.40625
3
[]
no_license
pub fn fib(n: u32) -> u32 { match n { n if n < 2 => n, _ => fib(n - 1) + fib(n - 2) } } pub fn fib_iter(n: u32) -> u32 { let mut pair = (0, 1); match n { 0 | 1 => n, _ => { for _ in 2..=n { pair = (pair.1, pair.0 + pair.1) } ...
true
7b32588302d342a2087963bf82135206533a5da8
Rust
Happy-Ferret/lark
/components/parser/src/lexer_helpers.rs
UTF-8
17,263
2.984375
3
[]
no_license
#![allow(unused_variables)] use crate::ast::{DebugModuleTable, Debuggable}; use crate::pos::{Span, Spanned}; use crate::program::{ModuleTable, StringId}; use codespan::ByteIndex; use derive_new::new; use log::{debug, trace, warn}; use std::fmt::{self, Debug}; use std::marker::PhantomData; /// This enum describes whi...
true
68ac9faa83ceff05d5911288aea13991da8ba40c
Rust
EthanYidongArchives/flite
/src/lib.rs
UTF-8
2,765
2.640625
3
[ "MIT" ]
permissive
pub mod ffi; pub mod error; use const_cstr::const_cstr; use std::ptr; use std::ffi::CString; use std::sync::Once; use error::FliteError; pub type FliteResult<T> = Result<T, FliteError>; macro_rules! drop_impl { ($st:ty) => { impl Drop for $st { fn drop(&mut self) { unsafe { ...
true
34cd7cb32bf63177bb56ca601f11de36df8e10ce
Rust
actix/actix-web
/actix-web/src/http/header/content_language.rs
UTF-8
1,726
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
use language_tags::LanguageTag; use super::{common_header, QualityItem, CONTENT_LANGUAGE}; common_header! { /// `Content-Language` header, defined /// in [RFC 7231 §3.1.3.2](https://datatracker.ietf.org/doc/html/rfc7231#section-3.1.3.2) /// /// The `Content-Language` header field describes the natural...
true
4042fe2f47826f0e8a09c0db13eefc5c6a696044
Rust
pamsilva/rusty-hangman
/src/input.rs
UTF-8
479
3.453125
3
[]
no_license
use std::io; pub fn take_user_guess() -> String { println!("Take your guess:"); loop { let mut guess = String::new(); io::stdin().read_line(&mut guess) .expect("Failed to get input!"); match guess.trim().parse() { Ok(val) => { return val; ...
true
4c9869b3f9b361c3de0dddfea55f56faba901bd7
Rust
rossnomann/telefeed
/src/app.rs
UTF-8
2,067
2.765625
3
[ "MIT" ]
permissive
use crate::{ cache::Cache, config::{Config, ConfigError}, reader::Reader, }; use dotenv::dotenv; use redis::{Client as RedisClient, RedisError}; use reqwest::Client as HttpClient; use std::{env, fmt}; use tgbot::{Api, ApiError}; use tokio::sync::mpsc::channel; const CHANNEL_BUFFER_SIZE: usize = 100; pub a...
true
a64738d3a538ebe64744a9703a478777bf322b98
Rust
frewsxcv/cryptopals-crypto-challenges-rust
/set-1/challenge-5/src/main.rs
UTF-8
669
2.5625
3
[ "CC0-1.0" ]
permissive
extern crate data_encoding; extern crate utils; use data_encoding::HEXUPPER; use utils::BytesExt; const INPUT: &[u8] = b"Burning 'em, if you ain't quick and nimble\n\ I go crazy when I hear a cymbal"; const XOR_KEY: [u8; 3] = [b'I', b'C', b'E']; const EXPECTED_HEX: &[u8] = b"0B3637272A2B2E63622C2E69692A2369...
true
eb98b57eb8d83c6d4956803c0eb3da4304e02ddf
Rust
ikysil/rust99
/working-with-vectors/P20/src/lib.rs
UTF-8
352
3.359375
3
[]
no_license
pub fn remove_at<T: Copy>(k: usize, li: &Vec<T>) -> (Vec<T>, T) { let mut li_copy = li.clone(); let x = li_copy.remove(k); (li_copy, x) } #[cfg(test)] mod tests { use super::*; #[test] fn test_remove_at_1() { let li = vec!['a', 'b', 'c', 'd']; assert_eq!(remove_at(1, &li), (vec!...
true
70d4c14ebe17e4aa0667773285a69a1daa782074
Rust
copterust/alt-stm32f30x-hal
/src/dma.rs
UTF-8
12,287
2.671875
3
[ "Apache-2.0", "MIT" ]
permissive
//! General Purpose DMA #![allow(dead_code)] use core::marker::PhantomData; use core::ops; use crate::rcc::AHB; #[derive(Debug)] /// Error pub enum Error { /// Overrun Overrun, #[doc(hidden)] _Extensible, } /// Event pub enum Event { /// HalfTransfer HalfTransfer, /// TransferComplete ...
true
b984ff5a4ad88df6a3808b5ab05dab731c0b45f8
Rust
t3nsed/oboe
/src/main.rs
UTF-8
5,155
2.65625
3
[ "MIT" ]
permissive
#![feature(proc_macro_hygiene, decl_macro)] #![feature(register_attr)] #![feature(plugin)] #[macro_use] extern crate rocket; #[macro_use] extern crate lazy_static; extern crate serde_json; extern crate serde; extern crate rocket_multipart_form_data; extern crate regex; // defines tools needed to control data inward/ou...
true