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
d84a7eba9a7818a8e8672d6a48bd3408bb42c1c7
Rust
uldza/serde_eetf
/src/ser.rs
UTF-8
17,790
3.09375
3
[]
no_license
use num_bigint::BigInt; use num_traits::cast::FromPrimitive; use serde::ser::{self, Serialize}; use std::convert::TryFrom; use std::io; use heck::SnakeCase; use eetf::{self, Term}; use crate::error::{Error, Result}; /// Serializes a value into EETF using a Write pub fn to_writer<T, W>(value: &T, writer: &mut W) -> ...
true
14cb3537313d50e67be6b434e32d9c15f7395a45
Rust
isaacthefallenapple/rust-ansi
/src/cursor.rs
UTF-8
2,113
3.421875
3
[]
no_license
use regex::Regex; macro_rules! print_esc { ($e:expr) => { print!("\x1b{}", $e); }; } pub fn move_vert(n: i32) { if n >= 0 { print_esc!(format!("[{}A", n)); } print_esc!(format!("[{}B", -n)); } pub fn move_hor(n: i32) { if n >= 0 { print_esc!(format!("[{}C", n)); } ...
true
a2daf3139ed62095c67f042130c6bb3a970da2eb
Rust
tyehle/advent-of-code
/2019/d04/src/main.rs
UTF-8
2,071
3.84375
4
[]
no_license
fn is_valid(pw: &[u8]) -> bool { let mut double = false; let mut prev = pw[0]; for d in pw.iter().skip(1) { if *d < prev { return false; } if *d == prev { double = true; } prev = *d; } double } fn is_valid_b(pw: &[u8]) -> bool { ...
true
9b98b23745263b010e6f0b8b2d0ac069efbe666a
Rust
cottonguard/kyopro-rust
/src/libs/io/output.rs
UTF-8
3,857
2.765625
3
[]
no_license
use std::{io::prelude::*, mem::MaybeUninit, ptr, slice, str}; pub struct KOutput<W: Write> { dest: W, delim: bool, } impl<W: Write> KOutput<W> { pub fn new(dest: W) -> Self { Self { dest, delim: false } } pub fn bytes(&mut self, s: &[u8]) { self.dest.write_all(s).unwrap(); } ...
true
34379d5f2138f2f9f43113d234ff3cc5e56b0f90
Rust
gen0083/atcoder_python
/rust/abc218/src/bin/d.rs
UTF-8
895
2.796875
3
[]
no_license
use std::collections::{BTreeSet, HashMap}; use proconio::input; fn main() { input!{ n: usize, points: [(u64, u64); n] } let mut count = 0; let mut xs_by_y: HashMap<u64, BTreeSet<u64>> = HashMap::new(); let mut ys_by_x: HashMap<u64, BTreeSet<u64>> = HashMap::new(); for (x, y) in ...
true
7cf2372fd62c2d84ee0fe9e318e4e2f4c333921e
Rust
danieldickison/kachiclash
/build.rs
UTF-8
527
2.890625
3
[ "MIT" ]
permissive
use std::process::Command; fn main() -> Result<(), String> { println!("running sass"); let status = Command::new("sass") .arg("public/scss/:public/css/") .status() .expect("run sass"); if !status.success() { return Err(format!("sass failed with {}", status)); } prin...
true
9947ab9952a538d544e4e3cc13983ac592101fe0
Rust
Xaeroxe/nonzero_signed
/src/lib.rs
UTF-8
3,272
3.640625
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::cmp::Ordering; use std::fmt; use std::num::*; macro_rules! impl_nonzero_fmt { ( ( $( $Trait: ident ),+ ) for $Ty: ident ) => { $( impl fmt::$Trait for $Ty { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.get().f...
true
d4029f71804eb6f947237e4b4d09911119f4fcf1
Rust
PSudoLang/PSudo
/libpsudoc/src/parse/rules/expression/field_get.rs
UTF-8
1,984
2.734375
3
[ "MIT" ]
permissive
use super::*; use crate::coretypes::{Expression, MemberExpression, Spanned, Token, TokenCategory}; pub struct FieldGet; impl ParseFunction for FieldGet { type Output = Box<dyn FnOnce(Expression) -> Expression>; fn try_parse( context: &mut ParseContext, session: &mut CompileSession, ) -> ...
true
ee7111bc37b03e82496f08ad9909fd4412f6c74e
Rust
isgasho/k9
/tests/e2e/test_utils.rs
UTF-8
4,223
2.65625
3
[ "MIT" ]
permissive
use anyhow::{Context, Result}; use derive_builder::Builder; use rand::prelude::*; use regex::RegexBuilder; use std::collections::BTreeMap; use std::fs; use std::path::PathBuf; use std::process::Command; use std::str::FromStr; const E2E_TEMP_DIR: &str = "e2e_tmp_dir"; const CAPTURE_TEST_RESULT_RE: &str = "^test (?P<tes...
true
84f082e0b82cfcc2640e8bb060a2f8fcdd609a65
Rust
dkohlsdorf/audio_pattern_discovery
/src/neural.rs
UTF-8
3,092
2.578125
3
[]
no_license
extern crate bincode; extern crate serde_derive; use crate::error::*; use crate::numerics::*; use crate::discovery::*; use bincode::{deserialize, serialize}; use std::fs::File; use std::io::prelude::*; /// Single layer Autoencoder #[derive(Serialize, Deserialize, Clone)] pub struct AutoEncoder { pub w_encode: Ma...
true
ec4355fdb14993154388514c21cebeca5b89fb7e
Rust
arichnad/slsh
/src/main.rs
UTF-8
3,243
2.859375
3
[ "MIT" ]
permissive
use std::io; use nix::{ sys::signal::{self, SigHandler, Signal}, unistd, }; use ::slsh::*; fn main() -> io::Result<()> { let config = get_config(); if let Ok(config) = config { if config.command.is_none() && config.script.is_none() { /* See if we are running interactively. */ ...
true
0971b9804d22305e0e4d315e71463fc03f6c161b
Rust
cessen/psychopath
/src/parse/basics.rs
UTF-8
3,798
3.03125
3
[ "GPL-3.0-or-later", "GPL-3.0-only", "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-only", "Apache-2.0", "MIT" ]
permissive
//! Some basic nom parsers #![allow(dead_code)] use std::str::{self, FromStr}; use nom::{ character::complete::{digit1, multispace0, one_of}, combinator::{map_res, opt, recognize}, number::complete::float, sequence::{delimited, tuple}, IResult, }; // ==============================================...
true
b4fba85df4dac643aceac208fcae5c7b6ef57374
Rust
rust-lang/rust
/tests/ui/ptr_ops/issue-80309-safe.rs
UTF-8
296
2.53125
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// run-pass // compile-flags: -O // Regression test for issue #80309 pub fn zero(x: usize) -> usize { std::ptr::null::<i8>().wrapping_add(x) as usize - x } pub fn qux(x: &[i8]) -> i8 { x[zero(x.as_ptr() as usize)] } fn main() { let z = vec![42, 43]; println!("{}", qux(&z)); }
true
4f0fb4ba81ceee93a5ce33edc069e215141e9c36
Rust
Noble-Mushtak/Advent-of-Code
/2022/day18/src/lib.rs
UTF-8
2,407
2.78125
3
[]
no_license
use std::cmp::{min, max}; use std::collections::{HashSet, VecDeque}; use std::error::Error; use std::fs; peg::parser! { grammar parser() for str { rule isize() -> isize = n:$(['0'..='9']+) { n.parse().unwrap() } rule point() -> (isize, isize, isize) = x:isiz...
true
38028eb820b7a53228ab1e9d46cda190fdef26a8
Rust
timothee-haudebourg/generic-btree
/src/dot.rs
UTF-8
367
3.03125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pub trait Display { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result; fn dot(&self) -> Displayed<Self> { Displayed(self) } } pub struct Displayed<'a, T: ?Sized>(&'a T); impl<'a, T: Display> std::fmt::Display for Displayed<'a, T> { fn fmt(&self, f: &mut std::fmt::Formatter) -> st...
true
b29f3d86fe84b02341ed4880361247e5fda0aaf6
Rust
unfo/adventofrust
/src/day1.rs
UTF-8
2,742
3.921875
4
[]
no_license
/* Specifically, they need you to find the two entries that sum to 2020 and then multiply those two numbers together. For example, suppose your expense report contained the following: 1721 979 366 299 675 1456 In this list, the two entries that sum to 2020 are 1721 and 299. Multiplying them together produces 1721 * ...
true
e1d26fc66a4dd5a3754784a28e08d19f0841847d
Rust
GrossBetruger/RustPlaygound
/number_cruncher/src/main.rs
UTF-8
929
3.375
3
[]
no_license
extern crate num; use num::{BigInt, BigUint, Zero, One, FromPrimitive}; fn factorial(n: usize) -> BigInt { let mut f: BigInt = One::one(); for i in 1..(n+1) { let bu: BigInt = FromPrimitive::from_usize(i).unwrap(); f = f * bu; } f } fn n_choose_k(n: usize, k: usize) -> BigInt { fa...
true
af77708ded62e682d671b77f65ef0936d2f14fcd
Rust
smwls/aoc20
/src/day3.rs
UTF-8
2,254
3.546875
4
[]
no_license
use std::iter::successors; use std::ops::Add; #[derive(Debug, Clone, PartialEq)] enum GridCell { Tree, Square } type Row = Vec<GridCell>; type Grid = Vec<Row>; #[derive(Debug, Copy, Clone, PartialEq)] struct Coord { right: usize, down: usize } impl Add for Coord { type Output = Self; fn ad...
true
6a6460e8389000c5d47f34289991afd034eebaf6
Rust
flashbuckets/rustful
/src/file.rs
UTF-8
2,268
3.59375
4
[ "MIT" ]
permissive
//!File related utilities. use std::path::{Path, Component}; use mime::{Mime, TopLevel, SubLevel}; include!(concat!(env!("OUT_DIR"), "/mime.rs")); ///Returns the MIME type from a given file extension, if known. /// ///The file extension to MIME type mapping is based on [data from the Apache ///server][apache]. /// ...
true
6f4945f52af8043c9ccda5d67caea9ae581113fd
Rust
juliotpaez/jpar
/src/parsers/helpers.rs
UTF-8
11,060
3.15625
3
[ "MIT" ]
permissive
use crate::result::{ParserResult, ParserResultError}; use crate::{Cursor, ParserInput}; /// Restores the reader when a not found error is returned. pub fn not_found_restore<'a, P, C, R, Err>( mut parser: P, ) -> impl FnMut(&mut ParserInput<'a, Err, C>) -> ParserResult<R, Err> where P: FnMut(&mut ParserInput<'a...
true
5242413bd009bf183503fb77e550deae2035902c
Rust
pelian/bn-api
/db/src/test/builders/settlementtransaction_builder.rs
UTF-8
1,780
2.84375
3
[ "BSD-3-Clause" ]
permissive
use diesel::prelude::*; use prelude::*; use uuid::Uuid; pub struct SettlementtransactionBuilder<'a> { settlement_id: Option<Uuid>, event_id: Uuid, order_item_id: Option<Uuid>, settlement_status: Option<SettlementStatus>, transaction_type: Option<SettlementTransactionType>, value_in_cents: i64, ...
true
de170dcebe363de7d2c1a67007da8db8ec0891cc
Rust
owen8877/leetcode-rs
/src/problem_24.rs
UTF-8
1,436
3.21875
3
[]
no_license
use crate::listnode::*; pub fn swap_pairs(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> { let mut dummy = Box::new(ListNode::new(0)); dummy.next = head; let mut p = dummy.as_mut(); fn core(p: &mut ListNode) { match p.next.as_ref() { None => {}, Some(n1) => { ...
true
9d0e021ba44eda5c905cc77721b0ecf97f892a61
Rust
CStichbury/emosaic
/src/mosaic/image.rs
UTF-8
4,008
2.9375
3
[ "MIT" ]
permissive
use std::fs::{self}; use std::io; use std::path::{Path, PathBuf}; use std::sync::mpsc::channel; use std::thread; use image::{DynamicImage, GenericImage, Pixel, RgbaImage, Rgba}; use super::color::{average_color, QuadRgba}; use crate::{Tile, TileSet}; pub fn fill_rect<T>(img: &mut T, color: &T::Pixel, rect: &(u32, u3...
true
2d7e819f928114e32be3e036a0092ce4fc767276
Rust
serbe/anet
/src/future.rs
UTF-8
647
2.796875
3
[ "MIT" ]
permissive
use super::interval::Interval; use futures::prelude::*; pub struct IntervalFuture { interval: Interval, last: usize, } impl IntervalFuture { pub fn new(interval: Interval) -> IntervalFuture { let last = interval.get_counter(); IntervalFuture { interval, last } } } impl Future for Inte...
true
89d95e09f55b7bfdf94d9ec5778bda870de95851
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/bytes/src/buf/buf_mut.rs
UTF-8
15,631
2.703125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::buf::{limit, Chain, Limit, UninitSlice}; #[cfg(feature = "std")] use crate::buf::{writer, Writer}; use core::{cmp, mem, ptr, usize}; use alloc::{boxed::Box, vec::Vec}; pub unsafe trait BufMut { ...
true
904d5932a7c2483ee4d82986d7094e8dc8fb28f6
Rust
mishazawa/monorap
/minifb_utils/src/primitives/mod.rs
UTF-8
3,699
2.9375
3
[]
no_license
use crate::color::Color; use crate::renderer::{Processing, Renderer, ShapeMode}; use crate::util; pub fn dot(renderer: &mut Renderer, x0: i32, y0: i32) -> () { let (x, y) = renderer.apply_translation(x0, y0); match util::coords_to_index(x, y, renderer.width, renderer.height) { Some(index) => { ...
true
28f1d10cdf3b87248bfb517ff434abbe559a0032
Rust
tiffany352/wasm-rs
/src/reader/names.rs
UTF-8
1,443
3.109375
3
[ "Apache-2.0", "MIT" ]
permissive
use super::*; use std::str::from_utf8; pub struct NameSection<'a> { pub count: u32, pub entries_raw: &'a [u8], } pub struct NameEntryIterator<'a> { count: u32, local_count: u32, iter: &'a [u8] } pub enum NameEntry<'a> { Function(&'a str), Local(&'a str), } impl<'a> NameSection<'a> { ...
true
d2e9e070a781514e700c523f41f226143ff772eb
Rust
ericrobolson/Archived_Tremor
/v1/portia_client_server/src/lib.rs
UTF-8
1,592
3.0625
3
[ "MIT" ]
permissive
mod ecs; mod math{ pub use game_math::f32::*; } pub enum MultiplayerMode{ DeterministicRollback, ClientServer } pub type ClientId = u32; pub struct Server { clients: Vec<Client>, max_outgoing_packet_bytes: usize, max_clients: u32, outbound_tick_rate: u32, } impl Server { pub fn main_l...
true
aa685d850694ed7794d5c2154f0f3744b0138a64
Rust
CodeSteak/hs_app
/hs_crawler/src/crawler/canteen_plan.rs
UTF-8
3,080
2.5625
3
[ "MIT" ]
permissive
use super::*; use crate::util::*; use std::io; use std::io::Read; use std::collections::HashMap; use select::document::Document; use select::predicate::*; use chrono::{Date, Local}; use reqwest; type CanteenPlan = HashMap<Date<Local>, Vec<String>>; const URL_THIS_WEEK: &str = "https://www.swfr.de/essen-trinken/s...
true
b6d86a4f12b56bb0f04cc8768dba7b8eedf02ceb
Rust
drueck/advent-of-code-2020
/day-07/src/main.rs
UTF-8
1,799
3.40625
3
[]
no_license
// Advent of Code 2020: Day 7 // // We have a list of rules for bags at the airport, specifically a list // of bag types that must contain a specific number of other bag types. // Our challenge for part 1 is to find the number of bags that could // contain a shiny gold bag. Some bags will contain it directly, and other...
true
ab5666a45ad8e4e12f36be77e7c9a2ea74d85e4b
Rust
thomcc/startup
/testcases/dylib_runner/main.rs
UTF-8
1,555
2.53125
3
[ "Apache-2.0", "MIT", "Zlib" ]
permissive
fn main() { let mut args = std::env::args().skip(1); let path: std::path::PathBuf = args.next().expect("expected target path").into(); let name = args.next().expect("expected lib name"); let sofile = path.join(format!("lib{}.so", name)); let dll = path.join(format!("{}.dll", name)); let dylib =...
true
6ab0ecfc441d11fe121d62ffcbe01cf94ddd7afb
Rust
sector-f/dose-rs
/dose-types/examples/serialize.rs
UTF-8
1,712
2.640625
3
[]
no_license
extern crate serde_json; extern crate dose_types; use dose_types::*; use std::path::PathBuf; fn main() { // Requests let add_request = Request::Add { url: String::from("http://www.example.com"), path: PathBuf::from("/path/to/file") }; println!("Add request:\n{}\n", serde_json::to_string(&add_request).un...
true
8577c9f380517be083cf87dce1be3be6e140a50d
Rust
66Origin/nitox
/src/protocol/mod.rs
UTF-8
1,887
3.1875
3
[ "MIT", "Apache-2.0" ]
permissive
use bytes::Bytes; /// Trait used to implement a common interface for implementing new commands pub trait Command { /// Command name as a static byte slice const CMD_NAME: &'static [u8]; /// Encodes the command into bytes fn into_vec(self) -> Result<Bytes, CommandError>; /// Tries to parse a buffer ...
true
712ca1425dd183eed2a97093ad0ccd4290ae9b6c
Rust
maxastyler/Spirograph
/src/main.rs
UTF-8
2,877
2.8125
3
[]
no_license
extern crate image; use std::fs::File; use std::f64::consts::*; // let img = spiro_image((2000, 2000), linspace(-2., 2., 20), path_points(100000), &path, &gen_envelope); // Some path that takes t from 0 -> 1 and should close on itself fn path(t: f64) -> (f64, f64) { let theta = 2.*PI*t; let r = 500.*(1.-thet...
true
68009e0563d1afe531a5d2e315ec66f9c8236879
Rust
VictorKoenders/pixelflut
/src/mode/async_std.rs
UTF-8
2,271
2.625
3
[]
no_license
use crate::{ client::ClientState, screen::{Screen, ScreenUpdater}, }; use async_std::{ io::{ReadExt, WriteExt}, net::{TcpListener, TcpStream}, }; pub fn start(args: crate::Args, screen: impl Screen, updater: Option<impl ScreenUpdater>) { if let Some(count) = args.core_count { // ASYNC_STD_T...
true
2986f11e85be20ef683b3cddbb0b286a6d611e7c
Rust
wibbe/tiny-rts
/src/main.rs
UTF-8
2,855
2.6875
3
[ "MIT" ]
permissive
// Make sure we don't open a console window if we are building on windows and in release mode #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] extern crate tiny; mod cmd; mod game; use tiny::*; use tiny::default_font; use tiny::palette::dawn_bringer as pal; use std::rc::{Rc}; struct App { ga...
true
92fc976b9b9d6a0ddd127d872253d860dbba2da6
Rust
RustUser/Rust-Switch
/src/main.rs
UTF-8
650
3.53125
4
[]
no_license
mod switch; use switch::*; #[derive(Debug)] struct Point { x: i32, y: i32, } impl Point { fn new(x: i32, y: i32) -> Point { return Point { x, y, }; } } fn main() { let array: [i32; 4] = [5, 4, 3, 2]; let mut output: Vec<Point> = Vec::new(); let m...
true
6796738fedadda3070097f8f7aed6d33565a3efd
Rust
Maaarcocr/TWiS
/src/client.rs
UTF-8
1,140
2.875
3
[]
no_license
use hyper::header::Headers; use hyper::Result; use hyper::client::{Client, Response}; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; header!{ (Authorization, "Authorization") => [String] } header!{ (UserAgent, "User-Agent") => [String] } #[derive(Debug)] pub struct Github { client: Client, ...
true
83b6c90747ebfdd33e9a8126fa60f6ed51ffa02d
Rust
19h/polygon-rs
/src/models/exchange.rs
UTF-8
2,529
2.53125
3
[]
no_license
/* * Polygon API * * The future of fintech. * * OpenAPI spec version: 1.0.1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ #![allow(unused_imports)] use serde_json::Value; use bigdecimal::BigDecimal; use chrono::{NaiveDateTime, DateTime, FixedOffset, Utc}; use crate::models::*; //us...
true
36f81e491e64884bcae4eff8b51b5201ae56ad5a
Rust
colin-kiegel/twig-rust
/src/engine/parser/lexer/patterns/verbatim_end.rs
UTF-8
3,218
2.921875
3
[ "BSD-3-Clause" ]
permissive
// This file is part of rust-web/twig // // For the copyright and license information, please view the LICENSE // file that was distributed with this source code. //! The `verbatim_end` pattern used by the lexer to tokenize the templates. /// /// Written as regular expressions (perl-style). use super::Options; use re...
true
5ad6b5645360d9b6821f7ed0c09bd628ccb2bf52
Rust
kimlimjustin/xplorer
/api/web/src/drives.rs
UTF-8
2,581
3.015625
3
[ "Apache-2.0" ]
permissive
use std::process::Command; use sysinfo::{DiskExt, System, SystemExt}; #[derive(serde::Serialize, Debug)] pub struct DriveInformation { name: String, mount_point: String, total_space: u64, available_space: u64, is_removable: bool, disk_type: String, file_system: String, } #[derive(serde::Seri...
true
734ef1f33671ba9ee0e9d8a12009340490308900
Rust
mrjones/simcastle
/src/core/gamestate.rs
UTF-8
8,700
2.828125
3
[]
no_license
use super::castle; use super::character; use super::economy; use super::population; use super::statemachine; use super::types; use super::workforce; use log::{info}; use anyhow::Context; use rand::Rng; use serde::{Deserialize, Serialize}; pub struct GameSpec { pub initial_potential_characters: usize, pub init...
true
4e8c99e01fd26d809819e42a04ee98a032871e30
Rust
r8d8/u2f-hid-rs
/src/linux/devicemap.rs
UTF-8
1,615
2.875
3
[]
no_license
use rand::{thread_rng, Rng}; use std::collections::hash_map::ValuesMut; use std::collections::HashMap; use std::ffi::OsString; use ::platform::device::Device; use ::platform::monitor::Event; pub struct DeviceMap { map: HashMap<OsString, Device> } impl DeviceMap { pub fn new() -> Self { Self { map: Ha...
true
461f5485b47943e91e8adeed43013bbecfc37d7e
Rust
petitviolet/rsstable
/src/sst/rich_file.rs
UTF-8
1,621
3.078125
3
[]
no_license
use std::{ fs::{File, OpenOptions}, io, ops::Deref, path::{Path, PathBuf}, }; pub(crate) struct RichFile { pub underlying: File, pub dir: String, pub name: String, } #[derive(Debug)] pub(crate) enum FileOption { New, Append, ReadOnly, } impl FileOption { fn open(&self, path:...
true
df6c591baa26687c2269a2e2e45b18f1122faa87
Rust
remram44/rpztar
/src/main.rs
UTF-8
7,545
2.828125
3
[]
no_license
use anyhow::{Context, Result as AResult, anyhow}; use flate2::read::GzDecoder; use nix::unistd::{FchownatFlags, Gid, Uid, fchownat}; use tar::{Archive, Entry, EntryType}; use std::collections::HashSet; use std::convert::TryInto; use std::env; use std::ffi::{OsStr, OsString}; use std::fs; use std::io::{BufRead, Read}; u...
true
c446d197211f9fddece9b19602a5daa33859a3ec
Rust
winding-lines/weaver
/lib-index/src/repo/mod.rs
UTF-8
654
2.546875
3
[]
no_license
use lib_error::*; use std::convert::From; mod config; mod encrypted_repo; pub use self::encrypted_repo::EncryptedRepo; /// Represents a collection in the repo. #[derive(Debug)] pub struct Collection(pub String); impl Collection { fn name(&self) -> &str { &self.0 } } impl From<String> for Collection ...
true
37c1cbb83c93ea366349890bebd611d7d316dd6e
Rust
soundybot/helium
/src/routes/upload.rs
UTF-8
2,696
2.546875
3
[ "MIT" ]
permissive
use crate::enums::PermissionLvl; use crate::s3::upload::upload_to_s3; use crate::s3::util::get_default_tags; use crate::structs::{HeliumConfig, HeliumConfigWrapper}; use crate::util; use crate::util::build_perm_err; use actix_multipart::Multipart; use actix_web::body::Body; use actix_web::http::Error; use acti...
true
f4637ddd034d78bf8ede1f6273038f77654119fd
Rust
xDerekFoster/cargo-mobile
/src/android/adb/device_name.rs
UTF-8
1,276
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use super::adb; use crate::{ android::env::Env, util::cli::{Report, Reportable}, }; use once_cell_regex::regex; use std::str; #[derive(Debug)] pub enum Error { DumpsysFailed(super::RunCheckedError), InvalidUtf8(str::Utf8Error), NotMatched, } impl Reportable for Error { fn report(&self) -> Repo...
true
03fa952b8d42a854a083e0fdee4367c1b5c71298
Rust
lineCode/tuix
/widgets/src/inputs/slider.rs
UTF-8
17,696
3.484375
3
[ "MIT" ]
permissive
use crate::common::*; #[derive(Debug, Clone, PartialEq)] pub enum SliderEvent { // TODO - Remove this ValueChanged(f32), SetValue(f32), SetMin(f32), SetMax(f32), } pub struct Slider { // The track that the thumb slides along track: Entity, // An overlay on the track to indicate the val...
true
559188a66f369418b1082e6b10da18f973d61080
Rust
drconopoima/quick-sort-rust
/src/random_generator.rs
UTF-8
1,451
3.28125
3
[ "Apache-2.0" ]
permissive
use std::num::Wrapping; /// Pseudo-random number generator based on Lehmer algorithm /// Source https://lemire.me/blog/2019/03/19/the-fastest-conventional-random-number-generator-that-can-pass-big-crush/ use std::sync::Mutex; use std::time::{SystemTime, UNIX_EPOCH}; lazy_static::lazy_static! { static ref RG: Mutex...
true
2c3a9c380020b72c6ddef6a7604aa39c2cd7a0bb
Rust
bmac/ggj-2019-kaiju
/src/main.rs
UTF-8
5,939
2.734375
3
[]
no_license
// Draw an image to the screen extern crate quicksilver; use quicksilver::{ geom::{Rectangle, Shape, Transform, Vector}, graphics::{Background::Img, Color, Image}, // We need Image and image backgrounds input::{Key, ButtonState}, lifecycle::{run, Asset, Settings, State, Window, Event}, // To load anyth...
true
05d10de8995bb07f8533b552c6c41ab4ff8711e3
Rust
binh-vu/semantic-modeling
/algorithm/src/data_structure/unique_array.rs
UTF-8
1,455
3.25
3
[ "MIT" ]
permissive
use std::collections::HashSet; use std::ops::Index; use std::process::id; use std::hash::Hash; pub struct UniqueArray<V, K: Hash + Eq + PartialEq + Clone=String> { data: Vec<V>, id: HashSet<K> } impl<V, K: Hash + Eq + PartialEq + Clone> UniqueArray<V, K> { pub fn new() -> UniqueArray<V, K> { Uniqu...
true
38e23148c94406360e227f3eaa308697769390b8
Rust
gitter-badger/tmpo
/src/error/mod.rs
UTF-8
818
2.90625
3
[ "MIT" ]
permissive
use std::fmt; use std::fmt::{Formatter, Display}; #[derive(Debug)] pub enum RunError { Config(String), IO(std::io::Error), Input(String), Repository(String), Template(String), Update(String), } impl Display for RunError { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match self { Self::Con...
true
9cdcfda6219fb094564a79e6f4f1dbd67ccc63cd
Rust
YewoMhango/cli_calc
/src/token.rs
UTF-8
3,476
4.03125
4
[]
no_license
#[derive(Debug, Clone, Copy, PartialEq)] pub enum Token { Plus, Minus, Multiplication, Division, Modulo, Power, SquareRoot, Combination, Permutation, Logarithm, NaturalLogarithm, ArcTan, ArcCos, ArcSin, Tan, Sin, Cos, Factorial, ...
true
9e2778d9961cbd5235979231d5dc3a6f3f707491
Rust
dumpstr/looper
/src/main.rs
UTF-8
549
4.3125
4
[]
no_license
fn main() { //this just prints "AGANE!!" until stopped /* loop{ println!("AGANE!!"); } */ //counts down from 5 using while loop /* let mut number = 5; while number != 0 { println!("{}!", number); number -= 1; } println!("B L A S T O F F !"); */ ...
true
017842c23fb91d4247c6037eaefad519eb9e2fa6
Rust
royswale/leetcode
/src/bin/maximum-depth-of-binary-tree.rs
UTF-8
891
3.421875
3
[ "MIT" ]
permissive
fn main() {} struct Solution; // Definition for a binary tree 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 { ...
true
1bc73d946a8baf97f6bcbecbdac4d31ed01a4876
Rust
Techcable/gc-arena
/src/gc-sequence/src/then.rs
UTF-8
2,484
2.828125
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain", "MIT" ]
permissive
use gc_arena::{Collect, MutationContext, StaticCollect}; use crate::Sequence; #[must_use = "sequences do nothing unless stepped"] #[derive(Debug, Collect)] #[collect(no_drop)] pub enum Then<'gc, S, F> where S: Sequence<'gc>, { First(S, Option<StaticCollect<F>>), Second(Option<(S::Output, StaticCollect<F>)...
true
46161defd25510999ca5c9d3f08ea1244246e58d
Rust
nimiq/core-rs-albatross
/zkp/examples/prover/setup.rs
UTF-8
750
2.546875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{path::PathBuf, time::Instant}; use nimiq_primitives::networks::NetworkId; use nimiq_zkp_circuits::setup::setup; use rand::thread_rng; /// Generates the parameters (proving and verifying keys) for the entire zkp circuit. /// This function will store the parameters in file. /// Run this example with `cargo ru...
true
72ef829f6005940dc764d8cfec6d472cb9582fdb
Rust
tyrchen/rust-training
/live_coding/training_code/src/actor.rs
UTF-8
2,204
3.375
3
[]
no_license
use anyhow::Result; use tokio::sync::{mpsc, oneshot}; pub struct Actor<State, Request, Reply> { // receiver side mpsc receiver: mpsc::Receiver<ActorMessage<Request, Reply>>, state: State, } impl<State, Request, Reply> Actor<State, Request, Reply> where State: Default + Send + 'static, Request: Han...
true
3f0011ceefafff916f9c2182ceb64120976f4a1f
Rust
eHammarstrom/advent-of-code-2020
/day3/src/main.rs
UTF-8
2,366
3.21875
3
[]
no_license
use std::io::prelude::*; use std::io; fn input_to_string<R: Read>(r: R) -> io::Result<String> { let mut reader = io::BufReader::new(r); let mut data = String::new(); reader.read_to_string(&mut data)?; Ok(data) } fn input_to_matrix(input: &str, (col_len, row_len): (usize, usize)) -> Vec<Vec<bool>> { ...
true
8ccf38a44939fdc92fb3c3b67b258cd6cf7c03cf
Rust
maudnals/wasm-image-operations
/lib-img-operations/src/lib.rs
UTF-8
2,158
2.609375
3
[]
no_license
#![feature(use_extern_macros)] #[macro_use] extern crate stdweb; use stdweb::{ Array, js_export, }; use stdweb::web::{ TypedArray }; #[js_export] fn reduce_sum_u8(arr: TypedArray<u8>) -> u32 { // need vec to iter() (there is no iter() on TypedArray) let vec: Vec<u8> = arr.to_vec(); // need u...
true
1b8cbf25994bb459e2428070f21d416a0f260f40
Rust
AndrewMendezLacambra/rust-programming-contest-solutions
/atcoder/abc144_f.rs
UTF-8
2,351
3
3
[]
no_license
fn main() { let s = std::io::stdin(); let mut sc = Scanner { stdin: s.lock() }; let n: usize = sc.read(); let m: usize = sc.read(); let mut graph = vec![vec![]; n]; let mut inverse = vec![vec![]; n]; for _ in 0..m { let a = sc.read::<usize>() - 1; let b = sc.read::<usize>() ...
true
7b82c1033dd3e3b757acabf63ab2bd1e8bd2e492
Rust
lavriv92/rust-example
/src/modules/structs.rs
UTF-8
1,376
3.53125
4
[]
no_license
extern crate std; use std::f64::consts::PI; use super::traits::HasArea; pub struct Circle { x: f64, y: f64, radius: f64, } impl Circle { pub fn new(x: f64, y: f64, radius: f64) -> Circle { Circle { x: x, y: y, radius: radius } } } pub struct S...
true
c24b58cdeba972ac1eb1e14ee5cd1a604a42903d
Rust
jsim2010/market
/src/error.rs
UTF-8
21,673
3.40625
3
[]
no_license
//! Defines the errors that can be thrown by an [`Agent`]. #[cfg(doc)] use crate::{Agent, Consumer, Producer}; use { alloc::string::{String, ToString}, core::{ convert::TryFrom, fmt::{self, Debug, Display, Formatter}, marker::PhantomData, }, fehler::{throw, throws}, never::N...
true
4e9ae7ea47d768bebf98b594934239ddb2520e68
Rust
m9s/xmc1000
/xmc1000/src/port0/phcr1/mod.rs
UTF-8
13,417
2.828125
3
[]
no_license
#[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::PHCR1 { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut...
true
c16a3ca34ee6d3139af390490132e2c9e2b7f3c8
Rust
PatrickMcSweeny/exercism_solutions
/rust/grains/src/lib.rs
UTF-8
256
3.34375
3
[]
no_license
const SQUARES: u32 = 64; pub fn square(s: u32) -> u64 { if s < 1 || s > SQUARES { panic!("Square must be between 1 and {}", SQUARES); } 2_u64.pow(s - 1) } pub fn total() -> u64 { (1..=SQUARES).map(|number| square(number)).sum() }
true
6f701516bf64bc071a5c7fd3facd3c5dfcc72cda
Rust
briansunter/Rust-webapp-starter
/src/utils/error.rs
UTF-8
3,019
3.109375
3
[ "Apache-2.0" ]
permissive
use std::result; use std::io; use std::fmt; use std::error; use std::num; use utils::jwt; pub type Result<T> = result::Result<T, Error>; #[derive(Debug)] pub enum Error { IoError(io::Error), CodedError(ErrorCode), TokenError(jwt::Error), ParseIntError(num::ParseIntError), Message(String) } impl ...
true
7cd6f534e6813139bac61e2400d4d23bae9e7790
Rust
Vrixyz/rusttd
/src/math_utils.rs
UTF-8
892
3.453125
3
[ "MIT" ]
permissive
use bevy::math::Vec3; pub fn move_towards(current: Vec3, target: Vec3, max_distance_delta: f32) -> Vec3 { let to_vector = target - current; let sqdist = target.distance_squared(current); if sqdist == 0.0 || (max_distance_delta >= 0.0 && sqdist <= max_distance_delta.powf(2.0)) { return target; ...
true
1aec046c8a915b7fc4ff8cc32b61ec6e5e360f65
Rust
iotaledger/bee
/bee-protocol/bee-protocol/src/peer/packet_handler.rs
UTF-8
12,628
3.015625
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2022 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use bee_gossip::Multiaddr; use futures::{ channel::oneshot, future::{self, FutureExt}, stream::StreamExt, }; use log::trace; use tokio::select; use tokio_stream::wrappers::UnboundedReceiverStream; use crate::packets::{HeaderPacket...
true
38278499fdc999354eb81889cb1b830dd3f00342
Rust
LinAGKar/advent-of-code-2018-rust
/day21b-hardcode/src/main.rs
UTF-8
936
2.96875
3
[ "MIT" ]
permissive
use std::collections::HashSet; use std::io::Read; fn main() { let mut input = String::new(); std::io::stdin().read_to_string(&mut input).unwrap(); let mut constants = input.lines().skip(1).map(|line| line.split_whitespace()); let val_start: u64 = constants.nth(7).unwrap().nth(1).unwrap().parse().unwra...
true
5664b0d8ec99fa5d0351c35db4c0873f166c29d0
Rust
y-yagi/til
/leetcode/sort-integers-by-the-number-of-1-bits/rust/src/lib.rs
UTF-8
446
3.484375
3
[]
no_license
#[cfg(test)] mod tests { use super::*; #[test] fn it_works() { assert_eq!( Solution::sort_by_bits(vec![0, 1, 2, 3, 4, 5, 6, 7, 8]), vec![0, 1, 2, 4, 8, 3, 5, 6, 7] ); } } struct Solution {} impl Solution { pub fn sort_by_bits(arr: Vec<i32>) -> Vec<i32> { ...
true
3cf944b11bd0aa9b2614fde0e31731d8ca63ae5d
Rust
lemonrock/file-descriptors
/src/posix_message_queues/OpenOrCreatePosixMessageQueue.rs
UTF-8
4,163
2.625
3
[ "MIT" ]
permissive
// This file is part of file-descriptors. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/file-descriptors/master/COPYRIGHT. No part of file-descriptors, including this file, may be copied, modified, propag...
true
1a5473e4b08ff80250c59ab817fe6837c4896c41
Rust
ymgyt/kvsd
/src/core/principal/mod.rs
UTF-8
248
2.640625
3
[ "MIT" ]
permissive
mod user; pub(crate) use user::User; #[derive(Debug, Clone)] pub(crate) enum Principal { AnonymousUser, User(User), } impl Principal { pub(crate) fn is_authenticated(&self) -> bool { matches!(self, Principal::User(_)) } }
true
3d3af12ba055277cc7a9728f3e52781633f45fc2
Rust
mbacch/max31855
/examples/linux_raspi.rs
UTF-8
956
2.625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
extern crate linux_embedded_hal as hal; extern crate max31855; use std::thread; use std::time::Duration; use max31855::{Max31855, Units}; use hal::spidev::{self, SpidevOptions}; use hal::{Pin, Spidev}; use hal::sysfs_gpio::Direction; fn main() { /* Configure SPI */ let mut spi = Spidev::open("/dev/spidev0....
true
5747f231766920cdf696ac237920cbce1639c6ee
Rust
arti4109-arquitectura-de-software/g2-reto1-2020-01-mati-g2
/src/engine/mod.rs
UTF-8
5,506
2.765625
3
[]
no_license
pub mod engine_bheap; pub mod engine_btree; pub mod engine_keyedheap; pub mod offer_ord; use crate::offers::{Offer, OfferEvent, OfferEventKeyed, OfferKey, Side}; use crossbeam_channel::{self, Receiver, Sender}; #[derive(Debug)] pub enum MatchResult { Complete, Partial { offer: Offer, to_substract: u64 }, N...
true
0657dfb0b4c1357c16f41fe014c0584d2512a77d
Rust
NjinN/Mo
/src/lang/msolver.rs
UTF-8
6,917
2.59375
3
[]
no_license
use std::collections::HashSet; use std::sync::{Arc, RwLock}; use std::time::{Duration, SystemTime}; use crate::*; use crate::lang::*; pub fn bind_ctx(list: &mut Vec<PMtoken>, ctx: PMctx){ bind_ctx_raw(list, ctx.clone(), HashSet::new()) } pub fn bind_ctx_local(list: &mut Vec<PMtoken>, ctx: PMctx, local: HashSet<...
true
0d75326378625eeb2578c8c5dee9b77bbd432d69
Rust
ray33ee/Native-Regex
/src/main.rs
UTF-8
3,770
2.953125
3
[ "MIT" ]
permissive
use clap::{Arg, App, crate_version, crate_authors}; use std::fs::OpenOptions; use std::io::Write; use native_regex_lib::rust_translate; fn main() -> Result<(), String> { let matches = App::new("Native Regex") .version(crate_version!()) .author(crate_authors!()) .about("Tool for convertin...
true
42ef1c4da1908e0faf332b33270b2bca8a727edf
Rust
SUSF-Robotics-and-Software/AutonomyControl
/src/tc_constructor.rs
UTF-8
2,178
2.90625
3
[]
no_license
// --------------------------------------------------------------------------- // TELECOMMAND CONSTRUCTOR // // Provides a single interface to the GUI for building telecommands which will // be sent to the Rover via the TmTcInterface module. // // Diferent types of telecommand are defined as structs here. // ----------...
true
6d06c67fe7bae988674f101765942865cb27a6a2
Rust
krzysz00/rust-kernel
/kernel/console.rs
UTF-8
831
2.765625
3
[ "MIT" ]
permissive
use machine; use mutex::Mutex; use core::fmt::{Write,Error}; use core::result::Result; const PORT: u16 = 0x3F8; pub struct Console; static CONSOLE_LOCK: Mutex<()> = Mutex::new(()); impl Console { pub fn write_bytes(&self, bytes: &[u8]) { let _lock = CONSOLE_LOCK.lock(); for b in bytes { ...
true
ba35abeb0f839a64be1b4e81c285663e7d4e4aac
Rust
lnds/desafios-programando.org
/2019-12-08/brute-force-sha512/src/main.rs
UTF-8
469
2.75
3
[]
no_license
#[macro_use] extern crate itertools; use sha2::{Digest, Sha512}; fn main() { let target = Sha512::new().chain(b"help").result(); let alpha = "abcdefghijklmnopqrstuvwxyz"; let col = iproduct!(alpha.chars(), alpha.chars(), alpha.chars(), alpha.chars()) .map(|(a, b, c, d)| format!("{}{}{}{}", a, b, c,...
true
9fd608ffeec0fd44866eaa7c8369fc7835052aa0
Rust
nicholastmosher/atsam4s16b-rs
/src/matrix/ccfg_smcnfcs/mod.rs
UTF-8
7,776
2.5625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
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::CCFG_SMCNFCS { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, ...
true
6b153dfb4818df77793081645ac06f67ce5c389e
Rust
onnovalkering/brane
/brane-dsl/src/errors.rs
UTF-8
8,118
2.625
3
[ "Apache-2.0" ]
permissive
use crate::scanner::{Span, Tokens}; use nom::error::{VerboseError, VerboseErrorKind}; pub fn convert_parser_error( input: Tokens, e: VerboseError<Tokens>, ) -> String { use std::fmt::Write; let mut result = String::new(); for (i, (tokens, kind)) in e.errors.iter().enumerate() { match kind...
true
afad660855542850819b8ada3bcc2669d15d9b2f
Rust
helloooooo/prac-algo
/atcoder/src/29.rs
UTF-8
1,224
3.15625
3
[]
no_license
use std::collections::BTreeSet; fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap...
true
e331078c8164008b5ce8236fde20154826361ed4
Rust
alexisfontaine/ocean
/components/router.rs
UTF-8
2,805
2.765625
3
[]
no_license
use yew::prelude::*; use yew_router::agent::RouteRequest; use yew_router::prelude::*; use super::components::anchor::{render, Kind, AnchorModifier, ButtonModifier}; use super::utils::ne_assign; pub enum Message<STATE> { Navigate, Navigation(Route<STATE>), } pub struct Anchor<SWITCH, STATE = ()> where STATE: Rout...
true
620c2bd5a679efeb2c46eadfef7a173d9a031ba0
Rust
ThomasZumsteg/exercism-rust
/custom-set/src/lib.rs
UTF-8
1,668
3.65625
4
[]
no_license
#[derive(Debug)] pub struct CustomSet<T: PartialEq + Clone> { set: Vec<T> } impl<T: PartialEq + Clone> CustomSet<T>{ pub fn new(items: Vec<T>) -> CustomSet<T> { let mut set = CustomSet { set: vec![] }; for item in items { set.add(item) } set } pub fn is_empty(&self) -> bool { self....
true
1b56d55947d9c97b39d0a6c3ea4f42ddbd88ddee
Rust
gvanderest/adventofcode
/2021/day6/src/main.rs
UTF-8
4,320
3.515625
4
[]
no_license
use rayon::prelude::*; use std::collections::HashMap; use std::fs; fn step_lanternfish( current_fish: Vec<usize>, reset_fish_value: usize, new_fish_value: usize, ) -> Vec<usize> { current_fish .par_iter() .flat_map(|days| -> Vec<usize> { match days { 0 => [re...
true
654135aa84945b1c24116d7b46dba36464487346
Rust
arendjr/ts-rs
/example/src/lib.rs
UTF-8
2,414
2.9375
3
[ "MIT" ]
permissive
#![allow(dead_code)] use serde::Serialize; use std::collections::BTreeSet; use std::rc::Rc; use ts_rs::{export, TS}; #[derive(Serialize, TS)] #[ts(rename_all = "lowercase")] enum Role { User, #[ts(rename = "administrator")] Admin, } #[derive(Serialize, TS)] // when 'serde-compat' is enabled, ts-rs tries ...
true
3cfcb7468f5508dce5fc3b4b4834f8ad55439782
Rust
ytyaru/Rust.Advanced.Function.Closure.20190708174220
/src/2/main.rs
UTF-8
364
2.890625
3
[ "CC0-1.0" ]
permissive
/* * Rustの高度な機能(関数、クロージャ)。 * CreatedAt: 2019-07-08 */ fn main() { } /* // error[E0277]: the size for values of type `(dyn std::ops::Fn(i32) -> i32 + 'static)` cannot be known at compilation time fn returns_closure() -> Fn(i32) -> i32 { |x| x + 1 } */ fn returns_closure() -> Box<Fn(i32) -> i32> { Box::new(|x|...
true
f40512b96ce9cd00ddff6276ac7daaf36e415a57
Rust
hamishgibbs/rust_dsa
/src/bin/edit_distance.rs
UTF-8
2,009
3.78125
4
[]
no_license
/* How it works: Calculates the edit distance (a string distance metric) for two strings. Edit distance is the number of changes needed to make two strings equal. i.e. (test, tset) has an edit distance of one. */ use std::cmp::min; pub fn edit_distance(str_a: &str, str_b: &str) -> u32 { // Initialize a vect...
true
e821f12a6541d1eca6ab0d2e9d710f15889be27a
Rust
MattiasBuelens/advent-of-code-2019
/src/bin/day7/main.rs
UTF-8
3,543
3.03125
3
[ "MIT" ]
permissive
use std::cmp::max; use std::collections::VecDeque; use permutohedron::Heap; use advent_of_code_2019::input::parse_list; use advent_of_code_2019::intcode::*; fn main() { let input: Vec<i64> = parse_list(include_str!("input"), ','); println!("Answer to part 1: {}", part1(&input)); println!("Answer to part ...
true
58b6dffcbb0a845fd80f534aa700cae52f991de0
Rust
xfbs/afp
/src/ui/view/section_overview.rs
UTF-8
2,798
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate gtk; use crate::ui::*; use gtk::prelude::*; #[derive(Clone)] pub struct SectionOverView { body: gtk::Grid, title: gtk::Label, subsections: gtk::FlowBox, exam: gtk::Button, practise: gtk::Button, } impl SectionOverView { pub fn new() -> SectionOverView { SectionOverView { ...
true
5d2c60da5f7373e8bd53bf13ef5c1e8e388abcca
Rust
ilovelll/learn-rust-by-example
/ch9-functions/src/closures.rs
UTF-8
4,267
3.5
4
[]
no_license
fn main() { fn function (i: i32) -> i32 { i + 1} let closure_annotated = |i: i32| -> i32 {i + 1}; let closure_inferred = |i| i + 1; println!("function: {}", function(1)); println!("closure_anotated: {}", closure_annotated(1)); println!("closure_inferred: {}", closure_inferred(1)); let one = || 1; pri...
true
af7dc574031cb0d36adc0cc93c6ebd42569c055c
Rust
stakeada/jormungandr
/jcli/src/jcli_app/utils/rest_api.rs
UTF-8
7,431
2.609375
3
[ "MIT", "Apache-2.0" ]
permissive
use hex; use jcli_app::utils::{open_api_verifier, CustomErrorFiller, DebugFlag, OpenApiVerifier}; use reqwest::{self, header::HeaderValue, Client, Request, RequestBuilder, Response}; use serde::{self, Serialize}; use serde_json::error::Error as SerdeJsonError; use std::fmt; pub const DESERIALIZATION_ERROR_MSG: &'stati...
true
0fda630aa56158451a0b52a9077b1b3370f9939b
Rust
ErickHdez96/lc
/src/terminal.rs
UTF-8
1,710
3.78125
4
[]
no_license
use core::fmt; #[derive(Debug, Copy, Clone)] pub enum Color { Black, Red, Green, Yellow, Blue, Magenta, Cyan, White, BrightBlack, BrightRed, BrightGreen, BrightYellow, BrightBlue, BrightMagenta, BrightCyan, BrightWhite, } impl Color { pub fn to_str(s...
true
f3b8017c1b05eba070c139ce0efca71f7d090544
Rust
Cyclonecinta88/naught
/src/error.rs
UTF-8
2,643
2.546875
3
[ "MIT" ]
permissive
extern crate hmac; extern crate hyper; extern crate serde; extern crate tokio; use std::error::Error as StdError; use std::fmt; use serde::Serialize; #[derive(Serialize, Debug)] pub enum Error { AddrParse(String), Hyper(String), HyperHTTP(String), TimerError, NotFound, StoreFailed(String), ...
true
294de65b9912ccdc30a42a3727c468adb7f59b3a
Rust
softprops/dynomite
/dynomite/trybuild-tests/fail/incorrect-fn-path-in-skip-serializing-if.rs
UTF-8
684
2.59375
3
[ "MIT" ]
permissive
use dynomite::{Attributes}; #[derive(Attributes)] struct Test1 { #[dynomite(skip_serializing_if = "true")] field: u32, } #[derive(Attributes)] struct Test2 { #[dynomite(skip_serializing_if = "2 + 2")] field: u32, } #[derive(Attributes)] struct Test3 { #[dynomite(skip_serializing_if = "|| true")] ...
true
bbba9c5e53bd6bf93cf16f357672f50c719522b9
Rust
iCodeIN/css-1
/src/optimize.rs
UTF-8
661
2.859375
3
[ "Apache-2.0" ]
permissive
use std::fs; use std::io::Error; use std::process; use crate::css; pub fn css(file: &str) -> Result<(), Error> { let contents = match fs::read_to_string(file) { Ok(str) => str, Err(e) => return Err(e), }; let optimized = match css::optimize(contents) { Ok(opt) => opt, Err(...
true
152af7a1c0036867adcc8454e8b74a5784d9548e
Rust
Nugine/heng-rs
/heng-utils/src/queue.rs
UTF-8
408
3.171875
3
[]
no_license
pub struct Queue<T> { tx: async_channel::Sender<T>, rx: async_channel::Receiver<T>, } impl<T: Send> Queue<T> { pub fn unbounded() -> Self { let (tx, rx) = async_channel::unbounded(); Self { tx, rx } } pub async fn push(&self, value: T) { self.tx.send(value).await.unwrap(); ...
true
12711b438c36484e00588468906c42d0be841e28
Rust
bwhetherington/rust-lisp
/src/errors.rs
UTF-8
1,070
2.90625
3
[]
no_license
use values::Value; use sexpr::SExpr; pub fn arity_at_least(expected: usize, found: usize) -> String { format!("Expected at least {} arg(s), found {}.", expected, found) } pub fn arity_at_most(expected: usize, found: usize) -> String { format!("Expected at most {} arg(s), found {}.", expected, found) } pub fn...
true
0b386dfedff3afdaf40a630b1296388b3c2f68cd
Rust
acshi/jlrs
/jlrs/src/wrappers/ptr/function.rs
UTF-8
5,463
2.75
3
[ "MIT" ]
permissive
//! Wrapper for `Function`, the super type of all Julia functions. //! //! All Julia functions are subtypes of `Function`, a function can be called with the methods //! of the [`Call`] trait. Note that you don't need to cast a [`Value`] to a [`Function`] in order //! to call it because [`Value`] also implements [`Call`...
true