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
8b143a1590c19bf2346ddbeade83c2552381032e
Rust
ArthurDeveloper/triangulo-rust
/src/main.rs
UTF-8
2,353
2.546875
3
[ "MIT" ]
permissive
#![allow(unused_variables)] use glium::{glutin, Display, Surface, Program, VertexBuffer, texture::pixel_buffer::PixelBuffer, index}; use glutin::{window::WindowBuilder, ContextBuilder, event_loop::{EventLoop, ControlFlow}, event::{Event, WindowEvent, StartCause}}; pub mod file_reader; pub mod...
true
9de987e65c9aac48deb94aedb638e765f26d83b3
Rust
FauxFaux/argon2min
/benches/constant_eq.rs
UTF-8
638
2.53125
3
[ "MIT" ]
permissive
// demonstrates (to some degree of certainty modulo process scheduling) that the // run time of `verifier::constant_eq` is independent of its inputs. #![feature(test)] extern crate argon2min; extern crate test; use argon2min::verifier::constant_eq; #[bench] fn param_are_equal(b: &mut test::Bencher) { let lhs = (0...
true
dbd59281a59f564e1f6c44709fda5fb4c20482c3
Rust
ustulation/rust-ffi
/c_wrapper-rust_wrapper-rust/rust-backend/src/lib.rs
UTF-8
194
2.84375
3
[]
no_license
pub fn free_function(value: i32) -> i32 { value / 3 } #[cfg(test)] mod test { use super::*; #[test] fn free_function_test() { assert_eq!(free_function(27), 9); } }
true
d2f87c9f56875b18fa512bab78ee9fae4ff51a50
Rust
UkolovaOlga/rust-lnpbp
/src/rgb/schema/script.rs
UTF-8
3,328
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// LNP/BP Rust Library // Written in 2020 by // Dr. Maxim Orlovsky <orlovsky@pandoracore.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warra...
true
06622421b77fe2edfe547afdfde6432adcaaa5ef
Rust
tomocy/rust-cookbook
/meter/src/main.rs
UTF-8
504
3.546875
4
[]
no_license
use std::ops; fn main() {} #[derive(Debug, PartialEq)] struct Meters(f64); impl ops::Add<Centimeters> for Meters { type Output = Meters; fn add(self, other: Centimeters) -> Self::Output { Meters((self.0 * 100.0 + other.0) / 100.0) } } struct Centimeters(f64); #[cfg(test)] mod tests { use s...
true
9343a68912e9985cd4bcf7e956dc6c5ba529121a
Rust
badboy/signify-rs
/libsignify/examples/basic.rs
UTF-8
1,642
3.21875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Basic example that shows how to verify a signature of some file. //! //! You could, for example, replace the file reading with a HTTP client. use libsignify::{Codeable, PublicKey, Signature}; use std::{fs, path::Path}; fn main() -> Result<(), Box<dyn std::error::Error>> { println!("verifying signature of messa...
true
64804c355b80ed03a85b9eff3190d8d74f1aeaf5
Rust
grogers0/advent_of_code
/2021/day12/src/main.rs
UTF-8
5,307
2.71875
3
[ "MIT" ]
permissive
use std::collections::{BTreeSet, HashSet, VecDeque}; use std::io::{self, Read}; fn parse(puzzle_input: &str) -> (Vec<String>, Vec<Vec<usize>>) { let mut cave_names = BTreeSet::new(); for line in puzzle_input.lines() { for name in line.split("-") { cave_names.insert(name.to_string()); ...
true
e8605ecaae41e79936c2ab1b759cc733e7704eaf
Rust
nus-cs4215/sourceror
/lib-backend-wasm/src/opt_var_conv.rs
UTF-8
1,900
2.90625
3
[]
no_license
use crate::var_conv::*; pub fn encode_opt_vartype(ir_opt_vartype: Option<ir::VarType>) -> &'static [wasmgen::ValType] { match ir_opt_vartype { Some(ir_vartype) => encode_vartype(ir_vartype), None => &[], } } // Like encode_widening_operation(), but handles unreachable cases. // Used when widen...
true
63b81d50d4a3b0164b539bab7b78e31241bd192f
Rust
aJns/aoc2020
/d04/src/main.rs
UTF-8
5,647
2.828125
3
[]
no_license
#[macro_use] extern crate lazy_static; extern crate regex; use std::io::{self, Read, Write}; use std::iter::Iterator; use std::str::{Lines, FromStr}; use std::string::ParseError; use std::collections::HashMap; use regex::{Regex, RegexSet}; fn parse_passports(lines: Lines) -> Vec<String> { let mut passports: Vec...
true
abb6f57068e9ccf145d6e02466694c4d1a7c2ba6
Rust
stepht/devrc
/src/devrc_log.rs
UTF-8
1,344
3.078125
3
[ "MIT" ]
permissive
use serde::Deserialize; use crate::workshop::Designer; #[derive(Debug, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord)] pub enum LogLevel { #[serde(rename = "off")] Off = 0, // Quiet mode #[serde(rename = "error")] Error = 1, #[serde(rename = "info")] Info = 2, // Show tasks commands ...
true
9dbb7ee9b03b04106e72ee11340ee3d79ab996a6
Rust
hreikin/fast-ssh
/src/config.rs
UTF-8
1,590
2.953125
3
[ "MIT" ]
permissive
use crate::Theme; use anyhow::Result; use serde::Deserialize; use std::fs; #[derive(Debug, Clone, Deserialize)] pub struct Config { pub theme: Theme, } pub fn resolve_config() -> Config { let mut config = Config { theme: Theme::default(), }; if let Ok(parsed_config) = parse_user_config() { ...
true
371224e672e3c9c67dd21b357f9b68e7c27190d4
Rust
justizin/rust-syseng
/integ-test-example/src/lib.rs
UTF-8
412
3.40625
3
[]
no_license
//! This is a library that contains functions related to //! dealing with processes, //! and makes these tasks more convenient use std::process; /// This function gets the process ID of the current /// executable. It returns a non-zero number /// ``` /// fn get_id() { /// let x = integ_test_example::get_process_id(...
true
71b9c0a511daa533d40423e9f78e93d695a6fb47
Rust
wtfiscrq/octocrab
/src/api/pulls.rs
UTF-8
10,882
2.734375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! The pull request API. mod comment; mod create; mod list; mod merge; use snafu::ResultExt; use crate::{Octocrab, Page}; pub use self::{create::CreatePullRequestBuilder, list::ListPullRequestsBuilder}; /// A client to GitHub's pull request API. /// /// Created with [`Octocrab::pulls`]. pub struct PullRequestHand...
true
e8f232930e8158d7485a5f9b8bd894e5d2a1c457
Rust
mx00s/syntastic
/src/ast/errors.rs
UTF-8
2,556
3.3125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use super::Ast; use std::{error::Error, fmt}; /// Error matching [Ast] with sort expected by [Operator](`super::Operator`) #[derive(Debug, PartialEq)] pub struct ArgumentSortMismatch<V, O, S> { /// Operand position pub index: usize, /// Expected sort pub parameter: S, /// Actual [Ast] operand ...
true
6686d28f56ef06311d06bc610633e91267bb5341
Rust
RossMeikleham/Super-CHIP8-Rust
/src/system/io/sdl_io.rs
UTF-8
1,627
3.109375
3
[ "MIT" ]
permissive
extern crate sdl; pub struct IOImpl { key_set: [char; 16] } fn index(keyset:[char; 16], key:char) -> Option<u8> { for i in keyset.iter() { if *i == key { return Some(*i as u8); } } None } impl IOImpl { pub fn new(key_set: [char; 16]) -> IOImpl { ...
true
00575d77155fa4bb679195a3f1148061ad6a115e
Rust
nojima/windows-rs-game-of-life
/src/wrapper/timer.rs
UTF-8
508
2.625
3
[]
no_license
use crate::wrapper::window::Window; use bindings::Windows::Win32::UI::WindowsAndMessaging::*; pub struct Timer { id: usize, } impl Timer { pub fn set(window: &Window, id: usize, interval_millis: u32) -> anyhow::Result<Timer> { let ret = unsafe { SetTimer(window.hwnd(), id, interval_millis, None) }; ...
true
3fd9f1fc45de222476f1cec969b3ff77fe6404c9
Rust
Elementalish1/learning_rust
/specific_things/matches/src/main.rs
UTF-8
323
3.984375
4
[]
no_license
fn main() { for i in 1..22 { disp_num(i); } } fn disp_num(number: i32) { println!("Tell me about {}", number); match number { 1 => println!("One!"), 2 | 3 | 4 | 5 | 6 | 7 => println!("2 to 7"), 7..=19 => println!("8 to 19"), _ => println!("anything else!") }...
true
5fb4f732869f8e01042f8d2ba5ef7d30e141965a
Rust
plaidman/advent
/2018-rust/src/one/part_two.rs
UTF-8
417
3.015625
3
[]
no_license
use std::collections::HashMap; pub fn run(lines: Vec<String>) { let mut sum = 0; let mut tracker = HashMap::new(); let mut current = 0; loop { sum += lines[current].parse::<i32>().unwrap(); if tracker.contains_key(&sum) { break; } tracker.insert(sum, true)...
true
9f15795d7d1881df7dcd1e0247464ce5d3615236
Rust
nomadeel/aoc_2019
/src/grid.rs
UTF-8
3,035
3.375
3
[]
no_license
use std::convert::TryFrom; use std::{ io::{BufRead, BufReader, Read}, iter::{repeat, FromIterator}, f64::consts::PI, }; use num::integer::gcd; #[derive(Clone)] pub struct Grid<T> { cells: Vec<T>, pub w: usize, pub h: usize, } impl<T> Grid<T> where T: Clone + Default + TryFrom<u8>, { pu...
true
ecf3e494b5ca493437d3c53949095f763cde4264
Rust
jo12bar/rust-exe-packer
/elk/elk/src/process.rs
UTF-8
38,842
3.21875
3
[]
no_license
//! Defines a dependency graph encompassing the whole program. use crate::name::Name; use anyhow::Context; use custom_debug_derive::Debug as CustomDebug; use enumflags2::BitFlags; use mmap::{MapOption, MemoryMap}; use multimap::MultiMap; use std::{ cmp::{max, min}, collections::HashMap, ffi::CString, i...
true
31f96f8bb9fb71301fd7f0f473fac1cca9b95dbb
Rust
Satellite-GPO/simulation-server
/url_query/src/lib.rs
UTF-8
1,990
3.625
4
[ "MIT" ]
permissive
use std::{ ops::Index, str::FromStr }; use hashbrown::HashMap; pub struct UrlQuery(HashMap<String, Option<String>>); impl UrlQuery { pub fn from(query_str: &str) -> Self { Self(query_str.split('&') .filter(|x| x != &"") .map(|expr| { let mut values = expr.s...
true
7f2e3ff7828c117c91098e24aa9119e2f54e56f4
Rust
gatoWololo/adventOfCode2020
/src/day1/main.rs
UTF-8
1,820
3.46875
3
[]
no_license
use anyhow::Result; use std::collections::HashSet; fn main() -> Result<()> { let input = std::fs::read_to_string("./src/day1/input.txt")?; let input = input.split_ascii_whitespace(); let hs: HashSet<i32> = input.map(|s| s.parse::<i32>().unwrap()).collect(); let (e1, e2) = find_two_entries(&hs, 2020).u...
true
7dc2f4e567da1c159d5d38ace400d8f5385ed4e1
Rust
woodgear/watch-the-wall
/src/main.rs
UTF-8
2,014
2.859375
3
[]
no_license
use std::time::{Duration,Instant}; use reqwest; use chrono::prelude::*; #[macro_use] extern crate clap; #[derive(Clap,Debug)] #[clap(version = "0.1", author = "废物点心")] struct Opts { #[clap(short = "u", long = "url", default_value = "http://www.google.com")] url:String, #[clap(short = "p", long = "proxy")] ...
true
2b84472d9e13016c9afc63cf81289234146d5eb0
Rust
rkr35/exercism-rust-track-solutions
/atbash-cipher/src/lib.rs
UTF-8
938
3.1875
3
[ "MIT" ]
permissive
#![warn(clippy::pedantic)] fn encode_using_group_size(plain: &str, group_size: Option<usize>) -> String { let group_size = group_size.unwrap_or(std::usize::MAX); let mut s = plain .bytes() .filter_map(|c| if c.is_ascii_alphabetic() { Some(char::from(b'a' + b'z' - c.to_ascii_l...
true
26bb44725d6334fa7535bde02cea94b0b6c82e9d
Rust
nownabe-misc/iridium
/src/assembler/mod.rs
UTF-8
8,081
2.71875
3
[]
no_license
pub mod assembler_errors; pub mod opcode_parsers; pub mod operand_parsers; pub mod register_parsers; pub mod instruction_parsers; pub mod program_parsers; pub mod label_parsers; pub mod directive_parsers; pub mod symbols; use nom::types::CompleteStr; use assembler::assembler_errors::AssemblerError; use assembler::ins...
true
4ef777137ee5fdc898e673e95b3694a914a8dca3
Rust
rayon-rs/rayon
/src/iter/try_reduce_with.rs
UTF-8
3,410
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::plumbing::*; use super::ParallelIterator; use super::Try; use std::ops::ControlFlow::{self, Break, Continue}; use std::sync::atomic::{AtomicBool, Ordering}; pub(super) fn try_reduce_with<PI, R, T>(pi: PI, reduce_op: R) -> Option<T> where PI: ParallelIterator<Item = T>, R: Fn(T::Output, T::Output) -...
true
df096f2d0ac74115eb9278e62d4e7573c960a114
Rust
atenjin/redspot-ink-example2
/contracts/miner-erc20/lib.rs
UTF-8
5,375
3.171875
3
[]
no_license
#![cfg_attr(not(feature = "std"), no_std)] use ink_prelude::string::String; pub use erc20_ownable::Erc20Minable; #[metis_lang::contract] mod erc20_ownable { use super::String; use erc20::Result; use metis_erc20 as erc20; use metis_lang::import; #[cfg(not(feature = "ink-as-dependency"))] use m...
true
e2bbb9e1f46b3cfd0d0e3ea6705e68e6dbc33515
Rust
lucafanselau/city-builder
/crates/gfx/src/compat/from_hal.rs
UTF-8
2,591
2.859375
3
[]
no_license
use gfx_hal::format::Format; use render::util::format::TextureFormat; pub trait FromHalType { type Target; fn convert(self) -> Result<Self::Target, String>; } impl FromHalType for Format { type Target = TextureFormat; fn convert(self) -> Result<Self::Target, String> { match self { ...
true
951a69e3d23b01219230f7518c49daa449863010
Rust
netvl/xml-rs
/src/reader/parser/inside_reference.rs
UTF-8
3,417
3.015625
3
[ "MIT" ]
permissive
use crate::reader::error::SyntaxError; use std::char; use crate::common::{is_name_char, is_name_start_char, is_whitespace_char}; use crate::reader::lexer::Token; use super::{PullParser, Result, State}; impl PullParser { pub fn inside_reference(&mut self, t: Token) -> Option<Result> { match t { ...
true
4860b9d1c1b5ad81c0b118d29e30316d8c535fb7
Rust
tov/min-max-heap-rs
/src/hole.rs
UTF-8
7,767
3.28125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{mem, ptr}; use std::mem::ManuallyDrop; use super::index::*; // From std::collections::BinaryHeap: pub struct Hole<'a, T: 'a> { data: &'a mut [T], elt: ManuallyDrop<T>, pos: usize, } enum Generation { Child, Grandchild, } impl<'a, T> Hole<'a, T> { /// Create a new Hole at index `pos...
true
b614e97c2a08c8cc69aec460fff70732a18ab6e0
Rust
jalhadi/herd-api
/src/webhook_publisher.rs
UTF-8
3,859
2.875
3
[]
no_license
use actix; use actix::prelude::*; use std::time::{Duration}; use std::collections::{HashMap, HashSet}; use futures::future::{join_all}; use crate::db; use crate::db::DbPool; use crate::publisher::{PublishMessage}; const WEBHOOK_UPDATE_INTERVAL: Duration = Duration::from_secs(60); pub struct WebhookPublisher { p...
true
2dacfb76d5256e285b75b3cc234536c0e3b30083
Rust
k-hamada/exercism
/rust/robot-simulator/src/lib.rs
UTF-8
1,864
3.78125
4
[]
no_license
#[derive(PartialEq, Debug)] pub enum Direction { North, East, South, West, } pub struct Robot { x: isize, y: isize, d: Direction, } impl Robot { pub fn new(x: isize, y: isize, d: Direction) -> Self { Robot { x, y, d } } pub fn turn_right(self) -> Self { let d =...
true
11a5df74bd9135eac3337bfff7259bb45bc6f133
Rust
AThilenius/filament-rs
/filament_high_level/src/components/mesh_bytes_load_request.rs
UTF-8
1,115
2.75
3
[ "MIT" ]
permissive
use crate::components::mesh::{VertexAttributeDefinition, VertexDefinition}; pub struct MeshBytesLoadRequest { pub(crate) size_of_t: usize, pub(crate) data: Option<(Vec<u8>, Vec<u16>)>, pub(crate) definitions: Vec<VertexAttributeDefinition>, } impl MeshBytesLoadRequest { pub fn new<T>(vertices: Vec<T>,...
true
863105fbab81f1afaa41058c2eb0c0a913cb7282
Rust
3Hren/msgpack-rust
/rmp-serde/tests/encode.rs
UTF-8
8,482
2.734375
3
[ "MIT" ]
permissive
extern crate rmp_serde as rmps; use std::io::Cursor; use serde::Serialize; use crate::rmps::encode::{self, Error}; use crate::rmps::{Raw, RawRef, Serializer}; #[test] fn pass_null() { let mut buf = [0x00]; let val = (); val.serialize(&mut Serializer::new(&mut &mut buf[..])).ok().unwrap(); assert_e...
true
1a25f94c096d800d81253aaeb75b1cccb9efb138
Rust
GameRuiner/adventofcode
/src/day7.rs
UTF-8
5,615
3.140625
3
[]
no_license
use std::collections::HashSet; use std::collections::HashMap; #[allow(dead_code)] pub fn handy_haversacks(rules: &[String]) -> usize { let mut colors = HashSet::<String>::new(); let mut find_colors = Vec::<String>::new(); find_colors.push("shiny gold".to_string()); let mut temp_candidats = find_col...
true
cb2ecb6574c0eca72a299941b16bac185bb01543
Rust
adbjesus/moco_abm
/src/error.rs
UTF-8
849
3.1875
3
[ "MIT" ]
permissive
#[derive(Debug)] pub enum ErrorKind { EmptyApproximation, EmptyRegion, UnsortedSegment, UnsortedSegments, WrongDimensions, } #[derive(Debug)] pub struct Error { pub kind: ErrorKind, pub message: Option<String>, } impl Error { pub fn new(kind: ErrorKind) -> Self { Error { ...
true
ab158716cc143d61fb6afe489decd5ae9644afcc
Rust
ldcduc/moon
/components/painting/src/primitive/rect.rs
UTF-8
593
2.875
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct Rect { pub x: f32, pub y: f32, pub width: f32, pub height: f32, } impl Rect { pub fn new(x: f32, y: f32, w: f32, h: f32) -> Self { Self { x, y, width: w, ...
true
b72dd51814575e83e1f775cde8bb747ba58bfdce
Rust
Liby99/geometry-sketchpad
/core/lib/src/components/styles/circle_style.rs
UTF-8
428
2.71875
3
[]
no_license
use super::LineStyle; use crate::math::*; use specs::prelude::*; #[derive(Debug, Copy, Clone)] pub struct CircleStyle { pub fill: Color, pub border: LineStyle, } impl Component for CircleStyle { type Storage = FlaggedStorage<Self, VecStorage<Self>>; } impl CircleStyle { pub fn apply_alpha(self, a: f32) -> Se...
true
9c9abd3adb7517d67d2857489dca77f9673ea065
Rust
BooleanCat/safely
/libsafely/src/config/linux/syscall_arg.rs
UTF-8
1,284
3.4375
3
[]
no_license
use serde::{Deserialize, Serialize}; #[serde(rename_all = "camelCase")] #[derive(Serialize, Deserialize, Debug)] pub struct SyscallArg { pub index: u32, pub value: u64, #[serde(skip_serializing_if = "Option::is_none")] pub value_two: Option<u64>, pub op: String, } impl SyscallArg { pub fn ne...
true
6997f448cb34205421a741a1c62c8a8d222b63a5
Rust
bevyengine/bevy
/crates/bevy_reflect/bevy_reflect_derive/src/utility.rs
UTF-8
14,911
3.171875
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! General-purpose utility functions for internal usage within this crate. use crate::derive_data::{ReflectMeta, StructField}; use crate::field_attributes::ReflectIgnoreBehavior; use crate::fq_std::{FQAny, FQOption, FQSend, FQSync}; use bevy_macro_utils::BevyManifest; use bit_set::BitSet; use proc_macro2::{Ident, Spa...
true
b9f562d0c6add5e20739e98c9afa75c92a55f49b
Rust
mashtizadeh/wasmtime
/cranelift/codegen/src/binemit/stackmap.rs
UTF-8
4,993
3.21875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
use crate::bitset::BitSet; use crate::ir; use crate::isa::TargetIsa; use alloc::vec::Vec; type Num = u32; const NUM_BITS: usize = core::mem::size_of::<Num>() * 8; /// A stack map is a bitmap with one bit per machine word on the stack. Stack /// maps are created at `safepoint` instructions and record all live referenc...
true
34c9712a25c53d5fd6d6e4cbae6c43ad2fa3dc58
Rust
boneskull/wld
/src/models/mob.rs
UTF-8
3,473
3.484375
3
[ "Apache-2.0" ]
permissive
use crate::enums::{ EntityType, TBool, }; use scroll::{ ctx::{ SizeWith, TryFromCtx, TryIntoCtx, }, Endian, Error as ScrollError, Pread, Pwrite, LE, }; /// Represents a "mob"; a non-friendly NPC entity. /// /// See [Terraria Wiki: Enemies](https://terraria.gamepedia.com/Enemies) for more ...
true
e77f706e830dcd8a86316c778e665ebf25a5d1d7
Rust
danielgallagher0/bluenrg
/tests/extensions.rs
UTF-8
809
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate bluenrg; extern crate core; use bluenrg::{HardwareError, InvalidHardwareError}; use core::convert::TryInto; macro_rules! assert_eq_hw_error { ($val:expr, $expected:path) => { if let Ok($expected) = $val.try_into() { () } else { panic!("{:?} !==> {:?}", $val, $e...
true
4f6c1219fc522b60438b732654657076d34eaa56
Rust
virtuoushub/nphysics
/src_testbed/objects/fluid.rs
UTF-8
4,043
2.578125
3
[ "BSD-2-Clause" ]
permissive
use crate::objects::node::GraphicsNode; use kiss3d::window::Window; use na::{Point3, RealField, Vector3}; use nphysics::math::{Point, Vector}; use salva::object::{Boundary, Fluid as SalvaFluid}; use simba::scalar::SubsetOf; #[derive(Copy, Clone, Debug)] pub enum FluidRenderingMode { VelocityColor { min: f32, max: ...
true
b2a56c62e74b1c1f6ebbefd95a5ed58bb965e8a5
Rust
Dgame/serde_conv
/serde_conv/src/de.rs
UTF-8
5,905
3.078125
3
[]
no_license
use serde::{Deserialize, Deserializer}; use serde_derive::Deserialize; use std::collections::HashMap; //#[extract("...")] #[macro_export] macro_rules! extract { ($name:ident, $attr:expr) => { paste::item! { pub fn [<extract_ $name>]<'de, T, D>(deserializer: D) -> Result<T, D::Error> ...
true
42db4d80951c322b91085d1d374e9ce67e774b97
Rust
antash-mishra/rust-playground
/multithreading.rs
UTF-8
1,980
3.609375
4
[]
no_license
use std::thread; use std::time::Duration; use std::sync::mpsc; use std::sync::Mutex; fn main() { let v = vec![1,2,3]; let handle = thread::spawn( || { for i in 1..10 { println!("hi number {} from the spawned thread!", i); thread::sleep(Duration::from_millis(1)); } ...
true
d9b14ca01bb2547800237316d1aea9a414c470fd
Rust
Abdillah/genta-rs
/src/tracker_sparql/mod.rs
UTF-8
2,534
2.59375
3
[]
no_license
pub mod ffi; pub struct Connection(*mut ffi::TrackerSparqlConnection); impl Connection { pub fn new() -> Result<Self, String> { let mut error: std::mem::MaybeUninit<*mut ffi::GError> = std::mem::MaybeUninit::new(std::ptr::null_mut()); let connection = { let connection = unsafe { ffi::t...
true
e1927221c87f146f6e0c68cf5527265f2a169871
Rust
ISibboI/shrev-rs
/examples/basic.rs
UTF-8
1,071
3.21875
3
[]
no_license
extern crate shrev; use shrev::EventChannel; #[derive(Clone, Debug, PartialEq, Eq)] pub struct TestEvent { data: u32, } fn main() { let mut channel = EventChannel::new(); channel.drain_vec_write(&mut vec![TestEvent { data: 1 }, TestEvent { data: 2 }]); let mut reader_id = channel.register_reader();...
true
5b5ccff2ababc5fe45c74e3b24dcea61adfe9f92
Rust
fudini/bendec
/src/tests/generated/rust/unions_enums.rs
UTF-8
4,263
2.8125
3
[ "MIT" ]
permissive
/** GENERATED BY BENDEC TYPE GENERATOR */ #[allow(unused_imports)] use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub use super::shared::*; // primitive built-in: u8 // primitive built-in: u16 #[repr(u16)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)] pub enum AnimalKind { //...
true
e3d65758f17829185bf6e53ca4433786a03e9b36
Rust
petgraph/petgraph
/src/algo/k_shortest_path.rs
UTF-8
3,244
3.109375
3
[ "Apache-2.0", "MIT" ]
permissive
use std::collections::{BinaryHeap, HashMap}; use std::hash::Hash; use crate::algo::Measure; use crate::scored::MinScored; use crate::visit::{EdgeRef, IntoEdges, NodeCount, NodeIndexable, Visitable}; /// \[Generic\] k'th shortest path algorithm. /// /// Compute the length of the k'th shortest path from `start` to eve...
true
2444c29657e5a8f2bc2a6621023322b2280701af
Rust
johannesvollmer/rustlight
/src/bsdfs/mod.rs
UTF-8
8,734
2.8125
3
[]
no_license
use crate::structure::*; use serde::{Deserialize, Deserializer}; use serde_json; use cgmath::{InnerSpace, Point2, Vector2, Vector3}; #[cfg(feature = "pbrt")] use pbrt_rs; use std; pub fn reflect_vector(wo: Vector3<f32>, n: Vector3<f32>) -> Vector3<f32> { -(wo) + n * 2.0 * wo.dot(n) } pub fn check_reflection_condi...
true
13f5161ae7d419a4e57b03eafe1c88b950efc180
Rust
JonJakova/rust_stat
/src/main.rs
UTF-8
931
3.421875
3
[]
no_license
mod statistics; use rand::Rng; use self::statistics::stats_calculator_f64; fn main() { let vect_size = get_user_input_as_usize(); let rand_vect = generate_random_vector(vect_size); println!(""); println!("Mean: {}", stats_calculator_f64::mean(&rand_vect)); println!("Medium: {}", stats_calculator_...
true
720420bc051c196d2eec716c0f6392cc8fe788e4
Rust
andrewdavidmackenzie/flow
/flowstdlib/src/math/multiply/multiply.rs
UTF-8
1,154
2.9375
3
[ "MIT" ]
permissive
use serde_json::json; use serde_json::Value; use flowcore::{RUN_AGAIN, RunAgain}; use flowcore::errors::*; use flowmacro::flow_function; #[flow_function] fn _multiply(inputs: &[Value]) -> Result<(Option<Value>, RunAgain)> { let i1 = inputs[0].as_u64().ok_or("Could not get i1")?; let i2 = inputs[1].as_u64().ok...
true
fd61c48674a77d4c8251b777b16c00de002f495f
Rust
deutsche-nationalbibliothek/pica-rs
/pica-matcher/tests/occurrence_matcher.rs
UTF-8
1,167
2.734375
3
[ "MIT", "Unlicense" ]
permissive
use pica_matcher::OccurrenceMatcher; use pica_record::OccurrenceMut; #[test] fn test_occurrence_matcher_eq() -> anyhow::Result<()> { let matcher = OccurrenceMatcher::new("/02")?; assert!(!matcher.is_match(&OccurrenceMut::new("01"))); assert!(matcher.is_match(&OccurrenceMut::new("02"))); assert!(!match...
true
24804afbfcf1d6b288415908c2fab46e169a9169
Rust
pinkisemils/rust_rdrand
/src/main.rs
UTF-8
1,338
2.71875
3
[]
no_license
#![feature(asm)] #![feature(test)] use rand::SeedableRng; extern crate rand; extern crate time; use test::test::Bencher; extern crate test; fn rand_int() -> Option<u64> { let rand_int: u64; let ok: u8; unsafe { asm!("rdrand $0; setc $1;" :"=r"(rand_int), "=r"(ok) : ...
true
a452d89677b9d78792786f25de62d604aceca7a5
Rust
oOBoomberOo/megumax
/src/core/walker.rs
UTF-8
2,113
2.625
3
[]
no_license
use super::{Filter, Link}; use crate::config::Config; use crate::share::replace_prefix; use anyhow::Result; use std::path::{Path, PathBuf}; pub struct Walker { source: PathBuf, destination: PathBuf, iter: Iter, filter: Filter, } impl Walker { pub fn new(source: PathBuf, destination: PathBuf) -> Self { let iter...
true
779f2ebe0ac7f559d92364580f10ca4e527245cc
Rust
delta94/2020-fall-bug
/backend/event/src/event.rs
UTF-8
3,480
2.953125
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub enum EventPayload { Sound { wav_file: String, }, Position { from: (i32, i32, i32), to: (i32, i32, i32), }, Luminosity { from: i32, to: i32, }, } #[derive(Seriali...
true
6c6e3856f8165bad1916c3d02bd138cf2db516ef
Rust
BeLZeL/scripts
/rust/examples/021_redis/src/main.rs
UTF-8
1,842
2.703125
3
[]
no_license
use redis::Commands; fn do_something() -> redis::RedisResult<()> { let client = redis::Client::open("redis://127.0.0.1:6379/")?; let mut con = client.get_connection()?; do_set(&mut con)?; do_set_hl(&mut con)?; do_commands_hl(&mut con)?; do_sub(&mut con)?; Ok(()) } fn do_set(con: &mu...
true
568d8504b867af7923b96dcf9f541af623b7c4d1
Rust
meain/rust-errors-talk
/src/cliarg.rs
UTF-8
214
3.40625
3
[]
no_license
fn greet(name: String) -> String { format!("Hello, {}!", name) } fn main() { let name = std::env::args().nth(1); println!("{:?}", name); let greeting = greet(name); println!("{}", greeting); }
true
84e442a6f27a2cc0731e2232d2558dfd54a0ee2f
Rust
WRansohoff/svd2rust_example_stm32l0x1
/svd_lib/stm32l0x1/src/gpiob/odr.rs
UTF-8
25,531
2.859375
3
[ "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::ODR { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W...
true
2dbce2d6d3b94a298a1773f3d202fc89c24a87af
Rust
dmitris/adventofcode-2020
/day07/src/main.rs
UTF-8
2,262
3.03125
3
[ "MIT" ]
permissive
use std::error::Error; // use std::io::BufRead; // use daggy::Dag; use regex::Regex; #[derive(Debug)] struct BagRec { color : String, num : u32, // quantity of bags of this color allowed } // const MIN_TOKENS : usize = 7; // minimal number of space-separated tokens in a line fn parse_line(line: &str) -> Resu...
true
67fac6ab653debc46ca4157f21f92cdc75b82ee3
Rust
tathanhdinh/binex
/src/main.rs
UTF-8
3,055
2.984375
3
[]
no_license
#[macro_use] extern crate quicli; use quicli::prelude::*; use std::{ fs, io::{self, Read, Seek, Write}, num, result, }; fn try_parse_number(num_str: &str) -> result::Result<usize, num::ParseIntError> { // TODO: reimplement match &num_str[..=1] { "0x" | "0X" => usize::from_str_radix(&num_str...
true
982892611beecdcd9f3c00d0681dd906a6053c58
Rust
nunomaduro/nunomaduro.com
/application/src/http/routes/about.rs
UTF-8
1,049
2.65625
3
[]
permissive
use crate::http::Route; use askama::Template; use async_trait::async_trait; use domain::contracts::StaticRepository; use hyper::{Body, Request, Response}; use infrastructure::repositories::MarkdownStaticRepository; use presentation::templates::AboutTemplate; pub struct About { repository: Box<dyn StaticRepository>...
true
e5df6ea0786082ba4f6cb1b798eb01547c64b396
Rust
aviansie-ben/rust-raytracer
/src/mesh.rs
UTF-8
13,245
2.71875
3
[]
no_license
use std::collections::HashMap; use std::collections::hash_map::Entry; use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::Path; use cgmath::{EuclideanSpace, InnerSpace, Point2, Point3, Vector2, Vector3}; use cgmath::num_traits::Float; use itertools::Itertools; use crate::bvh::Bvh; use crate::ob...
true
8031fc703589f1c61be2e234309b81e25ef0f322
Rust
zwhitchcox/leetcode_rs
/src/_0070_climbing_stairs.rs
UTF-8
365
3.296875
3
[ "MIT" ]
permissive
struct Solution; impl Solution { fn climb_stairs(n: i32) -> i32 { match n { 1 | 2 => n, k => (2..k).fold((1, 2), |acc, _| (acc.1, acc.0 + acc.1)).1, } } } #[test] fn test() { assert_eq!(Solution::climb_stairs(3), 3); assert_eq!(Solution::climb_stairs(2), 2); ...
true
2087327b66eb6917bb9d51ceb8536394ecd71c17
Rust
karimElmougi/epi-rust
/src/array/multiply_integers.rs
UTF-8
1,419
3.546875
4
[]
no_license
pub fn multiply(a: &[i32], b: &[i32]) -> Vec<i32> { let mut result = vec![0; a.len() + b.len()]; let mut carry = 0; for (i, digit) in result.iter_mut().enumerate().rev() { let mut accumulator = 0; let skip_val = std::cmp::max(0, i as isize - a.len() as isize) as usize; for (index_a...
true
0f8047f83aef77a443bd76db52e7578aef7f39d0
Rust
mjaric/pong-game
/src/ui.rs
UTF-8
1,548
2.734375
3
[]
no_license
use amethyst::core::ecs::{Entity, World}; use amethyst::assets::Loader; use amethyst::ui::{TtfFormat, UiTransform, Anchor, UiText, LineMode}; use amethyst::prelude::*; #[derive(Default)] pub struct ScoreBoard { pub score_left: i32, pub score_right: i32, } pub struct ScoreText { pub left_player_score: Enti...
true
d4742a6985c5900c07a1fb836bd705e0f79414e2
Rust
nicey0/rs_cel_auto
/src/auto.rs
UTF-8
2,752
3.109375
3
[ "MIT" ]
permissive
const NGH: [(i32, i32); 8] = [ (-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1), ]; pub struct Grid<CellType: Copy + PartialEq> { c: Vec<CellType>, width: usize, } impl<CellType: Copy + PartialEq> Grid<CellType> { pub fn new_1d(c: Vec<CellType>, width: usize) ...
true
4072dd223da5a30bc2b8e886c03152c1e839eebe
Rust
kenoss/frum
/src/commands/uninstall.rs
UTF-8
2,865
2.765625
3
[ "MIT" ]
permissive
use crate::config::FrumConfig; use crate::input_version::InputVersion; use crate::outln; use crate::symlink::remove_symlink_dir; use crate::version::Version; use anyhow::Result; use colored::Colorize; use log::debug; use std::ffi::OsStr; use std::io::prelude::*; use std::path::Component; use std::path::PathBuf; use thi...
true
2db142bcd8310b58811b28944be84596df00d222
Rust
liljencrantz/crush
/src/lib/stream/where.rs
UTF-8
2,334
2.734375
3
[ "MIT" ]
permissive
use crate::lang::command::Command; use crate::lang::command::OutputType::Passthrough; use crate::lang::errors::{error, CrushResult}; use crate::lang::state::contexts::CommandContext; use crate::lang::{argument::Argument, data::table::ColumnType}; use crate::lang::{data::table::Row, value::Value}; use signature::signatu...
true
f0a46225cf431f975284921188c15ff95a052e50
Rust
jk983294/CommonScript
/rust_learn/learn/topics/io/file_in.rs
UTF-8
253
2.828125
3
[]
no_license
use std::io::Read; fn main() { let file_path = "/tmp/rust_demo_io.txt"; let mut file = std::fs::File::open(file_path).unwrap(); let mut contents = String::new(); file.read_to_string(&mut contents).unwrap(); print!("{}", contents); }
true
66528568bb0cc2f568104eb6a4dad4e480c8b624
Rust
jamesward/oop-evolution
/rustable/typeclass/src/main.rs
UTF-8
874
3.53125
4
[]
no_license
trait ToChar { fn to_char(&self) -> char; } impl ToChar for char { fn to_char(&self) -> char { return *self; } } impl ToChar for &str { fn to_char(&self) -> char { return self.chars().next().unwrap(); } } impl <T : ToChar> ToChar for Vec<T> { fn to_char(&self) -> char { ...
true
0bba61120b5576ae78909711ab889b75a0dd972c
Rust
krenzland/euler
/rust/src/p27.rs
UTF-8
1,242
3.078125
3
[]
no_license
use ntheory::primes; use bit_vec::BitVec; fn max_prime(a: i32, b: i32, primes: &BitVec) -> u32 { let mut n = 0; loop { let eval = n * n + a * n + b; if eval < 0 || !primes[eval as usize] { return n as u32; } n += 1; } } fn best_prime_coeff() -> (i32, i32) { ...
true
33b12861821a13867768255aebb22820214448e0
Rust
playXE/ExVM-RS
/src/heap.rs
UTF-8
16,870
2.9375
3
[ "Apache-2.0" ]
permissive
extern "C" { fn malloc(x: usize) -> *mut u8; } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub struct Page { pub(super) data: *mut u8, pub(super) top: *mut u8, pub(super) limit: *mut u8, pub(super) size: usize, } pub const PAGE_SIZE: usize = 4096; impl Page { #[inline]...
true
1054145afe591cb7233f690589085151d062f672
Rust
EFanZh/LeetCode
/src/problem_0312_burst_balloons/dynamic_programming.rs
UTF-8
1,493
3.03125
3
[]
no_license
pub struct Solution; // ------------------------------------------------------ snip ------------------------------------------------------ // impl Solution { pub fn max_coins(nums: Vec<i32>) -> i32 { let n = nums.len() + 1; let mut cache = vec![0; n * (n - 1) + 1]; for length in 1..n { ...
true
b251376b07c14bec20933457c2e43f0cfce540a7
Rust
inickt/cs4500-wortham
/Fish/Common/src/common/game_tree.rs
UTF-8
10,952
3.796875
4
[]
no_license
//! This file contains code that represents the GameState at any point //! during the game, in a lazily-evaluated tree structure. use crate::common::gamestate::GameState; use crate::common::action::Move; use std::collections::HashMap; /// Represents an entire game of Fish, starting from the given GameState /// passed ...
true
b98891079f54927b1e3b41d5a8d4bb052bd374ff
Rust
alexcrichton/bors2
/src/models/event.rs
UTF-8
1,731
2.921875
3
[]
no_license
use pg::GenericConnection; use pg::rows::Row; use errors::*; pub struct Event { pub id: i32, pub provider_id: Provider, pub provider_event_id: String, pub provider_event: String, pub event: String, } pub enum Provider { GitHub, Travis, AppVeyor, } impl Event { pub fn insert(conn...
true
5993ec8ae50801c2655300450e6c129598acaa49
Rust
josecm/exercism-rust
/matching-brackets/src/lib.rs
UTF-8
503
3.3125
3
[]
no_license
use std::collections::HashMap; pub fn brackets_are_balanced(string: &str) -> bool { let map: HashMap<char, char> = vec![(')', '('), (']', '['), ('}', '{')] .into_iter() .collect(); let mut stack = Vec::new(); for c in string.chars() { if map.values().any(|&a| a == c) { s...
true
162967e2a837e3c4de0205871e36377859daf555
Rust
dsegovia90/express-vs-rocket
/rust-rocket/src/main.rs
UTF-8
1,725
2.890625
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; use rocket_contrib::json::Json; #[macro_use] extern crate serde_derive; use num_bigint::BigUint; use num_traits::{Zero, One}; use std::mem::replace; use std::time::Instant; #[derive(Serialize)] struct ResponseBack { result: String, ...
true
e5f39b700563b0163324841be757868a8eb72ba2
Rust
maxbla/gel-o
/examples/delay_deprecated.rs
UTF-8
1,352
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
#[allow(deprecated)] use gelo::{filter_map_events_with_delay, GrabStatus}; use std::env; use std::thread::sleep; use std::time::{Duration, Instant}; const DEFAULT_MS_DELAY: u32 = 60; /// The old version of the delay example. See examples/delay.rs for the up-to-date version /// this example uses deprecated functions w...
true
a715d52af4c048ed49bf5b66fb90b2ac86610984
Rust
muzudho/rust_kifuwarabe_shell
/src/models/diagram_json.rs
UTF-8
2,495
3.078125
3
[ "MIT" ]
permissive
/// .json ファイルを書き出す際に使う。 extern crate serde_json; use std::collections::HashMap; /// JSONを出力するときにだけ使う入れ物。 #[derive(Serialize, Default, Deserialize, Debug)] pub struct DiagramJson { entry_point: String, nodes: Vec<NodeJson>, } impl DiagramJson { pub fn new() -> DiagramJson { DiagramJson { ...
true
794dff7fdf706288a5d55ca19cb42fc889723733
Rust
etaoins/arret
/compiler/mir/ops.rs
UTF-8
25,556
2.609375
3
[ "Apache-2.0" ]
permissive
use std::rc::Rc; use arret_runtime::abitype; use arret_runtime::boxed; use arret_syntax::datum::DataStr; use arret_syntax::span::Span; use crate::codegen::GenAbi; use crate::id_type::ArcId; use crate::mir::tagset::TypeTagSet; new_counting_id_type!(PrivateFunIdCounter, PrivateFunId); new_global_id_type!(RegId); #[...
true
d184721941588df20e84581c84cb965b8b177ba1
Rust
pdf-rs/pdf_derive
/src/lib.rs
UTF-8
17,455
3.5
4
[]
no_license
//! `pdf_derive` provides a proc macro to derive the Object trait from the `pdf` crate. //! # Usage //! There are several ways to derive Object on a struct or enum: //! ## 1. Struct from PDF Dictionary //! //! A lot of dictionary types defined in the PDF 1.7 reference have a finite amount of possible //! fields. Each o...
true
37aa55596b0924ab179a58ad37ba7bc8fef4fefe
Rust
afsharalex/trade_log-lib
/src/bin/create_stock.rs
UTF-8
1,595
2.734375
3
[]
no_license
extern crate diesel; extern crate trade_log_lib; use self::trade_log_lib::*; use std::io::{stdin, Read}; use std::ops::Deref; #[cfg(not(windows))] const EOF: &str = "CTRL+D"; #[cfg(windows)] const EOF: &str = "CTRL+Z"; fn main() { let conn = establish_connection(); // Get Ticker println!("Please enter ...
true
33d6e25d0da1933950937d4893dd1205a0237a26
Rust
Elena-Liebl/rust-project
/src/network/handshake.rs
UTF-8
3,937
2.90625
3
[ "Apache-2.0" ]
permissive
use crate::interface::*; use crate::network::notification::*; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::net::SocketAddr; use std::str::FromStr; use std::string::ToString; #[derive(Serialize, Deserialize, Debug)] pub struct NetworkInfo { name: String, address: String, } pub f...
true
4141fcf9cbd84748af754b7f72f3af57e6bb14be
Rust
GabrielBueno/calcrr
/src/calc.rs
UTF-8
3,022
3.5625
4
[]
no_license
use std::collections::HashMap; use crate::parser::Stmt; use crate::parser::Expr; use crate::lexer::Token; pub struct Calc { mem: HashMap<String, f64>, } impl Calc { pub fn new() -> Calc { Calc { mem: HashMap::new() } } pub fn run(self: &mut Calc, stmt: &Stmt) -> Result<f64, &'static str> { ...
true
9241f7d459f9ed1db41de8ba7c6d71ed8f22c36a
Rust
asampley/UTF-Nate
/src/youtube/mod.rs
UTF-8
4,955
2.671875
3
[]
no_license
//! Structures and functions to authenticate and access the [YouTube API] //! //! In order to access the API, you just need a key, defined in [`YoutubeApi`] //! //! [YouTube API]: https://developers.google.com/youtube/v3/docs pub mod api; use tracing::{error, info}; use reqwest::Client; use serde::{Deserialize, Seri...
true
fd110e81c6b72d3abc16a0b02676bae9e4ed8f79
Rust
potocpav/lv2
/src/ttl/def.rs
UTF-8
1,628
2.96875
3
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-mit-taylor-variant" ]
permissive
use std::fmt; #[derive(Clone)] pub struct Plugin { pub id: String, pub name: String, pub uri: String, pub category: Option<Category>, pub ports: Vec<Port>, pub ui: Option<PluginUI>, } #[derive(Clone)] pub enum Category { AmplifierPlugin, } #[derive(Clone)] pub struct Port { pub dire...
true
b72346cc7f849304d8c848627bc44a68e026d805
Rust
maplant/rust-decimal
/benches/std_ops.rs
UTF-8
1,062
2.78125
3
[ "MIT" ]
permissive
use criterion::Criterion; use rust_decimal::Decimal; use std::str::FromStr; lazy_static! { static ref BASE : Decimal = Decimal::from_str("2.01").unwrap(); static ref INPUTS : [Decimal; 7] = [ Decimal::from_str("1").unwrap(), Decimal::from_str("2").unwrap(), Decimal::from_str("100").unwr...
true
ac734b84a5049a62631ba4d50e13c382ec8d7bb2
Rust
krsanky/gtk-rust-template
/src/application.rs
UTF-8
2,894
2.703125
3
[]
no_license
use gio::prelude::*; use gtk::prelude::*; use std::env; use crate::config; use crate::window::Window; pub struct Application { app: gtk::Application, window: Window, } impl Application { pub fn new() -> Self { let app = gtk::Application::new(config::APP_ID, gio::ApplicationFlags::FLAGS_NONE).unwr...
true
38e47056f8113baad9726cc2335d289426408d12
Rust
ichyo/rust-text-scanner
/examples/practice.rs
UTF-8
207
2.609375
3
[]
no_license
// https://atcoder.jp/contests/practice/tasks/practice_1 use text_scanner::scan; fn main() { let (a, b, c): (i32, i32, i32) = scan(); let s: String = scan(); println!("{} {}", a + b + c, s); }
true
1bbb71b241a92dd1cf3afecd32349fe16024851d
Rust
JulianKnodt/hollow_heap
/src/unit_tests.rs
UTF-8
1,251
3.015625
3
[]
no_license
use crate::hollow_heap::HollowHeap; #[test] fn simple() { let mut h = HollowHeap::new(); h.push(-1, "d"); h.push(2, "o"); h.push(1, "a"); h.push(3, "b"); h.push(0, "c"); assert_eq!(h.peek(), Some(&"d")); } #[test] fn rm() { let mut h = HollowHeap::new(); h.push(2, "o"); h.push(1, "a"); h.push(3,...
true
c4b8309020bc781f6cbbc926eaa116aa3ffe316c
Rust
EduRenesto/aoldaq-rs
/src/capi.rs
UTF-8
3,130
2.953125
3
[]
no_license
use super::{ Aoldaq, AoldaqArgs }; /// Creates an AOLDAQ instance. #[no_mangle] pub unsafe extern fn aoldaq_create_instance(args: *const AoldaqArgs) -> *mut Aoldaq { let instance = Box::new(Aoldaq::create(&*args)); Box::into_raw(instance) } /// Destroys an AOLDAQ instance, stopping the threads and dropping ev...
true
d5f4f2537530689c2da780f69e94eaf7ff4cc8ef
Rust
CrazyFork/watchexec
/src/gitignore.rs
UTF-8
8,070
3.328125
3
[ "Apache-2.0" ]
permissive
extern crate glob; use std::fs; use std::io; use std::io::Read; use std::path::{Path, PathBuf}; // Immutable, ordered set of Patterns // Used to implement whitelisting pub struct PatternSet { patterns: Vec<Pattern>, } // Represents a single gitignore rule // // Currently we ignore rules about whether to match //...
true
e3916b21538b1723c6c783a427ed4f8d50368ffb
Rust
minno726/feh-sim-seed
/src/results/svg_graph.rs
UTF-8
5,659
2.9375
3
[ "MIT" ]
permissive
use seed::prelude::*; use std::fmt::Write; use wasm_bindgen::JsCast; use crate::counter::Counter; use crate::stats; use crate::Msg; const XMIN: f32 = 0.0; const YMIN: f32 = 0.0; const WIDTH: f32 = 100.0; const HEIGHT: f32 = 60.0; /// SVG elements for displaying the results within the graph. If `highlight` is /// gi...
true
933f19355b234f571a567872d840f6d642f91464
Rust
mvoronin/dumpfuzzcator
/src/main.rs
UTF-8
11,118
2.578125
3
[ "MIT" ]
permissive
extern crate clap; extern crate crypto; extern crate rand; extern crate yaml_rust; use crypto::md5::Md5; use crypto::digest::Digest; use rand::Rng; use std::collections::HashMap; use std::env; use std::error::Error; use std::fs::File; use std::process; use std::io; use std::io::Write; use std::io::BufReader; use std...
true
82fc75c09e2394045a84fa1d58e1117823befcf1
Rust
schien-dong/hhvm
/hphp/hack/src/utils/config_file/rust/lib.rs
UTF-8
3,920
2.65625
3
[ "MIT", "PHP-3.01", "Zend-2.0" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use std::collections::BTreeMap; use std::path::Path; use std::str::FromStr; use sha1::{Digest, Sha1}; #[derive(Clone)] pub struct Conf...
true
b4e0bc93e4a35d35c88f6bdd3fe39c12506c49b8
Rust
Osama530/simple_iot_api
/src/modules/lights.rs
UTF-8
1,678
3.046875
3
[]
no_license
use rocket::request::Form; use crate::modules::colours; #[derive(Serialize, Deserialize)] pub struct Lights { pub light: Light } #[derive(Serialize, Deserialize)] pub struct Light { pub name: String, pub switch: SimpleSwitch, pub modes: Modes } impl Light { pub fn new_light(name: String, switch: ...
true
fd0b8ecd842fc38b5b654f9359426265dcb9a271
Rust
ritsz/rust-programming
/Borrow_AsRef.rs
UTF-8
662
4.03125
4
[]
no_license
use std::borrow::Borrow; use std::fmt::Display; /* foo runs for anything that borrows i32 So it will work for both & and &mut */ fn foo<T: Borrow<i32> + Display>(a: T) { println!("a is borrowed: {}", a); } fn main() { let mut i = 5; /* When writing generic code, it is often desirable ...
true
e07c0a2ed1d274c204d2c0daaec2590e195bdc24
Rust
opilar/advent-of-code-2019
/src/day1.rs
UTF-8
825
3.296875
3
[]
no_license
#[aoc_generator(day1)] pub fn input_generator(input: &str) -> Vec<u32> { input .lines() .map(|s| s.parse().unwrap()) .collect() } #[aoc(day1, part1)] pub fn part1(input: &[u32]) -> u32 { input .iter() .copied() .map(calc_fuel) .sum() } fn calc_fuel(mass:...
true