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
8966d93dc83f222573ebef578600b751972763b6
Rust
YusukeHosonuma/workspace
/Rust/tutorial/tutorial_4_5/src/main.rs
UTF-8
488
3.953125
4
[]
no_license
fn main() { let x = 5; // 通常のコントロールフローとしての if else-if else if x == 5 { println!("x is 5!"); } else if x == 6 { println!("x is 6!"); } else { println!("x is not 5 or 6 :(") } let x = 5; // 式として評価できる let y = if x == 5 { 10 } else { 15 ...
true
36ee0d3f9d7836458d06badd7698779e889edef4
Rust
ebkalderon/mruby-rs
/src/ser/serializer.rs
UTF-8
4,433
2.703125
3
[]
no_license
use std::ffi::CString; use mruby_sys::{mrb_ary_new_from_values, mrb_bool, mrb_float, mrb_int, mrb_state, mrb_value}; use super::ToValue; use crate::class::Class; use crate::symbol::ToSymbol; use crate::value::Value; #[derive(Debug)] pub struct Serializer(*mut mrb_state); impl Serializer { pub(crate) const fn ne...
true
b2b45340b54ca7956303b28cc2930257ba3cd0ef
Rust
CroPo/roguelike-tutorial-2018
/part_4/src/render.rs
UTF-8
547
2.546875
3
[ "WTFPL" ]
permissive
use tcod::console::{Console, Root}; use map_objects::map::GameMap; use tcod::Map; pub trait Render { fn draw(&self, console: &mut Console); fn clear(&self, console: &mut Console); } pub fn render_all<T: Render>(objs: &Vec<T>, map: &mut GameMap, fov_map: &Map, fov_recompute: bool, console: &mut Root) { m...
true
ab3cc841cc5ea581ff80f78e66dcf8f5b08bf965
Rust
zed0/advent-of-code
/2020/src/bin/aoc-24/main.rs
UTF-8
6,462
3.046875
3
[]
no_license
#![allow(unused_imports)] use std::fs; use std::env; use std::time::SystemTime; use std::collections::{HashMap, BTreeMap, HashSet}; use itertools::Itertools; use regex::Regex; use std::convert::{TryInto,TryFrom}; use std::num::TryFromIntError; use core::str::FromStr; use std::collections::VecDeque; use num::abs; use r...
true
afc226d9226f41cedfe4032026b9826824891396
Rust
LgnMs/my-leetcode-rust
/hash_table/length_of_longest_substring.rs
UTF-8
1,662
3.640625
4
[ "MIT" ]
permissive
/* * @lc app=leetcode.cn id=2 lang=rust * * [3] 无重复字符的最长子串 * https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ * - [滑动窗口] [哈希表] */ use std::collections::{HashSet, VecDeque}; pub fn length_of_longest_substring(s: String) -> i32 { let s = s.into_bytes(); let mut max = 0; ...
true
832d0a5593657e4a05a4300bb0cfe2a26a4d00b8
Rust
loganyu/leetcode
/problems/1010_pairs_of_songs_with_total_duration_divisible_by_60.rs
UTF-8
1,146
3.390625
3
[]
no_license
/* You are given a list of songs where the ith song has a duration of time[i] seconds. Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0. Example 1: Input: time = [30,20,...
true
f7a7d3bf21432764eac5584b1e31eb85ebd1e82d
Rust
electromeow/color-please
/src/string_returning.rs
UTF-8
4,162
3.484375
3
[ "MIT" ]
permissive
use crate::Color; /// Returns the given text's foreground dyed with color given. pub fn make_colored_fg(text: &str, color: Color) -> String { let mut string = String::new(); string.push_str(&match color { Color::Black => String::from("\x1b[30m"), Color::Red => String::from("\x1b[31m"), ...
true
de6b49eaa5a33b3f45bffd62195ca6c69c6d5bc9
Rust
boa-dev/boa
/boa_ast/src/statement/switch.rs
UTF-8
6,363
3.71875
4
[ "MIT", "Unlicense" ]
permissive
//! Switch node. //! use crate::{ expression::Expression, statement::Statement, try_break, visitor::{VisitWith, Visitor, VisitorMut}, StatementList, }; use boa_interner::{Interner, ToIndentedString, ToInternedString}; use core::ops::ControlFlow; /// A case clause inside a [`Switch`] statement, as d...
true
dfbde052bde9a94b8391a3e78a7d7dbbb6bd7b9c
Rust
lythesia/leet
/rs/src/quests/combination_sum_iv.rs
UTF-8
2,189
3.640625
4
[]
no_license
/** * [377] Combination Sum IV * * Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target. The test cases are generated so that the answer can fit in a 32-bit integer.   Example 1: Input: nums = [1,2,3], target = 4 Output: 7 Explanation:...
true
d5e477b76aa522475150f966624db6fb94d6ec6a
Rust
damienstanton/tinystd
/src/sort/quick.rs
UTF-8
2,060
3.234375
3
[ "Apache-2.0" ]
permissive
// 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 in writing, software // distributed ...
true
3e65c0bc81fe05e7975da8fba6513a0ea5495dda
Rust
ericrobolson/das_ubershader
/src/pixel_machine/mod.rs
UTF-8
46,363
3.234375
3
[ "MIT" ]
permissive
mod data; mod op; use std::u8; pub use data::*; pub use op::*; use crate::Texture; use game_utils::collections::Stack; use image::GenericImageView; /// Various errors that may occur. #[derive(Debug, PartialEq)] pub enum Error { /// A number was attempted to be divided by zero. DivideByZero, /// An inval...
true
31fbb45415491b97f244ce789106ef79737b8efa
Rust
kavitaasiwal/guide
/code/2_10_mixed.rs
UTF-8
933
2.703125
3
[ "MIT" ]
permissive
use plotters::prelude::*; fn main() { let root_area = BitMapBackend::new("images/2.10.png", (600, 400)).into_drawing_area(); root_area.fill(&WHITE).unwrap(); let mut ctx = ChartBuilder::on(&root_area) .set_label_area_size(LabelAreaPosition::Left, 40) .set_label_area_size(LabelAreaPosition:...
true
1f9b3fb5d2c2016031ed0dbc4b2dabde9e361333
Rust
grenewode/advent-of-code-2019
/day-two/src/main.rs
UTF-8
1,167
2.578125
3
[]
no_license
const PROGRAM: &'static [i32] = &[ 1, 0, 0, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 10, 1, 19, 1, 19, 9, 23, 1, 23, 13, 27, 1, 10, 27, 31, 2, 31, 13, 35, 1, 10, 35, 39, 2, 9, 39, 43, 2, 43, 9, 47, 1, 6, 47, 51, 1, 10, 51, 55, 2, 55, 13, 59, 1, 59, 10, 63, 2, 63, 13, 67, 2, 67, 9, 71, 1, 6, 71, 75, 2, 75, ...
true
df310efc3739c97460a38e3825f875f451db9f5d
Rust
BenoitZugmeyer/RustyAdventOfCode
/2015/src/bin/day19.rs
UTF-8
9,753
2.734375
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate regex; use regex::Regex; use std::collections::btree_map; use std::collections::BTreeMap; use std::collections::BTreeSet; use std::collections::VecDeque; use std::io; use std::io::BufRead; trait MapGetDefault<K, V> { fn get_default_mut(&mut self, key: K) -> &mu...
true
cad1c63099b41e73be378f83ae9ab8815074957e
Rust
ergoplatform/sigma-rust
/gf2_192/src/lib.rs
UTF-8
1,916
2.796875
3
[ "CC0-1.0" ]
permissive
//! Implementation of finite field arithmetic and polynomial interpolation/evaluation in Galois //! field GF(2^192). // Coding conventions #![forbid(unsafe_code)] #![deny(non_upper_case_globals)] #![deny(non_camel_case_types)] #![deny(non_snake_case)] #![deny(unused_mut)] #![deny(dead_code)] #![deny(unused_imports)] #...
true
d5ff7fee265ef4de53af92d382985618fe9b9d4d
Rust
yamakii/think_like_a_programmer_in_rust
/puzzle/src/main.rs
UTF-8
5,615
3.578125
4
[ "MIT" ]
permissive
#![allow(dead_code)] fn main() { // puzzle::triangle(); // digit::check_digit(); message::print_digit(); } mod puzzle { use num::abs; pub fn triangle() { for i in 0..7 { for _ in 0..(4 - abs(4 - i)) { print!("#"); } println!(); } ...
true
b97b29dd97610d0a8ffb8cde46018603a39a9cfc
Rust
typst/typst
/crates/typst/src/util/fat.rs
UTF-8
2,048
3.265625
3
[ "Apache-2.0", "Bitstream-Vera", "CC-BY-4.0", "OFL-1.1", "LicenseRef-scancode-gust-font-1.0", "BSD-3-Clause", "LicenseRef-scancode-ubuntu-font-1.0", "0BSD", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-public-domain", "MIT", "LicenseRef-scancode-public-domain-disclaimer" ]
permissive
//! Fat pointer handling. //! //! This assumes the memory representation of fat pointers. Although it is not //! guaranteed by Rust, it's improbable that it will change. Still, when the //! pointer metadata APIs are stable, we should definitely move to them: //! <https://github.com/rust-lang/rust/issues/81513> use std...
true
0fad6f4988e50793094bb540fffb8cf0ac8d6ccd
Rust
wickerwaka/advent2020
/day04/src/main.rs
UTF-8
2,598
2.953125
3
[]
no_license
use advent::*; use std::collections::HashSet; fn main() -> Result<(), Error> { let input = std::fs::read_to_string("day04/input.txt")?; let required_keys: HashSet<&str> = vec!["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"] .into_iter() .collect(); let mut valid_keys = 0; let mut val...
true
0ee5f9d0b0270c70329ea26102dfbe4704431aae
Rust
lutzer/advent-of-code-20
/day9/src/main.rs
UTF-8
2,341
3.359375
3
[]
no_license
use std::fs; use clap::{Arg, App}; const FILENAME : &str = "input.txt"; const PREAMBLE_SIZE : usize = 25; fn validate_number(number_list : &Vec<i64>, index : usize, preamble_size : usize) -> (i64,bool) { for i in index-preamble_size..index { for j in i+1..index { if number_list[i] + number_list[j] == numb...
true
4e68d99c601cb171b225f3e82ac04b0efc16626f
Rust
mnts26/aws-sdk-rust
/sdk/connect/src/model.rs
UTF-8
342,593
2.765625
3
[ "Apache-2.0" ]
permissive
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. /// <p>Contains information about the phone configuration settings for a user.</p> #[non_exhaustive] #[derive(std::clone::Clone, std::cmp::PartialEq)] pub struct UserPhoneConfig { /// <p>The phone type.</p> pub phone_type: std::opt...
true
2f957fb63e32a11e459775c9fe97516bcaad4be4
Rust
iCodeIN/argdata-rust
/src/values/int.rs
UTF-8
924
2.96875
3
[ "BSD-2-Clause" ]
permissive
use crate::{fd, Argdata, IntValue, ReadError, Value}; use std::io; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub struct Int<T> { value: T, } /// Create an argdata value representing an integer (of fixed width, e.g. `i32`). pub fn int<T>(value: T) -> Int<T> where T: Copy, IntValue<'static>...
true
3672e4df5994eeb3d385f67af9570c7637e7ffad
Rust
ischeinkman/tmpas
/src/plugins/loadable/luaplugin.rs
UTF-8
11,620
2.53125
3
[ "MIT" ]
permissive
use super::LuaConfig; use crate::config::Config; use crate::model::{EntryPlugin, ListEntry, RunFlags}; use anyhow::{Context, Error}; use mlua::{self, FromLua, Lua, Value as LuaValue}; use std::cmp::{Eq, PartialEq}; use std::fs; mod api; use api::STATE_KEY; pub struct LuaPlugin { conf: LuaConfig, env: Lua, }...
true
96b04033d643f60a5aef32665df5e2303c37c49d
Rust
emojisum/emojisum
/contrib/emojisum-rs/src/lib.rs
UTF-8
2,640
3.140625
3
[ "MIT" ]
permissive
// Copyright 2018 Stichting Organism // // 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...
true
bdcd782e07300b9b8f24f4b5f17921bdfe84f228
Rust
matix522/uranos
/src/memory/armv8/translation_tables.rs
UTF-8
7,756
2.546875
3
[ "MIT" ]
permissive
use register::{mmio::*, register_bitfields}; #[repr(transparent)] #[derive(Clone, Copy)] pub struct PageRecord(pub u64); #[repr(transparent)] #[derive(Clone, Copy)] pub struct TableRecord(pub u64); impl From<PageRecord> for TableRecord { fn from(val: PageRecord) -> Self { TableRecord(val.0) } } // A ...
true
7a60940c968a191bf2f6a948f95cf885652dd5b9
Rust
ducaale/xh
/src/request_items.rs
UTF-8
26,289
2.71875
3
[ "MIT" ]
permissive
use std::{ borrow::Cow, collections::HashSet, fs::{self, File}, io, path::{Path, PathBuf}, str::FromStr, }; use anyhow::{anyhow, Result}; use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use reqwest::{blocking::multipart, Method}; use crate::cli::BodyType; use crate::nested_json; use...
true
688269ba7311b7557c9c622f0daee15a5b35acbd
Rust
BarePotato/gooey
/widgets/src/checkbox.rs
UTF-8
2,453
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
use gooey_core::{figures::Figure, Callback, Context, Scaled, StyledWidget, Widget}; #[cfg(feature = "gooey-rasterizer")] mod rasterizer; #[cfg(feature = "frontend-browser")] mod browser; pub const LABEL_PADDING: Figure<f32, Scaled> = Figure::new(5.); #[derive(Default, Debug)] pub struct Checkbox { label: String...
true
7ce4461a31fa310ffd09ffef96248a37f09b9a19
Rust
Aimable-rich/breeze
/metrics/src/sender.rs
UTF-8
5,599
2.578125
3
[ "Apache-2.0" ]
permissive
use super::Snapshot; use std::io::{Result, Write}; use std::time::{Duration, Instant}; use tokio::net::UdpSocket; use tokio::sync::mpsc::Receiver; use tokio::time::{interval, Interval}; use futures::ready; pub(crate) struct Sender { rx: Receiver<Snapshot>, addr: String, socket: Option<UdpSocket>, buf...
true
bfbaa83225e56fdf07a4f6289f7a19ce565f7eeb
Rust
dan-sf/advent_of_code
/2018/day9/solution1.rs
UTF-8
1,548
3.25
3
[]
no_license
use std::fs; use std::io::Read; fn play_game(players: i32, last_marble: i32) -> i32 { let mut player_scores: Vec<i32> = vec![0;players as usize]; let mut player_index: usize = 3; let mut circle: Vec<i32> = vec![0, 2, 1]; let mut current: i32 = 1; for marble in 3..(last_marble+1) { if marb...
true
6300324a23793c64d6d63834c190188c0e94b1fe
Rust
korken89/smlang-rs
/examples/named_state_with_reference_data.rs
UTF-8
849
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
//! State data example //! //! An example of using referenced state data with lifetimes together with an action. #![deny(missing_docs)] use smlang::statemachine; /// State data #[derive(PartialEq)] pub struct MyStateData<'a>(&'a u32); statemachine! { name: StatesWithRefData, transitions: { *State1 +...
true
5116942eb526d5da063d98891aa7ca4655a19a0a
Rust
lazear/adventofcode2018
/day01/src/main.rs
UTF-8
1,014
3.359375
3
[ "MIT" ]
permissive
extern crate util; use std::collections::HashSet; use std::io; fn part1(data: &[i64]) -> i64 { data.iter().sum() } fn part2(data: &[i64]) -> i64 { let mut set = HashSet::<i64>::new(); let mut r = 0; loop { for &x in data { if set.contains(&r) { return r; ...
true
324e64fd9a6fbe6cf8d461f8a460cccbdad54769
Rust
gifnksm/mirri-editor
/src/geom.rs
UTF-8
1,022
3.078125
3
[ "MIT" ]
permissive
use std::ops::Range; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)] pub(crate) struct Point { pub(crate) x: usize, pub(crate) y: usize, } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Default)] pub(crate) struct Size { pub(crate) cols: usize, pub(crate) rows: usize, } #[derive(Debug,...
true
c8343d8575d84f3304c373303d11171d5e675d54
Rust
msathis/gstreak
/src/main.rs
UTF-8
1,238
2.6875
3
[]
no_license
use clap::App; use clap::load_yaml; use git2::Repository; use anyhow::{Error, Result}; use crate::commit::Committer; use crate::config::ConfigFile; pub mod commit; pub mod config; pub mod data; fn main() -> Result<(), Error>{ let yaml = load_yaml!("cli.yml"); let matches = App::from_yaml(yaml) .get_...
true
e45f4d7e11709ba9cff6429aefa4ab665e9a676e
Rust
barollet/flyskux
/engine/src/lib.rs
UTF-8
2,269
2.546875
3
[ "MIT" ]
permissive
// Entry point of the Vulkan engine // Initialize Vulkan instance, device and swapchain // The main window is initialized with the swapchain creation #[macro_use] extern crate vulkano; pub mod rendering; mod shaders; use std::sync::Arc; use winit::EventsLoop; use vulkano::device::Device; use vulkano::device::Queu...
true
668e05d6cb33f44840ef10e872f5ab39f0bc7d6e
Rust
terakoya76/puresql
/src/executors/selector.rs
UTF-8
46,120
3.15625
3
[]
no_license
use columns::column::Column; use tables::tuple::Tuple; use tables::field::Field; use parser::statement::*; #[derive(Debug, Clone, PartialEq)] pub enum Selectors { Leaf(Selector), And(Box<Selectors>, Box<Selectors>), Or(Box<Selectors>, Box<Selectors>), } #[derive(Debug, Clone, PartialEq)] pub struct Select...
true
b54f0949e0d2de7370f954dd39dd981a8241fa6e
Rust
InnuIO/actix
/examples/single_bp.rs
UTF-8
1,380
2.78125
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate actix; extern crate futures; extern crate tokio; #[macro_use] extern crate actix_derive; use actix::prelude::*; use futures::Future; #[derive(Message)] struct Toggle; struct Status; impl Message for Status { type Result = bool; } struct MyActor { toggle: bool, } impl Default for MyActor { ...
true
770bd3d31990ba41b8d6198086d1ea5688f463ac
Rust
danylaporte/flock
/flock_derive/src/entity_id.rs
UTF-8
3,963
2.5625
3
[ "MIT", "Apache-2.0" ]
permissive
use inflector::Inflector; use proc_macro2::TokenStream; use quote::quote; use syn::{DeriveInput, Ident, LitStr}; pub fn generate(input: DeriveInput) -> TokenStream { let ident = &input.ident; let mut set = ident.to_string().to_screaming_snake_case(); set.push_str("_SET"); let set = Ident::new(&set, i...
true
c159fcddc36d004808f5189a3b21794988a96495
Rust
atorstling/corsware
/src/lib.rs
UTF-8
20,663
3.09375
3
[ "MIT" ]
permissive
//! # Corsware //! Yet another implementation of the CORS Specification for Iron. extern crate iron; extern crate unicase; #[macro_use] extern crate hyper; pub use unicase::UniCase; use iron::prelude::*; use iron::method::Method; use iron::method::Method::*; use iron::status; //use iron::headers::Origin as OriginHead...
true
fd88c0a85f2d56e327f5f9520fa6e167f0332d36
Rust
verath/advent-of-code-2019
/day1/src/bin/day1_part1.rs
UTF-8
277
2.734375
3
[]
no_license
use std::str::FromStr; fn main() { let input = day1::INPUT.trim_end(); let total_required_fuel = input .split('\n') .map(|s| i64::from_str(s).unwrap()) .map(day1::required_fuel) .sum::<i64>(); println!("{}", total_required_fuel); }
true
a1d144400171438a01b1a83e385ad686666f1768
Rust
sudaraka/udemy-rust
/11-control_flow/src/main.rs
UTF-8
573
3.46875
3
[]
no_license
fn main() { let temp = 35; if 30 < temp { println!("really hot outside"); } else if 10 > temp { println!("really cold!"); } else { println!("temperature is OK"); } let day = if 20 < temp { "sunny" } else { "cloudy" }; println!("today is {}", day); println!("it is {}", if 20...
true
1ede88578467a197141d9515f6314a298006b978
Rust
olback/tradfri-rs
/src/authenticator.rs
UTF-8
1,185
2.578125
3
[]
no_license
use { crate::TradfriConnection, coap::{message::request::Method, CoAPRequest}, serde::Deserialize, std::net::IpAddr, }; #[derive(Debug, Deserialize)] struct AuthResponse { #[serde(rename = "9091")] pre_shared_key: String, #[serde(rename = "9029")] version: String, } pub struct TradfriA...
true
2bf3020e52f58f6abc6b509da24bf1c355c66321
Rust
vmx/forest
/ipld/amt/src/bitmap.rs
UTF-8
2,597
3.296875
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT use encoding::{de, ser, serde_bytes}; use std::{cmp, fmt, u8}; /// Map of bits to indicate which indexes contain values and which are empty #[derive(PartialEq, Eq, Clone, Debug, Default, Copy)] pub struct BitMap { b: u8, } impl ser::...
true
d7826fe19f50a15620c63ddd51324bb646c7662b
Rust
eminence/ipfsrs
/src/multihash.rs
UTF-8
1,468
3.109375
3
[]
no_license
use rust_base58::FromBase58; use rust_base58::ToBase58; use ::bin_to_hex; /// The base58 encoding of a multihash #[derive(Debug)] pub struct MultihashStr(pub String); /// The raw multihash bytes #[derive(Debug)] pub struct MultihashBytes(pub Vec<u8>); /// The hex encoding of a multihash #[derive(Debug)] pub struct ...
true
606213cde6af43ab028283c88666803f3dcd3402
Rust
go717franciswang/exercism
/rust/anagram/src/lib.rs
UTF-8
416
3.109375
3
[]
no_license
pub fn anagrams_for<'a>(s: &str, inputs: &[&'a str]) -> Vec<&'a str> { inputs.iter().cloned().filter(|s2| eq(s, s2)).collect::<Vec<&str>>() } fn eq(s1: &str, s2: &str) -> bool { let mut set1 = s1.to_lowercase().chars().collect::<Vec<char>>(); let mut set2 = s2.to_lowercase().chars().collect::<Vec<char>>();...
true
243cd7712232c4bdeea3bbe6a67195ffe70b3a06
Rust
jfager/d3cap
/src/multicast/src/lib.rs
UTF-8
1,908
2.875
3
[]
no_license
#![feature(mpsc_select)] use std::sync::mpsc::{channel, Sender, SendError, Receiver}; use std::thread; use std::sync::Arc; use std::io; #[derive(Clone)] pub struct Multicast<T:Send+Sync+'static> { msg_tx: Sender<Arc<T>>, dest_tx: Sender<Sender<Arc<T>>> } impl<T:Send+Sync+'static> Multicast<T> { pub fn sp...
true
c24a0c9a58f2b9ea559ae1f9936cb2ebe1232b74
Rust
jasonblog/note
/Rust/code/learn_rust/learn_loop_ref2/src/main.rs
UTF-8
1,743
3.5
4
[]
no_license
#[derive(Debug)] enum List { //Cons(i32, RefCell<Rc<List>>), Cons(i32, RefCell<Weak<List>>), Nil, } impl List { fn tail(&self) -> Option<&RefCell<Weak<List>>> { match self { Cons(_, item) => Some(item), Nil => None, } } } use std::rc::Rc; use std::cell::RefC...
true
92ec30a3d3993677d6210e0034a99548ba4e1172
Rust
rkjk/aoc2020
/aoc9/src/main.rs
UTF-8
3,870
3.28125
3
[]
no_license
use std::collections::{HashMap, HashSet, VecDeque}; use std::fs::File; use std::io::prelude::*; use std::io::{BufReader, Error, ErrorKind}; use std::time::Instant; struct XMAS { order: VecDeque<i64>, dict: HashSet<i64>, } impl XMAS { fn new() -> Self { XMAS { order: VecDeque::new(), ...
true
76b8e7117c3b2c904237acc9a8e1ff219806fe5c
Rust
run-ze/exercism
/rust/sum-of-multiples/src/lib.1.rs
UTF-8
356
3.359375
3
[]
no_license
pub fn sum_of_multiples(limit: u32, factors: &[u32]) -> u32 { let mut sum = 0; for i in 0..limit { if factors.iter().any(|factor| check_factor(i, *factor)) { sum += i } } sum } fn check_factor(num: u32, factor: u32) -> bool { if factor == 0 { num == 0 } else ...
true
8957bcd611f727d4a22874a6129e8de961a94208
Rust
alirizakeles/Rust-Game-of-life
/src/glw/mod.rs
UTF-8
2,087
2.625
3
[ "MIT" ]
permissive
extern crate gl; pub mod shader; pub mod program; pub mod color; pub mod math; pub mod rendertarget; pub mod mesh; pub use self::mesh::{Mesh,MeshBuilder}; pub use self::program::{GraphicsPipeline,PipelineBuilder}; pub use self::math::Vec2; pub use self::color::Color; pub use self::shader::{Shader, Uniform}; pub use s...
true
6dbf13b828ad56ddfcaf5c41c80562af6697b0cb
Rust
little-dude/netlink
/rtnetlink/examples/get_links_thread_builder.rs
UTF-8
3,728
2.578125
3
[ "MIT", "MITNFA" ]
permissive
// SPDX-License-Identifier: MIT use futures::stream::TryStreamExt; use rtnetlink::{ new_connection, packet::rtnl::{ constants::{AF_BRIDGE, RTEXT_FILTER_BRVLAN}, link::nlas::Nla, }, Error, Handle, }; async fn do_it(rt: &tokio::runtime::Runtime) -> Result<(), ()> { env_logger::i...
true
16cd0fde57f38e892558375f21633969661de323
Rust
maghoff/plaintalk
/src/pushgenerator.rs
UTF-8
6,206
3.15625
3
[]
no_license
use std::convert; use std::io::{self, Write}; #[derive(Debug, Clone)] pub enum Error { // Io(io::Error), Unspecified(&'static str), } impl convert::From<io::Error> for Error { fn from(_err: io::Error) -> Error { // Error::Io(err) Error::Unspecified("IO error") } } enum PushGeneratorState { Initial, Generat...
true
fd407a71d75864658a202725de902a19d7170cd0
Rust
iameva/boardbots-rust
/src/main.rs
UTF-8
914
2.6875
3
[]
no_license
#![feature(map_first_last)] mod games; mod quoridor; use self::quoridor::*; use games::Board; use parser::parse_move; use printer::print_quoridor; use std::io::{self, Read, Write}; fn main() { let mut game: Quoridor = games::Board::new(2).unwrap(); let mut quit: bool = false; while !quit { println!("{:?}\n...
true
d1f94c76c2804feac2888d09d861ec6046357964
Rust
y-yagi/til
/leetcode/find-max-consecutive-ones/rust/src/lib.rs
UTF-8
626
3.15625
3
[]
no_license
#[cfg(test)] mod tests { use super::*; #[test] fn is_valid_test() { assert_eq!(Solution::find_max_consecutive_ones(vec![1, 0, 0, 1, 1, 0, 1]), 2); assert_eq!(Solution::find_max_consecutive_ones(vec![1, 1, 0, 1, 1, 1]), 3); } } struct Solution {} use std::cmp::max; impl Solution { ...
true
0b7ff535c46c7bea21f3572523e9d2b5df2429aa
Rust
cdn64/asm-rust
/src/main.rs
UTF-8
1,222
2.796875
3
[]
no_license
mod computer; mod instruction; mod instruction_sequencer; mod label; mod program; mod register; mod value; use computer::*; pub use instruction::*; use instruction_sequencer::*; pub use label::*; use program::*; pub use register::*; pub use value::*; const MAX_EXECUTION_COUNT: i32 = 30; fn main() { let program =...
true
a78c0018aeebd340f6adbee33f627a1a99759d00
Rust
g-s-k/berts
/up/src/model.rs
UTF-8
2,895
3.03125
3
[ "MIT" ]
permissive
use std::collections::HashSet; use std::path::PathBuf; use serde_derive::Serialize; use beet_db::{read_all, Album, Item}; use beet_query::Query; pub struct Model { albums: Vec<Album>, items: Vec<Item>, legal_paths: HashSet<PathBuf>, } #[derive(Serialize)] pub struct Stats { albums: usize, items:...
true
661ab28ba31beabffa57490c0434f020402e33e7
Rust
C-Saunders/days_between
/src/main.rs
UTF-8
2,105
2.859375
3
[ "MIT" ]
permissive
extern crate clap; extern crate days_between; use clap::{App, Arg}; use std::process; use days_between::{calculate, inputs}; fn main() { let args = App::new("DaysBetween") .version("0.6.0") .author("Charlie S. <charlieasaunders@gmail.com>") .about("A command line utility for working with d...
true
02e5b959804f41668fb82b3a61a82aa76eff388e
Rust
hyperium/hyper
/src/common/buf.rs
UTF-8
4,044
3.40625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::VecDeque; use std::io::IoSlice; use bytes::{Buf, BufMut, Bytes, BytesMut}; pub(crate) struct BufList<T> { bufs: VecDeque<T>, } impl<T: Buf> BufList<T> { pub(crate) fn new() -> BufList<T> { BufList { bufs: VecDeque::new(), } } #[inline] pub(crate)...
true
e87a79655f72ff21e537e33ec704fc79bbd4cf8b
Rust
TheArduinoBoy/tk_os
/src/task/keyboard.rs
UTF-8
5,323
2.515625
3
[]
no_license
use super::terminal::parse_command; use crate::logger::{LockedLogger, LOGGER}; use crate::serial_println; use alloc::string::{String, ToString}; use alloc::vec::Vec; use conquer_once::spin::OnceCell; use core::{ pin::Pin, task::{Context, Poll}, }; use crossbeam_queue::ArrayQueue; use futures_util::{ stream:...
true
4427f422e0e9f866e9e67da7fc7127c6226ea691
Rust
cargorust/pyro
/pyro/src/slice.rs
UTF-8
2,973
3.125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Temporary helper module until raw slices `*mut [T]` are on stable, or until `&[T]` is not UB //! anymore for unitialized memory. use std::marker::PhantomData; pub enum Mutable {} pub enum Immutable {} mod sealed { pub trait Sealed {} } pub trait Mutability: sealed::Sealed {} impl sealed::Sealed for Mutable {}...
true
2e957145326dba314cba3412af579e6865c35a18
Rust
ashryanbeats/rust-fibonacci
/src/main.rs
UTF-8
810
3.828125
4
[]
no_license
use std::io; fn main() { let n: u32 = get_input(); let fib_at_n = calc_fib(n); println!("The Fibonacci number at index {} is {}.", n, fib_at_n); } fn get_input() -> u32 { loop { println!("Enter the index of the Fibonacci number would you like (0-index)."); let mut input = String::new(); ...
true
e5d681747f690b03986c982601b6158ec70e37a6
Rust
jockbert/text_block_layout
/src/lib.rs
UTF-8
15,047
3.96875
4
[ "MIT" ]
permissive
use unicode_width::UnicodeWidthStr; /// Represents a block of some width an height containing text. /// /// The key feature of a [Block] is that it enables you to easily specify /// how chunks of text should be positioned in relation to other block, by /// joining blocks together, either vertically or horizontally, an...
true
e3d8ce3459832f64ff261f0e6be7c1791e0bd231
Rust
Enet4/dicom-rs
/core/src/value/primitive.rs
UTF-8
191,507
2.953125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Declaration and implementation of a DICOM primitive value. //! //! See [`PrimitiveValue`](./enum.PrimitiveValue.html). use super::DicomValueType; use crate::header::{HasLength, Length, Tag}; use crate::value::partial::{DateComponent, DicomDate, DicomDateTime, DicomTime, Precision}; use crate::value::person_name::P...
true
f65207ddede738ffd13f88a0ed653be8c7711837
Rust
gabssnake/tree-tags
/src/crawler.rs
UTF-8
14,118
2.625
3
[ "MIT" ]
permissive
use crate::language_registry::LanguageRegistry; use crate::store::{Store, StoreFile}; use ignore::{WalkBuilder, WalkState}; use std::collections::HashMap; use std::fmt; use std::fs::File; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use tree_sitter::{Language, Parser, Point, P...
true
bbd1678851735124e2914b07127abfdecfd025ca
Rust
mmillerxyz/hellcheck
/src/notifiers/telegram.rs
UTF-8
1,534
2.828125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use crate::config::TelegramNotifierConfig; use crate::notifiers::{Notification, Notifier}; use crate::reactor::State; pub struct TelegramNotifier { http_client: ::reqwest::Client, token: String, chat_id: String, } impl TelegramNotifier { pub fn from_config(config: &Tele...
true
2ed33a909147612e5df6dcffd68a24adbf227e0f
Rust
Maniarr/nasmo
/shellcode-parser/src/lexer/token.rs
UTF-8
513
2.609375
3
[]
no_license
#[derive(Debug, Clone, PartialEq)] pub enum Token { Register(String), Assignation(Box<Token>, Box<Token>), Group(Vec<Box<Token>>), Literal(String), Syscall(String, Vec<Box<Token>>) } #[derive(Clone, Debug)] pub struct Instruction { pub mnemonic: String, pub operands: Vec<String>, pub us...
true
28338fbd40b3a23cadaa78d56a56ed2617afcc24
Rust
wujunze/tikv
/src/raftstore/coprocessor/config.rs
UTF-8
3,369
2.640625
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 PingCAP, Inc. // // 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 i...
true
ab7fa48f8772886ea307fbe1d432a6005b18f9cd
Rust
JeanMertz/tower
/tower-ready-cache/tests/ready_cache.rs
UTF-8
2,104
2.671875
3
[ "MIT" ]
permissive
use futures::prelude::*; use tower_ready_cache::{error, ReadyCache}; use tower_test::mock; fn with_task<F: FnOnce() -> U, U>(f: F) -> U { use futures::future::lazy; lazy(|| Ok::<_, ()>(f())).wait().unwrap() } type Req = &'static str; type Mock = mock::Mock<Req, Req>; #[test] fn poll_ready_inner_failure() { ...
true
01fdbc733972f6309db96144b07b3436c4cbca8a
Rust
aguestuser/cryptopals_rust
/src/encoding.rs
UTF-8
1,527
3.171875
3
[]
no_license
extern crate base64; extern crate hex; #[derive(Debug, PartialEq)] pub struct Hex(pub String); #[derive(Debug, PartialEq)] pub struct Base64(pub String); pub fn hex_to_base64(h: Hex) -> Result<Base64, hex::FromHexError> { let hex_bytes = hex::decode(h.0)?; Ok(Base64(base64::encode(&hex_bytes))) } pub fn bas...
true
4c1da245b548649fcf1bb2232d293b9df652d688
Rust
bartekus/jets
/src/core/metadata.rs
UTF-8
3,839
2.78125
3
[]
no_license
use crate::io::Writer; use crate::spi::Result; use bytes::{Buf, BufMut, Bytes}; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::{Arc, RwLock}; pub(crate) struct FieldInfo { id: u32, kind: u8, name: String, } pub(crate)...
true
5b9abbdf5f803b14f66bd40b1bc4e3d99e918fb1
Rust
AMCorvi/allocator
/src/chunk/medium/pools.rs
UTF-8
25,348
2.640625
3
[ "MIT" ]
permissive
/***************************************************** PROJECT : hpc_allocator_rust VERSION : 0.1.0-dev DATE : 05/2018 AUTHOR : Valat Sébastien LICENSE : CeCILL-C *****************************************************/ /// This module implement t...
true
3be98890999c0c1564b1204635cea6bfa2a86a4c
Rust
svip/adventofcode
/2015/day08/day08-2.rs
UTF-8
467
2.796875
3
[ "MIT" ]
permissive
use std::io; use std::io::prelude::*; fn main() { let stdin = io::stdin(); let (mut literal_length, mut encoded_length) = (0i32, 0i32); for l in stdin.lock().lines() { let line = l.unwrap(); literal_length += line.len() as i32; let mut parsed_line = line .replace("\\", "\\\\") .replace("\"", "\\\""); ...
true
83f21a32c1f94f436fa0f5a3aaccc61804655739
Rust
peterschwarz/diesel
/diesel_derives/src/deprecated/belongs_to.rs
UTF-8
1,370
2.609375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use syn::parse::{ParseStream, Result}; use syn::token::Comma; use syn::{parenthesized, Ident, LitStr}; use deprecated::utils::parse_eq_and_lit_str; use parsers::BelongsTo; use util::BELONGS_TO_NOTE; pub fn parse_belongs_to(name: Ident, input: ParseStream) -> Result<BelongsTo> { if input.is_empty() { abort...
true
347da24d48b6d40ef8520642db6cf52e6efd9fb0
Rust
psFried/dgen
/src/interpreter/source.rs
UTF-8
4,457
3.21875
3
[ "MIT" ]
permissive
use failure::Error; use std::borrow::Cow; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use crate::IString; #[derive(Clone, Debug, PartialEq)] pub enum UnreadSource { /// reference to a file on the local filesystem. The filename will become the module name File(PathBuf), /// source is held en...
true
864f4c9bc9de0fec26ba10c2b819cec65a5d9c9e
Rust
nicholastmosher/ifad
/ifad-core/src/index.rs
UTF-8
12,406
3.140625
3
[]
no_license
use std::collections::{HashMap, HashSet}; use crate::{Aspect, AnnotationStatus, Gene, Annotation}; pub type GeneIndex<'a> = HashMap<Aspect, HashMap<AnnotationStatus, HashSet<&'a Gene<'a>>>>; pub type AnnoIndex<'a, 'b> = HashMap<String, (&'a Gene<'a>, HashSet<&'b Annotation<'b>>)>; #[derive(Debug, Eq, PartialEq)] pub ...
true
4f64beae57ca53d397b64d61027a3257c962e37c
Rust
yjv/rust_cache
/src/hash_map.rs
UTF-8
2,717
3.453125
3
[]
no_license
extern crate time; use self::time::Duration; use std::collections::HashMap; use super::common::CacheEntry; use super::common::Cache; use super::common::Cacheable; use std::any::Any; pub struct HashMapCache { hash_map: HashMap<String, CacheEntry> } #[derive(Debug)] pub enum Error { CacheSerializationFailure(Bo...
true
e9e524c2d0496e5571db43c1cced739de8179b18
Rust
jvo203/fits_web_ql
/src/molecule.rs
UTF-8
1,713
2.9375
3
[ "MIT", "LicenseRef-scancode-free-unknown" ]
permissive
use rusqlite; use serde_json; #[derive(Debug)] pub struct Molecule { species: String, name: String, frequency: f64, qn: String, cdms_intensity: f64, lovas_intensity: f64, e_l: f64, linelist: String, } impl Molecule { pub fn from_sqlite_row(row: &rusqlite::Row) -> Molecule { ...
true
15efe11ad2839658f446ea9e5d0b2cfdb1244354
Rust
TBNRItzDogeORG/cache
/in-memory/src/repository/emoji.rs
UTF-8
5,121
2.921875
3
[ "ISC" ]
permissive
use crate::{config::EntityType, InMemoryBackend, InMemoryBackendError}; use futures_util::{ future::{self, FutureExt}, stream::{self, StreamExt}, }; use rarity_cache::{ entity::{ guild::{EmojiEntity, EmojiRepository, GuildEntity, RoleEntity}, user::UserEntity, Entity, }, repo...
true
e48666347dff0f1123501fa6adb37468832b1599
Rust
iximeow/reifenfeuerd
/src/commands/auth.rs
UTF-8
7,275
2.6875
3
[ "MIT" ]
permissive
use display::DisplayInfo; use tw; use std; use std::collections::HashMap; use hyper; use ::Queryer; use commands::Command; static FAV_TWEET_URL: &str = "https://api.twitter.com/1.1/favorites/create.json"; static UNFAV_TWEET_URL: &str = "https://api.twitter.com/1.1/favorites/destroy.json"; pub static AUTH: Command = ...
true
5a5ec16671b45304ce307fb4da7a8590f31e9776
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_1201/src/main.rs
UTF-8
137
2.765625
3
[ "MIT" ]
permissive
use leetcode_1201::solution1::Solution; fn main() { let result = Solution::nth_ugly_number(4, 2, 3, 4); println!("{result}"); }
true
e13dcaa352c0f6b177193802c18f34ddcfb5b072
Rust
ffwff/iro
/src/ssa/isa/mod.rs
UTF-8
26,176
2.65625
3
[ "MIT" ]
permissive
use crate::ast::PathVec; use crate::utils::uniquerc::UniqueRc; use fnv::FnvHashMap; use smallvec::SmallVec; use std::collections::BTreeSet; use std::convert::TryInto; use std::hash::Hash; use std::rc::Rc; mod types; pub use types::*; mod print; #[derive(Debug, Clone, PartialEq)] pub enum IntrinsicType { None, ...
true
57233e112aab26dadc4d7f500a9c442eb6a415d4
Rust
jacklund/aws-instance
/src/commands/ssh.rs
UTF-8
2,065
2.734375
3
[]
no_license
use crate::{cmdline::OsNames, util, AwsInstanceError, Result}; use lazy_static::lazy_static; use rusoto_ec2::Ec2Client; use std::collections::HashMap; use std::process::{exit, Command}; lazy_static! { static ref USERNAME_MAP: HashMap<OsNames, &'static str> = { let mut m = HashMap::new(); m.insert(O...
true
84998c282f06ae1c858779483df806ec26b011ad
Rust
tianchengli/flatdata
/flatdata-rs/lib/src/helper.rs
UTF-8
2,648
3.734375
4
[ "Apache-2.0" ]
permissive
//! Module containing helper traits and macros. /// Helper trait defining a constant for an integer type whether it is signed. pub trait Int { /// `true` if the implementing type is signed, otherwise `false`. const IS_SIGNED: bool; } impl Int for bool { const IS_SIGNED: bool = false; } impl Int for i8 { ...
true
af2fc06b78584c4a275b41a614bde6b575bf3e9a
Rust
luctius/rl_tools
/rl_utils/src/map.rs
UTF-8
7,424
3.3125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::fmt::{Debug, Display, Formatter, Result}; use std::ops::{Index, IndexMut}; use crate::{Area, Coord}; #[derive(Eq, PartialEq, Hash, Debug, Copy, Clone, Ord, PartialOrd)] pub enum MovementCost { Possible(usize), Impossible, } pub trait MapObject: PartialEq + Clone + Debug { fn is_transparent(&self...
true
57294c9971f62805c1619575bebd4a6028094afc
Rust
finalfusion/finalfusion-inspector
/src/models/metadata_model.rs
UTF-8
1,931
2.5625
3
[ "BlueOak-1.0.0" ]
permissive
use std::cell::RefCell; use std::rc::Rc; use finalfusion::prelude::*; use gtk::prelude::*; use gtk::ListStore; use toml::Value; use crate::embeddings_ext::EmbeddingsExt; use crate::models::{EmbeddingsModel, WordStatus}; pub struct MetadataModel { embeddings: RefCell<Rc<Embeddings<VocabWrap, StorageViewWrap>>>, ...
true
40f700d51123acec7f3d8180bec2b26d656bf7e2
Rust
pettan0818/book_algo_rust
/ex3-5/src/main.rs
UTF-8
1,575
3.21875
3
[]
no_license
fn main() { let n: i32 = 5; let w = 25; let n_vec: Vec<i32> = vec![10, 5, 3, 8, 7]; assert_eq!(n, (n_vec.len() as i32)); // lenはusizeを返すのでキャスト println!("Input Info\nN:{}, W:{}, NVec: {:?}", n, w, n_vec); let res: bool = algo(n, w, n_vec); if !res { println!("Not Found On this condt...
true
badd16c72b7ae4ea970fd08801f471ccd064a80c
Rust
NorabX/rustils
/src/parse/int.rs
UTF-8
11,642
3.515625
4
[ "MIT" ]
permissive
use error::ParseError; use RoundingMode; use RoundingMode::*; pub trait ToI32 { fn to_i32_res(self) -> ParseResultI32; fn to_i32(self) -> i32; } pub trait ToI32RM { fn to_i32_rm_res(self, rm: RoundingMode) -> ParseResultI32; fn to_i32_rm(self, rm: RoundingMode) -> i...
true
ff7fdc116d4a1cd5c388fb39f217ff17d4ab671d
Rust
sam-wright/Advent-of-Code
/2020/day15/src/lib.rs
UTF-8
2,432
3.71875
4
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::Read; pub fn read_input(filename: &str) -> Vec<usize> { let mut contents = String::new(); let mut file = File::open(filename).unwrap(); file.read_to_string(&mut contents).unwrap(); let collection: Vec<usize> = contents.split(",").map(|x| x...
true
c7a2dbf3be3dca9c92d6ec20775137cf55c9ca80
Rust
andelf/rust-rocks
/src/comparator.rs
UTF-8
8,156
3.015625
3
[ "Apache-2.0" ]
permissive
//! A Comparator object provides a total order across slices that are //! used as keys in an sstable or a database. use std::mem; use std::slice; use std::os::raw::{c_int, c_char}; use std::cmp::Ordering; use std::str; use rocks_sys as ll; /// A Comparator object provides a total order across slices that are /// use...
true
00ae31c62433d3315cf565330f9a1cd51eba4e28
Rust
ipetkov/conch-runtime
/conch-runtime/src/spawn/builtin/pwd.rs
UTF-8
2,754
2.8125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::generate_and_print_output; use crate::env::{ AsyncIoEnvironment, FileDescEnvironment, StringWrapper, WorkingDirectoryEnvironment, }; use crate::path::{has_dot_components, NormalizationError, NormalizedPath}; use crate::spawn::ExitStatus; use clap::{App, AppSettings, Arg}; use futures_util::future::BoxFut...
true
fe0b395ce6e189a6e0a72540aadef716365e7a94
Rust
arthurDz/algorithm-studies
/rust/next_permutation.rs
UTF-8
864
2.78125
3
[]
no_license
impl Solution { pub fn next_permutation(nums: &mut Vec<i32>) { if nums.len() == 1 { return; } let length = nums.len(); for i in 1..length { if nums[length - i - 1] < nums[length - 1] { let mut j = length - 1; while j > len...
true
225033a7d870aa9ac18d0172cafab5c4c14edcbd
Rust
FSMaxB/rust-genealogy
/genealogy/src/genealogy.rs
UTF-8
20,475
2.578125
3
[]
no_license
use crate::genealogist::typed_relation::TypedRelation; use crate::genealogist::Genealogist; use crate::genealogy::relation::Relation; use crate::genealogy::weights::Weights; use crate::post::Post; use genealogy_java_apis::collection::Collection; use genealogy_java_apis::exception::Exception; use genealogy_java_apis::li...
true
5b34c5388125f4444b211488533de0d7a629a728
Rust
stanbar/mini-keccak
/src/core.rs
UTF-8
4,867
2.96875
3
[]
no_license
use crate::matrix::Matrix; use std::convert::TryInto; fn to_array(hash: Vec<u16>) -> [u8; 16] { let flattened: Vec<u8> = hash .iter() .map(|x| vec![((x & 0xFF00) >> 8) as u8, (x & 0x00FF) as u8]) .flatten() .collect(); flattened.try_into().expect("Could not map vec to array") } ...
true
97f71d785bbbcf7a322e5cd3fef77705e6eacec9
Rust
jean-airoldie/libzmq-rs
/libzmq/src/group.rs
UTF-8
8,195
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Message groups used by the `Radio` and `Dish` sockets. use crate::prelude::TryFrom; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use thiserror::Error; use std::{ borrow::{Borrow, Cow, ToOwned}, ffi::{CStr, CString}, fmt, ops, option, str, }; /// The maximum allowed number of charac...
true
50e80248e0a6b23f968ff5939532f83eab7cdd63
Rust
Link87/Labo
/src/washer.rs
UTF-8
3,890
3.359375
3
[]
no_license
use futures::unsync::oneshot::Sender; use telegram_bot_fork::UserId; use std::mem; use std::time::{Duration, Instant}; use crate::timer::Timer; /// A washer implemented as a state machine. #[derive(Debug)] pub struct Washer { state: WasherState, } /// The states a washer can be in. #[derive(Debug)] pub enum Was...
true
758667ac0eabf201bf0c34b4d3d60dca3d405c88
Rust
EFanZh/LeetCode
/src/problem_0225_implement_stack_using_queues/slow_push.rs
UTF-8
1,256
3.171875
3
[]
no_license
// ------------------------------------------------------ snip ------------------------------------------------------ // use std::collections::VecDeque; pub struct MyStack { q: VecDeque<i32>, } impl MyStack { fn new() -> Self { Self { q: VecDeque::new() } } fn push(&mut self, x: i32) { ...
true
d2f07074c2fe8a3a53fe21a19d975bc2c9d57d7f
Rust
ellipticoin/moonshined
/ellipticoin_types/src/lib.rs
UTF-8
4,596
2.90625
3
[]
no_license
pub mod db; pub mod traits; pub use db::Db; use std::ops::{BitXor, Shr}; pub const ADDRESS_LENGTH: usize = 20; use hex; use num_bigint::{BigInt, BigUint}; use serde::{Deserialize, Serialize}; use std::{ array::TryFromSliceError, convert::{TryFrom, TryInto}, fmt::{self, Display, Formatter}, }; #[derive( ...
true
3cabeda1ff3c3d4019e7933a7895f537a93458ad
Rust
ramsayleung/rspotify
/rspotify-model/src/search.rs
UTF-8
1,655
2.640625
3
[ "MIT" ]
permissive
//! All object related to search use serde::{Deserialize, Serialize}; use crate::{ FullArtist, FullTrack, Page, SimplifiedAlbum, SimplifiedEpisode, SimplifiedPlaylist, SimplifiedShow, }; /// Search for playlists #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct SearchPlaylists { p...
true
29e14d9c9b4e18e673a5de7953e2d42136536855
Rust
psyomn/programming-exercise-solutions
/archive/challenge-0019/holmes-words-rs/src/main.rs
UTF-8
1,076
3.15625
3
[]
no_license
extern crate regex; use regex::Regex; use std::fs::File; use std::io::Read; use std::env; fn main() -> () { let args: Vec<String> = env::args().collect(); let data_path: String = match args.iter().nth(1) { Some(v) => v.clone(), None => panic!("Need a data path"), }; println!("Using p...
true
c22d3d3617c4e7b3a10fd94fa43d04b337f3a3a8
Rust
AndrewMendezLacambra/rust-programming-contest-solutions
/aoj/grl_6_b.rs
UTF-8
4,855
2.953125
3
[]
no_license
fn main() { let s = std::io::stdin(); let mut sc = Scanner { reader: s.lock() }; let v: usize = sc.read(); let e: usize = sc.read(); let f: i64 = sc.read(); let mut solver = primal_dual::MinimumCostFlowSolver::new(v); for _ in 0..e { let u: usize = sc.read(); let v: usize = ...
true
d66e8c4f4acebe15e6033f12375ff167fb523fa7
Rust
vain0x/languages
/lambda-calc-rs/lc-v1/src/token/token_data.rs
UTF-8
585
2.90625
3
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::token_kind::TokenKind; use std::fmt::{self, Debug}; pub(crate) struct TokenData { pub(crate) text: String, pub(crate) kind: TokenKind, pub(crate) len: usize, } impl Debug for TokenData { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.kind { TokenKi...
true
488a7f96ab40109a648631b263b68ff94241201f
Rust
shmutalov/WSBot
/src/btag.rs
UTF-8
1,788
2.90625
3
[]
no_license
extern crate discord; extern crate reqwest; extern crate regex; use std::io::Read; use regex::Regex; use discord::Discord; use discord::model::Event; struct Player { discord: str, name: str, } //Ловим и вырезаем батл таг fn slicebtag() { let btag_reg = Regex::new(r"^!wsreg\s+([0-9\p{Cyrilli...
true