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
b6658877ade6e67982468afe23b9de6348f0e784
Rust
marmeladema/tracking-allocator-rs
/src/lib.rs
UTF-8
13,412
2.84375
3
[ "MIT" ]
permissive
use std::alloc::{GlobalAlloc, Layout, System}; use std::cell::Cell; use std::sync::atomic::{AtomicUsize, Ordering}; mod private { pub trait Sealed {} impl Sealed for u8 {} impl Sealed for u16 {} } thread_local! { static CURRENT_TAG_U8: Cell<u8> = Cell::new(u8::default()); static CURRENT_TAG_U16: ...
true
d12b4b2ad1a1f7053839b52fa9789ea321105bd6
Rust
Rust-SDL2/rust-sdl2
/src/sdl2/filesystem.rs
UTF-8
2,377
2.84375
3
[ "MIT" ]
permissive
use crate::get_error; use libc::c_char; use libc::c_void; use std::error; use std::ffi::{CStr, CString, NulError}; use std::fmt; use crate::sys; #[doc(alias = "SDL_GetBasePath")] pub fn base_path() -> Result<String, String> { let result = unsafe { let buf = sys::SDL_GetBasePath(); let s = CStr::fr...
true
71b0c6ba59fb2b704ded7bc3ac3eb78c37c07cb5
Rust
zicklag/me-learning-opengl
/src/lib.rs
UTF-8
4,587
2.765625
3
[]
no_license
use surfman::{ Connection, ContextAttributeFlags, ContextAttributes, GLVersion, SurfaceAccess, SurfaceType, }; use winit::{ dpi::PhysicalSize, DeviceEvent, Event, EventsLoop, KeyboardInput, VirtualKeyCode, WindowBuilder, WindowEvent, }; surfman::declare_surfman!(); pub trait RenderHandler { fn init(gl...
true
8b35b3ff28695f19e3fecb030632c6f40a4a94f3
Rust
mre/slack
/src/search/messages.rs
UTF-8
3,693
3.421875
3
[]
no_license
//! # search_messages //! //! This method returns messages matching a search query. //! See https://api.slack.com/methods/search.messages //! //! ## Required arguments: //! `query` (String) //! Search query. May contains booleans, etc. //! Example: pickleface //! //! ## Optional arguments: //! //! `highli...
true
768ff697c7fb4f639cc119c15484df31e904ff57
Rust
Aaqib-kk/discovery
/src/05-led-roulette/src/main.rs
UTF-8
3,744
2.578125
3
[ "Apache-2.0", "MIT", "CC-BY-4.0" ]
permissive
// #![deny(unsafe_code)] // #![no_main] // #![no_std] // use aux5::{entry, prelude::*, Delay, Leds}; // #[entry] // fn main() -> ! { // let (mut delay, mut leds): (Delay, Leds) = aux5::init(); // let ms = 50_u8; // loop { // for curr in 0..8 { // let next = (curr + 1) % 8; // ...
true
1e14b658ad18ab4958508a6f2e7a1ab5985a410e
Rust
adam-bates/rust_game_proto
/src/game/ecs/components/timer.rs
UTF-8
2,936
3.609375
4
[]
no_license
use specs::{Component, VecStorage}; use specs_derive::Component; // Thanks Bevy for this timer implementation #[derive(Default, Component, Debug)] #[storage(VecStorage)] pub struct Timer { pub duration: f32, pub repeating: bool, pub elapsed: f32, pub finished: bool, pub should_tick: bool, } impl ...
true
1cc98f2a58db1360fbab0faa87f1f355e3fad27c
Rust
niax/aoc-2020
/day-19/src/main.rs
UTF-8
1,330
2.6875
3
[ "Apache-2.0" ]
permissive
use commons::io::load_file_lines; use day_19::{grammar, types::MatchType}; use std::collections::HashMap; fn main() { let parser = grammar::RuleParser::new(); let input_lines = load_file_lines::<String>("input.txt").map(|res| res.unwrap()); let mut ruleset: HashMap<u32, MatchType> = HashMap::new(); let...
true
3c8bb7dfcd0325668abd74d46c74d317bca3b8cb
Rust
tkyk0317/raspi-rust
/src/shell.rs
UTF-8
850
2.5625
3
[]
no_license
use crate::{ dev::uart::{Uart, UartObserver}, println, }; const BUF_SIZE: usize = 256; pub struct Shell { pub buf: [u8; BUF_SIZE], } // UARTからの割り込み通知trait impl UartObserver for Shell { // 割り込み通知 fn notify(&self, data: u32) { let c = data as u8; if c == 0xD { // 改行処理 ...
true
8e566d33928c2b16be6145f7ff5a4e4e6bc2b66f
Rust
gitter-badger/jolimail
/server/src/model/template_version/update.rs
UTF-8
2,380
2.703125
3
[]
no_license
use super::COLUMNS; use crate::error::ServerError; use crate::model::template_version::TemplateVersion; use deadpool_postgres::Client; use serde::{Deserialize, Serialize}; use serde_json::Value as JsonValue; use tokio_postgres::types::ToSql; use uuid::Uuid; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Te...
true
e42dd99f9bd89bbe6465ea9a91089edf8f304239
Rust
Noxime/scaleway
/src/utils.rs
UTF-8
3,351
2.890625
3
[]
no_license
use crate::{TokenId, Serialize, Deserialize, Client, Method, error::ApiError, Error, header, UserId}; #[derive(Debug)] pub(crate) enum Endpoint { Account(Account), Compute(Region, Compute), } impl From<Account> for Endpoint { fn from(account: Account) -> Endpoint { Endpoint::Account(account) }...
true
1db3e0cb91cd0f40be1c84d6e5544a3f33db28ef
Rust
bumzack/xargo
/src/util.rs
UTF-8
1,827
3.078125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::fs::File; use std::io::{Read, Write}; use std::path::Path; use std::{fs, io}; use toml::{Parser, Value}; use errors::*; pub fn cp_r(src: &Path, dst: &Path) -> Result<()> { (|| -> io::Result<()> { for e in src.read_dir()? { let e = e?; let f = e.file_name(); ...
true
46c8d4c1c4fdc8d5a1450874c1e44cc782555375
Rust
sec-js/tui-rs
/examples/demo/crossterm.rs
UTF-8
2,140
2.6875
3
[ "MIT" ]
permissive
use crate::{app::App, ui}; use crossterm::{ event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyCode}, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; use std::{ error::Error, io, time::{Duration, Instant}, }; use tui::{ bac...
true
a9fbb74485eacd92925d3beee5b1be01a88d28b3
Rust
thegenius/bullet
/src/template_installer.rs
UTF-8
6,058
2.859375
3
[ "Apache-2.0" ]
permissive
use fs::File; use git2::Repository; use std::collections::HashMap; use std::fs; use std::path::Path; use std::path::PathBuf; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct InstalledRecord { name: String, url: String, path: String, } pub fn prepare_dir(dir: &Path) { if dir.exists() { ...
true
5a815e366569f2a9b3e685ba1d87b673e27316be
Rust
ldelriof/rust
/ch8/src/pig_latin.rs
UTF-8
586
3.203125
3
[]
no_license
pub fn phrase(phrase: &mut str) -> String { let vowals = ['a', 'e', 'i', 'o', 'u']; let mut pig_phrase = String::new(); for word in phrase.split_whitespace() { let mut wvec: Vec<char> = word.chars().collect(); let fchar = wvec[0]; wvec.push('-'); if vowals.contains(&fchar) {...
true
0497c2b8f7199e7956241afcf87b3b272e0c0faa
Rust
DamienAI/rust-backend-example
/src/person/service.rs
UTF-8
2,999
2.921875
3
[ "MIT" ]
permissive
use mongodb::{bson, Collection, Database}; use actix_web::{error, web, HttpRequest, HttpResponse, Responder}; use crate::person::model::{EditablePerson, Person}; // For json decoding errors pub fn json_error_handler(err: error::JsonPayloadError, _req: &HttpRequest) -> error::Error { let detail = err.to_string(); ...
true
e4b6cf244c109f2602b5bc87ddf1fe9ed1ed15d9
Rust
EngineersBox/Rust-MQTT
/src/macros.rs
UTF-8
3,225
2.828125
3
[]
no_license
#[macro_export] macro_rules! ternary { ($condition:expr, $v1:expr, $v2:expr) => { if $condition { $v1 } else { $v2 }; }; } #[macro_export] macro_rules! if_let_some { ($var:pat = $value:expr) => { let $var = if let Some(it) = $value { it } else { return; ...
true
4394428a23eecc27c0e4b8cf879488d16069c94a
Rust
FengchenX/orbtk-mirror
/crates/widgets/src/scroll_indicator.rs
UTF-8
4,800
2.6875
3
[ "MIT" ]
permissive
use crate::prelude::*; /// The `ScrollIndicatorState` handles the `ScrollIndicator` widget. #[derive(Default, AsAny)] pub struct ScrollIndicatorState; impl State for ScrollIndicatorState { fn update_post_layout(&mut self, _: &mut Registry, ctx: &mut Context) { let padding = *ctx.widget().get::<Thickness>(...
true
7c651262c3f12c12ea6762735c84080a1b16d6d2
Rust
oeb25/riport
/src/hub.rs
UTF-8
5,055
2.53125
3
[]
no_license
use actix::*; use futures::future::join_all; use futures::prelude::*; use std::collections::HashMap; use std::fs; use std::io; use std::path::PathBuf; use crate::client::{Client, ClientId}; use crate::project::file::FileId; use crate::project::{Project, ProjectId, ProjectInfo}; use crate::project_actor::{GetInfo, Pro...
true
b52e5ef3abedb96d2cbc76d8a909cd9964e0ded1
Rust
TedDriggs/darling
/tests/suggestions.rs
UTF-8
620
2.796875
3
[ "MIT" ]
permissive
#![allow(dead_code)] #![cfg(feature = "suggestions")] use darling::{FromDeriveInput, FromMeta}; use syn::parse_quote; #[derive(Debug, FromDeriveInput)] #[darling(attributes(suggest))] struct Lorem { ipsum: String, dolor: Dolor, } #[derive(Debug, FromMeta)] struct Dolor { sit: bool, } #[test] fn suggest_...
true
b0ddf099447aa69ddff1bc9c1608a9b3c65705ab
Rust
germansmedia/math
/src/multivector.rs
UTF-8
51,499
3.109375
3
[ "MIT" ]
permissive
// (C) Copyright 2020, by Germans Media Technology & Services // Math // 2D, 3D and 4D multivectors use std::{cmp,fmt,ops}; use crate::*; #[derive(Clone)] pub struct MultiVec2<T> { pub r: T, pub x: T, pub y: T, pub xy: T, } macro_rules! impl_multivec2 ( ($t:ty) => ( impl MultiVec2<$t> { ...
true
e638d16b28e77adb19a121a5ed6e26a86a454d16
Rust
fanfeilong/rust-learn
/src/EnumsAndPatternMatching/enums/src/main.rs
UTF-8
2,030
3.6875
4
[]
no_license
fn main() { // basic { let four = IpAddrKind::V4; let six = IpAddrKind::V6; println!("{:?}", four); println!("{:?}", six); } // use { route(IpAddrKind::V4); } // compound { let home = IpAddr { kind: IpAddrKind::V4, ...
true
4593edf9ea682aaad2956e57b7077f4229a89bca
Rust
simonsan/rfc-index
/src/main.rs
UTF-8
21,680
2.78125
3
[ "Apache-2.0" ]
permissive
use crate::{ errors::{Error, Result}, github::{get_merged_rfc_metadata, init_tag_metadata, update_from_pr, UpdateOptions}, metadata::{ all_metadata, all_metadata_numbers, delete_metadata, infer_team_from_tags, metadata_exists, open_metadata, read_tag_metadata, save_metadata, write_tag_metada...
true
7444ce2dd7694e87b1a2e43e0b6765d2c2c62577
Rust
jedisct1/rust-sthash
/src/nhpoly1305/nh/mod.rs
UTF-8
1,868
2.5625
3
[ "BSD-2-Clause" ]
permissive
#[cfg(target_arch = "x86_64")] mod avx2; mod portable; use byteorder::{ByteOrder, LittleEndian}; pub const NH_NUM_PASSES: usize = 4; pub const NH_PAIR_STRIDE: usize = 2; pub const NH_MESSAGE_UNIT: usize = NH_PAIR_STRIDE * 8; // 16 pub const NH_NUM_STRIDES: usize = 64; pub const NH_MESSAGE_DWORDS: usize = NH_PAIR_STRI...
true
cac82faee82b52243a7be3b7ecf0e0a802572747
Rust
antoine-de/rust-geo
/src/algorithm/contains.rs
UTF-8
20,659
3.3125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use num_traits::{Float, ToPrimitive}; use types::{Bbox, Line, LineString, MultiPolygon, Point, Polygon, COORD_PRECISION}; use algorithm::intersects::Intersects; use algorithm::distance::Distance; /// Checks if the geometry A is completely inside the B geometry. pub trait Contains<Rhs = Self> { /// Checks if th...
true
18e1d13fa33fe2b059568e7a059c5f8f6141714d
Rust
ralendor/libra
/network/src/noise/handshake.rs
UTF-8
17,576
2.71875
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 //! The handshake module implements the handshake part of the protocol. //! This module also implements additional anti-DoS mitigation, //! by including a timestamp in each handshake initialization message. //! Refer to the module's do...
true
ac34fcaccff30d3b348779bde98de9bc12333dc7
Rust
mqzry/rust-euler
/src/main.rs
UTF-8
2,749
3.53125
4
[ "Apache-2.0" ]
permissive
use std::time::Instant; fn main() { println!("Results for problem 1."); let (result, time) = time_problem(&problem1a); println!("Result for problem 1a is: {}. \nIt took {} ms.", result, time); let (result, time) = time_problem(&problem1b); println!("Result for problem 1b is: {}. \nIt took {} ms.",...
true
7f38ddd5af453d3b549af8aae67d9c0f78f809f0
Rust
lynn/hexs-cellar
/src/memory.rs
UTF-8
11,281
2.8125
3
[ "MIT" ]
permissive
use std::mem::transmute; use world::World; use geometry::Point; use sprite::Sprite; use util; // In Hex's Cellar, the player's spells manipulate an u8[40] of bytes that // affect the world around her. This file gives a "RAM map" for that array. // Color (3 bits = 8 bright colors) and character (5 bits, offset added t...
true
07f997a1b096f9e6297fd54a48d7aab5c8e27c84
Rust
eira-fransham/rsedis
/storage/src/util.rs
UTF-8
1,079
3.125
3
[ "BSD-2-Clause" ]
permissive
use std::{ fs, io::{self, Write}, }; /// Trait for readers/writers whose length can be set. This is intended for /// file handles and wrappers around file handles. pub trait SetLen { /// Set the length of this file, truncating data if the length is less than /// the current and zero-filling if it is gr...
true
d1febb7c2a8ed65ec280d2dfd2801714f8d214cb
Rust
AntonGepting/tmux-project-cfg-rs
/src/session_cfg_tests.rs
UTF-8
1,047
2.65625
3
[ "MIT" ]
permissive
#[test] fn session_create() { use super::session_cfg::SessionCfg; use super::session_cfg::SessionOptionsCfg; let options = SessionOptionsCfg { detached: Some(true), ..Default::default() }; let session_cfg = SessionCfg::new("test".to_string(), Some(options)); let id = session_cfg...
true
6995ae22fe0b2675bd82eae4b1e0ff6876cd60f0
Rust
viktorchvatal/nanocv
/examples/load_save.rs
UTF-8
556
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use image::{open, GrayImage}; use nanocv::{ImgBuf, ImgSize}; fn main() { // Load image using piston image let buf = open("examples/raster.png").unwrap().into_luma(); // Convert into ImgBuf let size = ImgSize::new(buf.width() as usize, buf.height() as usize); let img = ImgBuf::from_vec(size, buf.int...
true
ac13604c4ddec369261d4075cf0c2d6c5f7b62c6
Rust
vicioux/basset-vault-contracts
/packages/basset_vault/src/nasset_token_rewards.rs
UTF-8
3,275
2.515625
3
[]
no_license
use cosmwasm_std::{Decimal, Uint128}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::common::OrderBy; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct InstantiateMsg { pub psi_token_addr: String, pub nasset_token_addr: String, pub governance_cont...
true
7dcff584e97161be3f2154c547010536ad27dd7e
Rust
ChanTsune/Portable-Network-Archive
/lib/src/archive/entry/name.rs
UTF-8
4,185
3.28125
3
[ "MIT" ]
permissive
use crate::util::try_to_string; use std::error::Error; use std::ffi::OsStr; use std::fmt::{self, Display, Formatter}; use std::path::{Component, Path, PathBuf}; use std::str; /// A UTF-8 encoded entry name. #[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)] pub struct EntryName(String); /// Error of invali...
true
c5a58fe4e680a2a09a9021c95dbcdfffe423c657
Rust
vkill/books-rs
/book/examples/ch13-01-cacher.rs
UTF-8
433
3.203125
3
[]
no_license
//! [Closures]: Anonymous Functions that Can Capture Their Environment //! //! [closures]: https://doc.rust-lang.org/book/ch13-01-closures.html use std::error::Error; use the_book::ch13::sec01::Cacher; fn main() -> Result<(), Box<dyn Error>> { let mut c = Cacher::new(|x| x); for _ in { 1..1_000 } { le...
true
9dfbea3ddb0eaeeed1223d317cd02440ac6606ea
Rust
Wandalen/wMath
/rust/test/math/adapter/impl_interfaces_macro_test.rs
UTF-8
3,610
2.828125
3
[ "MIT" ]
permissive
use test_tools::*; use math_adapter:: { X2, X3, X4, }; use super::*; tests_impls! { fn impls_x2_for_structure() { let x2 = X2( 1, 2 ); assert!( implements!( x2 => X2NominalInterface ) ); assert!( implements!( x2 => X2Interface ) ); assert!( implements!( x2 => X2BasicInterface ) ); assert!...
true
1790a6b5d4ee1a5f782740b1e87b827c40e7bcff
Rust
einzigartigerName/mac_app_bundler
/cli/src/main.rs
UTF-8
2,318
3.078125
3
[ "MIT" ]
permissive
extern crate clap; use app_bundler::*; use app_bundler::ExitCode::*; use clap::{App, Arg}; use std::path::PathBuf; use std::process; use std::str::FromStr; const ARG_BINARY: &str = "binary"; const ARG_ICON: &str = "icon"; const ARG_NAME: &str = "output"; /// Parse Arguments and create Data Struct fn parse_args() -...
true
e654529127ab5d21d6b1e60d38f49ec3f0eff281
Rust
imkgerC/rust-socha2020
/referee/src/logging.rs
UTF-8
673
2.953125
3
[]
no_license
use std::fs::{File, OpenOptions}; use std::io::Write; pub struct Log(File); impl Log { pub fn init(path: &str, append: bool) -> Log { if !append { let _ = std::fs::remove_file(path); } let file = OpenOptions::new() .create(true) .write(true) ....
true
235e0867ee0355379db12dd12856732e3280d97d
Rust
david-sawatzke/probe-rs
/probe-rs/src/coresight/ap_access.rs
UTF-8
3,165
3.03125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::access_ports::{ generic_ap::{GenericAP, IDR}, APRegister, }; pub trait AccessPort { fn get_port_number(&self) -> u8; } pub trait APAccess<PORT, REGISTER> where PORT: AccessPort, REGISTER: APRegister<PORT>, { type Error: std::error::Error; fn read_ap_register(&mut self, port: POR...
true
e260f71caccfc7639ce7e7a53d16611dc222ea91
Rust
Kerollmops/Advent-of-Code-2020
/solutions/day-4/src/main.rs
UTF-8
4,515
3.109375
3
[]
no_license
use maplit::hashset; const INPUT: &str = include_str!("../../../inputs/day-4.txt"); fn main() -> anyhow::Result<()> { let mut part_one_valid_passport = 0; for input in INPUT.split("\n\n") { let mut mandatory_fields = hashset!{ "byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid" }; // "cid" for en...
true
95812e95b79a09ef4a5e59b6ed7c9a70d1ce20cb
Rust
rome/tools
/crates/rome_js_formatter/src/utils/array.rs
UTF-8
4,384
3.078125
3
[ "MIT" ]
permissive
use crate::prelude::*; use crate::AsFormat; use crate::context::trailing_comma::FormatTrailingComma; use rome_formatter::write; use rome_js_syntax::{ AnyJsArrayAssignmentPatternElement, AnyJsArrayBindingPatternElement, AnyJsArrayElement, JsLanguage, }; use rome_rowan::{AstNode, AstSeparatedList}; /// Utility ...
true
78ed57ef76920da661c1e77c48882bd5b3002bb6
Rust
abrkn/madmax-suez
/src/server.rs
UTF-8
7,195
2.546875
3
[]
no_license
use std::str; use std::collections::BTreeMap; use std::sync::mpsc; use std::thread; use rustc_serialize::json::{self, Json, ToJson}; use websocket; use websocket::stream::{WebSocketStream}; use websocket::ws::sender::Sender; use websocket::ws::receiver::Receiver; use utils::*; use balances::*; use engine::*; use mess...
true
cf13f22c0075e9091e1752e8424e933f2ae37409
Rust
brigadecore/brigade-sdk-for-rust
/src/projects.rs
UTF-8
5,519
2.78125
3
[ "Apache-2.0" ]
permissive
use crate::{ client::Client, client::ClientConfig, events::EventSubscription, meta::{APIVersion, Kind, List, ListOptions, ObjectMeta, TypeMeta}, worker::WorkerSpec, }; use anyhow::{Error, Result}; use serde::{Deserialize, Serialize}; use serde_with::*; #[skip_serializing_none] #[derive(Serialize, D...
true
aefc582c044285472c91b80137dc8b28ffa3a6a3
Rust
Thaelz/liballistic
/src/conversions.rs
UTF-8
2,229
3.46875
3
[]
no_license
/* Conversions::* * > Lengths : Inches | Meters | Foots | Yards * Inches | __ |in_to_m | | * Meters | m_to_in| __ | m_to_f |m_to_yd * Foots | | f_to_m | __ | * Yards | |yd_to_m | | __ * * > Masses : Grains, Kilograms * >...
true
10d0d15d91521abb87befaab9399b8705f81344b
Rust
avranju/kube-rust
/src/models/io_k8s_kubernetes_pkg_api_v1_toleration.rs
UTF-8
4,008
2.609375
3
[ "MIT" ]
permissive
/* * Kubernetes * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * * OpenAPI spec version: v1.7.12 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ /// V1Toleration : The pod this Toleration is attached to tolerates any taint tha...
true
1d635aae20eba559a9301d4f5e3e66adaef401db
Rust
ToF-/LearningRust
/char_patterns_8/src/main.rs
UTF-8
2,042
3.03125
3
[]
no_license
// 000111 // 012210 // 02 ../\.. // 01 ./**\. // 00 /****\ // 10 \****/ // 11 .\**/. // 12 ..\/.. fn main() { use std::io; fn print_pattern(rows:u32, cols:u32, size:u32) { for row in 0..rows*size*2 { let mut inside = false; for col in 0..cols*size*2 { let...
true
566184ce313540a1243dccf9fe0ab19e4a534519
Rust
m-lima/advent-of-code-2020
/src/bin/061/main.rs
UTF-8
489
2.875
3
[]
no_license
use std::collections::HashSet; const INPUT: &str = include_str!("input.txt"); fn main() { let count: usize = INPUT .split("\n\n") .map(|line| { line.split('\n') .map(|string| string.chars().collect::<HashSet<_>>()) .fold(HashSet::new(), |mut acc, curr| {...
true
f56d762f5fd7ae1f7cd4361088dcf34b206572ed
Rust
jvff/pegast
/src/lib.rs
UTF-8
1,778
3.0625
3
[]
no_license
pub mod input; pub mod rules; use { crate::input::Input, std::{ borrow::Cow, error::Error, fmt::{self, Display, Formatter}, ops::Deref, }, }; #[cfg(feature = "derive")] pub use { crate::rules::sets::SetEntries, pegast_derive::{FromStr, PegAstNode, SetEntries}, }; #[...
true
dd4b9cf6b4353f36c7c6d36e0698205eb2ad910c
Rust
byron7cueva/learn-rust
/intermedio/first-project/src/trait.rs
UTF-8
5,849
3.875
4
[]
no_license
// traits -> Rasgos (Similares a las interfaces en otros lenguajes de programacion) // Definimos un trait usando la palabra clave trait y luego el nombre del rasgo // Dentro de las llaves declaramos los métodos que describen los comportamientos de los // tipos que tienen este rasgo. // Cada tipo que implemente este ra...
true
dc43e8bce826309487590cf26b630c583419dece
Rust
Forlos/bininfo
/src/formats/png/mod.rs
UTF-8
57,521
2.578125
3
[]
no_license
use scroll::{self, Pread}; use ansi_term::Color; use failure::Error; use crate::Opt; use crate::Problem; use crate::format::{fmt_indent, fmt_indentln, fmt_png_header}; pub const PNG_HEADER: &'static [u8; PNG_HEADER_SIZE] = b"\x89PNG\x0D\x0A\x1A\x0A"; pub const PNG_HEADER_SIZE: usize = 8; #[derive(Debug, Pread, Parti...
true
5e651488854dcf49ac64e73276ab8887ecea6918
Rust
warpforge/warpgrapher
/src/engine/resolvers.rs
UTF-8
37,949
2.8125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Contains the type aliases, enumerations, and structures to allow for the creation of custom //! resolvers. use crate::engine::context::GraphQLContext; use crate::engine::context::RequestContext; use crate::engine::database::{ DatabaseEndpoint, DatabasePool, NodeQueryVar, RelQueryVar, SuffixGenerator, Transacti...
true
0946e4149ec404f5c4c314a652c1af5739137ee3
Rust
ahmelsayed/rr
/src/main.rs
UTF-8
722
2.59375
3
[]
no_license
// Auther: Ahmed ElSayed // Date: 8-31-2014 extern crate rr; use std::io; use std::os; use rr::parser; use rr::store; fn main() { let rr_options = rr::parser::parse(os::args()); match rr_options.mode { parser::Help => show_help(), parser::Get => store::get(&rr_options.key), parser::Set...
true
2e421db028d6d8ce12478fa1629ff574e3565276
Rust
adarshpannu/mylists
/src/deque.rs
UTF-8
3,587
3.59375
4
[]
no_license
#![allow(warnings)] use std::cell::RefCell; use std::rc::Rc; struct List<T> { head: NodePtr<T>, tail: NodePtr<T>, } type NodePtr<T> = Option<Rc<RefCell<Node<T>>>>; struct Node<T> { elem: T, next: NodePtr<T>, prev: NodePtr<T>, } impl<T> Node<T> { fn new(elem: T) -> Rc<RefCell<Node<T>>> { ...
true
e88efde7d1d3f7a566608fb1a7a892a4dc7ac764
Rust
toumorokoshi/greyhawk-language
/src/codegen/statement.rs
UTF-8
4,522
2.59375
3
[]
no_license
use std::collections::HashMap; use std::rc::Rc; use ast::{Statement, Statements}; use vm::{Scope, types, Op, get_type_ref_from_string}; use vm::function::{Function, VMFunction}; use super::{gen_expression}; use codegen::{CGError, CGResult, Block, Context}; pub fn gen_statement(c: &mut Context, s: &Statement) -> CGResu...
true
08a50ad32bc557eba81c6ea16522af872139c409
Rust
mmizutani/ooxml-rs
/src/document/spreadsheet/style.rs
UTF-8
11,174
2.609375
3
[]
no_license
use crate::packaging::element::*; use crate::packaging::namespace::Namespaces; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename = "numFmt")] pub struct NumberFormat { #[serde(rename = "numFmtId")] id: usize, #[serde(rename = "formatCode")] pub...
true
28f697764957cb53ab81e4c80730e0eccf678537
Rust
nalshihabi/azure-sdk-for-rust
/sdk/cosmos/src/resources/user.rs
UTF-8
1,252
2.875
3
[ "LicenseRef-scancode-generic-cla", "MIT", "LGPL-2.1-or-later" ]
permissive
//! Utilities for interacting with [`User`]s. use super::Resource; /// A logical namespace for scoping permissions on resources. /// /// You can learn more about users [here](https://docs.microsoft.com/rest/api/cosmos-db/users). #[derive(Serialize, Deserialize, Clone, Debug, PartialOrd, PartialEq)] pub struct User { ...
true
6a1fbc5aee6c527c3817a7e7f8b73156bc42c967
Rust
yonipeleg33/timed
/timed_proc_macros/src/lib.rs
UTF-8
4,976
2.875
3
[]
no_license
#![allow(unused_imports)] use darling::FromMeta; use proc_macro::TokenStream; use proc_macro2::Span; use quote::quote; use syn::{AttributeArgs, ItemFn}; #[derive(Debug, FromMeta)] struct TracingArgs { #[darling(default)] enabled: Option<bool>, #[darling(default)] main: Option<String>, } #[derive(Debu...
true
d547136c75c6e36278186309d693e5fa26f32cda
Rust
trescommas/crypto-crawler-rs
/crypto-rest-client/src/exchanges/mxc/mxc_spot.rs
UTF-8
1,958
2.78125
3
[ "Apache-2.0" ]
permissive
use super::super::utils::http_get; use crate::error::Result; use std::collections::HashMap; const BASE_URL: &str = "https://www.mxc.co"; /// MXC Spot market. /// /// * REST API doc: <https://mxcdevelop.github.io/APIDoc/> /// * Trading at: <https://www.mxc.com/trade/pro> pub struct MxcSpotRestClient { _access_key:...
true
ce383ae9dbc47fd4525966e0efc839fae532f44b
Rust
yangby-cryptape/rust-slices
/src/lib.rs
UTF-8
2,785
3.28125
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright (C) 2019 Boyu Yang // // 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 t...
true
4a4cd48f42bd4e1f35028fe9beaa257e69b21b3d
Rust
pipi32167/LeetCode
/rust/src/problem_1005.rs
UTF-8
944
3.453125
3
[]
no_license
#[derive(Debug)] struct Solution {} impl Solution { pub fn largest_sum_after_k_negations(mut a: Vec<i32>, mut k: i32) -> i32 { a.sort(); // println!("{:?}", a); let mut a: Vec<i32> = a .iter() .map(|x| { if *x < 0 && k > 0 { k -= 1; -*x } else { ...
true
d3b61f4e2cb745d924e5911dcfad5235bdd5f42a
Rust
MarkWilds/rust_raytracer_in_a_weekend
/src/vec3.rs
UTF-8
3,796
3.296875
3
[]
no_license
use std::fmt; use std::fmt::Write; use std::ops; use rand::{thread_rng, Rng}; #[derive(Copy, Clone)] pub struct Vec3 { pub x: f32, pub y: f32, pub z: f32, } impl Vec3 { pub fn new() -> Vec3 { Vec3 { x: 0_f32, y: 0_f32, z: 0_f32 } } pub fn one() -> Vec3 { Vec3 { x: 1_f32, y: 1_...
true
710086c941ce6d96bc87da21ce489124611c5827
Rust
id4ho/algorithms-rust
/src/algo1/graphs/mod.rs
UTF-8
2,176
3.171875
3
[]
no_license
#[derive(Clone)] pub struct AdjacencyList { pub node_count: usize, pub edge_count: usize, nodes: Vec<Vec<u32>>, } impl AdjacencyList { pub fn from_vector(mut adjacency_lists: Vec<Vec<u32>>) -> AdjacencyList { let mut node_count: usize = 0; let mut edge_count: usize = 0; for (i, vector) in adjacency...
true
e3b2b24a73b372b066a18bf7ea283ec310871ed2
Rust
mpdrescher/huffman-compression
/src/byteweight.rs
UTF-8
622
3.5
4
[ "MIT" ]
permissive
pub type Distribution = [usize; 256]; pub type ByteWeight = (u8, usize); //-> byte, count pub struct ByteWeightCounter { counter: Distribution } impl ByteWeightCounter { pub fn new() -> ByteWeightCounter { ByteWeightCounter { counter: [0; 256] } } pub fn feed(&mut self, byte: u8) { self.counter[byte...
true
1f5dd942a7f98f8bc38583c2dfa3fb0603cabdca
Rust
immunant/c2rust
/tests/statics/src/test_thread_locals.rs
UTF-8
1,333
2.53125
3
[ "BSD-3-Clause", "Apache-2.0" ]
permissive
//! feature_thread_local use crate::thread_locals::rust_thread_entry; use libc::{c_int, c_uint}; use std::thread; #[link(name = "test")] extern "C" { fn thread_entry(_: c_uint, _: *mut c_int); } #[no_mangle] static mut gesi: u32 = 71; #[no_mangle] static mut rust_gesi: u32 = 71; #[no_mangle] static mut fesi: u32...
true
0f5df934280664a34d5315459d0ddacdc03df5bc
Rust
SimonWang9610/rust-js-wasm
/rust/utils/src/trained/mod.rs
UTF-8
1,983
2.84375
3
[ "MIT" ]
permissive
extern crate serde; extern crate serde_json; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use crate::ConvertT; use crate::activation::Activation; use crate::layer::Layer; use ndarray::{Array, Array2, Ix2}; use std::cell::RefCell; #[derive(Serialize, Deserialize)] pub struct LayerJson { neu...
true
f03692ce54a88b4cbf4e1cefe16e1e1ce9ec64e9
Rust
mishan88/pishirase
/tests/pishirase.rs
UTF-8
3,124
2.53125
3
[ "MIT" ]
permissive
use chrono::NaiveTime; use pishirase::{is_publish_message, is_straight_time, read_certs_file}; use std::path::PathBuf; #[test] fn test_create_mqtt_options() {} #[test] fn test_read_certs_file() { let text = read_certs_file(PathBuf::from("./tests/test_certs/test.pub.pem.txt")).unwrap(); assert_eq!( te...
true
41c579919da01f596b05b62e48cb502726f5d492
Rust
jeff-davis/cdylib-plugin.rs
/src/lib.rs
UTF-8
1,779
3
3
[]
no_license
//! Provides workarounds for two problems encountered with ``cdylib`` //! crates for plugin-style shared libraries, where the library refers //! to symbols in the host program: //! 1. Linking errors on some platforms due to undefined symbols //! 1. Difficulty finding the produced shared library for testing or installat...
true
166a42ca8f8a86a0cb8d751d57d475003bcb6a5d
Rust
Kuzirashi/godwoken
/crates/jsonrpc-types/src/blockchain.rs
UTF-8
8,639
2.59375
3
[ "MIT" ]
permissive
use anyhow::{anyhow, Error as JsonError}; use ckb_fixed_hash::H256; use ckb_jsonrpc_types::{JsonBytes, Uint32, Uint64}; use gw_types::{packed, prelude::*}; use serde::{Deserialize, Serialize}; use std::convert::{TryFrom, TryInto}; #[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)] #[serde(rename_all ...
true
7b9fb771a83ba0d59b338198f42bc4ea97d1074d
Rust
JMLX42/rust-delta-crdts
/src/gcounter.rs
UTF-8
2,761
3.203125
3
[ "MIT" ]
permissive
use std::collections::HashSet; use crate::vclock::{VClock, Value}; use crate::traits::{Actor, DCRDT}; use dcrdt_macro::*; #[derive(Debug)] struct GCounter<A: Actor, V: Value> { owner: A, state: VClock<A, V>, } impl<A: Actor, V: Value> GCounter<A, V> { fn new(owner: A) -> Self { GCounter { ...
true
0b0ba3b8862baf0ca8b5ff84f518b8939f12109f
Rust
naiveai/adventofcode
/rust/2019/src/bin/11/main.rs
UTF-8
10,412
2.703125
3
[ "CC0-1.0" ]
permissive
#![feature(entry_insert, destructuring_assignment)] use anyhow::{anyhow, bail, ensure}; use clap::{App, Arg}; use derive_more::From; use digits_iterator::*; use itertools::Itertools; use std::{collections::HashMap, convert::TryFrom, fmt, fs, iter, sync::Mutex}; use tokio::pin; use tokio_stream::{Stream, StreamExt}; f...
true
c1482650f2f05ce087a33545c60b8d69567038d0
Rust
oberien/dilobo
/src/expiring_map.rs
UTF-8
1,239
3.0625
3
[]
no_license
use std::collections::{VecDeque, HashMap}; use std::time::{Instant, Duration}; #[derive(Debug, Clone)] pub struct ExpiringMap<K, V> where K: ::std::cmp::Eq + ::std::hash::Hash { map: HashMap<K, V>, queue: VecDeque<(K, Instant)>, ttl: Duration, } impl<K, V> ExpiringMap<K, V> where K: ::std::cmp::Eq + ::std...
true
f350c377a0d91e8bdaeca9cb4938504245fbcda5
Rust
JohnDowson/crypton
/src/utils.rs
UTF-8
1,777
3.015625
3
[]
no_license
use std::env::{self, var_os}; use std::ffi::OsString; use std::process::Command; use thiserror::Error; pub type CResult<T> = Result<T, Box<dyn std::error::Error>>; #[derive(Debug, Error)] pub enum AppError { #[error("No editor could be found. Please set $EDITOR of $VISUAL")] NoEditor, #[error("The note wa...
true
6a39007ed0136ef748aaa9e52330f84d0eefccd7
Rust
7phs/wordvector-rs
/src/testing/wordvector.rs
UTF-8
2,627
2.78125
3
[ "MIT" ]
permissive
use dictionary::Dictionary; use utils::doc_parse; use {WordVector}; use testing::model::TestModel; #[test] fn test_wordvector_dictionary() { let model = TestModel::default(); let vector = WordVector::new(&model, &model); let exist_dict = vector.dictionary(&doc_parse("намело сугробы за калиткой")); l...
true
780367cb78ac3363e67c368df8120b2fbd9e9052
Rust
cessen/ropey_old
/src/lib.rs
UTF-8
51,540
2.546875
3
[ "CC0-1.0" ]
permissive
#![allow(dead_code)] //#![feature(test)] //#![feature(unicode)] //extern crate test; extern crate unicode_segmentation; mod string_utils; mod tests; mod benches; use std::cmp::{min, max}; use std::mem; use std::str::Chars; use unicode_segmentation::{UnicodeSegmentation, Graphemes}; use string_utils::{ char_count...
true
fb88ce0f527701ec3a044673652ab86863bea956
Rust
1600/xerxism
/rust/beer-song/1.rs
UTF-8
384
3.03125
3
[]
no_license
fn main(){ // for i in (1..5).rev() { // println!("{}",i) // } pub fn sing( round_starts : u32 , round_ends : u32 ) -> String { let mut result : String = "".to_owned(); for i in (round_ends..round_starts+1).rev() { result.push_str(&i.to_string()); } re...
true
11fff8a94183d73f346ed504941720123c0ab580
Rust
mozilla/gecko-dev
/third_party/rust/zerovec/src/varzerovec/vec.rs
UTF-8
15,851
3.078125
3
[ "LicenseRef-scancode-unicode", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use crate::ule::*; use alloc::vec::Vec; use core::cmp::{Ord, Ordering, PartialOrd}; use core::fmt; use core::ops::De...
true
409752e8d1cbbae512b144d4c5a118b8052c68bb
Rust
gallowstree/tsurust
/common/src/game.rs
UTF-8
537
2.984375
3
[]
no_license
use crate::board::*; pub struct Game { players: Vec<Player>, board: Board, } impl Game { pub fn perform_move(&mut self, mov: Move) { self.board.place_tile(mov); let alive_players = self.players.iter_mut().filter(|player| player.alive); /// make alive players follow the path in fr...
true
390c4e800ea0e629852d24ef84d9f1dcdab1ca2e
Rust
Uriopass/inline_tweak
/examples/watch.rs
UTF-8
245
2.921875
3
[ "CC0-1.0" ]
permissive
use inline_tweak::{tweak, watch}; fn main() { loop { println!("{}", tweak!(4.5)); // Try changing the value while the application is running watch!(); // The thread will sleep here until anything in the file changes } }
true
c25f3531b05e9dafce1301180f36d2f28f86d622
Rust
ives9638/hadron
/hadron/src/cmd/sub.rs
UTF-8
2,059
2.71875
3
[ "Apache-2.0" ]
permissive
//! Subscribe to data on a stream. use std::sync::Arc; use anyhow::{Context, Result}; use hadron::{StreamSubDelivery, SubscriberConfig, Subscription, SubscriptionStartingPoint}; use structopt::StructOpt; use crate::Hadron; /// Subscribe to data on a stream. #[derive(StructOpt)] #[structopt(name = "sub")] pub struct...
true
91440f641c37ca46a63343f9c1dace06e67621b2
Rust
tramulns/rust-by-example
/generics/bounds/src/main.rs
UTF-8
1,447
3.6875
4
[]
no_license
// Типаж, который реализует маркер печати: `{:?}`. use std::fmt::{Debug, Display}; // Определим функцию `printer`, которая принимает обобщённый тип `T`, // который должен реализовать типаж `Display` #[allow(dead_code)] fn printer<T: Display>(t: &T) { println!("{}", t); } // Обобщённый тип `T` должен реализовать `...
true
955ce33b12dc8720b1e7e6b98523d566017f5b9a
Rust
felipear89/rust-book
/variables/src/main.rs
UTF-8
2,241
4.15625
4
[]
no_license
fn shadowing() { let x = 5; let x = x + 1; let x = x * 2; println!("[shadowing] The value of x is: {}", x); // THIS IS NOT POSSIBLE // let mut spaces = " "; // spaces = spaces.len(); let spaces = " "; let spaces = spaces.len(); println!("{}", spaces) } fn data_types() ...
true
8b09865217d12a57e6b6ebf873edfd61d95eea24
Rust
sogapalag/contest
/comm/convolution.rs
UTF-8
802
2.78125
3
[]
no_license
/// Depends on: fft.rs, ModInt.rs /// Primitive root defaults to 3 (for 998244353); for other moduli change the value of it. fn conv(a: Vec<ModInt>, b: Vec<ModInt>) -> Vec<ModInt> { let n = a.len() - 1; let m = b.len() - 1; let mut p = 1; while p <= n + m { p *= 2; } let mut f = vec![Mod...
true
5d8f230df9b1156dab3811400fe4510fa24cbeeb
Rust
zheeeng/leetcode.daily
/908.smallest-range-i.0.rs
UTF-8
567
2.75
3
[]
no_license
/* * @lc app=leetcode id=908 lang=rust * * [908] Smallest Range I */ impl Solution { pub fn smallest_range_i(a: Vec<i32>, k: i32) -> i32 { if a.len() == 0 { return 0 } let (max, min) = a.iter().fold((a[0], a[0]), |acc, cur| { match acc { (max, min...
true
5af9917d37cd5c0219304350c6940fd0aa9f5aa8
Rust
guoraymon/leetcode-rust
/src/maximum_depth_of_binary_tree.rs
UTF-8
1,945
3.96875
4
[]
no_license
// Definition for a binary macros node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, l...
true
4ea6d2177abc82195d507876fc2049a0f3ec6f1c
Rust
alecmocatta/amadeus
/amadeus-core/src/par_stream/chain.rs
UTF-8
1,854
2.59375
3
[ "Apache-2.0" ]
permissive
use derive_new::new; use futures::Stream; use pin_project::pin_project; use serde::{Deserialize, Serialize}; use std::{ pin::Pin, task::{Context, Poll} }; use super::{ParallelStream, StreamTask}; #[pin_project] #[derive(new)] #[must_use] pub struct Chain<A, B> { #[pin] a: A, #[pin] b: B, } impl_par_dist! { imp...
true
f5c2b684437d8387226ad2eb4a25090428fa8638
Rust
IThawk/rust-project
/rust-master/src/test/ui/suggestions/issue-64252-self-type.rs
UTF-8
334
3.140625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// This test checks that a suggestion to add a `self: ` parameter name is provided // to functions where this is applicable. pub fn foo(Box<Self>) { } //~^ ERROR expected one of `:`, `@`, or `|`, found `<` struct Bar; impl Bar { fn bar(Box<Self>) { } //~^ ERROR expected one of `:`, `@`, or `|`, found `<` } ...
true
9834b1fb941dc5efb0776415b3010ac9880bbed0
Rust
cgaebel/mio
/src/handler.rs
UTF-8
2,570
2.859375
3
[]
no_license
use error::{MioResult, MioError}; use nix::fcntl; use poll::IoEvent; use reactor::{Reactor}; use std::mem; /// `drop` is called when the connection dies. Return an error to kill the /// connection yourself. pub trait Handler { fn readable(&mut self, reactor: &mut Reactor) -> MioResult<()>; fn writable(&mut sel...
true
fdbf12a790af86a8b31c481efa76080d2f08d8b5
Rust
rivertam/rust-clippy
/tests/ui/redundant_clone.rs
UTF-8
1,238
3.34375
3
[ "MIT", "Apache-2.0" ]
permissive
#![warn(clippy::redundant_clone)] use std::ffi::OsString; use std::path::Path; fn main() { let _ = ["lorem", "ipsum"].join(" ").to_string(); let s = String::from("foo"); let _ = s.clone(); let s = String::from("foo"); let _ = s.to_string(); let s = String::from("foo"); let _ = s.to_owne...
true
cc637c887be1f28f9f1e402ec7317658c1451aaf
Rust
zigguratvertigo/rust-sort
/src/main.rs
UTF-8
3,197
2.9375
3
[ "MIT" ]
permissive
//#![feature(rustc_private)] extern crate rand; mod bubblesort; mod insertionsort; mod shellsort; mod mergesort; mod selectionsort; mod quicksort; mod heapsort; // Externals use rand::distributions::{IndependentSample, Range}; const NUM_VALUES: usize = 10; const MAX_RANGE: u32 = 100; fn main() { // Initialize t...
true
4a632990f4fb98f3209266d91c4e156faff8c255
Rust
SuryaElavazhagan/glab-cli
/src/utils/ui.rs
UTF-8
316
3.3125
3
[]
no_license
use std::io; /// Prompts for input and returns it. pub fn prompt(message: &str) -> io::Result<String> { loop { print!("{}: ", message); let mut buf = String::new(); io::stdin().read_line(&mut buf)?; let input = buf.trim(); if !input.is_empty() { return Ok(input.to_owned()); } } }
true
74df14ee6278e8538366bcb1c4f51a0743a402ef
Rust
graydot/rust-cryptopals
/src/bin/c12.rs
UTF-8
4,030
2.96875
3
[]
no_license
use cryptopals::oracle::*; use cryptopals::aes::*; use cryptopals::utils::*; use cryptopals::base64::*; use std::collections::HashMap; use rand::*; use std::f64::MAX as f64MAX; const APPEND: &str = "Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkgaGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyB...
true
8d7aecd605aba63a4e2861b34da25b335c5156d0
Rust
danhper/diem
/sdk/offchain/src/types.rs
UTF-8
24,100
2.5625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use serde::{ de::{Deserializer, Error}, Deserialize, Serialize, }; use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; use crate::payment_command::Actor; /// A header set with a unique UUID (according to RFC412...
true
b5dd3b01d37de62b704e34dc16432dae56afd179
Rust
shikharvashistha/oak
/experimental/oak_async/src/grpc.rs
UTF-8
9,391
2.671875
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
8f9518fc76ab932cd75b8057814b75e76dcbb194
Rust
Fifthrow/rust-kdb
/src/kbox.rs
UTF-8
2,933
3.25
3
[ "MIT" ]
permissive
use crate::type_traits::KObject; use crate::{k::K, kapi}; use std::mem::ManuallyDrop; use std::ops::Deref; use std::ptr::NonNull; use std::{fmt, ops::DerefMut}; /// Represents a memory managed K pointer. They are the /// KDB equivalent of a Rust Box, a zero overhead wrapper /// around a K pointer. It will call `r0` to...
true
85cb6fa96fa605c02d7aa3b2971183b4a4a0b95b
Rust
bleepster/exercism
/rust/nth-prime/src/lib.rs
UTF-8
524
3.359375
3
[]
no_license
fn is_prime(n: u32) -> bool { for i in 2..n { if n % i == 0 && i != n { return false; } } true } pub fn nth(n: u32) -> u32 { let mut found_primes = 0; let mut current_guess = 2; let mut last_found = current_guess; loop { if is_prime(current_guess) { ...
true
c10bf49533bafcdef061442c0d08e27de8a12243
Rust
guyoung/CaptfEncoder
/CaptfEncoder-V3/main/src/apps/widgets/wgt_editor_dnd.rs
UTF-8
2,052
2.640625
3
[]
no_license
use fltk::{app, dialog, enums::Event, prelude::*, text::*}; pub fn attach_event(editor: &mut TextEditor, buf: &mut TextBuffer) { editor.handle({ let mut dnd = false; let mut released = false; let buf2 = buf.clone(); let dialog_x = (editor.x() + editor.width() / 2) as i32 - 20...
true
92a0629385af8b40095cbdd300d512a2892056f7
Rust
Shuumatsu/rdns
/src/proto/question.rs
UTF-8
936
2.859375
3
[]
no_license
use crate::proto::query::Query; use crate::proto::{BytePacketBuffer, Result}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Question { // A domain name represented as a sequence of labels, where each label consists of a length octet followed by that number of octets. pub name: String, pub qtype: Query,...
true
7a1deb15da7886d5f57e414270304449d679f8e1
Rust
fabianschuiki/moore
/src/vhdl/ty2/enums.rs
UTF-8
7,547
3.0625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2016-2021 Fabian Schuiki //! Enumeration types. use std::fmt::{self, Display}; use std::iter::{once, repeat}; pub use num::BigInt; use crate::common::name::{get_name_table, Name}; use crate::ty2::prelude::*; use crate::ty2::ScalarSubtype; /// An enumeration type. /// /// This can either be an `Enu...
true
3f5ea6e9fba843fb08aab04f80723742534479fe
Rust
drahnr/rsa-der
/src/errors.rs
UTF-8
2,080
2.96875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fmt; use std::fmt::{Display, Formatter}; /// Error type for `rsa-der`. #[derive(Debug, Clone, PartialEq)] pub enum Error { /// Indicates that a DER decoding error occurred. InvalidDer(simple_asn1::ASN1DecodeErr), /// Indicates that the RSA bitstring was not found. BitStringNotFound, /// In...
true
148b7c0b4696fd02a608246a2c42bcf0e7eb9e64
Rust
ssmike/threading
/src/async.rs
UTF-8
1,928
2.953125
3
[]
no_license
use std::sync::Mutex; use std::marker::PhantomData; use std::boxed::{Box, FnBox}; use future::{Future, Promise}; use std::thread; use std::mem; pub struct DeferScope<'t> { to_run: Mutex<Vec<Box<'t + FnBox() -> ()>>>, _marker: PhantomData<&'t ()> } impl<'t> DeferScope<'t> { pub fn defer<Func: 't + FnOnce()...
true
45b62ca6a1b5a4d17a6fe655ddfec7408d9a6b54
Rust
mesalock-linux/crates-sgx
/vendor/image/src/ico/encoder.rs
UTF-8
2,973
3.171875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::prelude::v1::*; use byteorder::{LittleEndian, WriteBytesExt}; use std::io::{self, Write}; use color::{bits_per_pixel, ColorType}; use png::PNGEncoder; // Enum value indicating an ICO image (as opposed to a CUR image): const ICO_IMAGE_TYPE: u16 = 1; // The length of an ICO file ICONDIR structure, in bytes: c...
true
005e079637998123c64a5b85437eace2e6f0db7c
Rust
JoeNotCharles/mobi-rs
/src/huff.rs
UTF-8
5,735
2.84375
3
[ "MIT" ]
permissive
#![allow(dead_code)] use crate::Reader; type HuffmanResult<T> = Result<T, HuffmanError>; pub enum HuffmanError { IoError(std::io::Error), CodeLenOutOfBounds, BadTerm, InvalidHuffHeader, InvalidCDICHeader, InvalidDictionaryIndex, } impl From<std::io::Error> for HuffmanError { fn from(e: st...
true