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
e7ea69b4291ff2bdf7885fe2a63225028f72e26f
Rust
RevelationOfTuring/Rust-exercise
/src/function_closures_type_anonymity.rs
UTF-8
1,444
3.890625
4
[ "Apache-2.0" ]
permissive
/* 闭包从周围的作用域中捕获变量是简单明了的。 这样会有某些后果吗?确实有。 观察一下使用闭包作为函数参数,这要求闭包是`泛型`的,闭包定义的方式决定了这是必要的。 // `F` 必须是泛型的。 fn apply<F>(f: F) where F: FnOnce() { f(); } 当闭包被定义,编译器会隐式地创建一个`匿名类型的结构体`,用以储存闭包捕获的变量。 同时为这个未知类型的结构体实现函数功能,通过Fn、FnMut或FnOnce三种trait中的一种。 若使用闭包作为函数参数,由于这个结构体的类型未知,任何的用法都要求是泛型的。 然而,使用未...
true
824bee1bd08febb0228c4131388d531ef57bf753
Rust
Scylardor/pbrt-rs
/src/lib.rs
UTF-8
1,143
3.125
3
[ "MIT" ]
permissive
mod math; pub mod types; mod parser; use parser::Parser; pub use parser::ParseError; mod integrators; use integrators::{Integrator, PathIntegrator}; struct SceneData { pub integrator: Box<Integrator> } pub struct Raytracer { scene: SceneData } impl Raytracer { pub fn from(scene_path: &str) -> Result<...
true
cadc1ed46da2dc83a698bdd13272159a3ead8f67
Rust
wbprice/tasks-and-subtasks
/src/main.rs
UTF-8
1,232
3.375
3
[]
no_license
#[derive(Debug, Copy, Clone)] enum Activity { GoToStore, GoToWork, Play } #[derive(Debug, Copy, Clone)] enum Subactivity { Step, Jump, Kick, Walk } #[derive(Debug, Clone)] struct Task { activity: Activity, subtasks: Box<Vec<Subtask>> } impl Task { fn new(activity: Activity) ->...
true
58040ae8d901ad9191bf7ebf08eb4d991e3a5d81
Rust
AndreasHae/rust-http-server
/src/domain.rs
UTF-8
2,171
3.703125
4
[]
no_license
use serde::{Deserialize, Serialize}; use std::cmp::Eq; use std::fmt::Debug; use std::sync::RwLock; #[derive(Deserialize, PartialEq, Eq, Debug)] pub struct UserCreation { name: String, } #[derive(Serialize, Clone, PartialEq, Eq, Debug)] pub struct User { id: u32, name: String, } pub struct AppState { ...
true
619ac2da03cd251a469ae6a4146e310c58446a2a
Rust
gen0x39/gbadev
/src/main.rs
UTF-8
7,671
2.609375
3
[]
no_license
#![no_std] #![feature(start)] #[panic_handler] fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } mod rgb; mod gba_color; mod graphics; mod font; mod font_def; mod io; use rgb::RGB; use rgb::RGBDef; use gba_color::GBAColor; use graphics::Graphics; use crate::io::key_up_is_pressed; use crate::io::key_a_is_...
true
8ad9d72a303f1c35df91b4cfb71a045e47d82168
Rust
paisit04/udemy-rust
/Traits/src/op_overloading.rs
UTF-8
1,425
3.8125
4
[]
no_license
use std::ops::{Add, AddAssign, Neg}; use std::cmp::PartialEq; #[derive(Debug)] struct Complex<T> { re: T, im: T } impl<T> Complex<T> { fn new(re: T, im: T) -> Complex<T> { Complex::<T> { re, im } } } impl<T> Add for Complex<T> where T: Add<Output = T> { type Output = Complex<T>; ...
true
c3991de6e467e6d2e698b7e9cd96bca3bb99c6c5
Rust
Munksgaard/freqalyze
/src/lib.rs
UTF-8
1,509
3.140625
3
[]
no_license
#![feature(inclusive_range_syntax)] fn score_byte(c: u8) -> Option<u64> { let c = if b'A' <= c && c <= b'Z' { c - b'A' + b'a' } else { c }; match c { b'e' => Some(5), b'a' | b't' => Some(4), b'h' | b'i' | b'n' | b'o' | b'r' | b's' | b' ' => Some(3), b'b'...
true
9e74c29ebcf59ea53e57ec6dec4b381ac68cb5fc
Rust
fergusonB/cpufreq
/src/main.rs
UTF-8
333
2.59375
3
[]
no_license
use cpufreq; use std::thread; fn main() { let interval = cpufreq::get_interval(); loop { let data = cpufreq::get_data(); let results = cpufreq::search(&data); let formatted_results = cpufreq::format(results); println!("{:?}", formatted_results); thread::sleep(interv...
true
bc8671ba2d2a3ac47d2c682243e6739bd66cc498
Rust
lfdominguez/elastic
/src/queries/src/aggregations/mod.rs
UTF-8
17,119
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
pub(crate) mod date_histogram; pub(crate) mod stats; pub(crate) mod terms; use self::{ date_histogram::DateHistogramAggregation, stats::{ AvgAggregation, MaxAggregation, SumAggregation, }, terms::TermAggregation, }; use std::{ collections::{ hash_map::Iter, H...
true
ff7d5e62f366618c910bcfaf9cbc55756b48725e
Rust
prscoelho/aoc2020
/src/day08/day08.rs
UTF-8
2,518
3.609375
4
[]
no_license
use std::collections::HashSet; #[derive(Clone, Copy)] struct Instruction { value: i64, kind: InstructionKind, } #[derive(Clone, Copy)] enum InstructionKind { ACC, JUMP, NOP, } fn parse_instruction(line: &str) -> Instruction { let mut tokens = line.split(" "); let instr = tokens.next().unwra...
true
94786e62877359597d539427f3d13fc16b358015
Rust
tragle/blarf
/src/bin/blarf.rs
UTF-8
880
2.515625
3
[ "MIT" ]
permissive
extern crate blarf; use blarf::{exec, Config}; use std::path::Path; const ARTICLES_ROOT: &str = "articles"; const DEST_ROOT: &str = "site"; fn main() -> std::io::Result<()> { let args = blarf::util::get_args(); let articles_dir: &Path = &args .value_of("articles") .map_or(Path::new(ARTICLES_...
true
69e461b2ecb2c233a9be1ded13f47cc2eb758b57
Rust
lholznagel/cachem
/derive/src/lib.rs
UTF-8
1,520
2.5625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![feature(proc_macro_diagnostic)] //! This crate provides useful derives for different traits of the database. /// Implementation of the [cachem::Get2] trait mod get; /// Implementation of the [cachem::Parse] trait mod parse; /// General purpose functions mod utils; use proc_macro::TokenStream; use quote::quote; us...
true
19d5c29e021f752dca24abb1dd300d135b9032b5
Rust
eHammarstrom/tracing
/tracing-proc-macros/src/lib.rs
UTF-8
1,734
2.625
3
[ "MIT" ]
permissive
extern crate proc_macro; use proc_macro::TokenStream; use quote::quote; use syn; use syn::parse_macro_input; #[proc_macro_attribute] pub fn traced_test(attr_args: TokenStream, input: TokenStream) -> TokenStream { let fun = parse_macro_input!(input as syn::ItemFn); let num_args = attr_args.clone().into_iter().c...
true
8b32d01feb3c1face03900cafe185b28ac1579e1
Rust
zhiburt/tabled
/tabled/src/settings/modify.rs
UTF-8
3,657
3.34375
3
[ "MIT" ]
permissive
use crate::{ grid::{ config::Entity, records::{ExactRecords, Records}, }, settings::{object::Object, CellOption, Settings, TableOption}, }; /// Modify structure provide an abstraction, to be able to apply /// a set of [`CellOption`]s to the same object. /// /// Be aware that the settings ar...
true
2721744a693baa52a64d8d6ff9084c75e3a253d5
Rust
Ryan-Cummings/r3
/src/main.rs
UTF-8
1,714
2.5625
3
[]
no_license
extern crate termion; extern crate reqwest; extern crate select; use std::fs::File; use std::io::{BufReader, BufRead}; use std::io::Error; use std::result::Result; use select::document::Document; use select::predicate::Name; fn get_urls(url: &str) -> Result<(), Error> { let url2req = format!("http://{}", url); ...
true
c8b5a896b1644699c3a2952a4ab6833f62fb3662
Rust
doraneko94/numerical
/src/pde/parabolic.rs
UTF-8
3,366
2.78125
3
[]
no_license
use eom::traits::*; use ndarray::*; use ndarray_linalg::*; //use crate::implicit::*; use crate::difference::*; use ndarray_linalg::solve::LUFactorized; #[derive(Clone)] pub struct Parabolic { pub range: (f64, f64), pub c: f64, pub dt: f64, pub x_part: usize, pub dx: f64, pub lu: LUFactorized<nd...
true
197ba57caf533558d1c3c3a2490c7466c2a5a1ee
Rust
michel-steuwer/container-project
/rust_containers/src/container_library/binary_search_tree.rs
UTF-8
13,386
3.421875
3
[]
no_license
use std::cmp; use std::cmp::Ordering; use std::vec::Vec; pub struct Node<T: Ord> { value: T, height: i64, count: usize, left: Option<Box<Node<T>>>, right: Option<Box<Node<T>>> } impl <T: Ord> Node<T> { pub const fn new(v: T) -> Node<T> { Node { value: v, height: 0, count: 1, left: None...
true
c7513cd0589762004a596bcd100a7b1a2c533923
Rust
gnoliyil/fuchsia
/third_party/rust_crates/ask2patch/regex-automata/src/regex.rs
UTF-8
31,353
3.5
4
[ "BSD-2-Clause", "MIT", "Unlicense" ]
permissive
#[cfg(feature = "std")] use dense::{self, DenseDFA}; use dfa::DFA; #[cfg(feature = "std")] use error::Result; #[cfg(feature = "std")] use sparse::SparseDFA; #[cfg(feature = "std")] use state_id::StateID; /// A regular expression that uses deterministic finite automata for fast /// searching. /// /// A regular expressi...
true
404d73aec9fbf886757955fd3e797ea7de7b8924
Rust
w32blaster/kml-to-gpx-converter
/src/output.rs
UTF-8
2,175
2.53125
3
[]
no_license
use crate::commons::UniversalPoint; const XML_PREFIX: &str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <gpx xmlns=\"http://www.topografix.com/GPX/1/1\" xmlns:gpsies=\"https://www.gpsies.com/GPX/1/0\" creator=\"AllTrails https://www.alltrails.com\" version=\"1.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-ins...
true
4fc3f862b7af3334f321b2c2f51c9d27fb3be182
Rust
mpapazekos/rust-simple-http-server-example-
/src/server.rs
UTF-8
2,826
3
3
[]
no_license
use crate::http::Request; use crate::utils::{HttpHandler, ThreadPool}; use crate::WebSiteHandler; use std::convert::TryFrom; use std::io::Read; use std::net::{TcpListener, TcpStream}; use std::sync::Arc; // ========================================================================= pub struct Server<'s> { addr: St...
true
f76cd6800d4f2f60a4112ade8b0bd12d40f4a990
Rust
leejw51crypto/chain-tx-enclave
/chain/client-cli/src/command/wallet_command.rs
UTF-8
1,453
2.953125
3
[ "Apache-2.0", "MIT", "BSD-3-Clause" ]
permissive
use quest::{ask, success}; use structopt::StructOpt; use client_common::{ErrorKind, Result}; use client_core::WalletClient; use crate::ask_passphrase; #[derive(Debug, StructOpt)] pub enum WalletCommand { #[structopt(name = "new", about = "New wallet")] New { #[structopt(name = "name", short, long, he...
true
cb357e7f2158e22b79df6a2c779f273ce7d4fd9b
Rust
iqlusioninc/crates
/hkd32/src/lib.rs
UTF-8
2,364
3.171875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! HMAC-based Hierarchical Key Derivation: deterministically derive a //! hierarchy of symmetric keys from initial keying material through //! repeated applications of the Hash-based Message Authentication Code //! (HMAC) construction. //! //! This library implements a fully symmetric construction inspired by //! [BIP...
true
bfb4da9cc04b6700aceafedaa2bd1d62d37a273f
Rust
msiemens/RusTiny
/src/driver/error.rs
UTF-8
2,684
3.0625
3
[ "MIT" ]
permissive
//! Error reporting // IDEA: Cache errors in the session and have an abort_if_errors() that // is called every now and then. // IDEA: Show the source line and underline the offending token use ansi_term::Colour::Red; use driver; use driver::codemap::{BytePos, Loc}; use front::ast::{Node, Span}; use std::env; us...
true
6472bc7717291c068e5f3427a66b1ad83fd71d19
Rust
CapnRat/adventofcode2020
/src/solutions/day_05_1.rs
UTF-8
1,670
3.25
3
[]
no_license
use crate::solutions::input::get_data; #[derive(Debug, Default, Eq, PartialEq)] pub struct BoardingPass { pub row: u8, pub column: u8 } impl BoardingPass { pub fn get_seat_id (&self) -> u16 { (self.row as u16) * 8 + (self.column as u16) } } pub fn run() -> String { let passes: Vec<Boa...
true
99c8bd5f6eee3d786caef4c47386b3256eebe3f5
Rust
lelander/websocket-tests
/rust-websocket/src/bin/client.rs
UTF-8
2,195
2.84375
3
[]
no_license
#[macro_use] extern crate failure; extern crate websocket; use failure::Error; use std::net::TcpStream; use std::time::Duration; use websocket::client::ClientBuilder; use websocket::sync::Client; use websocket::{Message, OwnedMessage}; fn main() { let mut client = ClientBuilder::new("ws://localhost:3000") .e...
true
85cbb096cc0cee9e60743212fb4bf8f499a1e670
Rust
chromium/chromium
/third_party/rust/clap/v4/crate/examples/git-derive.rs
UTF-8
4,242
3.0625
3
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "BSD-3-Clause" ]
permissive
use std::ffi::OsStr; use std::ffi::OsString; use std::path::PathBuf; use clap::{Args, Parser, Subcommand, ValueEnum}; /// A fictional versioning CLI #[derive(Debug, Parser)] // requires `derive` feature #[command(name = "git")] #[command(about = "A fictional versioning CLI", long_about = None)] struct Cli { #[com...
true
93d8fb22ae594774172889d2616850a96659d19c
Rust
klausi/letsencrypt-inwx
/src/rpc.rs
UTF-8
4,776
2.703125
3
[ "MIT" ]
permissive
use reqwest::{Client, Response, StatusCode}; use reqwest::header::{Cookie, SetCookie}; use sxd_document::writer::format_document; use sxd_document::{parser, Package}; use sxd_document::dom::Document; use sxd_xpath::evaluate_xpath; use cookie; pub struct RpcRequestParameter { pub name: &'static str, pub value: ...
true
1f9184b065cbf549850111813fcf28fd3faee434
Rust
ibear1213/iLyrics
/src/types/rect.rs
UTF-8
1,540
2.890625
3
[ "MIT" ]
permissive
use bindings::Windows::Win32::Graphics::Direct2D::D2D_RECT_F; use super::Size; #[derive(Debug, Clone, Copy, PartialEq)] pub struct Rect { pub left: f32, pub top: f32, pub right: f32, pub bottom: f32, } impl Rect { pub fn width(&self) -> f32 { self.right - self.left } pub fn heigh...
true
6b65c78c5063ebb69ee418c95a094998d89223bc
Rust
bouzuya/rust-atcoder
/before-cargo-atcoder/abc130_c/src/main.rs
UTF-8
853
3.21875
3
[]
no_license
fn read<T: std::str::FromStr>( stdin_lock: &mut std::io::StdinLock, buf: &mut Vec<u8>, delimiter: u8, ) -> T { buf.clear(); let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap(); buf.truncate(l - 1); // remove delimiter let s = unsafe { std::str::from_utf8_unchecked(&buf)...
true
cc112a43293f5f2b691784b410f61b6df15527fa
Rust
jtschichold/rust-rtin1weekend
/src/main.rs
UTF-8
6,126
2.71875
3
[]
no_license
mod vec3; mod ray; mod hitable; mod hitablelist; mod sphere; mod camera; mod material; use crate::ray::Ray; use crate::vec3::Vec3; use crate::hitable::Hitable; use crate::hitablelist::HitableList; use crate::sphere::Sphere; use crate::camera::Camera; use crate::material::{Lambertian, Metal, Dielectric}; use rand::Rng...
true
eed17b9b62d4113af3a699888b57b77e5c950900
Rust
jamesandariese/tock
/kernel/src/upcall.rs
UTF-8
5,001
3.15625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Data structure for storing an upcall from the kernel to a process. use core::ptr::NonNull; use crate::config; use crate::debug; use crate::process; use crate::process::ProcessId; use crate::syscall::SyscallReturn; use crate::ErrorCode; /// Type to uniquely identify an upcall subscription across all drivers. /// ...
true
c85e00c574830c3fe355bd11188edca499666c18
Rust
gnoliyil/fuchsia
/src/ui/bin/terminal/src/ui/terminal_scroll_bar.rs
UTF-8
18,026
2.53125
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { crate::ui::TerminalMessages, carnelian::{make_message, AppSender, Coord, MessageTarget, Point, Rect, Size, ViewKey}, }; const MAXIMUM_THUMB_...
true
3e5c02dee7e1eaa5eb53ad58e2bdd2802e7c8001
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/toml_edit-0.2.1/src/formatted.rs
UTF-8
7,290
2.921875
3
[ "BSD-2-Clause", "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::decor::{Decor, Formatted, InternalString, Repr}; use crate::key::Key; use crate::parser::strings; use crate::parser::TomlError; use crate::table::{Item, KeyValuePairs, TableKeyValue}; use crate::value::{Array, DateTime, InlineTable, Value}; use combine::stream::position::Stream as PositionStream; use std::it...
true
06c1ef8a9ee799a49dfcef4f634a24b71f89bf00
Rust
franziskuskiefer/rust-cuint
/tests/test_util.rs
UTF-8
9,710
2.84375
3
[]
no_license
extern crate cuint; extern crate time; use cuint::util::CTimeOperations; use time::PreciseTime; #[test] fn test_equal() { fn test_inner<T>(a: T, b: T, expected: T) where T: PartialEq + std::fmt::Debug + CTimeOperations<T>, { let x = T::equal(&a, &b); println!("{:?} == {:?}: {:?}", ...
true
79fc08a5ad733df3fb08b4492a3e5c3d7eb0bdd5
Rust
znx3p0/vm_api
/src/sh.rs
UTF-8
855
2.734375
3
[]
no_license
use std::process::Command; pub fn sh<'a>(s: &'a str) -> String { let output = if cfg!(target_os = "windows") { Command::new("cmd") .args(&["/C", s]) .output() .expect("failed to execute process") } else { Command::new("sh") .arg("-c") .arg(s) ...
true
34dffa23901294f2aee9916d3b31d64d0e085d56
Rust
trevershick/puml-lsp
/src/codec.rs
UTF-8
2,544
2.8125
3
[]
no_license
use bytes::Buf; use bytes::BufMut; use bytes::BytesMut; use log::*; use std::io; use std::option::Option; use std::result::Result; use tokio_util::codec::{Decoder, Encoder}; #[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub enum LspEvent { Message(String), } #[derive(Copy, Clone, Debug, Eq, Partia...
true
cbe70806f79098c76b6209968ad0455d772b3065
Rust
archer884/dpg_282_easy
/src/bits.rs
UTF-8
2,381
3.546875
4
[ "MIT" ]
permissive
use fib_u64::Fib64; use std::iter::Rev; use std::ops::Range; pub trait Fiddle { fn set(self, bit: u64) -> u64; fn unset(self, bit: u64) -> u64; fn bits(self) -> Bits; } impl Fiddle for u64 { fn set(self, bit: u64) -> u64 { set(self, bit) } fn unset(self, bit: u64) -> u64 { uns...
true
d6e71c4e7c1471f21009e4cd9e2c7d6618f1a587
Rust
itang/tests
/test-rusts/testactix_multi_applications/src/main.rs
UTF-8
516
2.53125
3
[]
no_license
use actix_web::{http::Method, server, App, HttpRequest, Responder}; fn ping(_: &HttpRequest) -> impl Responder { "Pong" } fn index(_: &HttpRequest) -> impl Responder { "index" } fn main() { server::new(|| { vec![ App::new() .prefix("/api") .resource("/p...
true
db52ffd43fe8146ca4ce09b7efa187d8ff6b89b4
Rust
FyroxEngine/Fyrox
/src/resource/model/mod.rs
UTF-8
19,260
2.953125
3
[ "MIT" ]
permissive
#![warn(missing_docs)] //! Contains all data structures and method to work with model resources. //! //! Model is an isolated scene that is used to create copies of its data - this //! process is known as `instantiation`. Isolation in this context means that //! such scene cannot be modified, rendered, etc. It just a ...
true
3058e66c189a6eec9adb5af575b39b27dd48b5fe
Rust
Epictetus/rust
/src/test/stdtest/char.rs
UTF-8
1,029
2.6875
3
[ "MIT", "BSD-1-Clause", "LicenseRef-scancode-other-permissive", "bzip2-1.0.6", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
import core::*; use std; import char; #[test] fn test_is_whitespace() { assert char::is_whitespace(' '); assert char::is_whitespace('\u2007'); assert char::is_whitespace('\t'); assert char::is_whitespace('\n'); assert !char::is_whitespace('a'); assert !char::is_whitespace('_'); assert !ch...
true
94158ff1083d0ee526e9be0ab4b1a1e669a02936
Rust
thedodd/wither
/wither/examples/readme.rs
UTF-8
1,205
2.9375
3
[ "Apache-2.0" ]
permissive
use futures::stream::StreamExt; use serde::{Deserialize, Serialize}; use wither::bson::{doc, oid::ObjectId}; use wither::mongodb::Client; use wither::{prelude::*, Result}; // Define a model. Simple as deriving a few traits. #[derive(Debug, Model, Serialize, Deserialize)] #[model(index(keys = r#"doc!{"email": 1}"#, opt...
true
d80985fddb02349358ac1c9ef78b3c75c70edb89
Rust
anookinov-family/hello-okad
/src/components/header.rs
UTF-8
827
2.828125
3
[]
no_license
use yew::prelude::*; #[derive(Clone, PartialEq, Properties)] pub struct Props { pub text: String, } pub struct ListHeader { props: Props, } impl Component for ListHeader { type Message = (); type Properties = Props; fn create(props: Self::Properties, _link: ComponentLink<Self>) -> Self { ...
true
2d8271f9d892fa6ad36c72c0cf189ff150fd5b3d
Rust
naari3/gomiatsume
/src/config.rs
UTF-8
4,716
2.921875
3
[]
no_license
extern crate webbrowser; use std::io::{Read, Write}; pub struct Config { pub consumer_key: String, pub consumer_secret: String, pub token: egg_mode::Token, pub user_id: u64, pub screen_name: String, } impl Config { pub async fn load(consumer_key: &str, consumer_secret: &str) -> S...
true
fe5545c851f41cc483311b64eac42c080433a778
Rust
jbachhardie/advent-of-code-2020
/src/day11.rs
UTF-8
4,910
3.484375
3
[]
no_license
struct SeatingSimulator { state: Vec<Vec<SeatingSpaceState>>, } #[derive(PartialEq, Eq, Debug)] enum SeatingSpaceState { Floor, Free, Occupied, } impl SeatingSimulator { fn new(input: Vec<String>) -> SeatingSimulator { SeatingSimulator { state: input .iter() ...
true
d6976091bf5052132e4cde0068f7bd84fa73e1a0
Rust
devops-utils/git-oxide
/git-odb/src/pack/data/verify.rs
UTF-8
1,796
2.796875
3
[ "MIT" ]
permissive
use crate::pack::data::File; use git_object::{owned, SHA1_SIZE}; use quick_error::quick_error; quick_error! { #[derive(Debug)] pub enum Error { Mismatch { expected: owned::Id, actual: owned::Id } { display("pack checksum mismatch: expected {}, got {}", expected, actual) } Io...
true
e80d70f308c83be8154443f69a427a6cec218c43
Rust
avp/gb-rust
/src/mem/mbc/mbc1.rs
UTF-8
2,696
3.265625
3
[]
no_license
use crate::mem::mbc::MBC; #[derive(Debug)] pub struct MBC1 { rom: Vec<u8>, ram: Vec<u8>, rom_bank: u8, ram_bank: u8, ram_on: bool, mode: Mode, } #[derive(Debug, Copy, Clone)] enum Mode { ROM, RAM, } impl MBC1 { pub fn new(rom: Vec<u8>, ram_size: usize) -> Self { Self { rom, ram: ve...
true
f87189570fc93c3201712c38a050f856e718c25e
Rust
rusticata/der-parser
/src/lib.rs
UTF-8
11,044
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE-MIT) //! [![Apache License 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](./LICENSE-APACHE) //! [![docs.rs](https://docs.rs/der-parser/badge.svg)](https://docs.rs/der-parser) //! [![crates.io](https://img.shields.io/...
true
7f11269186f669a6721b48d7a13fafc7efacba7f
Rust
ElementalAlchemist/advent-of-code-2020
/d15p2/src/main.rs
UTF-8
726
3.09375
3
[]
no_license
use std::collections::HashMap; fn main() { let numbers: Vec<u32> = vec![8, 0, 17, 4, 1, 12]; let mut number_count: u32 = numbers.len() as u32; let mut numbers: HashMap<u32, u32> = numbers .iter() .enumerate() .map(|(index, value)| (*value, index as u32)) .collect(); let mut most_recent_number: (u32, u32) =...
true
e4b210ed2bdef9ada0a53cc0d2a8b6809d546b91
Rust
input-output-hk/jormungandr
/jcli/src/jcli_lib/vote/committee/member_key.rs
UTF-8
3,723
2.9375
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::jcli_lib::vote::{Error, OutputFile, Seed}; use chain_crypto::bech32::Bech32; use chain_vote::committee::{ MemberCommunicationPublicKey, MemberPublicKey, MemberSecretKey, MemberState, }; use rand::rngs::OsRng; use rand_chacha::{rand_core::SeedableRng, ChaCha20Rng}; use std::{convert::TryInto, io::Write, p...
true
d373243b8051e52853165f0949f85d07d54a3e15
Rust
Lighty0410/srt-rs
/srt-protocol/src/protocol/encryption/mod.rs
UTF-8
1,873
3.265625
3
[ "Apache-2.0" ]
permissive
use crate::crypto::CryptoManager; use crate::packet::DataEncryption; use crate::DataPacket; use bytes::BytesMut; #[derive(Debug)] pub enum DecryptionError { UnexpectedUnencryptedPacket(DataPacket), UnexpectedEncryptedPacket(DataPacket), } #[derive(Debug)] pub struct Cipher(Option<CryptoManager>); impl Cipher...
true
b904e33febc1a95348903135eb43187cbaad478b
Rust
ctaggart/rustfmt_4132
/src/lib.rs
UTF-8
614
2.53125
3
[]
no_license
use rustfmt_nightly::{Config, Edition, EmitMode, Input, Session, Verbosity}; fn format(source: String) -> String { // https://github.com/rust-lang/rls/blob/master/rls/src/actions/format.rs let mut config = Config::default(); config.set().edition(Edition::Edition2018); config.set().emit_mode(EmitMode::...
true
732ca5c8b46a6b068e441d98c1c3aace36183d7a
Rust
drubinstein/advent-of-code-2019
/day2/day2.rs
UTF-8
2,059
3.3125
3
[]
no_license
use std::fs; #[macro_use] extern crate itertools; fn main() -> Result<(), Box<dyn std::error::Error + 'static>> { assert_eq!(run(vec![1,0,0,0,99].as_mut_slice()), 2); assert_eq!(run(vec![1,9,10,3,2,3,11,0,99,30,40,50].as_mut_slice()), 3500); let intcodes: Vec<usize> = fs::read_to_string("input.csv") ...
true
399737c5eb394b7311ffe5ce7d59b6ae1a431cfc
Rust
gabriel376/exercism
/rust/crypto-square/src/lib.rs
UTF-8
505
3.109375
3
[]
no_license
pub fn encrypt(input: &str) -> String { let chars = input .to_lowercase() .chars() .filter(|c| c.is_ascii_alphanumeric()) .collect::<Vec<char>>(); let len = chars.len() as f64; let rows = len.sqrt().ceil() as usize; let cols = len.sqrt().floor() as usize; let get_ch...
true
fa70a8614ec52b0a6ab9458dba2328c9c8987929
Rust
alanpoon/arcaders
/src/phi/mod.rs
UTF-8
5,207
2.671875
3
[]
no_license
#[macro_use] mod events; pub mod data; pub mod gfx; use self::gfx::Sprite; use sdl2::render::Renderer; use sdl2::pixels::Color; use std::collections::HashMap; use std::path::Path; use sdl2::ttf::Sdl2TtfContext; struct_events! { keyboard: { key_escape: Escape, key_up: Up, key_down: Down, ...
true
17e4484fa5b8bf144c21b4798d40c3b622198eb1
Rust
swift-nav/libsbp
/rust/sbp/src/messages/user.rs
UTF-8
3,411
2.546875
3
[ "MIT" ]
permissive
// Copyright (C) 2015-2021 Swift Navigation Inc. // Contact: https://support.swiftnav.com // // This source is subject to the license found in the file 'LICENSE' which must // be be distributed together with this source. All other rights reserved. // // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ...
true
76b9ce7dfd70dfd103e0d79ca9d7e8af714317b1
Rust
solana-labs/solana
/remote-wallet/src/ledger_error.rs
UTF-8
2,520
2.59375
3
[ "Apache-2.0" ]
permissive
use {num_derive::FromPrimitive, thiserror::Error}; #[derive(Error, Debug, Clone, FromPrimitive, PartialEq, Eq)] pub enum LedgerError { #[error("Solana app not open on Ledger device")] NoAppResponse = 0x6700, #[error("Ledger sdk exception")] SdkException = 0x6801, #[error("Ledger invalid parameter...
true
1b1cde0531183d52bcf15f7b6e7aa6feaca9cb49
Rust
sfackler/rust-postgres
/postgres-protocol/src/types/test.rs
UTF-8
5,521
3.0625
3
[ "Apache-2.0", "MIT" ]
permissive
use bytes::{Buf, BytesMut}; use fallible_iterator::FallibleIterator; use std::collections::HashMap; use super::*; use crate::IsNull; #[test] #[allow(clippy::bool_assert_comparison)] fn bool() { let mut buf = BytesMut::new(); bool_to_sql(true, &mut buf); assert_eq!(bool_from_sql(&buf).unwrap(), true); ...
true
15646507c240255bd3742273f5479b6397bf65b7
Rust
kalleakerblom/AdventOfCode2019
/src/day4.rs
UTF-8
1,906
3.3125
3
[]
no_license
use std::collections::HashMap; fn brute_count(start: u32, end: u32) -> u32 { let mut count = 0; for n in start..=end { let digits: Vec<char> = n.to_string().chars().collect(); let mut has_digit_twin = false; let is_growing = digits .windows(2) .inspect(|w| { ...
true
954596e530c0fa8d89c82a031b65aa805307ef84
Rust
Javran/exercism-solutions
/rust/nth-prime/src/lib.rs
UTF-8
1,212
3.640625
4
[ "Apache-2.0" ]
permissive
fn is_odd_prime(n: u32) -> bool { if n <= 1 { return false; } let upbound = (n as f64).sqrt().ceil() as u32; (3..=upbound).all(|i| n % i != 0) } // The straightforward approach: prime-test on odd numbers and keep track of the count. pub fn nth(n: u32) -> u32 { std::iter::once(2) .ch...
true
91bda790def51ab91c47d0d2c1e9f0e6cd0c7a68
Rust
jasonwilliams/boa
/boa_engine/src/vm/opcode/control_flow/try.rs
UTF-8
1,966
2.890625
3
[ "MIT", "Unlicense" ]
permissive
use crate::{ vm::{call_frame::EnvStackEntry, opcode::Operation, CompletionType}, Context, JsResult, }; /// `TryStart` implements the Opcode Operation for `Opcode::TryStart` /// /// Operation: /// - Start of a try block. #[derive(Debug, Clone, Copy)] pub(crate) struct TryStart; impl Operation for TryStart { ...
true
02fc920c5839e0bf95b6711a7d97155db9a62931
Rust
goriunov/tokio-aio-examples
/src/bin/echo-epoll-level.rs
UTF-8
3,396
3.109375
3
[ "MIT", "Apache-2.0" ]
permissive
// A simple UDP echo server using the Linux epoll facility to multiplex // reads and writes. This program uses level-triggered events, which // makes it functionally similar to programs using epoll's predecessors // select() and poll(). extern crate nix; use std::collections::VecDeque; use nix::sys::epoll::*; use ni...
true
e7f4a5f217ddd0e597f6c2bd1e5eab8fad22be6e
Rust
MislankaNova/fourthrail
/src/fourthrail/tile.rs
UTF-8
2,542
3
3
[]
no_license
extern crate pancurses as curses; use fourthrail::*; // A single map tile pub enum Tile { Empty, Tile { name : String, symbol : char, fore : i16, back : i16, pair : i16, opaque : bool, solid : bool } } impl Display for Tile { fn display...
true
9ea7470936828e171a0b249b747eef2133671544
Rust
0x192/iced_aw
/examples/web/src/color_picker_section.rs
UTF-8
1,909
3.03125
3
[ "MIT" ]
permissive
use crate::Section; use iced::{button, Align, Button, Color, Column, Element, Length, Row, Text}; use iced_aw::{color_picker, ColorPicker}; pub struct ColorPickerSection { color_picker_state: color_picker::State, button_state: button::State, color: Color, } #[derive(Clone, Debug)] pub enum Message { O...
true
00005a6e792b74024bae4f4ca26912431fc2b81e
Rust
pepijnd/sudoku_web_solver
/websolver/src/ui/model/editor.rs
UTF-8
1,051
3.265625
3
[ "MIT" ]
permissive
#[derive(Debug, Copy, Clone)] pub enum EditorAction { SetValue(u8), Solve, Erase, Clear, First, Prev, Next, Last, None, } impl Default for EditorAction { fn default() -> Self { Self::None } } impl std::fmt::Display for EditorAction { fn fmt(&self, f: &mut std::f...
true
8e1aa53f080c69aed0b914c02c66f04705886924
Rust
Srinathsri22/Rust_Workgroup_Codes
/Strings/main.rs
UTF-8
983
3.53125
4
[]
no_license
use std::mem; fn analyze_slice(slice: &[i32]) { println!("first element of the slice: {}", slice[0]); println!("the slice has {} elements", slice.len()); } fn main() { let xs: [i32; 5] = [1,2,3,4,5]; let ys: [i32; 500] = [0 ; 500]; println!("last element of array ys is {}", xs[2]); println!("...
true
8bc682ef55fd933900f0d4f8064df0d92efd3428
Rust
chadrc/simple-expression-language
/sel_executor/src/opexec/logical.rs
UTF-8
6,241
3.203125
3
[]
no_license
use super::super::context::SELExecutionContext; use super::utils::{get_left_right_results, get_value_from_result, get_values_from_results}; use super::SELExecutionResult; use sel_common::{to_byte_vec, DataType, SELTree, SELTreeNode}; fn logical_xor(left: bool, right: bool) -> bool { return (left || right) && left ...
true
400a3f4c0ede31f57f12b45715baca0e335a7306
Rust
abdelamzal/Rust-Programming
/variable-data-types/src/main.rs
UTF-8
271
3.078125
3
[]
no_license
fn main() { //integers let x = 45; //i32 integers par defaut let y: i64 = 45; //i64 let z: u64 = 45; //u64 unsigned integers : nombres positifs //floating let f = 6.7; //f32 let ff: f64 = 6.7; //f64 //boolean let b: bool = true; }
true
b6d7d56973550ec8d30889424991fcba23966e49
Rust
Waridley/godot-rust
/gdnative-core/src/object/as_arg.rs
UTF-8
5,240
2.921875
3
[ "MIT" ]
permissive
use crate::export::user_data::Map; use crate::export::NativeClass; use crate::object::ownership::{Ownership, Shared, Unique}; use crate::object::{GodotObject, Instance, Null, Ref, SubClass, TInstance, TRef}; /// Trait for safe conversion from Godot object references into API method arguments. This is /// a sealed trai...
true
ffa53e0735dac15a9d6549cea47f6b4dd5475499
Rust
akrantz01/hackathon-bot
/src/commands/mentors.rs
UTF-8
6,611
2.5625
3
[ "MIT" ]
permissive
use chrono::prelude::*; use log::error; use redis::Commands; use serenity::framework::standard::{macros::command, ArgError, Args, CommandError, CommandResult}; use serenity::model::prelude::*; use serenity::prelude::*; use serenity::utils::MessageBuilder; use crate::data::{add_help_request, get_connection, get_help_re...
true
ecbfb3f4c844f1967fa2c16ecd8a6c40d7270661
Rust
n-krueger/osm-routing-rs
/src/geo/traits.rs
UTF-8
154
3.21875
3
[]
no_license
pub trait Location { fn lat(&self) -> f64; fn lon(&self) -> f64; } pub trait Distance { fn distance<T: Location>(&self, other: &T) -> u64; }
true
74961d98a83c4a9fb9db10de8113b28142ddc59d
Rust
TimonPost/anasaizi
/anasaizi-core/src/vulkan/buffers/buffer.rs
UTF-8
4,487
2.703125
3
[]
no_license
use crate::{ engine::RenderContext, vulkan::{begin_single_time_command, end_single_time_command}, }; use ash::{ version::DeviceV1_0, vk, vk::{Buffer, DeviceMemory, Extent2D, Extent3D, Offset3D}, }; /// Creates and allocates a vulkan buffer. /// /// # Arguments /// - `size`: The size in bytes of the...
true
4eddf8af298bf0a9e4f4472e9849df98e8d5c616
Rust
amorye7/database_lib
/src/mysql_test.rs
UTF-8
7,571
2.96875
3
[]
no_license
#[cfg(test)] mod mysql_test{ extern crate mysql as my; extern crate rpassword; use interface; use interface::Entry; use interface::Table; use my_types; use std::str::FromStr; use std::fmt; use std::fmt::Display; use interface::ITryInto; use std::io; //The following is an example of how to use the my_types t...
true
07b1b4deeb1f0fb2bb005aa2a70f1880ead17d69
Rust
LinAGKar/advent-of-code-2020-rust
/day22b/src/main.rs
UTF-8
1,744
3.0625
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use std::io::Read; fn play_combat(mut decks: Vec<VecDeque<u8>>, outermost: bool) -> (usize, Option<VecDeque<u8>>) { if !outermost && decks[0].iter().max() >= decks[1].iter().max() { return (0, None); } let mut seen = std::collections::HashSet::new(); while deck...
true
75005a9ba6d9e9f02de6d40f45a0e776dfc7f70a
Rust
apiraino/poor-postman
/src/http_client.rs
UTF-8
1,683
2.859375
3
[ "MIT" ]
permissive
use reqwest::{Client, StatusCode}; use reqwest::Method; use reqwest::header::*; use serde_derive::Deserialize; use serde_json::Value; pub struct HttpClient { client: Client } #[derive(Debug, Deserialize)] pub struct APIResponse { pub status_code: u16, pub data: Value } impl HttpClient { pub fn new()...
true
cd1c278e37d0cb38f61fb6793b848cee3439ce4a
Rust
nushell/nushell
/crates/nu-command/tests/commands/mkdir.rs
UTF-8
2,818
3.015625
3
[ "MIT" ]
permissive
use nu_test_support::fs::files_exist_at; use nu_test_support::playground::Playground; use nu_test_support::{nu, pipeline}; use std::path::Path; #[test] fn creates_directory() { Playground::setup("mkdir_test_1", |dirs, _| { nu!( cwd: dirs.test(), "mkdir my_new_directory" ); ...
true
5f43663fc74a1985628a5bfa59f912247bbe3917
Rust
VulkanWorks/korangar
/src/map/object/model/node.rs
UTF-8
2,592
3.046875
3
[]
no_license
use maths::*; use graphics::{ Renderer, Camera, ModelVertexBuffer, Texture, Transform }; #[derive(Clone, Debug)] pub struct BoundingBox { pub smallest: Vector3<f32>, pub biggest: Vector3<f32>, pub offset: Vector3<f32>, pub range: Vector3<f32>, } impl BoundingBox { pub fn new(smallest: Vector3<f32...
true
5424142ba33daa61916a524cb59e528d2e8d387a
Rust
annesummers/advent-of-code-2017
/src/day2/mod.rs
UTF-8
1,996
3.375
3
[]
no_license
use file; pub fn run() { let inputs = file::read_inputs("Day2.txt"); let lines = read_values(&inputs); part1(&lines); part2(&lines); part2_recursive(&lines); part1(&read_values(&"5 1 9 5\n7 5 3\n2 4 6 8")); part2(&read_values(&"5 9 2 8\n9 4 7 3\n3 8 6 5")); } fn read_values(inputs: &str)...
true
73884c742bc0bd0a4b47d170cdb922536e56064c
Rust
sorear/smetamath-rs
/src/diag.rs
UTF-8
18,214
2.640625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Datatypes to represent diagnostics emitted by smetamath analysis passes. //! //! This includes an enum-based representation suited for programmatic //! interpretation and testing, as well as a mostly-text representation which //! can be used for various human-readable outputs. use parser::as_str; use parser::Compa...
true
2eeeb2f9d0d8244c5bf39233ade84aa3e9a060fe
Rust
ToruNiina/rustymill
/src/pdb/reader.rs
UTF-8
1,911
3.28125
3
[ "MIT" ]
permissive
use std::io::{BufRead, BufReader, Read}; use std::string::String; use std::vec::Vec; use super::{Atom, Hetatm, Ter}; pub enum Record { MODEL{serial : i32}, ATOM(Atom), HETATM(Hetatm), TER(Ter), ENDMDL, Other(String), } impl Record { fn new(line: String) -> Record { let length = lin...
true
e261def80ab3354617ee55b466763ed6a208c432
Rust
iuill/CompetitiveProgramming
/AOJ/ITP1_1_B_rust/programs/src/main.rs
UTF-8
248
2.796875
3
[]
no_license
fn main() { use std::io; let mut input = String::new(); io::stdin().read_line(&mut input).ok(); //let num:i32 = input.trim().parse().unwrap(); let num = input.trim().parse::<i32>().unwrap(); println!("{}", num*num*num); }
true
bfefbe243db12d39a2e41bbdb333494aec7df60b
Rust
proecho/french_cypher
/src/main.rs
UTF-8
2,584
3.390625
3
[]
no_license
use std::io; use std::char; fn main() { let input = input_taker(); // in tuple code word and message let answer = encoder(input); println!("{}", answer); } fn input_taker() -> (String, String) { println!("Input message"); let mut buffer = String::new(); let mut stdin = io::stdin(); stdin.rea...
true
bbf0b2026b57e6f9480a5f5bca15001cf46b26fc
Rust
sunng87/handlebars-rust
/examples/quick.rs
UTF-8
487
3.03125
3
[ "MIT" ]
permissive
use std::error::Error; use handlebars::Handlebars; use serde_json::json; fn main() -> Result<(), Box<dyn Error>> { let mut reg = Handlebars::new(); // render without register println!( "{}", reg.render_template("Hello {{name}}", &json!({"name": "foo"}))? ); // register template us...
true
476769095be064540094d508de130ad102c6aab6
Rust
fabianschuiki/moore
/src/derive/accept_visitor.rs
UTF-8
4,477
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2016-2021 Fabian Schuiki use proc_macro::TokenStream; use quote::{format_ident, quote}; use syn::DeriveInput; pub(crate) fn accept_visitor(input: TokenStream, with_foreach: bool) -> TokenStream { // Parse the input. let input = syn::parse_macro_input!(input as DeriveInput); let mut output...
true
41a18b1824109ba60794e769f50c564bdcf81882
Rust
Surpris/rs-deep
/src/dlfs01/common/loss_function.rs
UTF-8
2,016
3.28125
3
[ "MIT" ]
permissive
//! loss_function //! //! functions for loss use super::math::MathFunc; use super::operators::Operators; use super::util::cast_t2u; use num_traits::Float; use std::f64::consts::E; type Vec2d<T> = Vec<Vec<T>>; const EPS: f64 = 1E-8; pub trait LossFunc<T> where T: Float, { /// sum of squared error fn sum_...
true
3cd0ecf9bd158d7736940129c6516827f3663a5f
Rust
celialewis3/chip8rs
/src/ROMLoader.rs
UTF-8
344
3.03125
3
[]
no_license
use std::fs::File; use std::io::prelude::*; pub struct ROMLoader { pub rom: [u8; 128], } pub fn new(rom_name: &str) -> ROMLoader { let mut rom = File::open(rom_name).expect("ROM not found"); let mut data = [0u8; 128]; let size = rom.read(&mut data).expect("ROM cannot be read"); ROMLoader { ...
true
3a37c184db3de17aa393298c5cbf3f990bd36a54
Rust
Keats/contree
/src/deck.rs
UTF-8
2,788
3.75
4
[]
no_license
use rand::StdRng; use rand::Rng; use cards::{Suit, Rank, Card}; #[derive(Debug, Clone)] pub struct Deck { pub cards: [Card; 32], randomness: StdRng, } impl Deck { pub fn new() -> Deck { let mut cards = [Card::new(Suit::Spades, Rank::Ace); 32]; let mut i = 0; for suit in Suit::it...
true
7361cf6779e6c96733633b5ab8fc6af0af8cdceb
Rust
guilload/rust-class
/ps0/src/increment1.rs
UTF-8
214
3.359375
3
[ "MIT" ]
permissive
fn increment(p: &mut Vec<int>) { for x in p.iter_mut() { *x += 1; } } fn main() { let mut p = vec![1i, 2i, 3i]; increment(&mut p); for x in p.iter() { print!("{} ", x); } }
true
95fe5720c43c2376886a83b513af726c9bb8662b
Rust
mlunnay/rust_trace
/src/raytrace/texture.rs
UTF-8
2,261
3.09375
3
[ "MIT" ]
permissive
use super::Vec3; use std::sync::Arc; use noise::{NoiseFn, Fbm}; pub trait Texture: Send + Sync { fn value(&self, u: f64, v: f64, p: Vec3) -> Vec3; } pub struct ConstantTexture { pub color: Vec3 } impl ConstantTexture { pub fn new(color: Vec3) -> Self { ConstantTexture{color} } } impl Texture...
true
86aa59f1d99e4dc68edf4b3f5fa46f7fe2476bdc
Rust
amm834/rustlanguage
/exersiting_structure/src/main.rs
UTF-8
292
3.59375
4
[]
no_license
fn main() { let a = vec![1, 2, 3, 4, 5]; println!("Sum = {}", a.sum()); } trait Summable<T> { fn sum(&self) -> T; } impl Summable<i32> for Vec<i32> { fn sum(&self) -> i32 { let mut sum = 0; for i in self { sum += i; } sum } }
true
64347a892bd4fdf7335103dbf95a5ec8ce5d4746
Rust
psiphi75/mpu9250-i2c
/src/vector.rs
UTF-8
1,636
3.015625
3
[ "Apache-2.0" ]
permissive
/***************************************************************************** * * * Copyright 2018 Simon M. Werner * * * * ...
true
d6aa228c319020c5828f500268e8fc93dc40216a
Rust
nkotlyarov/zenith
/zenith_utils/src/seqwait.rs
UTF-8
8,948
3.4375
3
[ "Apache-2.0", "PostgreSQL" ]
permissive
#![warn(missing_docs)] use std::cmp::{Eq, Ordering, PartialOrd}; use std::collections::BinaryHeap; use std::fmt::Debug; use std::mem; use std::sync::mpsc::{channel, Receiver, Sender}; use std::sync::Mutex; use std::time::Duration; /// An error happened while waiting for a number #[derive(Debug, PartialEq, thiserror::...
true
3e6917568677060b86d47b1347a69b5619b9f4eb
Rust
bekicot/sdq
/src/main.rs
UTF-8
5,748
2.515625
3
[ "MIT" ]
permissive
#[macro_use] extern crate clap; use std::str; use std::fs; use clap::App; use quick_xml::Reader; use quick_xml::events::{Event}; struct DBValues { keys: Vec<String>, values: Vec<String> } use rusqlite::{Connection, NO_PARAMS}; fn main() { let yaml = load_yaml!("cli.yml"); let matches = App::from_ya...
true
34a39278e175d1ec300753ced034913a0fae1241
Rust
TmCookie/plebianbot
/sources/discord/src/main.rs
UTF-8
3,480
3.046875
3
[ "MIT" ]
permissive
#![allow(dead_code)] #![feature(str_escape)] extern crate discord; use discord::Discord; use discord::model::Event; use std::env; use std::io::prelude::*; use std::fs::File; use std::path::Path; use std::process::Command; fn main() { // variable to store apitoken let mut apitoken = String::new(); // ope...
true
392e30e2efaf1a946370ae3d984a3f72093cd689
Rust
Tormyst/FeGaBo
/src/gb/mem/cm/mod.rs
UTF-8
4,916
3.453125
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::Read; #[derive(Debug)] enum CMtype { ROM, MBC1, MBC2, MBC3, } pub struct CartrageMapper { cm_chip: CMtype, rom_page: u8, ram_page: u8, ram_enable: bool, mbc_mode: usize, rom: Vec<u8>, ram: Vec<u8>, } impl CartrageMapper { fn ram_size(r: &...
true
1690589583578621156594562b954317c3143d43
Rust
Pctg-x8/interlude
/src/error.rs
UTF-8
4,662
2.703125
3
[]
no_license
// Prelude: Error Enums and Crash Handling use std; use interlude_vk_defs::*; use std::os::raw::*; #[cfg(feature = "debugprint")] use freetype_sys::*; use std::borrow::Cow; pub enum EngineError { DeviceError(VkResult), IOError(std::io::Error), XServerError(c_int), #[cfg(feature = "debugprint")] FreeTypeError(FT_Err...
true
de209dce5114732d02ad92afcab2fde2de480a3f
Rust
lfdominguez/elastic
/src/elastic/examples/raw.rs
UTF-8
1,258
2.984375
3
[ "Apache-2.0", "MIT" ]
permissive
//! A raw search request. //! //! NOTE: This sample expects you have a node running on `localhost:9200`. //! //! This sample demonstrates a raw search request where the body is read into a `String` rather //! than being deserialised. extern crate elastic; extern crate env_logger; use elastic::prelude::*; use std::{ ...
true
693c6379dcc5879185e9e8c64556ac2ca0998405
Rust
lodestone/alfred-pinboard-rs
/src/commands/post.rs
UTF-8
2,672
2.546875
3
[ "MIT" ]
permissive
use super::*; use std::io::Write; use super::browser_info; impl<'api, 'pin> Runner<'api, 'pin> { pub fn post(&mut self, cmd: SubCommand) { debug!("Starting in run"); let input_tags: Vec<String>; let input_desc; // let conifg = self.config.as_ref().unwrap(); // let pinboard ...
true
fbd287454f1a195fffb2f4301107926eb19b04af
Rust
chapterzero/wiki-rs
/examples/async_wikidata.rs
UTF-8
781
2.53125
3
[]
no_license
use std::env; use wikipedia::r#async::WikipediaAsync; use wikipedia::errors::FetchError; use tokio::runtime::Runtime; use futures::try_join; fn main() { env_logger::init(); let args: Vec<String> = env::args().collect(); let page_name: &String = args.get(1) .expect("Require 2nd argument: wikidata id...
true
86424fd38baa82263740c309d233c426d1013346
Rust
lusen82/advent-of-code-2017
/src/dec_6.rs
UTF-8
2,103
3.25
3
[]
no_license
extern crate regex; extern crate ascii; use std::string::String; use std::i32; use std::collections::HashSet; use super::parse_utils; pub fn day6() { let inn: String = parse_utils::parse_input_file("inp6.txt"); day_6_calc(&inn); day_6_b_calc(&inn); } pub fn day_6_calc<'a>(inn: &'a str) -> Vec<i32> { ...
true
a4e913577987eabd76e32ba270ffa674a547ec56
Rust
denisidoro/abra
/src/tx.rs
UTF-8
1,514
2.9375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anyhow::{Context, Error}; use fs::DirEntry; use std::fs; use std::io; use std::io::prelude::*; use std::io::{BufRead, BufReader}; use std::os::unix::net::UnixStream; use std::path::PathBuf; use stringreader::StringReader; fn connect(entry: DirEntry) -> Result<Option<UnixStream>, Error> { let path = entry.path(...
true