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
1e10850332a71c0830210657de9686bcae7b0971
Rust
robertdigital/fix-rust
/fixcodegen/src/model.rs
UTF-8
3,247
2.71875
3
[ "Apache-2.0" ]
permissive
extern crate serde; pub trait FixComposite { fn entries(&self) -> &Vec<MessageEntry>; } #[derive(Serialize,Deserialize,Debug)] pub struct Message { pub name: String, pub msg_type : String, pub is_admin : bool, pub entries : Vec<MessageEntry>, } #[derive(Serialize,Deserialize,Debug)] pub struct M...
true
d9f6622c263ec2a5c23f1f06997b1eb598527252
Rust
owen8877/leetcode-rs
/src/problem_273.rs
UTF-8
1,824
3.75
4
[]
no_license
pub fn number_to_words(mut num: i32) -> String { fn helper(num: usize) -> String { let ones = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"]; let tens = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"]; let special = ["Ten",...
true
9ec7cc4e3938a23bdfb6c966e618e6f575a622a0
Rust
rectinajh/rust-leetcode
/src/l0083_delete_duplicates.rs
UTF-8
1,298
3.421875
3
[]
no_license
/* 给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。 示例 1: 输入: 1->1->2 输出: 1->2 示例 2: 输入: 1->1->2->3->3 输出: 1->2->3 */ use crate::share::ListNode; struct Solution {} impl Solution { pub fn delete_duplicates(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> { let mut head = head; let mut current = head.as_mut(...
true
603355f150673da42836cb03abf11f5fde60e01c
Rust
dmiyakawa/rust_rough_examples
/trait_exp_1.rs
UTF-8
1,412
3.921875
4
[]
no_license
// `trait トレイト名 {..}`でトレイトを定義 trait DuckLike { // トレイトを実装する型が実装すべきメソッドを定義 fn quack(&self); // デフォルトメソッドを定義することもできる fn walk(&self) { println!("walking"); } } // トレイトを実装するためだけのデータ型にはUnit構造体が便利 struct Duck; // `impl トレイト名 for 型名 {..}`で定義可能 impl DuckLike for Duck { // トレイトで実装されていないメソッドを実装側で...
true
cefccc9e443aee335d4892a07d16e2d516a881dd
Rust
connorskees/grass
/crates/compiler/src/utils/strings.rs
UTF-8
877
2.78125
3
[ "MIT" ]
permissive
use super::{is_name, is_name_start}; pub(crate) fn is_ident(s: &str) -> bool { let mut chars = s.chars().peekable(); match chars.next() { Some(c) if is_name_start(c) && !c.is_numeric() => {} Some(..) | None => return false, } while let Some(c) = chars.next() { if c == '\\' { ...
true
7f750ca2bce5ed83248bb45ba6d1044a82cd221e
Rust
1ybe/agora
/agora/src/errors.rs
UTF-8
831
3.15625
3
[ "MIT" ]
permissive
use std::error::Error; use std::fmt; use std::fmt::Debug; use std::path::{Path, PathBuf}; #[derive(Debug, Clone)] pub struct WithPath<Err> { path: PathBuf, inner: Err, } impl<E> WithPath<E> { pub fn context<T>( path: impl AsRef<Path>, f: impl FnOnce(&Path) -> Result<T, E>, ) -> Result<...
true
704fb6ffe9d6bfcf0691b5060dddeb8254f0ed3b
Rust
dtolnay-contrib/odbc2parquet
/src/parquet_buffer.rs
UTF-8
10,378
2.859375
3
[ "MIT" ]
permissive
use anyhow::Error; use chrono::NaiveDate; use num_bigint::BigInt; use odbc_api::sys::Timestamp; use parquet::{ column::{reader::ColumnReaderImpl, writer::ColumnWriterImpl}, data_type::{ByteArray, DataType, FixedLenByteArray, FixedLenByteArrayType, Int64Type}, }; use std::mem::size_of; /// Holds preallocated bu...
true
0c37b14345aff5e4427872c6a65c197e4a6ca408
Rust
Spawek/simplidb
/src/database.rs
UTF-8
381
2.875
3
[]
no_license
use std::path::PathBuf; #[derive(Debug)] pub struct Database { pub datastores: Vec<Datastore>, } #[derive(Debug)] pub struct Datastore { pub name: String, pub path: PathBuf, pub columns: Vec<Column>, // TODO: change to read data on-demand } #[derive(Debug, Clone)] // TODO: remove Copy/Clone pub struc...
true
4d285f4d2d22612593fb9783dea095b6f2f8d86f
Rust
FrancoLiberali/g8-parque-oxidado
/src/persona.rs
UTF-8
2,310
3.3125
3
[]
no_license
use std::{ sync::Arc, thread::JoinHandle }; use crate::{logger::{Logger, TaggedLogger}, parque::Parque}; use crate::juego::Juego; pub fn iniciar_hilos_personas(logger: Arc<Logger>, parque: Arc<Parque>, presupuestos: &[u32]) -> Vec<JoinHandle<()>> { let mut handles = vec![]; for (id, presupuesto_person...
true
0d375c863da5226e5ba1a70113ffe90e8fc45eef
Rust
wbw1974/webcalc
/src/prefix/mod.rs
UTF-8
6,790
3.453125
3
[ "MIT" ]
permissive
use unicode_segmentation::UnicodeSegmentation; use regex::Regex; /// Function that translates a infix notated equation to an prefix notated equation. /// # Example /// a + b -> + a b /// /// TODO: capture and fix negative signifier /// /// a + -b -> b - + a -> -b + a -> -b a + -> + a -b /// ... pub fn translate_infix(...
true
304307fab1c16bf49da2ca780c77010396d7616d
Rust
QiYuTechDev/vps_bench
/src/ping/mod.rs
UTF-8
959
2.625
3
[]
no_license
use structopt::StructOpt; use crate::report::BenchReport; use crate::shared::SharedCli; #[derive(Debug, StructOpt)] /// 连接服务器测试 APP_KEY 是否有效 pub struct PingCli { #[structopt(flatten)] pub shared: SharedCli, } impl PingCli { /// 运行 Ping 命令 pub fn run(&self) { println!("测试服务器地址: {}", self.share...
true
b01c612788d48388c23bbddc2735658e457bed0f
Rust
oxidecomputer/dropshot
/dropshot/tests/test_streaming.rs
UTF-8
4,422
2.515625
3
[ "Apache-2.0" ]
permissive
// Copyright 2021 Oxide Computer Company //! Test cases for streaming requests. use dropshot::{endpoint, ApiDescription, HttpError, RequestContext}; use http::{Method, Response, StatusCode}; use hyper::{body::HttpBody, Body}; use hyper_staticfile::FileBytesStream; use tokio::io::{AsyncSeekExt, AsyncWriteExt}; extern...
true
e0096f1c932f74f3b91071b17f8cda9c0e7deaeb
Rust
xcaptain/rust-algorithms
/leetcode/src/p203.rs
UTF-8
2,143
3.640625
4
[]
no_license
// https://leetcode-cn.com/problems/remove-linked-list-elements/ // https://users.rust-lang.org/t/how-to-delete-element-in-linkedlist/34951/20 // TODO: don't know how to remove #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>> } impl ListNode { #[inline] ...
true
592496e892affb2c79ca4c69e54ac583fda067fb
Rust
charliejeynes/arc
/src/math/tool/indexer.rs
UTF-8
614
2.921875
3
[]
no_license
//! Index producing functions. use crate::list::Cartesian::{Y, Z}; /// Create the next three-dimensional index from the given linear index. #[inline] #[must_use] pub fn three_dim(n: usize, res: [usize; 3]) -> [usize; 3] { let zi = n % res.get(Z as usize).expect("Missing resolution index."); let yi = (n / res....
true
ec7412ad2936decf5b537d97b146f28e8e36a8ab
Rust
lcarsos/secretgarden
/src/secret_types/x509/mod.rs
UTF-8
7,153
2.578125
3
[]
no_license
mod rfc2253; use anyhow::{anyhow, bail, Result as AHResult}; use clap::Clap; use openssl::asn1::Asn1Time; use openssl::hash::MessageDigest; use openssl::pkey::PKey; use openssl::rsa::Rsa; use openssl::x509::extension::{BasicConstraints, SubjectAlternativeName}; use openssl::x509::{X509NameBuilder, X509}; use serde::{D...
true
1988b4e050aea9b30c03ec35ddee503d317a2eba
Rust
abusch/rustracer
/rustracer-core/src/bsdf/mod.rs
UTF-8
8,341
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
mod bxdf; mod fourier; mod fresnel; mod lambertian; mod microfacet; mod oren_nayar; pub use self::bxdf::*; pub use self::fourier::*; pub use self::fresnel::*; pub use self::lambertian::*; pub use self::microfacet::*; pub use self::oren_nayar::*; use std::cmp; use bitflags::bitflags; use light_arena::Allocator; use ...
true
91b30f107073b33bf71cbde8a06d06239fdcb5e4
Rust
davidsteiner/seq-rs
/src/rendering/renderer.rs
UTF-8
8,362
2.625
3
[ "MIT" ]
permissive
use nalgebra::Point2; use svg::node::element::{Circle, Definitions, Element, Line, Marker, Path, Rectangle, Text}; use svg::node::{Node, Text as TextNode}; use svg::Document; static ARROW_HEAD_ID: &str = "arrow"; pub static LIGHT_BLUE: &str = "#add3ff"; pub static MEDIUM_BLUE: &str = "#62acff"; pub static LIGHT_PURP...
true
4abfeabae04e1b785eb0619b7f00186186d43005
Rust
AThilenius/iter_test
/src/main.rs
UTF-8
2,700
3.171875
3
[]
no_license
#![allow(dead_code)] use itertools::Itertools; use std::collections::HashMap; #[derive(Clone, Hash, Eq, PartialEq)] struct Location { x: i32, y: i32, z: i32, } impl Location { pub fn new() -> Self { Location { x: 0, y: 0, z: 0 } } } struct Chunk { data: Box<[u8]>, } impl Chunk { ...
true
ebbd7ab96c2f1c61ebb1f7b9a04d7fdd0ff23840
Rust
eihwaz/minecraft-protocol
/protocol-derive/src/render/encoder.rs
UTF-8
5,344
2.65625
3
[ "MIT" ]
permissive
use crate::parse::{AttributeData, BitfieldPosition, DiscriminantType, FieldData, VariantData}; use proc_macro2::TokenStream as TokenStream2; use proc_macro2::{Ident, Span}; use quote::quote; pub(crate) fn render_struct_encoder(name: &Ident, fields: &Vec<FieldData>) -> TokenStream2 { let render_fields = render_fiel...
true
fe3328c9904bb28782c52ba022c97dfe93d82043
Rust
danbev/learning-rust
/src/mutex.rs
UTF-8
471
3.1875
3
[]
no_license
use std::sync::Mutex; fn main() { println!("Mutex example"); let m = Mutex::new("bajja"); println!("{:?}", m); println!("is_poisoned: {}", m.is_poisoned()); let l = m.lock(); let s = l.unwrap(); println!("{:?}", s); let would_block_err = m.try_lock(); //.unwrap(); println!("{:?}", ...
true
0ed069cf178e507383368d83c034697e3e4181a9
Rust
faustfu/hello_proc_macro
/src/lib.rs
UTF-8
706
2.75
3
[]
no_license
extern crate proc_macro; use self::proc_macro::TokenStream; #[proc_macro_derive(A)] // declare derive(A) pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("struct A")); r#" impl A { fn a(&self) -> String { format!(...
true
fc9642fe782b08ac902c48fc9451802aeaaa7172
Rust
lambdaxymox/fuchsia
/third_party/rust_crates/vendor/zstd/src/block/decompressor.rs
UTF-8
2,592
3
3
[ "MIT", "BSD-3-Clause", "GPL-2.0-only", "BSD-2-Clause" ]
permissive
use crate::map_error_code; #[cfg(feature = "experimental")] use std::convert::TryInto; use std::io; use zstd_safe; /// Allows to decompress independently multiple blocks of data. /// /// This reduces memory usage compared to calling `decompress` multiple times. #[derive(Default)] pub struct Decompressor { context...
true
df08f7fdb95c952a8391538d7a4ec1c789ea7e18
Rust
Kenttleton/gs
/src/server/parser.rs
UTF-8
6,524
2.765625
3
[]
no_license
use crate::server::request; use std; const CR: u8 = '\r' as u8; //const LF: u8 = '\n' as u8; const SPACE: u8 = ' ' as u8; const QMARK: u8 = '?' as u8; const EQUALS: u8 = '=' as u8; const AMP: u8 = '&' as u8; const COLON: u8 = ':' as u8; pub struct Parser<I: Iterator<Item = u8>> { iter: std::iter::Peekable<I>, ...
true
55ef27df603b0719782cb7729d460b3ed5efbc43
Rust
elbart/rust-http-signatures
/src/lib.rs
UTF-8
8,980
2.890625
3
[]
no_license
extern crate base64; extern crate crypto; extern crate itertools; extern crate regex; extern crate time; use std::collections::HashMap; use std::fmt; use std::str; use base64::encode as b64_encode; use crypto::digest::Digest; use crypto::sha2::Sha256; use crypto::hmac::Hmac; use crypto::mac::Mac; use itertools::Itert...
true
68a53f931f6c7fbb24a98d9aaf51f3f78cbb047d
Rust
ckomaki/kaggle-santa-2017-winner-solution
/src/rust/loop_solver.rs
UTF-8
3,755
2.640625
3
[]
no_license
use assignment::Assignment; use std::collections::HashMap; use loop_canceler::LoopCanceler; use input::Input; use std::time::{SystemTime, UNIX_EPOCH}; use slot::Slot; pub struct LoopSolver<'a> { input: &'a Input, } impl<'a> LoopSolver<'a> { pub fn new(input: &Input) -> LoopSolver { LoopSolver { input...
true
2723f3307f81d11b86e7d6b8e060d947242adf4b
Rust
David-Thureson/rust-char-tree
/char_tree_mult_file/src/char_node/char_ext_node.rs
UTF-8
6,465
2.703125
3
[]
no_license
use typename::TypeName; #[macro_use] extern crate typename; #[macro_use] extern crate util; use util::*; use std::collections::HashMap; use std::cell::RefCell; use std::fmt::{self, Debug, Display}; use std::cmp; // Don't use rc::Weak because we'll have code later that needs sync::Weak. use std::rc::{self, Rc}; pub mo...
true
1aec94f56272b631fedb04a285d5c405fc5c080a
Rust
pedrocr/piston
/src/input/src/generic_event.rs
UTF-8
3,120
3.015625
3
[ "MIT" ]
permissive
//! Trait for generic events use std::any::Any; use {AfterRenderEvent, ControllerAxisEvent, CursorEvent, FocusEvent, IdleEvent, MouseCursorEvent, MouseRelativeEvent, MouseScrollEvent, PressEvent, ReleaseEvent, RenderEvent, ResizeEvent, TextEvent, TouchEvent, UpdateEvent}; use {EventId, Input, Motion}; use {...
true
9a8c35a16c49aead0a0bc2839c15ece8bd4a34a9
Rust
Lakelezz/serenity
/src/client/bridge/gateway/shard_manager_monitor.rs
UTF-8
2,434
3.40625
3
[ "ISC" ]
permissive
use parking_lot::Mutex; use std::sync::{ mpsc::Receiver, Arc }; use super::{ShardManager, ShardManagerMessage}; /// The shard manager monitor does what it says on the tin -- it monitors the /// shard manager and performs actions on it as received. /// /// The monitor is essentially responsible for running in i...
true
d8b089d822f4d33848efb44cf354a9751bc22157
Rust
polyhorn/polyhorn
/crates/polyhorn-ui/src/components/view.rs
UTF-8
1,493
2.78125
3
[ "MIT" ]
permissive
use polyhorn_core::{Platform, WeakReference}; use crate::events::EventListener; use crate::geometry::Size; use crate::handles::{Imperative, ViewHandle}; use crate::styles::ViewStyle; /// The base component. pub struct View<P, H> where P: Platform + ?Sized, H: ViewHandle + 'static, { /// Controls the appea...
true
ad81e9eef988e8b49440bc35a793211833e0b30a
Rust
KrzysztofMiler/Rust_tut
/prostokont_metody/src/main.rs
UTF-8
925
3.625
4
[]
no_license
#[derive(Debug)] struct Prost { wys: u32, szer: u32, } impl Prost {//btw. moæna to roazbi© an wiele bloków impl fn pole(&self) -> u32 { self.wys * self.szer } fn zmiesci(&self, other: &Prost) -> bool { self.szer > other.szer && self.wys > other.wys } fn kwad(size:u32) -> Pro...
true
71a91a71233b8bb0149d1216686ca646a79c40f1
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/termcolor/src/lib.rs
UTF-8
53,342
2.6875
3
[ "MIT", "Unlicense", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![deny(missing_debug_implementations, missing_docs)] use std::env; use std::error; use std::fmt; use std::io::{self, Write}; use std::str::FromStr; use std::sync::atomic::{AtomicBool, Ordering}; #[cfg(w...
true
7b59f5f049e0249f468c78121b7cae9311d87c72
Rust
webbrandon/mc
/src/handler/template/mod.rs
UTF-8
704
2.859375
3
[ "Unlicense" ]
permissive
use crate::file::parse_json; use std::process; use handlebars::Handlebars; pub use crate::model::{Template}; impl Template { pub fn render_template(&mut self) -> &String { let json = parse_json(&self.params()); let mut handlebars = Handlebars::new(); handlebars .register_templat...
true
9aea734eb468047b568ccf38134034bd3fb42082
Rust
vijaylaxmid/rust-demo-apps
/mysql-cdc/cdc-producer/src/binlog_manager/binlog_resume.rs
UTF-8
932
2.71875
3
[ "Apache-2.0" ]
permissive
use std::fmt; use cdc_messages::BnFile; #[derive(Debug)] pub struct Resume { file: String, offset: Option<u64>, } impl fmt::Display for Resume { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let offset = if let Some(offset) = self.offset { offset } else { ...
true
cd2852fca0622ce468d6de07456431e88e94c7c0
Rust
sebastian-vogt-cs/Rasm
/src/main.rs
UTF-8
4,715
3.5
4
[]
no_license
mod controller; mod register_machine; use controller::Controller; mod parser; mod ui; fn main() { //you can now parse a String to commands! The example in the comment below makes it the "old fashioned" way let commands = parser::parse( "DLOAD 10 -- some command ...
true
5c3aff0feebfcccae83bc73ab6411264a7d9e9f8
Rust
nats-io/nats.rs
/nats/src/proto.rs
UTF-8
13,192
2.640625
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2022 The NATS Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
true
863ba03928bc28c5b93a30a97d8d562f75e97c14
Rust
redox-os/netutils
/src/ntp/main.rs
UTF-8
819
2.515625
3
[ "MIT" ]
permissive
#![deny(warnings)] extern crate ntpclient; use ntpclient::retrieve_ntp_timestamp; use std::env; fn format_time(mut ts: i64) -> String { let s = ts%86400; ts /= 86400; let h = s/3600; let m = s/60%60; let s = s%60; let x = (ts*4+102032)/146097+15; let b = ts+2442113+x-(x/4); let mut c ...
true
13f82d37c727636046d91e6732df3a75daee1b34
Rust
uzkbwza/fckmaker
/examples/bf_optimized.rs
UTF-8
5,053
3.125
3
[]
no_license
use std::fs; use std::io::{stdout, Write}; use text_io::read; use fckmaker::{Interpreter, tape_model::*}; #[derive(Debug, Clone, Copy)] pub enum Instruction { Incr(u8), Decr(u8), Next(usize), Prev(usize), Read, Print, BeginLoop(usize), EndLoop(usize), EOF, } #[derive(Debug)] enum ...
true
1b770561b8f78ad851a765c590566ba9aa19291f
Rust
cognivore/icfpc2004-tbd
/src/py/vm.rs
UTF-8
12,292
2.9375
3
[]
no_license
#![allow(dead_code)] // TODO use std::collections::BTreeMap; use super::compiler::{Insn, CompiledProgram}; #[derive(Clone, PartialEq, Eq, Hash)] pub enum Value { None, Bool(bool), Int(i32), String(String), } impl std::fmt::Debug for Value { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::...
true
82316438263277c6e57c8dcab5feac9326c4c788
Rust
mkpankov/figures
/src/figures/square.rs
UTF-8
650
3.15625
3
[]
no_license
use super::{Area, Rect}; use std::fmt; pub struct Square { side: f64, } impl fmt::Display for Square { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "квадрат({}, {})", self.side, self.side) } } impl Square { pub fn new(side: f64) -> Option<Square> { if side > 0...
true
969ad660f721352829665e9099e389c54749fbad
Rust
jaheba-nursery/meta-grass
/bf/src/core.rs
UTF-8
714
2.5625
3
[]
no_license
use grass; use std::cmp::PartialEq; use std::ops::{Deref, DerefMut}; pub const TAPESIZE: usize = 2048; pub struct Tape { pub tape: [usize; TAPESIZE], pub position: usize, } pub struct MyMergePointData<'core> { pub program: &'core Vec<usize>, } create_bind!(MyMergePoint for MyMergePointData<'core> ...
true
44759cfd83308f80e5f2358513ca637899ac58c6
Rust
tylerreisinger/rust-fractal-generator
/src/mandelbrot.rs
UTF-8
1,506
3
3
[]
no_license
use num_complex::{Complex}; use fractal::{Fractal, FractalOrbit, EscapeTimeType}; #[derive(Clone)] pub struct Mandelbrot { iter_limit: usize, } impl Mandelbrot { pub fn new(iter_limit: usize) -> Self { Mandelbrot{iter_limit: iter_limit} } pub fn check_carteoid_inclusion(&self, c: &Complex<f6...
true
7ae77cde722ded5daf7070675e250a6392f15182
Rust
lePerdu/twisted
/src/symmetry.rs
UTF-8
7,255
2.9375
3
[ "MIT" ]
permissive
use std::marker::PhantomData; use crate::coord::Coord; use crate::puzzle::{PuzzleMove, PuzzlePerm}; use crate::util::{EnumCount, EnumIndex, IntoEnumIterator}; /// A subgorup of puzzle permutations which separate a puzzle permutation into a set of equivalence /// classes. /// /// This will usually correspond to rotati...
true
39fdeb8c3dd993c9de89ce3df5b5252dbbab4ade
Rust
LukasBombach/v8-ui-app
/poc/src/main copy 5.rs
UTF-8
1,552
2.5625
3
[]
no_license
use js_runtime_deno; use std::path::Path; use std::thread; use std::collections::HashMap; use winit::event::Event; use winit::event::StartCause; use winit::event::WindowEvent; use winit::event_loop::ControlFlow; use winit::event_loop::EventLoop; use winit::window::Window; use winit::window::WindowId; #[derive(Debug...
true
eeee8ee97342c76ee47ca9359f0a8ac9da8df228
Rust
hcpl/serde_mtproto
/src/helpers.rs
UTF-8
5,066
3.09375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Helper types for assisting in some [de]serialization scenarios. use std::fmt; use std::mem; use byteorder::{ByteOrder, LittleEndian}; use serde::de::{self, Deserializer, DeserializeSeed, Error as DeError, Visitor}; use serde::ser::{Serialize, Serializer, SerializeTupleStruct}; use crate::error::{self, DeErrorKin...
true
64d180bda78d7e9387a2a8b7dad9d4be4abf975c
Rust
ReddikHaien/render_plugin
/src/drawing.rs
UTF-8
1,586
2.703125
3
[]
no_license
use deno_core::OpState; use deno_core::ZeroCopyBuf; use deno_core::op_sync; use deno_core::error::AnyError; use deno_core::OpFn; use serde::Deserialize; use serde::Serialize; pub fn init(ops: &mut Vec<(&'static str, Box<OpFn>)>){ ops.push(("op_clear",op_sync(clear))); ops.push(("op_clear_color",op_sync(clear_c...
true
b63b6cb5a5641d3b14e421b930748646e8dbf34d
Rust
jfpedroza/exercism
/rust/grains/src/lib.rs
UTF-8
252
3.453125
3
[ "MIT" ]
permissive
pub fn square(s: u32) -> u64 { if s < 1 || s > 64 { panic!("Square must be between 1 and 64"); } 2u64.pow(s - 1) } pub fn total() -> u64 { // Sum i in [0, n] of 2^i = 2^(n+1) - 1 // 2u64.pow(64) - 1 u64::max_value() }
true
94bdd8b20c37ecb18be7a713de084e3232b251ad
Rust
ciaran2/feo3boy
/feo3boy/src/gbz80core/externdefs.rs
UTF-8
7,480
2.703125
3
[ "MIT" ]
permissive
//! Definitions of opcode externs which are common to multiple executors. use std::mem; use crate::gbz80core::ExecutorContext; use crate::{interrupts::Interrupts, memdev::RootMemDevice}; use feo3boy_opcodes::{ gbz80types::Flags, microcode::args::{Reg16, Reg8}, }; /// Read an 8-bit value from a register. #[i...
true
22cd6c20c00b8741b34009b511fcfa4c831e92a1
Rust
edolstra/hugefs
/src/control.rs
UTF-8
4,878
2.765625
3
[]
no_license
use crate::{ error::{Error, Result}, fs::{Contents, Ino}, fusefs::FilesystemState, hash::Hash, }; use log::debug; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; #[derive(Debug, Serialize, Deserialize)] pub enum Request { Status { path: PathBuf }, ...
true
a83d41cd6d84bda49e0cdc5803141523411e79d7
Rust
Lol3rrr/rizm
/compiler/src/parser/comparison.rs
UTF-8
2,397
3.75
4
[]
no_license
use std::iter::Peekable; use crate::{ ir, lexer::{Token, TokenMetadata}, }; /// Parses the Comparison Operator itself only consuming 2 entries /// from the Iterator and most and only consuming them if they /// are actually part of the Comparison /// /// # Example: /// ```rust /// # use compiler::lexer::{Token...
true
30ba3130d9e267f2495cdfe0654df8e2217eaed2
Rust
seanwallawalla-forks/nushell
/crates/nu-protocol/src/value/serde_bigdecimal.rs
UTF-8
681
2.90625
3
[ "MIT" ]
permissive
use bigdecimal::BigDecimal; /// Enable big decimal serialization by providing a `serialize` function pub fn serialize<S>(big_decimal: &BigDecimal, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { serde::Serialize::serialize(&big_decimal.to_string(), serializer) } /// Enable big decimal ...
true
6245d0f1f123780a375dd541db4e6eea6a7dd5f0
Rust
cargo-generate/cargo-generate
/tests/integration/template_config_file/includes_and_excludes.rs
UTF-8
3,349
2.671875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::helpers::prelude::*; #[test] fn it_only_processes_include_files_in_config() { let template = tempdir() .file( "cargo-generate.toml", indoc! {r#" [template] include = ["included"] exclude = ["excluded2"] "#}, ...
true
c1561bdbaa2483cf7744b171795de5eb3c53399b
Rust
area/aoc-2017-rust
/day13/src/main.rs
UTF-8
1,705
3.234375
3
[]
no_license
use std::io::Read; use std::fs::File; use std::collections::HashMap; use std::cmp; fn main() { let mut f = File::open("input").unwrap(); let mut input = String::new(); let _ = f.read_to_string(&mut input); let layers_input = input.trim().to_string(); let mut layers_map: HashMap<usize, usize> = ...
true
c04f96376e8bd9e6e7c3f439bcda85837f68ed75
Rust
nwtnni/simple-symbol
/src/lib.rs
UTF-8
5,238
3.546875
4
[ "MIT" ]
permissive
use std::cmp; use std::collections::HashMap; use std::fmt; use std::str; use std::sync; use once_cell::sync::Lazy; /// Global cache of interned strings static INTERNER: Lazy<sync::RwLock<Interner>> = Lazy::new(|| Default::default()); /// Implements naive string internment. /// /// Requires O(n) heap space to store u...
true
e6f47fa8c15e184c90d07d4c9a1e661667405e59
Rust
Panadero1/goblins
/src/ui/button.rs
UTF-8
2,304
3.109375
3
[]
no_license
use std::borrow::BorrowMut; use speedy2d::{Graphics2D, color::Color, font::{Font, TextAlignment, TextLayout, TextOptions}, shape::Rectangle, window::UserEventSender}; use super::rect::rect_from_size; pub struct Button<'a> { text: &'a str, font_size: f32, on_click: Box<dyn Fn(&UserEventSender<String>)>, ...
true
3b9e7f3587167da998435c6071635b66ecb2e711
Rust
redeyes2015/junkcodes
/adventofcode/2021/13/day13-1.rs
UTF-8
1,149
3.15625
3
[]
no_license
use std::fs; use std::collections::HashSet; fn main() { // let filename = "./test-input"; let filename = "./input-13"; let input = fs::read_to_string(filename).unwrap(); let (dots, folds) = input.split_once("\n\n").unwrap(); let mut map: HashSet<(i32, i32)> = HashSet::new(); for dot_line in d...
true
489320ad1cb58fe97bca179d1a662f2f3a177e0b
Rust
rnestler/aoc-2020
/aoc-2020-12/src/main.rs
UTF-8
5,740
3.6875
4
[ "MIT" ]
permissive
use std::fs::File; use std::io::prelude::*; #[derive(Debug, Copy, Clone, PartialEq, Eq)] enum Action { North(i32), South(i32), East(i32), West(i32), Left(i32), Right(i32), Forward(i32), } impl From<&str> for Action { fn from(value: &str) -> Action { let (action, value) = value.s...
true
b61fc7ac7e670bdc261e355840adbd7394dff506
Rust
arbaregni/BasicTranspilation
/src/type_checker.rs
UTF-8
14,547
3.1875
3
[]
no_license
use tokenizer::Token; use sexpr::{SexprId, SexprKind}; use manager::Manager; use util::Error; #[derive(Debug, Clone, Hash, Eq, PartialEq)] pub enum Type { String, Int, Real, Boole, Void, // Generic(&'static str), //TODO self-generic types List(Box<Type>), CustomType(String, usize), // th...
true
26dd13d1be305c8c0f8a8ef3f5f18d2057e49d97
Rust
cverna/zincati
/src/rpm_ostree/cli_status.rs
UTF-8
5,482
2.78125
3
[ "Apache-2.0" ]
permissive
//! Interface to `rpm-ostree status --json`. use super::Release; use failure::{bail, ensure, format_err, Fallible, ResultExt}; use serde::Deserialize; use std::collections::BTreeSet; /// JSON output from `rpm-ostree status --json` #[derive(Debug, Deserialize)] pub struct StatusJSON { deployments: Vec<DeploymentJS...
true
d39405f55fa97b407fdf180989c2386e44d6fbf3
Rust
Vlad-Shcherbina/rbc
/src/infoset.rs
UTF-8
7,873
2.984375
3
[]
no_license
use crate::game::{Square, Color, Piece, Move, BoardState}; pub struct Infoset { pub color: Color, pub fog_state: BoardState, pub possible_states: Vec<BoardState>, } impl Infoset { #[inline(never)] pub fn new(color: Color) -> Infoset { let start_state = BoardState::initial(); let mu...
true
c014c05d6825650f483fcde8a845f0511a7f7e7b
Rust
8bittree/furry-parakeet
/src/main.rs
UTF-8
1,152
2.703125
3
[ "MIT" ]
permissive
extern crate clap; use clap::{Arg, App, crate_version}; use std::fs::read; mod components; mod machine; /// Size of a ROM /// /// 256 words = 768 bytes const ROM_BYTES: usize = 768; fn main() -> Result<(), Box<dyn std::error::Error>> { println!("Hello, world!"); let matches = App::new("furry-parakeet") ...
true
9ec9e13c55cd9b2996a9f12cc4c12b7bc5e1ea24
Rust
MANGO1234/raft_rust
/src/server/debug.rs
UTF-8
1,027
2.828125
3
[]
no_license
use raft_rust::common::send_string; use serde::{Deserialize, Serialize}; use std::env; use std::net::TcpStream; #[derive(Serialize, Deserialize, Debug)] pub enum DebugMsg { SvrState, LogState, } fn print_help() { println!("[1|2|3] <cmd>") } #[allow(dead_code)] fn main() -> std::io::Result<()> { let a...
true
0553088d7869e98cd0cdd7653d7266eaca81ebf6
Rust
isgasho/doku
/doku/examples/doku.rs
UTF-8
537
3.046875
3
[ "MIT" ]
permissive
use doku::prelude::*; type People = Vec<Person>; #[derive(Doku)] struct Person { /// Person's first name #[doku(example = "Janet")] name: String, /// Person's last name #[doku(example = "NotARobot")] surname: Option<String>, /// Person's favourite color favorite_color: Color, } #[de...
true
0d14c518281b8a5006554b9be9c9a74d06a9fdcb
Rust
adam-mcdaniel/kiro-editor
/src/editor.rs
UTF-8
13,495
2.796875
3
[ "MIT" ]
permissive
use crate::error::Result; use crate::highlight::Highlighting; use crate::input::{InputSeq, KeySeq}; use crate::language::Language; use crate::prompt::{self, Prompt, PromptResult}; use crate::screen::Screen; use crate::status_bar::StatusBar; use crate::text_buffer::{CursorDir, Lines, TextBuffer}; use std::io::Write; use...
true
c5f5109a18bf5b0c0c2b8dcff56ceede1d1329e3
Rust
Borgaard/robinson
/src/main.rs
UTF-8
3,003
2.640625
3
[ "MIT" ]
permissive
#![feature(core, std_misc, collections, old_io, old_path)] extern crate getopts; extern crate image; use std::default::Default; use std::old_io::fs::File; mod css; mod dom; mod html; mod layout; mod style; mod painting; mod pdf; fn main() { // Parse command-line options: let mut opts = getopts::Options::new...
true
4e8fd531ec33c9c6346de561ac6367da66e777df
Rust
lythesia/leet
/rs/src/quests/increasing_triplet_subsequence.rs
UTF-8
1,341
3.46875
3
[]
no_license
/** * [334] Increasing Triplet Subsequence * * Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false.   Example 1: Input: nums = [1,2,3,4,5] Output: true Explanation: Any triplet where i < j ...
true
98d3845d84c44ba6b5c68a3f21186a33e9a29df1
Rust
tyjacobson/projects
/compile.rs
UTF-8
1,712
3.015625
3
[]
no_license
// // Author: Tyler Jacobson // // Email: tj545714@ohio.edu // // Name: compile.rs (ir) // // Date: April 14, 2019 // // Purpose: Will translate a program from GrumpyIR to equivalent GrumpyVM code. // // Notes: <Exp> -> <term> <exp'> $ // <prog> -> <fun_list>...
true
e8e87a8de067161bfcb6ff1c597321d6b0e50cc8
Rust
songww/dtd-rs
/dtd-macro/src/lib.rs
UTF-8
26,545
2.546875
3
[]
no_license
#![cfg_attr(is_nightly, feature(proc_macro_diagnostic))] use std::collections::HashMap; use std::iter::FromIterator; use inflector::Inflector; use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; use quote::{format_ident, quote, quote_spanned, TokenStreamExt}; use syn::parse::{Parse, ParseStream...
true
e369be9e068dcbacb0ff0953e7269f11042b8cb1
Rust
codebje/vtrs20
/emulator/src/rom.rs
UTF-8
6,356
3
3
[ "MIT" ]
permissive
use std::cell::RefCell; use std::thread; use std::time::{Duration, Instant}; use crate::bus::Bus; use crate::types::*; #[derive(PartialEq, Copy, Clone)] enum Mode { READ, ID, PROGRAM, WRITING, COMMAND1, COMMAND2, ERASE1, ERASE2, ERASE3, } pub struct ROM { start: u32, size:...
true
ab00059df9982d65b703e93a81b1754eb2525f92
Rust
vbakc/iterators-costs
/rust-bench/src/lib.rs
UTF-8
6,641
3.859375
4
[]
no_license
//! Test various zero-cost abstractions. //! We create a TestSet from which we sample pairs of vectors. //! //! Then we have various functions that calculate a number based on a pair of vectors, //! according to these rules for vectors `va` and `vb`: //! //! - Start with `sum = 0` //! - for every pair `a`, `b` in align...
true
de61e49de027b9d80bd030dcaa1bb629694364cd
Rust
chklauser/adventofcode-solutions
/2019/src/day6.rs
UTF-8
5,392
3.34375
3
[ "MIT" ]
permissive
use std::collections::hash_map::Entry; use fxhash::FxHashMap; #[aoc_generator(day6)] pub fn generator(input: &str) -> Vec<(String, String)> { input.lines().map(|l| { let mut parts = l.split(")"); (parts.next().expect("lhs of pair").to_owned(), parts.next().expect("rhs of pair").to_owned()) }).c...
true
91d39d72b9033f843b63dba4a68ed179dba184bf
Rust
remaininlight/glicol
/rs/synth/src/operation/add.rs
UTF-8
2,098
2.625
3
[ "MIT" ]
permissive
use super::super::*; pub struct Add { pub inc: f32 } impl Add { pub fn new(inc: f32) -> GlicolNodeData { mono_node!( Self { inc } ) } } impl Node<128> for Add { fn process(&mut self, inputs: &[Input<128>], output: &mut [Buffer<128>]) { let max_user_input = 2; let min_user_inp...
true
0f995a36e04429c934ea06e0459086b18793e5dd
Rust
shimmy1996/twixter
/src/main.rs
UTF-8
2,540
2.8125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use clap::{crate_version, App, Arg, SubCommand}; use std::path::Path; mod config; mod entry; mod follow; mod timeline; mod tweet; use crate::config::Config; fn main() { let command = App::new("twixter") .version(crate_version!()) .about("A client for twtxt, microblog for hackers") .arg( ...
true
bd164da4f16c718b6cb0ce496a145eaf1fd9853f
Rust
daschl/couchbase-inspector
/src/packet/transport.rs
UTF-8
1,073
3.171875
3
[]
no_license
use byteorder::{ByteOrder, BigEndian}; #[derive(Debug)] pub enum TransportPacket<'a> { TCP(TCPPacket<'a>) } #[derive(Debug)] pub struct TCPPacket<'a> { src_port: u16, destination_port: u16, pub payload: &'a [u8], } impl<'a> TCPPacket<'a> { pub fn parse(data: &'a [u8]) -> Self { let data_...
true
e32aba38a0d1d7b94ebdff281bdfb47ccc7a8110
Rust
secure-foundations/provably-safe-sandboxing-wasm-usenix22
/microbenchmark-compare-read-arr/benches/my_benchmark.rs
UTF-8
7,972
2.546875
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion}; use std::convert::TryInto; #[inline] pub fn direct(memory: &[u8], addr: usize) -> Option<u64> { let lower = addr; let upper = lower + std::mem::size_of::<u64>(); let limit = lower..upper; let l = memory.get(limit)?; ...
true
69fd097ce7a003aa07a18c634af7db7953435975
Rust
join3r/quiz13
/src/Quiz/10.rs
UTF-8
838
3.296875
3
[]
no_license
// Tento program si prejdeme spolu use std::mem::size_of_val; // size_of_val() Returns the size of the pointed-to value in bytes. fn main() { println!("bool - {} bytes", size_of_val(&true)); println!("u8 - {} bytes", size_of_val(&10_u8)); println!("i8 - {} bytes", size_of_val(&100_u8)); println!("u16...
true
9c974e28f1405a48a12503f77badeadb1d5e483b
Rust
lxq2537664558/NoProto
/no_proto_rs_old/target/package/no_proto-0.9.60/src/pointer/bool.rs
UTF-8
11,560
2.84375
3
[ "MIT" ]
permissive
//! NoProto supports Rust's native [`bool`](https://doc.rust-lang.org/std/primitive.bool.html) type. //! //! ``` //! use no_proto::error::NP_Error; //! use no_proto::NP_Factory; //! use no_proto::pointer::bytes::NP_Bytes; //! //! let factory: NP_Factory = NP_Factory::new("bool()")?; //! //! let mut new_buffer = facto...
true
3c522f8911a21fa54634b6be6d6673ebe8a08260
Rust
haetze/DemoRust
/projects/lambda_calc_t/src/terms/valbool.rs
UTF-8
699
3.09375
3
[]
no_license
use terms::show::Show; use terms::eval::Evaluate; use terms::typable::Typable; use terms::types::Type; use terms::Term; use std::collections::HashMap; #[derive(Debug, Clone, PartialEq)] pub struct ValBool { pub val: bool, pub t: Type, } impl ValBool { pub fn new(v: bool) -> ValBool { ValBool { ...
true
574aec1a2939d9da7251cf91564085ea2fb004b0
Rust
wackywendell/adventofcode2018
/src/day14/main.rs
UTF-8
4,022
3.46875
3
[]
no_license
#![warn(clippy::all)] use clap::App; type Recipe = i16; struct Recipes { first: usize, second: usize, recipes: Vec<Recipe>, } impl Recipes { fn new(first: Recipe, second: Recipe) -> Self { Recipes { first: 0, second: 1, recipes: vec![first, second], ...
true
00b0f9587f5b71c9b9a3e9fa631cd4c322421a14
Rust
chinatsu/ggetris
/src/state/tetris/piece.rs
UTF-8
5,140
2.703125
3
[ "MIT" ]
permissive
use ggez::{GameResult, Context}; use crate::gfx::PieceSprites; use super::SCALE; use super::point::Point; use super::piecedefs::{Piecedef}; use super::matrix::Matrix; use super::stats::{Stats, TimerStatus}; use super::randomizer::Randomizer; pub struct Piece { pub piece: Piecedef, pub next_piece: Piecedef, ...
true
34233a48be9eafc63c1b32d208a01e43c7a3b413
Rust
mozilla/gecko-dev
/third_party/rust/zerovec/src/flexzerovec/serde.rs
UTF-8
6,056
2.71875
3
[ "LicenseRef-scancode-unicode", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use super::{FlexZeroSlice, FlexZeroVec}; use alloc::vec::Vec; use core::fmt; use serde::de::{self, Deserialize, Deser...
true
db7ac25fe55e06ae55ad86c42babfafc3fde29a3
Rust
nshcat/lsystems-gui
/src/rendering/uniforms.rs
UTF-8
2,016
2.734375
3
[ "MIT" ]
permissive
use nalgebra_glm::{Mat4, Vec3, Vec2}; use gl::types::*; use std::ffi::CString; use std::ptr; use crate::rendering::shaders::*; /// Uniform handling impl Program { /// Set 4x4 matrix uniform on this program object /// TODO: Taking adress of the matrix like this might not work! pub fn set_uniform_mat4(&self,...
true
9afa0ffd7eecbf6ef09536d673ee85624d765cf0
Rust
daniel-vainsencher/rust-ndarray
/src/impl_methods.rs
UTF-8
33,150
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright 2014-2016 bluss and ndarray developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed ...
true
688d57e419ddf0fcee58aa8414573d17af9fc8fe
Rust
Klaven/raytracing_in_rust
/src/raytrace/material.rs
UTF-8
4,347
2.53125
3
[]
no_license
use super::ray::Ray; use super::vec::Vec3; use super::hitable::HitRecord; use super::camera::Camera; use super::camera::drand48; pub trait Material{ fn scatter(&self, r_in: &Ray, rec: &HitRecord, attenuation: &mut Vec3, scattered: &mut Ray)-> bool; fn clone(&self)-> Box<Material>; } pub struct Lambertian{ ...
true
c3f195108ca90bb5704d3a1172618b39fb8ac719
Rust
boa-dev/boa
/boa_engine/src/realm.rs
UTF-8
4,175
2.90625
3
[ "MIT", "Unlicense" ]
permissive
//! Boa's implementation of ECMAScript's `Realm Records` //! //! Conceptually, a realm consists of a set of intrinsic objects, an ECMAScript global environment, //! all of the ECMAScript code that is loaded within the scope of that global environment, //! and other associated state and resources. //! //! A realm is rep...
true
668a540da5e5cb51c960ceef79411a30603f6341
Rust
maurer/mycroft
/tests/clique.rs
UTF-8
726
2.90625
3
[]
no_license
use mycroft_macros::mycroft_program; const ZERO: u64 = 0; const END: u64 = 10; mycroft_program!( r#" reachable(u64, u64) edge(u64, u64) same_clique(u64, u64) ?clique: same_clique(~ZERO, ~END) promote: reachable(x, y) <- edge(x, y) extend: reachable(x, z) <- edge(x, y) & reachable(y, z) clique: same_clique(x, y) <-...
true
55b31bfe95fcd9fdafc03fcea673578f63dde392
Rust
vielhuber/gists
/gists/bitcoin hitchhiker's paradox #rust/main.rs
UTF-8
4,127
2.875
3
[]
no_license
extern crate chrono; use std::fs::File; use std::io::{self, prelude::*, BufReader}; use chrono::prelude::*; use rand::Rng; use std::collections::HashMap; fn main() -> io::Result<()> { let min_date = "0"; let mode_date = "0"; let iterations = 10000; let filename = "time.txt"; if mode_date != ...
true
b2a4d322d81fbf4a42f471a573b1281707bc25e6
Rust
Kethku/okeydokey
/src/main.rs
UTF-8
6,610
2.765625
3
[]
no_license
use std::fs::File; use std::env; use std::path::{PathBuf}; use std::io::{BufReader, BufRead}; use clap::{Subcommand, Parser}; use indoc::indoc; struct Profile { commands: Vec<(String, String)>, path: PathBuf } #[derive(Parser, Debug)] #[clap(author, version, about, long_about = None)] struct Cli { #[cl...
true
ceab0ac14f0a27f846a96d12b66665c1646f7448
Rust
Toruitas/drawing-tool
/src/features/drawer/canvas/math/src/lib.rs
UTF-8
3,287
3.078125
3
[ "MIT" ]
permissive
// The Rust file is used to convert pixel positions to what needs to be rendered in WASM. // Perhaps also determines if the location that is clicked is within the clickable area? // IMPORTANT: Sometimes the WebGL work will be done here in Rust. Other times in JS, // Depending upon whether or not the task at hand requ...
true
4e95ff33a740a6985fd72279d3fd22f003398616
Rust
Jascha-N/carguino
/carguino-build/src/tool.rs
UTF-8
541
2.921875
3
[]
no_license
use std::ffi::{OsStr, OsString}; use std::iter; use std::slice; pub struct Tool { command: PathBuf, args: Vec<OsString> } impl Tool { pub fn command(&self) -> &Path { &self.command } pub fn args(&self) -> Args { self.args.iter() } pub fn run() -> Result<Output, Output> { ...
true
fba00a1e8fe40e12899acf73aeba6ca7515d86f2
Rust
kindlychung/rs-cellular-automata
/automata-lib/src/automata.rs
UTF-8
6,284
2.890625
3
[ "MIT" ]
permissive
use crate::rules::*; use image::RgbImage; pub struct Automata1DIter<'a> { automata: &'a Automata1D, idx: i32, } impl<'a> Iterator for Automata1DIter<'a> { type Item = u8; fn next(&mut self) -> Option<Self::Item> { self.idx += 1; if self.idx >= self.automata.view_start + self.automata.vi...
true
cff3afeefb27806c9a02f7c39ec9a07156e8f533
Rust
NavyD/dict
/src/client/maimemo_client.rs
UTF-8
11,878
2.921875
3
[]
no_license
use crate::client::*; use crate::config::*; use chrono::Local; use cookie_store::CookieStore; use reqwest::Client; use scraper::{Html, Selector}; use serde::{Deserialize, Serialize}; use std::fmt; /// notepad包含必要的header info和内容detail #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Notepad { is_private: ...
true
90629df827acaf0b2301b6cf31f063b10f95a640
Rust
hawkinsw/domain
/domain-core/src/bits/name/uncertain.rs
UTF-8
16,584
3.3125
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A domain name that can be both relative or absolute. //! //! This is a private module. Its public types are re-exported by the parent. use std::{fmt, str}; use bytes::BufMut; use ::bits::compose::Compose; use ::master::scan::{CharSource, Scan, Scanner, ScanError, Symbol}; use super::builder::{DnameBuilder, PushErr...
true
c19b0e5035851524c412e874803b7556c2c5ffab
Rust
StephanHeijl/rust-asteroids
/src/main.rs
UTF-8
4,529
2.828125
3
[]
no_license
extern crate sdl2; extern crate rand; use std::time::Duration; use sdl2::EventPump; use sdl2::event::Event; use sdl2::keyboard::Keycode; mod character; mod spaceship; mod asteroid; mod bullet; use character::Character; use spaceship::Spaceship; use asteroid::Asteroid; use std::collections::HashSet; fn create_enem...
true
8983f1e6a0f652574f71b2522985af3eb300fe61
Rust
Shock-1/teensy4-rs
/imxrt1062-pac/imxrt1062-pwm1/src/sm/smcaptctrla.rs
UTF-8
20,149
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = "Reader of register SMCAPTCTRLA"] pub type R = crate::R<u16, super::SMCAPTCTRLA>; #[doc = "Writer for register SMCAPTCTRLA"] pub type W = crate::W<u16, super::SMCAPTCTRLA>; #[doc = "Register SMCAPTCTRLA `reset()`'s with value 0"] impl crate::ResetValue for super::SMCAPTCTRLA { type Type = u16; #[inline(...
true
c8dac827289458b6cb09643d9fde7167583444cb
Rust
ksev/txtdist
/src/lib.rs
UTF-8
9,160
4.0625
4
[ "MIT" ]
permissive
//! Txtdist is small utility crate for calculating the distance between two strings. /* #![feature(test)] extern crate test; */ use std::ops::{ Index, IndexMut }; use std::collections::BTreeMap; use std::cmp::min; // A simple wrapper around vec so we can get contiguous but index it like it's 2D array. struct N2Array...
true
d3be015743be8a7890a661683d76baddf295e3a8
Rust
AntonZelenin/rust-physics-engine
/examples/fireworks/fireworks_demo/payload.rs
UTF-8
268
2.703125
3
[]
no_license
#[derive(Clone)] pub(crate) struct Payload { pub(crate) firework_type: i32, pub(crate) count: u32, } impl Payload { pub(crate) fn new(firework_type: i32, count: u32) -> Self { Self { firework_type, count, } } }
true
196c19c14b63245813558c98ca638f15792e3ccf
Rust
nix-rust/nix
/src/sys/quota.rs
UTF-8
9,332
2.6875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Set and configure disk quotas for users, groups, or projects. //! //! # Examples //! //! Enabling and setting a quota: //! //! ```rust,no_run //! # use nix::sys::quota::{Dqblk, quotactl_on, quotactl_set, QuotaFmt, QuotaType, QuotaValidFlags}; //! quotactl_on(QuotaType::USRQUOTA, "/dev/sda1", QuotaFmt::QFMT_VFS_V1, ...
true
13210fc45ee6a4382eb2aa2e8f55ac19edc0e01c
Rust
cvsmith/advent-of-code-2020
/d9/src/main.rs
UTF-8
1,323
3.265625
3
[]
no_license
use itertools::Itertools; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; const LOOKBACK_LENGTH: usize = 25; /// Find first number that isn't the sum of two numbers in the previous 25 numbers fn main() { // Get nums let mut nums: Vec<u64> = Vec::new(); if let Ok(lines) = _read_lines(...
true
0165350acab63655573fe7e2777e35b151bae3fa
Rust
hopv/hoice
/src/learning/ice.rs
UTF-8
52,448
2.96875
3
[ "Apache-2.0" ]
permissive
//! ICE learner. //! //! The ICE learner implements the learning from [the original paper]. The learner is meant to run //! in parallel alongside the teacher. It receives [`LrnData`] from the teacher from which it //! constructs candidates for all predicates mentioned. //! //! # Data Projection //! //! The first step t...
true
6627247218310fabccd49ce30422a55364eae00a
Rust
AlexMercedCoder/rustrocketapi
/src/personroutes.rs
UTF-8
3,422
3.328125
3
[]
no_license
use rocket_contrib::json::Json; use std::collections::HashMap; use serde::{Serialize, Deserialize}; use postgres::{Client, NoTls, Error}; use dotenv::dotenv; use std::env; use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode}; use postgres_openssl::MakeTlsConnector; //CREATE HEROKU TLS BUILDER fn get_connector() ...
true