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
02f57b5f54940c09ea9f7bc91719e9f96b1a1654
Rust
isgasho/laboratory
/src/spec.rs
UTF-8
2,117
2.9375
3
[ "MIT" ]
permissive
use std::time::{Instant, Duration}; use std::borrow::BorrowMut; use serde::Serialize; use super::spec_result::SpecResult; use super::state::State; pub struct Spec { pub name: String, pub test: Box<dyn FnMut(&mut State) -> Result<(), String>>, pub pass: Option<bool>, pub error_msg: Option<String>, p...
true
bd65682a8e9f8c2c14ac2952bfc1372da7091a0c
Rust
Heurlinius/advent-of-code-2017
/day8/src/main.rs
UTF-8
3,523
3.4375
3
[ "MIT" ]
permissive
extern crate regex; use std::collections::HashMap; use regex::Regex; #[derive(Debug, Clone)] struct Instruction<'s> { reg: &'s str, change: Change, amount: isize, condition: Condition<'s>, } impl<'s> Instruction<'s> { fn exec(&self, registers: &mut HashMap<&'s str, isize>, known_highest: &mut isi...
true
8fa686e84e3c4ecc02afc4a4afe95435ed40154e
Rust
bytecodealliance/wasmtime
/cranelift/codegen/src/isa/aarch64/inst/args.rs
UTF-8
22,759
3
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! AArch64 ISA definitions: instruction arguments. use crate::ir::types::*; use crate::ir::Type; use crate::isa::aarch64::inst::*; use crate::machinst::{ty_bits, MachLabel, PrettyPrint, Reg}; use core::convert::Into; use std::string::String; //=========================================================================...
true
acc71e53d4634edb88f30677a64b2e296970c9dc
Rust
compenguy/pandora-api
/src/json/test.rs
UTF-8
1,990
2.59375
3
[ "WTFPL", "MIT" ]
permissive
/*! Test methods. */ // SPDX-License-Identifier: MIT AND WTFPL use pandora_api_derive::PandoraRequest; use serde::{Deserialize, Serialize}; use crate::errors::Error; use crate::json::{PandoraApiRequest, PandoraSession}; /// Check whether Pandora is available in the connecting client’s country, /// based on geoip dat...
true
fab2fbcdd1194d7025a26bdf987817c9685e695d
Rust
tgm-templates/rust-cli
/src/app.rs
UTF-8
2,752
3.109375
3
[ "MIT" ]
permissive
//! clap App for command cli use clap::{App, Arg}; use clap_generate::generate; use clap_generate::generators::{Bash, Zsh, Fish}; use std::env; use std::fs::File; use std::path::Path; use clap::ArgMatches; const COMMAND: &str = "@appName@"; const VERSION: &str = "0.1.0"; pub fn build_app() -> App<'static> { //tod...
true
0476fb53867de44ae332f18ce0dccf2b2ded5353
Rust
Kot-Zakhar/webasm-3d-viewer
/core/src/types.rs
UTF-8
2,283
3.078125
3
[ "Apache-2.0", "MIT" ]
permissive
pub use nalgebra::{ Vector3, Vector4, Matrix3, Matrix4, RowVector3, RowVector4, Point3, Point4, Perspective3 }; use std::ops; #[derive(Copy, Clone)] pub struct Pixel { pub color: Color<u8>, pub a: u8 } pub type Vertex = Vector4<f64>; pub fn _diagonal(val: f64) -> Matrix4<f64> { Matr...
true
be870dcf017d1e59d084a96000b8a7146c2770b9
Rust
abonander/shepherd
/src/echo.rs
UTF-8
211
2.609375
3
[ "MIT" ]
permissive
use std::io::stdio::{stdin, stdout}; fn main() { let mut stdout = stdout(); for line in stdin().lock().lines().filter_map(|line| line.ok()) { stdout.write_line(&*line).unwrap(); } }
true
58fb73222e2873feb7746e12222148329990e7e5
Rust
dodiameer/rust-cli-boilerplate
/src/config.rs
UTF-8
949
2.53125
3
[]
no_license
extern crate config; use anyhow::{Result, Context}; use config::{Config, ConfigError, Environment}; use serde::Deserialize; #[derive(Deserialize)] pub struct AppConfig { name: String, } impl AppConfig { pub fn new() -> Result<Self, ConfigError> { let logger = slog_scope::logger().new(o!("mod" => "conf...
true
8d9a5ca97853008d4b110abb2fb17ac9a7f740d4
Rust
sogapalag/contest
/atcoder/arc056/c.rs
UTF-8
1,874
3
3
[]
no_license
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::*; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok(); return ret; } fn get_word() -> String { let mut stdin = std::io::stdin(); ...
true
6f1a0a36e7bd07cc5d1bfcfea0e722e49c39389e
Rust
VictorElHajj/rust-n-body
/src/vector.rs
UTF-8
1,861
3.65625
4
[]
no_license
use std::ops::{Add, Div, Mul, Sub}; const EPSILON: f64 = 0.001; #[derive(PartialEq, Debug, Copy, Clone)] pub struct Vector3 { pub x: f64, pub y: f64, pub z: f64, } impl Vector3 { pub fn new(x: f64, y: f64, z: f64) -> Self { Vector3 { x, y, z } } pub fn zero() -> Vector3 { Vec...
true
56c6d70e2937318166f30057bd274081f8084a14
Rust
ACRONYM-Group/ACIRustServer
/src/commands/tests.rs
UTF-8
7,609
3.03125
3
[]
no_license
//! Tests for the commands use super::{Commands, CommandParsingError, Command}; fn test_command_parsing(test_output: bool) { let examples = vec![ "{\"cmd\": \"write_to_disk\", \"db_key\": \"DB_KEY\"}", "{\"cmd\": \"read_from_disk\", \"db_key\": \"DB_KEY\"}", "{\"cmd\": \"list_keys\", \"db_...
true
952b4c40b9718dbe90d74a726df3eb3a88f8ded8
Rust
PDFxy/mmtk-core
/src/util/address.rs
UTF-8
14,588
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
use atomic_traits::Atomic; use std::fmt; use std::mem; use std::ops::*; use std::sync::atomic::Ordering; use crate::mmtk::{MMAPPER, SFT_MAP}; use crate::util::heap::layout::mmapper::Mmapper; /// size in bytes pub type ByteSize = usize; /// offset in byte pub type ByteOffset = isize; /// Address represents an arbitra...
true
3ba59fc86f765bfee8130e566d1634ffcf122a7b
Rust
openstax/math-editor-sprint
/übertool/src/ast.rs
UTF-8
525
3.03125
3
[]
no_license
//! The abstract source tree for maths expressions. /// A symbol. #[derive(Debug)] pub enum Symbol { /// A generic identifier which has not (yet) been resolved into a more /// specific one. Identifier(String), /// Name for an object with a set of properties but no fixed value. Variable(String), /// Name fo...
true
a7c682dec0c8138a494ab55373af243d1d03a2ce
Rust
neilfutureftr/onchain_stuff
/FTRVoterpreview.rs
UTF-8
6,849
2.75
3
[]
no_license
//! A simple chat program using a ring buffer to store messages. use anchor_lang::prelude::*; use ftrvoterstate::{FtrState,StateModifierLoc}; use anchor_spl::token::{self, Burn, MintTo, SetAuthority, Transfer}; declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS"); #[program] pub mod chat { use super::*; ...
true
3653c25d8e9d831f44d264247bfdee2ee6af20b3
Rust
TrendingTechnology/ruzzt
/zzt_file_format/src/dosstring.rs
UTF-8
5,873
3.15625
3
[ "MIT" ]
permissive
use std; use std::ops::{Deref, AddAssign}; use serde::de; use serde::ser; #[derive(Clone, PartialEq, PartialOrd)] pub struct DosString { pub data: Vec<u8>, } impl DosString { pub fn new() -> DosString { DosString { data: vec![], } } pub fn from_slice(data: &[u8]) -> DosString { DosString { data: da...
true
462874935ef6c193f0b3a14f0a01975ad7f3d425
Rust
foxfriends/dwarf-mine-builder
/src/system/camera/shift.rs
UTF-8
1,039
2.71875
3
[]
no_license
use game_engine::{system, prelude::*}; use crate::resource::VisibleRange; use crate::model::Point3D; #[derive(Default, Debug)] pub struct ShiftCamera; system! { impl ShiftCamera { fn run( &mut self, keyboard_events: &Resource<KeyboardEvents>, visible_range: &mut Resourc...
true
013487b91aba7822bee5f1db9e174f919b6dfc7a
Rust
system76/lxd-rs
/src/container.rs
UTF-8
8,616
3.09375
3
[ "MIT" ]
permissive
use std::io; use std::path::Path; use super::{lxc, Location, Snapshot}; /// An LXD ephemeral container pub struct Container { name: String } impl Container { /// Create a new LXD container /// /// # Arguments /// /// * `location` - The location of the host /// * `name` - The name of the c...
true
5dbbeb7491139b167b0708cf893f660ae3d17886
Rust
AI-and-ML/alumina
/alumina_ops/src/nn/softmax.rs
UTF-8
10,295
2.609375
3
[ "MIT" ]
permissive
use alumina_core::{ base_ops::{OpInstance, OpSpecification}, errors::{ExecutionError, GradientError, OpBuildError, ShapePropError}, exec::ExecutionContext, grad::GradientContext, graph::{Graph, Node, NodeID}, shape_prop::ShapePropContext, util::wrap_dim, }; use indexmap::{indexset, IndexMap, IndexSet}; use ndarr...
true
daef475814da40a602b0112a0a38777ee0395f3e
Rust
jerry73204/rust-lidar-utils
/ouster-lidar/src/pcd_converter.rs
UTF-8
5,117
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Provides the converter type that converts packets to points. use super::{ config::Config, consts::PIXELS_PER_COLUMN, packet::{Column, Packet}, }; use crate::{common::*, utils::AngleExt as _}; use std::f64::consts::PI; fn spherical_to_xyz(range: Length, azimuth_angle: Angle, altitude_angle: Angle) -> [...
true
1fcd0e542f5602b1d6ace1a58feacdb0874263ce
Rust
insanitybit/sandbox
/src/sandbox.rs
UTF-8
2,988
3.171875
3
[ "MIT" ]
permissive
use ipc_channel::ipc; use serde::{Serialize, Deserialize}; use nix::unistd::{Fork, fork}; use super::std; use std::error::Error; use sandbox_descriptor::SandboxDescriptor; use sandbox_error::SandboxError; #[derive(Serialize, Deserialize)] enum Intern<T> { Success(T), Failure(String), } pub struct Sandbox { ...
true
5624451ef726a5579ae0342b56da6a058225727b
Rust
ganmacs/playground
/rust/mini-redis/src/connection.rs
UTF-8
2,484
2.921875
3
[]
no_license
use crate::error::Error; use crate::resp::{ParseErr, Resp, RespWriter}; use bytes::{Buf, BytesMut}; use std::io::{Cursor, Error as IError, ErrorKind}; use tokio::io::{AsyncReadExt, AsyncWriteExt, BufWriter}; use tokio::net::TcpStream; #[derive(Debug)] pub struct Connection { stream: BufWriter<TcpStream>, // t...
true
2a66e45911634e9a4a50ccc296b2c01d6c3578d9
Rust
no111u3/ssd1320z2
/src/display.rs
UTF-8
4,495
2.671875
3
[ "Apache-2.0" ]
permissive
//! SSD1320 OLED display driver. //! //! TODO: Create a normal documentation use crate::command::{AddrMode, Command, PortraitAddrMode, PreChargeLvl, VcomhLevel}; use crate::error::Error; use display_interface::{DataFormat::U8, DisplayError, WriteOnlyDataCommand}; use display_interface_spi::SPIInterfaceNoCS; use embed...
true
a15c02928b6a13cced627d1efe5f2b72e96c825d
Rust
GaiaWorld/pi_lib
/share/src/lib.rs
UTF-8
2,443
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
//! 提供五个类型:`Share`, `ShareWeak`,,`ShareMutex`, `ShareRwLock`,`ShareCell`. //! //! 在feature="rc"时: //! //! * `Share`等同于`std::rc::Rc` //! * `ShareWeak`等同于`std::rc::Weak` //! * `ShareMutex`等同于`LockCell(RefCell<T>)` //! * `ShareRwLock`等同于`LockCell(RefCell<T>)` //! * `ShareCell`等同于`std::cell::RefCell` //! * `ShareBool`等同于`U...
true
131e54c25555acbadc5a7a1873fb54d33c6ac959
Rust
neodes-h/design-pattern-rust
/src/adapter/main.rs
UTF-8
1,560
3.5625
4
[]
no_license
trait MediaPlayerTrait { fn play(&self, t: Type); } trait AdvancedMediaPlayerTrait { fn play_vlc(&self); fn play_mp4(&self); } struct VlcPlayer; struct Mp4Player; impl AdvancedMediaPlayerTrait for VlcPlayer { fn play_vlc(&self) { println!("vlc players play vlc video"); } fn play_mp4(...
true
32153b8f855250f7e4d054623af42e63163ce739
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/semver-0.9.0/src/version_req.rs
UTF-8
30,023
2.78125
3
[ "Apache-2.0", "MIT", "BSD-2-Clause" ]
permissive
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
true
a8001d899af097c6d4d6759932bec989d860a105
Rust
arkworks-rs/algebra
/ec/src/models/short_weierstrass/mod.rs
UTF-8
6,846
2.53125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use ark_serialize::{ CanonicalDeserialize, CanonicalDeserializeWithFlags, CanonicalSerialize, CanonicalSerializeWithFlags, Compress, SerializationError, Valid, Validate, }; use ark_std::io::{Read, Write}; use ark_ff::{fields::Field, AdditiveGroup}; use crate::{ scalar_mul::{ sw_double_and_add_affi...
true
f39f3c9c0eb0c422782f2a71e5d9cc33389cf059
Rust
simnalamburt/fate
/common/src/manager.rs
UTF-8
2,935
3.5625
4
[]
no_license
use std::collections::HashMap; use std::marker::PhantomData; use std::rc::Rc; use std::sync::atomic::{AtomicUsize, Ordering}; pub type Id = usize; pub trait Item<Param> { fn new(id: &Id, param: &Param) -> Self; } pub struct Manager<I, P> where I: Item<P>, { next_id: AtomicUsize, items: HashMap<Id, Rc...
true
698606f5a01066f3b31709c129cf67ebafa4ddde
Rust
kylejlin/fit_no_io
/src/io.rs
UTF-8
2,061
3.03125
3
[ "MIT" ]
permissive
use std::convert::TryInto; #[derive(Copy, Clone, PartialEq)] pub enum Endianness { Little, Big, } pub fn u8(map: &mut &[u8]) -> u8 { let (val, rest) = map.split_first().unwrap(); *map = rest; *val } pub fn i8(map: &mut &[u8]) -> i8 { u8(map) as i8 } pub fn u16(map: &mut &[u8], endianness: Endi...
true
af849672af73b1c2d9ec128d1a044655f3c3e4c3
Rust
IThawk/rust-project
/rust-master/src/test/ui/impl-trait/auto-trait-leak.rs
UTF-8
536
3.03125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use std::cell::Cell; use std::rc::Rc; fn send<T: Send>(_: T) {} fn main() { } // Cycles should work as the deferred obligations are // independently resolved and only require the concrete // return type, which can't depend on the obligation. fn cycle1() -> impl Clone { //~^ ERROR cycle detected //~| ERROR cy...
true
35c9b93b48f39d447dd146dea0d66f343567cc98
Rust
asomers/mockall
/mockall/tests/automock_impl_trait_for.rs
UTF-8
453
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
// vim: tw=80 //! A struct that implements a trait #![deny(warnings)] use mockall::*; pub trait Foo { fn foo(&self, x: u32) -> i64; } pub struct SomeStruct {} #[automock] impl Foo for SomeStruct { fn foo(&self, _x: u32) -> i64 { 42 } } #[test] fn returning() { let mut mock = MockSomeStruct:...
true
8025f93f8fc126f79d5e4722912eb9c12d7253dd
Rust
harehare/boxboard
/server/src/handler.rs
UTF-8
4,106
2.96875
3
[ "MIT" ]
permissive
use percent_encoding::percent_decode; use reqwest; use reqwest::StatusCode; use scraper::{Html, Selector}; use serde::{Deserialize, Serialize}; use std::convert::Infallible; use std::fmt; use std::str::FromStr; #[derive(Clone, Debug)] pub struct Url(String); impl fmt::Display for Url { fn fmt(&self, f: &mut fmt::...
true
2e4720d9cee49d5fff8184b8f1155292dec5021f
Rust
nebelgrau77/uc8159
/src/lib.rs
UTF-8
13,126
2.96875
3
[]
no_license
//! # `uc8159` //! //! This is a driver crate for accessing the `uc8159` E-Ink display controller. For now, most of //! the options are hard-coded for the //! [Pimoroni Inky Impression](https://shop.pimoroni.com/products/inky-impression) display as that's //! the only one I own, so proposing changes to add more featur...
true
fb1956dce5f075909ed05a7086607e1fa4a05488
Rust
ula-lang/ula
/src/lexer/literal.rs
UTF-8
1,312
3.453125
3
[ "Apache-2.0" ]
permissive
use std::fmt; use std::str::FromStr; #[derive(Clone, PartialEq)] pub enum Literal { Bool(bool), Float(f64), Integer(i64), Nil, String(String), } impl FromStr for Literal { type Err = (); fn from_str(s: &str) -> Result<Self, <Self as FromStr>::Err> { Ok(Literal::String(s.to_owned()...
true
37cf2448b9335721dc1ee3dcc4bd3b3da7077948
Rust
shockham/rodio
/src/engine.rs
UTF-8
14,562
2.6875
3
[ "Apache-2.0" ]
permissive
use std::cmp; use std::mem; use std::collections::HashMap; use std::thread::{self, Builder, Thread}; use std::time::Duration; use std::sync::mpsc::{self, Sender, Receiver}; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::Arc; use std::sync::Mutex; use cpal; use cpal::UnknownTypeBuff...
true
b9dedc94b25e3183d9e20a647aedd9fb2ac2ad3a
Rust
salmanrafiq5839/iot_test
/statemet_expression/src/main.rs
UTF-8
90
2.578125
3
[]
no_license
fn main() { let no = { let o = 10; o + 1 }; println!(" {}",no); }
true
f41ec7661edaab9d78d97b790f28200a0080c60b
Rust
FreeFull/monoplay
/src/constants.rs
UTF-8
1,857
2.90625
3
[ "MIT" ]
permissive
use std::fmt; pub type Comment = ShortString<[u8; 40]>; pub type Magic = ShortString<[u8; 8]>; pub const MAGIC: Magic = ShortString { size: 8, string: *b"MONOTONE" }; pub const NUM_ORDERS: usize = 256; pub const FILE_HEADER_SIZE: usize = 0x15F; #[derive(Copy)] #[repr(C)] pub struct Order(pub [u8; NUM_ORDERS]); impl...
true
29afbd43d92af91c27c242dbea21b5f46ef97033
Rust
martinhanzik/helium
/src/main.rs
UTF-8
3,781
2.578125
3
[ "MIT" ]
permissive
#![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] extern crate glium; extern crate glium_text; extern crate cgmath; #[macro_use] extern crate clap; use std::io::Read; use std::fs::File; use std::time::Duration; use std::thread; use clap::{Arg, App}; use glium::{DisplayBu...
true
99a0b4d2fc0459038c1a26313685b4d19ca95e30
Rust
tlent/advent-of-code
/year_2022/day_08/src/lib.rs
UTF-8
4,375
3.125
3
[]
no_license
use rayon::prelude::*; use std::cmp; pub const INPUT: &str = include_str!("../input.txt"); pub struct Grid { size: usize, data: Vec<u8>, } impl Grid { pub fn rows(&self) -> impl Iterator<Item = &[u8]> + ExactSizeIterator + DoubleEndedIterator { self.data.chunks_exact(self.size) } pub fn ...
true
dedf9b2773bf2aaaf869a8995ba86bd31d048f1a
Rust
sinato/concepts_pl
/src/parser_evalml1/nodes.rs
UTF-8
23,755
3.375
3
[]
no_license
use super::lexer::Tokens; use super::terms::{IfTerms, Term, Terms}; use std::io::{self, Write}; use std::ops::{Add, Mul, Sub}; #[derive(Debug, Clone)] pub enum RuleNode { EInt(EIntNode), EBool(EBoolNode), EIfInt(EIfIntNode), EIfError(EIfErrorNode), EIfT(EIfTNode), EIfTError(EIfTErrorNode), ...
true
40443bdda366d7d5854ab78e6a6a125e7f4da3b1
Rust
tinco/ncollide
/ncollide_entities/support_map/support_map.rs
UTF-8
1,256
3.21875
3
[ "BSD-2-Clause" ]
permissive
//! Traits for support mapping based shapes. /// Traits of convex shapes representable by a support mapping function. /// /// # Parameters: /// * V - type of the support mapping direction argument and of the returned point. pub trait SupportMap<P, V, M>: PreferedSamplingDirections<V, M> { // FIXME: add methods t...
true
3755c7563fea4f83542f78cebe5384b201a5ff07
Rust
ear7h/lang1
/src/parser.rs
UTF-8
13,678
2.65625
3
[]
no_license
use crate::expr::{Expr, Type, Pattern}; pub fn parse(s : &str) -> Option<Expr> { parser::main(s).ok() } peg::parser!{grammar parser() for str { pub rule pattern() -> Pattern = pat_bool() / pat_int() / pat_text() / pat_tuple() / s:ident() { Pattern::Var(s) ...
true
69b0528579ef3fcdee38523b95ef4eae3b8b670c
Rust
rithvikvibhu/tealdeer
/src/dedup.rs
UTF-8
581
3.5
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::mem; /// An extension trait to clear duplicates from a collection. pub(crate) trait Dedup<T: PartialEq + Clone> { fn clear_duplicates(&mut self); } /// Clear duplicates from a collection, keep the first one seen. /// /// For small vectors, this will be faster than a `HashSet`. impl<T: PartialEq + Clone> ...
true
3e646c1962860a11585dee705cd009a2fc9bd70a
Rust
MathiasPius/pius-blog
/src/error.rs
UTF-8
774
2.734375
3
[]
no_license
use actix_web::{HttpResponse, ResponseError}; #[derive(Fail, Debug)] pub enum BlogError { #[fail(display = "Template Error: {:?}", _0)] TemplateError(String), #[fail(display = "Missing content: {:?}", _0)] MissingContent(String), #[fail(display = "I/O Error: {:?}", _0)] IOError(String) } imp...
true
2892af86c3b01db169c55482a20ed32615af637f
Rust
Garvys/rustfst
/rustfst/src/utils/labels_to_fst.rs
UTF-8
8,402
3.46875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cmp; use crate::fst_traits::MutableFst; use crate::semirings::Semiring; use crate::tr::Tr; use crate::Label; /// Turns a list of input labels and output labels into a linear FST. /// The only accepted path in the FST has for input `labels_input` and for output `labels_output`. /// /// # Example /// /// ``` /...
true
197de17ae619fccbec79c745d89a130938618e55
Rust
brandon-chow/crustydb
/src/server/src/server_state.rs
UTF-8
7,413
2.875
3
[]
no_license
use std::collections::HashMap; use std::fs; use std::sync::{Arc, RwLock}; use crate::csv_utils; use crate::database_state::DatabaseState; use common::table::Table; use common::CrustyError; use txn_manager::transactions::Transaction; use crate::StorageManager; pub struct ServerState { /// Path to database metadat...
true
e29fc3aff9f5213898ffb6fa54e5f0ace0e966e5
Rust
unknownue/GLSLCookbook.rs
/src/objects/teapot_patch.rs
UTF-8
5,073
2.65625
3
[]
no_license
use glium::backend::Facade; use glium::{Surface, Program, DrawParameters}; use glium::uniforms::Uniforms; use crate::drawable::Drawable; use crate::error::{GLResult, GLErrorKind, BufferCreationErrorKind}; use crate::{Vec3F, Mat3F}; #[allow(non_snake_case)] #[repr(C)] #[derive(Debug, Clone, Copy, Default)] pub struc...
true
3d5e7bb65a4317d7e629af1603a3351a0d8686c4
Rust
richardwhiuk/adventofcode
/2020/rust/src/bin/five.rs
UTF-8
2,136
3.375
3
[]
no_license
use std::collections::HashSet; use std::fs::File; use std::io::{BufRead, BufReader}; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() -> Result<()> { a("input/five-test.txt")?; b("input/five-test.txt")?; a("input/five.txt")?; b("input/five.txt")?; Ok(()) } struct S...
true
f20aee6ac74988015cafef15b6dbc8402c19453d
Rust
YoshikawaMasashi/toid
/src/data/music_info/phrase.rs
UTF-8
2,429
3.265625
3
[]
no_license
use std::collections::{BTreeMap, BTreeSet}; use serde::{Deserialize, Serialize}; use super::beat::Beat; use super::note::Note; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Phrase<N: Note + Eq + Ord + Clone> { pub notes: BTreeMap<Beat, BTreeSet<N>>, pub length: Beat, } impl<N: Note + Eq + Ord +...
true
2809c2000b4b388a490e2a762da1fd1218a81f14
Rust
filipelbc/dit-v2
/src/utils/logging.rs
UTF-8
666
2.53125
3
[]
no_license
use log::{Level, LevelFilter, Metadata, Record}; struct Logger; impl log::Log for Logger { fn enabled(&self, _: &Metadata) -> bool { true } fn log(&self, record: &Record) { if record.level() == Level::Error { eprintln!("Error: {}", record.args()) } else { p...
true
ab828a75466936548042293838db34c8d45bce83
Rust
steveklabnik/rust-adt
/src/stack/stack.rs
UTF-8
503
3.765625
4
[ "BSD-3-Clause" ]
permissive
/// A stack. pub trait Stack<T> { /// Add an element to the top of the stack. fn push(&mut self, elem: T); /// Removes the element on the top of the stack and returns it, or None if the stack is empty. fn pop(&mut self) -> Option<T>; /// Returns a reference to the element on the top of the stack. ...
true
d0b9e1231ec6715e41078070a23877f6b2cd5948
Rust
saeedtabrizi/moleculer-rs
/examples/respond_with_event.rs
UTF-8
1,410
2.71875
3
[ "Apache-2.0" ]
permissive
use std::error::Error; use moleculer::{ config::{ConfigBuilder, Transporter}, service::{Context, Event, EventBuilder, Service}, ServiceBroker, }; use serde::{Deserialize, Serialize}; #[tokio::main] async fn main() -> eyre::Result<()> { env_logger::init(); color_eyre::install()?; let config = ...
true
08cf2e9d2d8c8e39284d39fe58098672701c102c
Rust
pierd/advent-of-code-2018
/src/bin/day02b.rs
UTF-8
1,076
2.765625
3
[ "MIT" ]
permissive
use std::io::{self, Read}; fn main() -> io::Result<()> { let mut input = String::new(); io::stdin().read_to_string(&mut input)?; let ids: Vec<&str> = input.lines().filter(|line| !line.is_empty()).collect(); for i in 0..ids.len() { for j in i..ids.len() { let diffs = ids[i] ...
true
f64a315cc5a66c88f7741b95f623cd0fe7c5b84c
Rust
shilangyu/AoC-2019
/src/day1.rs
UTF-8
679
3.09375
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::{BufRead, BufReader}; pub fn part1() -> i32 { let reader = BufReader::new(File::open("./inputs/day1.txt").unwrap()); let mut fuel = 0; for line in reader.lines() { let mut mass: i32 = line.unwrap().parse().expect("failed to parse into number"); mass /= 3; fuel += mass - 2; } ...
true
ab91e52d80b0bae87ea3ed79fbcd26ee64639c39
Rust
seanmonstar/httparse
/src/simd/sse42.rs
UTF-8
4,789
2.640625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::iter::Bytes; #[target_feature(enable = "sse4.2")] pub unsafe fn match_uri_vectored(bytes: &mut Bytes) { while bytes.as_ref().len() >= 16 { let advance = match_url_char_16_sse(bytes.as_ref()); bytes.advance(advance); if advance != 16 { return; } } supe...
true
d27805f1ed615236882c01eb6614997baa041bff
Rust
ctfhacker/adventofcode-2017-rs
/day_3/src/main.rs
UTF-8
3,072
3.484375
3
[]
no_license
use std::collections::HashMap; #[derive(Debug)] enum Direction { Left, Right, Up, Down } #[derive(Debug)] struct Marker { left: usize, right: usize, up: usize, down: usize, direction: Direction, coord: (isize, isize), grid: HashMap<(isize, isize), usize> } impl Marker { ...
true
d5a9fd0bdaab71b991c6af191a969fd316d7b077
Rust
andrewhalle/aoc2020
/src/days/day07.rs
UTF-8
4,636
3.140625
3
[]
no_license
use crate::Solution; use std::collections::{HashMap, HashSet}; type Graph<'a> = HashMap<&'a str, HashSet<(u32, &'a str)>>; struct Parser<'a> { input: &'a str, } impl<'a> Parser<'a> { fn rule(&mut self) -> Rule<'a> { let color = self.color(); self.input = self.input.strip_prefix("bags contain ...
true
1603ee73bb9a7bc3106c8dc10521129dfad4f35a
Rust
MartinVrbovcan/hmcrovator
/src/arguments.rs
UTF-8
4,508
3.015625
3
[ "MIT" ]
permissive
use super::thanks; use std::process; const HELP_MSG: &'static str = " A code evaluator written in rust. Usage: hmcrovator.exe [command to run program] [...options] * The \"command to run program\" is quoted as to be able to span across multiple spaces (see example below) Example use: ./hmcrovator.exe \"python ./my...
true
7a69ea9e3408ac3ee7ee7a2e2a5e9ea5131095b9
Rust
Aedron/Luoo.server
/src/db/utils.rs
UTF-8
6,871
2.71875
3
[ "MIT" ]
permissive
use std::{env, option::Option}; use bson::{Bson, Document}; use dotenv::dotenv; use mongodb::{Client, ThreadedClient}; use mongodb::{coll::Collection}; use mongodb::db::ThreadedDatabase; use super::models::{Single, VolInfo, VolTrack, Article, ArticleTrack}; lazy_static! { pub static ref LYRIC_COLLECTION: Collec...
true
9e2626583baef0769d7e15ac13cd27c0a040d769
Rust
TomOrth/Getting-Rusty
/loops.rs
UTF-8
420
3.390625
3
[]
no_license
fn main() { loop { println!("I am a loop"); break; } let mut x = 5; // mut x: i32 let mut done = false; // mut done: bool while !done { x += x - 3; println!("{}", x); if x % 5 == 0 { done = true; } } for (x = 0; x < 10; x++) { ...
true
74c69e1f2288e5d24b00b5b48282b8d045cb9f4f
Rust
TAKEDA-Takashi/rust-project-euler
/project-euler/src/bin/problem-115.rs
UTF-8
1,909
3.4375
3
[]
no_license
//! http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20115 //! //! 注意: これは Problem 114 をより難しくした問題である. //! //! 長さ n ユニットからなる 1 列上に, 最低 m ユニットの長さを持つ赤ブロックが置かれている. ただしどの赤ブロック同士も, 少なくとも 1 ユニットの黒い正方形が間にある(赤ブロックは長さが異なってもよい). //! //! 敷き詰め計数関数 F(m, n) は 1 列に敷き詰める方法が何通りかを表すとする. //! //! 例えば, F(3, 29) = 673135 ...
true
48723a3298dab9288b2e25f7ed588bdebac90bb8
Rust
AlexCouch/graviton
/ast/src/semantic.rs
UTF-8
26,581
2.515625
3
[ "MIT" ]
permissive
use super::{ast, Notice, NoticeLevel}; use std::collections::HashMap; const DEFAULT_NUM_PRIMITIVE_SIGNATURE: ast::PrimitiveType = ast::PrimitiveType::I32; const DEFAULT_NUM_TYPE_SIGNATURE: ast::TypeSignature = ast::TypeSignature::Primitive(DEFAULT_NUM_PRIMITIVE_SIGNATURE); const NIL_TYPE_SIGNATURE: ast::TypeSigna...
true
77b66c210617b88072414e11632f97fd37d031b8
Rust
leftwm/leftwm-theme
/src/operations/support.rs
UTF-8
1,003
2.75
3
[ "BSD-3-Clause" ]
permissive
use crate::errors; use crate::models::Config; use clap::Parser; use log::trace; use std::process::Command; #[derive(Parser, Debug)] pub struct Support { /// Names pub name: String, } impl Support { /// # Errors /// /// Should not error. pub fn exec(&self, config: &mut Config) -> Result<(), err...
true
88af466d81fe607f6a851e6da67321a1910f7ffb
Rust
atsamd-rs/atsamd
/hal/src/thumbv7em/clock/v2/reset.rs
UTF-8
6,791
2.953125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! This module is intentionally private. Its contents are publicly exported //! from the `v2` module, which is where the corresponding documentation will //! appear. use typenum::U1; use crate::pac::{GCLK, MCLK, NVMCTRL, OSC32KCTRL, OSCCTRL}; use super::*; /// Collection of low-level PAC structs /// /// This struc...
true
e3fec488e44b2a853afa645e7dc18603cbe8dbf0
Rust
SymmetricChaos/classic_crypto
/src/ciphers/playfair/slidefair.rs
UTF-8
2,985
3.5625
4
[]
no_license
use std::{collections::HashMap, fmt}; use std::{fs::File, io::{Error, Read, Write}}; pub struct Slidefair<'a> { /// The Slidefair Cipher, invented by Helen Fouché Gaines, is a cyclic key variation on the Playfair Cipher. Rather than using a single scrambled alphabet for each digraph it uses a different shifted al...
true
b1e50622c8423c6df7f483b5a07720f9c57d08b5
Rust
mlsteele/gdaxstat
/src/main.rs
UTF-8
2,159
2.734375
3
[ "MIT" ]
permissive
extern crate reqwest; #[macro_use] extern crate error_chain; extern crate chrono; extern crate ring; extern crate base64; #[macro_use] extern crate serde_derive; extern crate serde; extern crate serde_yaml; extern crate bigdecimal; mod errors; mod api; mod num; use bigdecimal::BigDecimal; use api::API; use errors::*...
true
455fbfcaa10f1b99d21b180b682e479eb0581083
Rust
fjardon/Epic-Asset-Manager
/src/configuration/mod.rs
UTF-8
8,272
2.734375
3
[ "MIT" ]
permissive
use std::fs; use clap::{App, Arg}; use config::Config; use egs_api::api::UserData; use env_logger::Env; use serde::{Deserialize, Serialize}; use std::fs::File; use std::io::{BufReader, Write}; use std::path::{Path, PathBuf}; #[derive(Clone)] pub(crate) struct Configuration { pub egs: Config, pub user_data: Op...
true
7bb34e1cd07646cd276779427b562b76dc2635f2
Rust
jbangelo/ws2812-timer-delay-rs
/src/lib.rs
UTF-8
3,002
3.3125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! # Use ws2812 leds with timers //! //! - For usage with `smart-leds` //! - Implements the `SmartLedsWrite` trait //! //! The `new` method needs a periodic timer running at 3 MHz //! //! If it's too slow (e.g. e.g. all/some leds are white or display the wrong color) //! you may want to try the `slow` feature. #![no...
true
64d530673631bd7d77c10741d2aaea32b9b35843
Rust
lqhuang/advent-of-code-2020
/src/bin/day13.rs
UTF-8
10,315
3.609375
4
[]
no_license
//! # --- Day 13: Shuttle Search --- //! //! Your ferry can make it safely to a nearby port, but it won't get much //! further. When you call to book another ship, you discover that no ships //! embark from that port to your vacation island. You'll need to get from the //! port to the nearest airport. //! //! Fortunate...
true
44449816c60c03bb5030947af4383e01c488e55c
Rust
RUSTools/hypergraph
/src/core/hyperedges/get_internal_hyperedge.rs
UTF-8
593
2.546875
3
[ "MIT" ]
permissive
use crate::{errors::HypergraphError, HyperedgeIndex, Hypergraph, SharedTrait}; impl<V, HE> Hypergraph<V, HE> where V: SharedTrait, HE: SharedTrait, { // Private method to get the internal hyperedge matching a HyperedgeIndex. pub(crate) fn get_internal_hyperedge( &self, hyperedge_index: ...
true
c70a671d93d8dee233ae536dee87736623c0a9d1
Rust
MrLarssonJr/provenance
/src/lib.rs
UTF-8
21,082
4.21875
4
[ "MIT" ]
permissive
//! This library provides containers where the keys are guaranteed to be valid. //! The key is generated when a value is inserted into the container. That key //! is guaranteed to only work with the map that generated it, and within that //! container always reference the same value. //! //! ``` //! use provenance::Pro...
true
d5e5e037e7157e6877585efca096d0ac43b6927b
Rust
seanwallawalla-forks/nushell
/crates/nu-command/src/commands/pathvar/add.rs
UTF-8
1,688
2.828125
3
[ "MIT" ]
permissive
use crate::prelude::*; use nu_engine::WholeStreamCommand; use nu_errors::ShellError; use nu_protocol::{Signature, SyntaxShape}; use nu_source::Tagged; use nu_test_support::{NATIVE_PATH_ENV_SEPARATOR, NATIVE_PATH_ENV_VAR}; use std::path::PathBuf; pub struct SubCommand; impl WholeStreamCommand for SubCommand { fn n...
true
5e7756154c40695b3c80635e287b5b492d24f175
Rust
370417/tower-defense
/backend/src/build.rs
UTF-8
13,875
2.796875
3
[]
no_license
use serde::{Deserialize, Serialize}; use wasm_bindgen::prelude::*; use crate::{ factory::create_factory, falcon::create_falcon_tower, graphics::SpriteType, map::{tile_center, Tile, TRUE_MAP_WIDTH}, missile::create_missile_tower, swallow::create_swallow_tower, tower::{ Tower, TowerSt...
true
63275b7a1f3b53ad9b39cbff056aa77b7a436931
Rust
zhnlk/jvm
/tools/javap/src/trans/code.rs
UTF-8
1,397
2.59375
3
[ "Apache-2.0" ]
permissive
use super::instruction::{get_instructions, InstructionInfo}; use classfile::{attributes::Code, ClassFile, OpCode}; pub struct Translator<'a> { pub cf: &'a ClassFile, pub code: &'a Code, } impl<'a> Translator<'a> { pub fn get(&self) -> Vec<String> { let codes = self.code.code.as_slice(); le...
true
79170ba32fb1882554206077767786c4c3128203
Rust
FauxFaux/argon2min
/src/verifier.rs
UTF-8
15,249
3.015625
3
[ "MIT" ]
permissive
use argon2::{defaults, Argon2, ParamErr, Variant, Version}; use std::error::Error; /// The main export here is `Encoded`. See `examples/verify.rs` for usage /// examples. use std::{fmt, str}; macro_rules! maybe { ($e: expr) => { match $e { None => return None, Some(v) => v, ...
true
b79a696f8af156ababd9139a72874fcc4376f0b0
Rust
dimo414/advent-2020
/src/aoc25.rs
UTF-8
1,251
3.109375
3
[]
no_license
pub fn advent() { let (card_key, door_key) = (3248366, 4738476); let card_loop = find_loop_size(card_key); let door_loop = find_loop_size(door_key); println!("Card Loop: {}, Door Loop: {}", card_loop, door_loop); let key = generate_key(card_loop, door_key); assert_eq!(key, generate_key(door_loop...
true
0fca17068ea339bcbc79f477a989b1d2d76a38ee
Rust
wulu90/leetcode
/src/remove_linked_list_elements.rs
UTF-8
1,162
3.328125
3
[]
no_license
use crate::leetcode::linked_list::ListNode; pub struct Solution; impl Solution { pub fn remove_elements(head: Option<Box<ListNode>>, val: i32) -> Option<Box<ListNode>> { let mut result = Box::new(ListNode::new(0)); let mut s_result = &mut result; let mut head = head.as_ref(); while...
true
b9f8d21bda2968e67a1108cf3a49bf0f8132f755
Rust
jannikkeye/git-auto-sync
/src/repo.rs
UTF-8
318
2.953125
3
[]
no_license
use std::path::PathBuf; const GIT_FOLDER: &str = ".git"; pub fn is_repo(target_path: &PathBuf) -> bool { let target_string = target_path.to_str().unwrap(); let target_git_path = PathBuf::from(format!("{}/{}", target_string, GIT_FOLDER)); println!("{:?}", target_git_path); target_git_path.is_dir() }
true
23ce752d776f7558aa78174cbf6a174ec0d44b61
Rust
jiyilanzhou/chw
/std_module/8_necessary/src/3_super_trait.rs
UTF-8
2,456
3.296875
3
[]
no_license
/* 0. 完全限定语法(消除歧义) 格式:" <Type as Trait>::function(receiver_if_method,next_arg ... ); " 对于关联函数而言上述形式会缺少" receiver "而只保留剩下的参数列表,可在任何 调用函数(包含方法)的地方使用完全限定语法,而 Rust 允许忽略能够从上下文推导 的部分。只有存在多个同名实现以致无法区分调用的具体实现时才需要这种较为烦琐 的显式语法 1. 超 Trait (supertrait) a. 继承父 trait:" trait subTrait : superTrait { // ... ...
true
32df2d98cf0e47344d61ed9268f2118a6ae7b005
Rust
carsonyannick/rustLLRBT
/src/socket.rs
UTF-8
4,838
3.25
3
[]
no_license
// use std::os::unix::net::UnixStream; use std::os::unix::net::{UnixStream, UnixListener}; use std::io::{Write, Read}; pub struct server { socket: UnixListener, } impl server { pub fn new(socketAddress: String) -> server { let socket = match UnixListener::bind(socketAddress) { ...
true
e2c413e779a3feb5c90bee89ef7538f1f5f8adc1
Rust
GreatGodOfFire/JavaDecompiler
/src/decompiler/field.rs
UTF-8
2,323
2.71875
3
[ "MIT" ]
permissive
const PUBLIC: u16 = 0x0001; const PRIVATE: u16 = 0x0002; const PROTECTED: u16 = 0x0004; const STATIC: u16 = 0x0008; const FINAL: u16 = 0x0010; const VOLATILE: u16 = 0x0040; const TRANSIENT: u16 = 0x0080; const SYNTHETIC: u16 = 0x1000; // idk how to use it but it doesn't look really important // const ENUM: u16 = 0x4000...
true
eced86085ed62a3cb66daee660743d7cbea49fa5
Rust
Regentag/Remember0416
/src/tray.rs
UTF-8
789
2.71875
3
[]
no_license
use trayicon::*; use std::sync::mpsc::{ Receiver }; #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum Events { Click, ShowOnlineInfo, About, Exit, } /// 트레이 아이콘 생성. pub fn new() -> (TrayIcon<Events>, Receiver<Events>) { let (s, r) = std::sync::mpsc::channel::<Events>(); let icon_bytes = include_bytes!("ribb...
true
1555bfd0a72979a898737b76304f4648cfad7f7b
Rust
grenade/poloniex-rs
/src/types/opened_order.rs
UTF-8
1,898
3.1875
3
[ "MIT" ]
permissive
use chrono::prelude::*; use super::TradeType; use super::deserialize::{string_to_f64, string_to_utc_datetime}; /// Structure returned from `buy` and `sell` API calls. #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct OpenedOrder { pub order_number: String, pub resulting_trades...
true
720b1ffc8e27852a049cacc0d49822a6ace7d84a
Rust
phudekar/snakes-and-ladders-rust
/src/lib/game.rs
UTF-8
2,978
3.453125
3
[]
no_license
use super::board::Board; use super::player::Player; use super::{Dice, Square}; use std::collections::HashMap; pub struct Game { players: HashMap<String, Player>, board: Board, current_player_index: usize, } impl Game { pub fn new(number_of_players: u8, snakes: Vec<Square>, ladders: Vec<Square>) -> Gam...
true
9017f9ee2ad11f15beac47fb33aff75f5673d1ea
Rust
rust-lang/rustlings
/exercises/variables/variables2.rs
UTF-8
255
2.765625
3
[ "MIT" ]
permissive
// variables2.rs // // Execute `rustlings hint variables2` or use the `hint` watch subcommand for a // hint. // I AM NOT DONE fn main() { let x; if x == 10 { println!("x is ten!"); } else { println!("x is not ten!"); } }
true
6c7dc8189e7b0a1f58beece8da6699101ad34ec9
Rust
IranNeto/LearningRust
/enums/src/main.rs
UTF-8
292
3.359375
3
[]
no_license
enum Direction { Up, Down, Stay } fn main() { let myDirection:Direction = Direction::Stay; match myDirection { Direction::Up => println!("You're going Up"), Direction::Down => println!("You're going down"), _ => println!("Something goes wrong") } }
true
e1d90d70a79ddf6849f1af37e24b9de403b02583
Rust
mengsuenyan/rcrypto
/src/dsa/signature.rs
UTF-8
1,747
3.078125
3
[ "Apache-2.0" ]
permissive
use rmath::bigint::BigInt; /// (r, s) pub struct SignatureContent { content: Vec<u8>, // in bytes r_len: usize, s_len: usize, } impl SignatureContent { pub fn new() -> Self { Self::with_capacity(1) } pub fn with_capacity(capacity: usize) -> Self { Self { co...
true
00d378f962f6aad244f31cb5c405ad48aed425d5
Rust
acw/cryptonum
/src/unsigned/primes.rs
UTF-8
6,669
3.375
3
[ "ISC" ]
permissive
use rand::RngCore; /// Functions related to the generation of random numbers and primes. pub trait PrimeGen: Sized + PartialOrd { /// Generate a random prime number, using the given RNG and running /// the primality check for the given number of iterations. This is /// equivalent to calling `random_primef`...
true
0a26ea8f57a444e1bccd34ad2a00043dc85a7ad2
Rust
lycus/prismo
/lexer.rs
UTF-8
7,027
3.015625
3
[ "MIT" ]
permissive
use core::io; use core::char; use core::unicode; #[deriving(Eq)] pub enum TokenType { EOF, IMPORT, QUALIFIED, RECORD, MATCH, WITH, CASE, WHILE, DO, IF, THEN, ELSE, LET, AS, FN, UNDERSCORE, ELLIPSIS, SEMICOLON, COMMA, COLON, DOT, AR...
true
72e8e8cdbe68bad575447e660d3ad19bbb0a8cd0
Rust
callym/vsop2013-rs
/src/util.rs
UTF-8
1,911
2.84375
3
[]
no_license
use crate::Error; use nom::{ bytes::complete::take_till, character::complete::{line_ending, space0}, combinator::{map_parser, map_res, opt}, }; pub const PLANETS: usize = 9; pub const FILES: [&'static str; 6] = [ "VSOP2013.m4000", "VSOP2013.m2000", "VSOP2013.m1000", "VSOP2013.p1000", "VSOP2013.p2000",...
true
00da44d0ca625a3823d7764d4b6ec78ea234a06e
Rust
JIghtuse/rosetta
/random_numbers/rust/rand.rs
UTF-8
283
2.8125
3
[]
no_license
use std::rand; use std::rand::distributions::{Normal, IndependentSample}; fn main() { let mut rands = [0.0, ..1000]; let normal = Normal::new(1.0, 0.5); for i in range(0u, 1000u) { let v = normal.ind_sample(&mut rand::task_rng()); rands[i] = v; } }
true
cd14e9b951ab6179993a4fadcca9d917fdbcd8a9
Rust
narodnik/nym
/sfw-provider/src/provider/mix_handling/mod.rs
UTF-8
2,829
2.625
3
[]
no_license
use crate::provider::storage::StoreData; use crypto::identity::DummyMixIdentityPrivateKey; use sphinx::{ProcessedPacket, SphinxPacket}; use std::path::PathBuf; use std::sync::{Arc, RwLock}; // TODO: this will probably need to be moved elsewhere I imagine // DUPLICATE WITH MIXNODE CODE!!! #[derive(Debug)] pub enum MixP...
true
3280985ffdece0f30805726ea5864e3b9e2242b2
Rust
sburton84/rust-http-proxy
/src/utils.rs
UTF-8
3,450
3
3
[]
no_license
use { std::{ io, pin::Pin, task::Poll, sync::{Arc, Mutex}, }, tokio::{ io::{AsyncRead, AsyncWrite}, net::TcpStream, }, tokio_tls::TlsStream, }; pub enum TcpOrTlsStream { Tcp(TcpStream), Tls(TlsStream<TcpStream>), } impl AsyncRead for TcpOrTls...
true
40ae2eee0103155a07868a6fcb7c734bce045d08
Rust
jhessin/you-choose
/src/disp.rs
UTF-8
321
2.9375
3
[]
no_license
use std::fmt; pub struct DispFunc<D> where D: fmt::Display, { pub func: Box<dyn Fn(D) -> String>, } impl<D> DispFunc<D> where D: fmt::Display, { pub fn new(func: Box<dyn Fn(D) -> String>) -> DispFunc<D> { DispFunc { func } } pub(crate) fn eval(&self, param: D) -> String { (*self.func)(param) } }...
true
b5f08c02185541b142f0935180c1a2be08224dd2
Rust
coreydexter/pngme
/src/chunk_type.rs
UTF-8
6,372
3.40625
3
[]
no_license
use std::{ convert::TryFrom, fmt::{self, Display, Formatter}, str::FromStr, }; use thiserror::Error; pub type ChunkTypeResult = Result<ChunkType, ChunkTypeError>; #[derive(Error, Debug)] pub enum ChunkTypeError { #[error("Input character length of chunk type was `{0}`, expected it to be exactly 4")] ...
true
4d05a7abef90ba88726da5d04e8f5dcb52381ab7
Rust
LegNeato/rust-aws-lambda
/aws_lambda_runtime/src/context.rs
UTF-8
3,978
3.015625
3
[ "MIT" ]
permissive
//! Types that contain invocation metadata. use std::collections::HashMap; use std::sync::Arc; /// Information about the client application that invoked the lambda function. #[derive(Debug)] pub struct Client { pub(crate) installation_id: String, pub(crate) app_title: String, pub(crate) app_version_code: ...
true
16913add73dc172f13339f0d62dee431ff397728
Rust
creativcoder/forest
/ipld/amt/src/lib.rs
UTF-8
1,223
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2020 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT //! AMT crate for use as rust IPLD data structure //! //! Data structure reference: //! https://github.com/ipld/specs/blob/51fab05b4fe4930d3d851d50cc1e5f1a02092deb/data-structures/vector.md mod amt; mod error; mod node; mod root; mod valu...
true
0eb06f6a38ea649ebfca7b551641470d484362e9
Rust
n1tsu/lsf-tui
/src/tui_mode.rs
UTF-8
7,060
2.75
3
[]
no_license
use rand::prelude::*; use std::io; use std::time::{Duration, Instant}; // tui use tui::backend::TermionBackend; use tui::Terminal; // termion use termion::event::Key; use termion::raw::IntoRawMode; // local modules use crate::draw::{draw_dictionary, draw_learn, WordState}; // use crate::draw::WORDS_LEARN_SIZE; use ...
true
8b0fd79a93b87c6f08d0c78c5940a987d50fac61
Rust
roller/bazbot
/src/main.rs
UTF-8
4,052
2.828125
3
[ "CC0-1.0" ]
permissive
use clap::{App, Arg, SubCommand, ArgMatches, AppSettings}; use bazbot::markov_words::WordsDb; use bazbot::ircconn::IrcConn; use irc::client::data::config::Config; use std::env; const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); fn cmd_add_phrase(words: &WordsDb, matches: &ArgMatches) { let ph...
true
b36be742d54aea88e71de391a17f742e4e7e1489
Rust
brayden-marshall/Logo
/src/parser.rs
UTF-8
25,094
3.578125
4
[]
no_license
use crate::error::ParseError; use crate::lexer::{Operator, Token}; use std::iter::Peekable; use std::slice; /// Statements are any logo 'sentence' that does not evaluate to a value #[derive(Debug, PartialEq, Clone)] pub enum Statement { Repeat { count: Expression, body: AST, }, VariableDecl...
true
fed8ca184758307dcdcc979d4083d474b5071f5b
Rust
brymko/AdventOfCode2020
/src/d15.rs
UTF-8
1,331
3.0625
3
[]
no_license
use crate::Perf; use std::collections::{HashMap, HashSet}; use std::iter::FromIterator; const INPUT: &str = "0,3,1,6,7,5"; // const INPUT: &str = "0,3,6"; pub fn main() { let perf = Perf::default(); let input: Vec<usize> = INPUT.split(',').filter_map(|c| c.parse().ok()).collect(); perf.print("setup"); ...
true