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
aa97b8f0ac1f97f521feac2a87593de70fa3e663
Rust
kingeta/triangle_tracing
/src/camera.rs
UTF-8
6,019
3.546875
4
[]
no_license
/* Quite complex actually; define coordinate systems etc and ray generation */ #![allow(dead_code)] use super::vector::*; /// From L the direction a camera points and G the global up, /// generate the orthonormal basis (L, S, U) where S points to /// the side (???) and U locally points up; this returns S and U fn dir...
true
853df81689c3e8e045f119933a3a08581f72326f
Rust
borispf/rustmotifs
/src/motifs.rs
UTF-8
7,869
2.578125
3
[]
no_license
use nauty::*; use network::*; pub use fixedbitset::FixedBitSet; use std::collections::{BTreeMap, BTreeSet}; use std::iter::FromIterator; pub type MotifId = u64; pub const MOTIF_BASE: u64 = 4; pub type MotifFreq = BTreeMap<MotifId, usize>; pub fn all_motifs(k: usize, net: &Network) -> BTreeMap<MotifId, usize> { l...
true
403df8e8e69d63523fe922ddf83326f76d182bba
Rust
brunocodutra/reducer
/src/reactor/boxed.rs
UTF-8
850
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::reactor::*; use alloc::boxed::Box; /// Forwards the event to the potentially _unsized_ nested [`Reactor`] (requires [`alloc`]). /// /// [`alloc`]: index.html#optional-features impl<S, T> Reactor<S> for Box<T> where S: ?Sized, T: Reactor<S> + ?Sized, { type Error = T::Error; fn react(&mut se...
true
94bd7dbbed9041da906e4739e292795777c75e4b
Rust
AndreasHaug/Advent-of-code-2020
/two/src/main.rs
UTF-8
1,345
3.296875
3
[]
no_license
use std::str::FromStr; use std::fs; fn valid_part1(line: String) -> bool { let split: Vec<&str> = line.split(|ch: char| ch == ' ' || ch == '-' || ch == ':').collect(); let f: usize = FromStr::from_str(split[0]).unwrap(); let t: usize = FromStr::from_str(split[1]).unwrap(); let search_str = split[4]; ...
true
96e19db80e455811bfe1341dbb9449fe7ac23def
Rust
yaowenqiang/cargo_workspace
/mysqlDemo/src/main.rs
UTF-8
1,323
3.078125
3
[]
no_license
use mysql::*; use mysql::prelude::*; #[derive[Debug, PartialEq, Eq]] struct Payment { customer_id: i32, amount: i32, account_name: Option<String>, } fn main() { let url = "mysql://root:password@localhost:3306/db_name"; let pool = Pool::new(url)?; let mut conn = pool.get_conn()?; conn.query_...
true
9280b9fecba3707df7710abbe28c64a3a9aa69a8
Rust
xcodecraft/tdd-example
/src/ui.rs
UTF-8
365
2.625
3
[ "MIT" ]
permissive
use model::* ; #[derive(Clone)] pub struct PhoneUI {} impl PhoneUI { pub fn stub() ->PhoneUI { PhoneUI{} } } impl ExamUi for PhoneUI { fn show_question(&self, question : &ExamQuest) { info!("UI: question : {:?}" , question) ; } fn wait_answer(&self) -> Answer { ...
true
2b1aeb33b2a20e58f070dbf24b54c187759b6aad
Rust
lukecollier/advent-of-code-2020
/seven/src/main.rs
UTF-8
4,192
3.0625
3
[]
no_license
use regex::Captures; use regex::Regex; use std::collections::{HashMap, HashSet}; use std::env; use std::fs; #[cfg(windows)] const LINE_ENDING: &'static str = "\r\n"; #[cfg(not(windows))] const LINE_ENDING: &'static str = "\n"; #[derive(Debug, PartialEq, Eq, Clone)] struct RawBag { pub name: String, pub can_co...
true
48084792f6c74b555abab114dc24566c00a9a4a8
Rust
iCodeIN/hippo-cli
/src/command/mod.rs
UTF-8
1,668
2.96875
3
[ "Apache-2.0", "LicenseRef-scancode-generic-cla" ]
permissive
use async_trait::async_trait; use clap::{App, ArgMatches}; pub(crate) mod newhippo; pub(crate) mod upload; /// A command runner is capabile of running particular subcommand. /// /// It is responsible for defining the command and its args, and then /// running the command to completion. #[async_trait] pub trait Comman...
true
4b83376a93302caa25def5de582fb70ce33a840f
Rust
nicholasfagan/serde-json-build-example
/build.rs
UTF-8
1,223
3.34375
3
[]
no_license
// a description of the 'Game' type is needed, to parse it from json. // It's kinda bad practice to refernce the crates code from it's build script, // so in a real program the 'Game' type should be moved to another crate that // both the build script and this crate can depend on. use serde::Deserialize; #[derive(Des...
true
757c93e9c5a8fcbe4cf9fb359f35b965cefeba5e
Rust
undo76/raytracer-rust
/core/src/sphere.rs
UTF-8
7,013
3.203125
3
[ "MIT" ]
permissive
use crate::*; #[derive(Debug)] pub struct Sphere { base: BaseShape, } impl Sphere { pub fn new(transform: Transform, material: Material) -> Sphere { Sphere { base: BaseShape::new(transform, material), } } } impl Default for Sphere { fn default() -> Sphere { Sphere:...
true
50d472c7a7ef1c5cd7cf895f7d7ad20cd73b5d01
Rust
mnauf/hackathon_try
/hackathon/hackathon/assignment_a/try/src/main.rs
UTF-8
357
3.15625
3
[]
no_license
use std::io; use std::convert::TryFrom; fn main() { let mut binary = String::new(); // println!("Enter a decimal: "); io::stdin().read_line(&mut binary) .ok() .expect("Couldn't read line"); let mut binary =binary.to_string(); println!("{}",binary.len()); for i in 0..binary.len()...
true
38ff02491568e0bfab0183d59189373b969b7b32
Rust
mnts26/aws-sdk-rust
/sdk/s3/src/operation.rs
UTF-8
346,254
2.90625
3
[ "Apache-2.0" ]
permissive
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. /// <p>This action aborts a multipart upload. After a multipart upload is aborted, no /// additional parts can be uploaded using that upload ID. The storage consumed by any /// previously uploaded parts will be freed. However, if any part ...
true
06e79c45e03ed9c6e7e555d57a715e8192b531e4
Rust
ebcode/Rust-Logo4.0-Interpreter
/src/main.rs
UTF-8
5,666
2.671875
3
[]
no_license
#![allow(dead_code)] // TODO: // - ... extern crate ggez; mod lexer; mod parser; mod evaluator; use std::io; use std::sync::mpsc; use std::thread; use std::time; use ggez::{conf, Context, ContextBuilder}; use ggez::event; use ggez::graphics::{self, Point2}; const WIDTH: u32 = 400; const HEIGHT: u32 = 400; const ...
true
6840561ec219a4ea1cff0564f2c7e43bc525ffb4
Rust
wasmerio/cranelift
/cranelift-faerie/src/container.rs
UTF-8
2,895
2.875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Utilities for working with Faerie container formats. use cranelift_codegen::binemit::Reloc; use target_lexicon::{Architecture, BinaryFormat, Triple}; /// An object file format. #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Format { /// The ELF object file format. ELF, /// The Mach-O object fil...
true
ae174cbc8acf27894b7268ba1a77874a9a74fa6f
Rust
devinmiller/RustBook
/Chapter3/branches/src/main.rs
UTF-8
1,312
4.375
4
[]
no_license
fn main() { if_branch(); else_if_branch(); if_let(); using_loop(); using_while(); using_for(); } fn if_branch() { let number = 3; if number < 5 { println!("condition was true"); } else { println!("condition was false"); } } fn else_if_branch() { let number...
true
ad51f14c45855f49c82ac1c7222e33bd51d4fd15
Rust
tsheinen/advent-of-code-2020
/src/day12.rs
UTF-8
4,800
3.25
3
[]
no_license
use itertools::Itertools; use nom::lib::std::convert::TryFrom; use pathfinding::num_traits::FloatConst; use std::convert::TryInto; /// https://adventofcode.com/2020/day/12 #[derive(Debug, Clone, Eq, PartialEq)] pub enum Action { North, West, East, South, Left, Right, Forward, } impl TryFr...
true
ca7ac235dce474329e496b6389c5738ce2a1290f
Rust
dorucioclea/omics
/publishing/domain/category.rs
UTF-8
636
2.640625
3
[]
no_license
mod name; mod repository; pub use name::*; pub use repository::*; use common::event::Event; use common::model::{AggregateRoot, StringId}; use common::result::Result; pub type CategoryId = StringId; #[derive(Debug, Clone)] pub struct Category { base: AggregateRoot<CategoryId, Event>, name: Name, } impl Categ...
true
0620ea247e06d2c8cc81d0402911983743119bd9
Rust
jeanm/bib-parser
/src/parser/ranges.rs
UTF-8
1,692
3.109375
3
[ "MIT", "Apache-2.0" ]
permissive
use pom::Parser; use pom::parser::*; use parser::sp0; use biblatex::Range; fn range() -> Parser<u8, Range> { let token = || sp0() * none_of(b",-{}\n ") .repeat(1..) .convert(|bs| String::from_utf8(bs)) - sp0(); let start = token() - sp0(); let end = (sym(b'-').repeat(1..) * sp0() * token())...
true
1410fd88b00f93245347d1ed1cc91e23f49b950a
Rust
NeKzor/lp
/backend/src/models/repository.rs
UTF-8
1,328
2.59375
3
[]
no_license
use serde::{Deserialize, Serialize}; use crate::models::database::Campaign; pub trait RepositoryItem { fn link() -> &'static str; } macro_rules! impl_link { ($struct_name:ident, $file_link:expr) => { impl RepositoryItem for $struct_name { fn link() -> &'static str { $file_...
true
0dd5ba0af74fca6362506106c22c16c837dec7b1
Rust
TyOverby/implicit
/examples/game.rs
UTF-8
2,260
2.953125
3
[]
no_license
extern crate lux; #[macro_use] extern crate implicit; extern crate num_traits; mod helper; use implicit::*; use implicit::formats::pdf::PdfWriter; use implicit::geom::*; const SIZE: f32 = 1.0; fn hex(x: f32, y: f32) -> Polygon { fn corner(center: (f32, f32), i: u32) -> Point { use std::f32::consts::PI; ...
true
19ca9dd3716b87ff69c071bdecd8a9976a14f3ac
Rust
oxidecomputer/tsc-simulator
/src/tests.rs
UTF-8
8,953
2.640625
3
[]
no_license
#[cfg(test)] mod tests { use super::{FRAC_SIZE_AMD, FRAC_SIZE_INTEL}; struct Frt { pub g: u64, pub h: u64, pub f: u32, pub v: u64, } #[rustfmt::skip] const FREQ_RATIO_TESTS_VALID: &'static [Frt] = &[ // Smaller frequencies (~KHz) // 0.5 = 2^-1 Frt { g: 10...
true
c565474d8d07dc99a8725ab99d63b9244864dafe
Rust
tokiwadai/minigrep
/src/lib.rs
UTF-8
4,888
3.640625
4
[]
no_license
use std::env; use std::fs; use std::error::Error; pub fn run(config: Config) -> Result<(), Box<dyn Error>> { let contents = fs::read_to_string(config.filename)?; let results = if config.case_sensitive { search(&config.query, &contents) } else { search_case_insensitive(&config.query, &conten...
true
aa99de6275ee504e2931d01cda5e3beaa2abe3f2
Rust
koukemo/rclrust
/rcl-sys/src/rcutils/logging.rs
UTF-8
3,768
2.53125
3
[ "Apache-2.0", "CC0-1.0", "CC-BY-4.0" ]
permissive
//! API in rcutils/logging.h use std::os::raw::{c_char, c_int}; use super::{rcutils_allocator_t, rcutils_ret_t, rcutils_time_point_value_t}; use crate::va_list; extern "C" { /// The flag if the logging system has been initialized. pub static mut g_rcutils_logging_initialized: bool; /// Initialize the lo...
true
adb0d0b06ce9ae1eb3f348006e6fce19b26313b1
Rust
zubchick/hackerrank
/30-days-of-code/review_loop.rs
UTF-8
674
3.390625
3
[]
no_license
fn read_line<T: std::str::FromStr>() -> T { let mut input = String::new(); std::io::stdin().read_line(&mut input).expect("Could not read stdin!"); match input.trim().parse() { Ok(v) => v, Err(_) => panic!("Could not parse input") } } fn main() { let n: u32 = read_line(); for _ in 0....
true
1d27eb237b7ea66f8029aa203672e22d37a8eef4
Rust
LFalch/stalch
/src/value.rs
UTF-8
9,523
3.453125
3
[ "MIT" ]
permissive
use std::cmp::Ordering; use std::f64::NAN; use std::fmt; use std::ops::*; use crate::cmd::Command; #[derive(Clone)] pub enum Value { Float(f64), Integer(i64), Bool(bool), Str(String), Variable(String), Block(u16, Vec<Command>), Null, } impl Value { pub fn parse(s: &str) -> Self { ...
true
bc9c4a078001e30181df4dc3e29d7a6d6e5046d3
Rust
garethellis0/advent-of-code-2018
/day3_take1/src/main.rs
UTF-8
7,211
3.21875
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use regex::Regex; #[derive(Debug)] #[derive(PartialEq)] struct Point { x: u32, y: u32, } //impl PartialEq for Point { // fn eq(&self, other: &Area) -> bool { // self.x == other.x && self.y == other.y // } //} #[derive(Debug)] #[derive(PartialEq)] struct...
true
ec8aed49254dd0b68709f19960de992b8433b294
Rust
gtank/defcon25_crypto_village
/curve25519-dalek/src/scalar.rs
UTF-8
33,182
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "CC0-1.0", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
// -*- mode: rust; -*- // // To the extent possible under law, the authors have waived all // copyright and related or neighboring rights to curve25519-dalek, // using the Creative Commons "CC0" public domain dedication. See // <http://creativecommons.org/publicdomain/zero/.0/> for full // details. // // Authors: // -...
true
deafb80b641b809956dfbe13f622e905e34fe7aa
Rust
rootmos/dont-fear-the-reaper
/src/main.rs
UTF-8
8,257
2.625
3
[]
no_license
use std::time::{Instant, Duration}; use std::env; use std::process::{Command, exit}; use std::fmt; use std::fs::{read_dir, File}; use std::io::Read; use std::collections::HashMap; extern crate log; use log::*; extern crate env_logger; extern crate nix; use nix::sys::signal::kill; use nix::sys::wait::{WaitStatus, wai...
true
e6c647daa05fbe9ed005e4db7965e3d8d614cc43
Rust
petrikvladimir/finalize_latex_changes
/src/bin/finalize_latex_changes.rs
UTF-8
2,858
2.609375
3
[]
no_license
#[macro_use] extern crate clap; extern crate colored; extern crate walkdir; extern crate finalize_latex_changes; use colored::*; use std::path::PathBuf; use walkdir::{WalkDir, DirEntry}; fn is_hidden(entry: &DirEntry) -> bool { entry.file_name().to_str().map(|s| s.starts_with('.')).unwrap_or(false) } fn is_tex(e...
true
cfb10ea940787cc9d3b9a5e9a561b02232e3b703
Rust
kaluna-hart/atcoder-answer-rust
/abc169/src/bin/e.rs
UTF-8
698
2.609375
3
[]
no_license
use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, a_b: [(i64, i64); n], } let (mut a_vec, mut b_vec): (Vec<i64>, Vec<i64>) = (Vec::new(), Vec::new()); for (a, b) in a_b { a_vec.push(a); b_vec.push(b); } a_vec.sort(); b_vec.sort(); ...
true
c1bc6c30f39aebef58fdaef34ef151c2eac559ec
Rust
haryu703/rust-cash-addr
/src/error.rs
UTF-8
1,598
2.640625
3
[ "MIT" ]
permissive
use std::result; use bech32; use failure::Fail; /// Alias of `Result` used by cash_addr. pub type Result<T> = result::Result<T, Error>; /// Errors #[derive(Debug, Fail)] pub enum Error { /// Invalid address format. /// # Arguments /// * Address. #[fail(display = "Invalid address format: {}", 0)] ...
true
21b819fb907e6058da231c11477f7bd771ace064
Rust
Honey-Be/fireplace
/fireplace_lib/src/handlers/render/screenshot.rs
UTF-8
6,670
2.8125
3
[ "MIT" ]
permissive
//! Handler and types related to taking screenshots. //! use chrono::Local; use handlers::keyboard::KeyPattern; use handlers::store::{Store, StoreKey}; use image::{DynamicImage, ImageFormat, RgbaImage}; use slog_scope; use std::fs::{self, File}; use std::path::PathBuf; use std::process::{Command, Stdio}; use wlc::{C...
true
f1539762245242476f32b1c0cf0bda253604996e
Rust
RalfJung/structural_crates
/structural_derive/src/tokenizers.rs
UTF-8
3,072
2.96875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use proc_macro2::{ TokenStream as TokenStream2, Span, }; use quote::{quote,ToTokens}; use syn::Ident; /// Whether to use the full path to an item when refering to it. #[derive(Debug,Copy,Clone,Eq,PartialEq)] pub(crate) enum FullPathForChars{ Yes, No, StructPmr, } //////////////////////////////...
true
c79e62f914f08d021a126e22de04ce834a893ff4
Rust
danieleades/aspen
/src/node.rs
UTF-8
5,871
3.53125
4
[ "MIT" ]
permissive
//! Behavior tree nodes and internal node logic. use crate::status::Status; use std::fmt; /// Represents a generic node. /// /// The logic of the node is controlled by the supplied `Tickable` object. /// Nodes are considered to have been run to completion when they return either /// `Status::Succeeded` or `Status::Fa...
true
f85331d9b41ab13b84b3a05e56c9785ecad16374
Rust
Icemic/libuv-rs
/examples/proc-streams.rs
UTF-8
1,344
2.796875
3
[ "MIT" ]
permissive
//! You must build proc-streams-test first: //! //! ```bash //! cargo build --example proc-streams-test //! ``` //! //! Then run: //! //! ```bash //! cargo run --example proc-streams //! ``` extern crate libuv; use libuv::prelude::*; use libuv::{exepath, ProcessHandle, ProcessOptions, StdioContainer, StdioFlags, Stdio...
true
50a1ded9db3fd3248ba5cc1fb948b05da2bbf8e1
Rust
craigfay/ml_chess
/rust_code/src/bin/play_vs_human.rs
UTF-8
3,081
3.5
4
[]
no_license
use chess_engine::*; use reinforcement_learning_chess::*; use std::collections::HashMap; pub struct GameOptions { pub agent_playing_as: Color, } pub fn play_vs_human(options: GameOptions) { // Create an agent, and attempt to restore // experiences created by previous training. let mut agent = Ches...
true
2b980fe52d2001ee210ac0cf1e6c400100093e17
Rust
Symforian/University
/Rust/List_5/4.robo2/src/main.rs
UTF-8
5,860
3.53125
4
[]
no_license
pub fn execute(code: &str) -> String { enum Dir{ North, South, West, East, } fn rot_r(direction: Dir) -> Dir { match direction{ Dir::North => Dir::East, Dir::East => Dir::South, Dir::South => Dir::West, Dir::West => Dir...
true
35dc9e61225297ba1f531f822825823ad0628777
Rust
ratel-rust/ratel-core
/ratel/src/astgen/mod.rs
UTF-8
2,857
2.875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[macro_use] mod macros; mod statement; mod expression; mod function; mod value; use serde::ser::{Serialize, Serializer, SerializeStruct}; use ast::{Loc, Node}; use module::Module; pub trait SerializeInLoc { #[inline] fn in_loc<S, F>(&self, serializer: S, name: &'static str, length: usize, build: F) -> Result...
true
0f0a5770fd441be7304b59e13d2f821e5765777c
Rust
jblondin/minnie
/src/eval/frame.rs
UTF-8
1,266
3.1875
3
[]
no_license
use std::cell::RefCell; use std::rc::Rc; use std::collections::HashMap; use eval::value::Value; use parse::ast::Identifier; #[derive(Clone, Debug, PartialEq)] pub struct Frame { frame_data: Rc<RefCell<FrameData>>, parent: Option<Box<Frame>>, } impl Frame { pub fn new() -> Frame { Frame { ...
true
4a66c087d916b990b5dd7d15fc9590e6dbda6fe2
Rust
johnmave126/symm_impl
/tests/mod_path.rs
UTF-8
1,293
3.46875
3
[ "MIT", "Apache-2.0" ]
permissive
use symm_impl::symmetric; mod inner { pub(crate) mod inner { pub(crate) trait Distance<Other> { fn distance(&self, other: &Other) -> f64; } pub(crate) struct Point2D { pub(crate) x: f64, pub(crate) y: f64, } pub(crate) struct Disk { ...
true
b6103294fd457ba6ed75e48c714641580ab591d5
Rust
davethecanuck/rust-bitfoo
/src/node/node.rs
UTF-8
7,525
3.3125
3
[]
no_license
use crate::{Addr,KeyIndex,KeyState}; use crate::node::iter::NodeIterator; #[derive(Debug)] pub enum Content { Bits(Vec<u64>), Nodes(Vec<Node>), } #[derive(Debug)] pub struct Node { pub index: KeyIndex, // Indexes content keys by vec offset pub (super) content: Content, // Contains vec of eith...
true
cf14823ad5d2ed03e6cd7b594dd887e9be93edbc
Rust
archer884/hangman-data
/src/service/mod.rs
UTF-8
2,473
2.765625
3
[]
no_license
use std::error::Error; use std::fmt; use postgres::error::Error as PgError; use postgres::rows::{Row, Rows}; use r2d2::PooledConnection; use r2d2_postgres; mod connection; mod game; mod page; mod token; pub use service::connection::{ConnectionService, PgConnectionService}; pub use service::game::{GameService, PgGameS...
true
9f601e721d2ecea5dd7d8563b170c355b5f56984
Rust
mdlayher/monkey-rs
/src/bin/monkey.rs
UTF-8
3,224
2.8125
3
[ "MIT" ]
permissive
extern crate getopts; extern crate mdl_monkey; use mdl_monkey::{ ast, compiler::Compiler, evaluator, lexer::Lexer, object::Environment, parser::Parser, token::Token, vm::Vm, }; use getopts::Options; use std::{env, time}; fn main() -> Result<(), String> { let args: Vec<String> = env::args().collect(); ...
true
cb4eeadb4941966634e401adadf295ab0170a924
Rust
tykim-gaia3d/hey_listen
/examples/async/src/main.rs
UTF-8
2,313
3.15625
3
[ "ISC" ]
permissive
use hey_listen::{ sync::{ AsyncDispatcher as Dispatcher, AsyncListener as Listener, AsyncDispatchResult as DispatcherRequest }, RwLock, }; use std::sync::Arc; use tokio::prelude::*; // `async trait`s are not supported on Rust `1.39.0`. // We will use this macro to bypass this. // I...
true
9b5a8d7e1682599ab3bd03ce9972098527d99b0b
Rust
shanlashari/vector
/src/event/metric.rs
UTF-8
8,910
3.078125
3
[ "Apache-2.0", "OpenSSL" ]
permissive
use chrono::{DateTime, Utc}; use derive_is_enum_variant::is_enum_variant; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Metric { pub name: String, pub timestamp: Option<DateTime<Utc>>, pub tags: Option<Ha...
true
a0b184ac602a93906687e1396499d53a79a27767
Rust
jrhea/mothra
/core/network/src/types/peer_info.rs
UTF-8
1,298
2.984375
3
[ "Apache-2.0" ]
permissive
//NOTE: This should be removed in favour of the PeerManager PeerInfo, once built. use crate::{EnrBitfield, SubnetId}; /// Information about a given connected peer. #[derive(Default, Debug, Clone)] pub struct PeerInfo { /// The current syncing state of the peer. The state may be determined after it's initial //...
true
874643fe2186b6939ff43b74d76e2384445d6c24
Rust
pixix4/advent-of-code-2019
/day-07/src/intmachine/machine.rs
UTF-8
1,029
2.8125
3
[]
no_license
use std::sync::mpsc::{channel, Receiver, Sender}; use super::{AllocationMode, Executer}; pub type Interface = (Sender<i32>, Receiver<i32>); #[derive(Debug)] pub struct Machine { pub program: Vec<i32>, pub allocation_mode: AllocationMode, executer_count: i32, } impl Machine { pub fn new(program: &[i3...
true
3dae5f1b6864d62bf944b6af5a5b2585c3384e01
Rust
greyhill/lightfield
/rs/phantom.rs
UTF-8
3,744
2.609375
3
[]
no_license
extern crate num; extern crate proust; use self::proust::*; use image_geom::*; use self::num::{FromPrimitive, Float}; use ellipsoid::*; use optics::*; use light_volume::*; use cl_traits::*; /// Renderer for phantoms pub struct PhantomRenderer<F: Float> { pub geom: LightVolume<F>, geom_buf: Mem, render_e...
true
f23e2bfac5e277fa7154784c0072db904d9b8e92
Rust
adisney3000/Rust-SCSI
/src/commands/read_position.rs
UTF-8
6,393
2.53125
3
[ "MIT" ]
permissive
use crate::sense::Sense; use std::convert::TryInto; //use std::fmt; /// SSC-4 Section 7.7 #[derive(Default, Debug)] pub struct ReadPosition { pub service_action: u8, pub allocation_length: u16, } impl ReadPosition { pub const SHORT_FORM_BLOCK: u8 = 0x0; pub const SHORT_FORM_VENDOR: u8 = 0x1; pub const LONG_...
true
2c1a44b39a01f8e0d5e3cca23e8714981efb3b07
Rust
DoumanAsh/arg.rs
/src/split.rs
UTF-8
2,767
3.953125
4
[ "Apache-2.0" ]
permissive
///Simple split of string into arguments pub struct Split<'a> { string: &'a str, } impl<'a> Split<'a> { ///Creates new instance pub const fn from_str(string: &'a str) -> Self { Self { string } } #[inline(always)] ///Retrieves next argument pub fn next_arg(&mut s...
true
402e3464133222cde530e9ffde8548aa31fa392c
Rust
jasonrhansen/RustedNES
/rustednes-core/src/mapper/mapper4.rs
UTF-8
10,693
2.703125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::cartridge::{self, Cartridge, Mirroring}; use crate::cpu::{Cpu, Interrupt}; use crate::mapper::{self, Mapper}; use crate::ppu::{self, Ppu}; use serde_derive::{Deserialize, Serialize}; pub struct Mapper4 { cartridge: Cartridge, next_bank_register: u8, bank_registers: [u8; 8], prg_rom_mode: ...
true
ea7fc59bc1056a4c7b816ce546b0103e38005682
Rust
franktea/leetcode-rust
/src/bin/0105.rs
UTF-8
1,157
3.1875
3
[]
no_license
use std::rc::Rc; use std::cell::RefCell; fn build(pre: &[i32], inord: &[i32]) -> Option<Rc<RefCell<TreeNode>>> { if pre.is_empty() { return None; } let root = Rc::new(RefCell::new(TreeNode::new(pre[0]))); if let Some(index) = inord.iter().position(|&x| x==pre[0]) { root.borrow_mut(...
true
f4713116d7e96587451c47444fea119b0c3608df
Rust
LinkTed/dbus-message-parser
/src/value/bus/mod.rs
UTF-8
3,950
3.265625
3
[ "BSD-3-Clause" ]
permissive
use std::cmp::{Eq, PartialEq}; use std::convert::{From, TryFrom}; use std::fmt::{Display, Formatter, Result as FmtResult}; use thiserror::Error; mod unique_connection_name; mod well_known_bus_name; pub use unique_connection_name::{UniqueConnectionName, UniqueConnectionNameError}; pub use well_known_bus_name::{WellKno...
true
8f1374eda14de5f1e55dd3636afb3979f089ddd6
Rust
hengyin1/node
/rs/todomvc/src/lib.rs
UTF-8
6,274
2.84375
3
[]
no_license
use dioxus::prelude::*; use tracing::info; use std::collections::HashMap; #[derive(PartialEq)] enum FilterState { All, Active, Completed, } #[derive(Debug, Clone, PartialEq)] struct TodoItem { id: u32, status: bool, content: String, } pub fn app(cx: Scope) -> Element { // let todos = cx....
true
23b244d25c432ec3c0d1b2e64d54d7897c01ea56
Rust
itscomputers/leema
/src/leema/reg.rs
UTF-8
7,548
3.015625
3
[ "MIT" ]
permissive
use leema::log; use leema::lstr::Lstr; use leema::val::Val; use std::collections::HashMap; use std::fmt; use std::io::Write; #[derive(PartialEq)] #[derive(Eq)] #[derive(PartialOrd)] #[derive(Ord)] #[derive(Clone)] pub enum Ireg { Reg(i8), Sub(i8, Box<Ireg>), } impl Ireg { pub fn sub(&self, newsub: i8) -...
true
3b82f2b522fd9b6c76e122dd1f2b79ecee015dff
Rust
TurtlePU/elliptic
/src/algebra/algo.rs
UTF-8
3,091
3.46875
3
[]
no_license
use num_bigint::BigUint; use num_traits::{FromPrimitive, One, Zero}; use super::traits::Integral; /// Returns (g, x, y) such that a * x + b * y = g = gcd(a, b). pub fn extended_gcd<T: Integral>(a: T, b: T) -> (T, T, T) { let (mut old_r, mut r) = (a, b); let (mut old_s, mut s) = (T::one(), T::zero()); let ...
true
487659e19677dcdf77aa721ae2702222df3278a6
Rust
2color/prisma-engines
/libs/datamodel/core/tests/functions/functionals_environment.rs
UTF-8
2,884
2.78125
3
[ "Apache-2.0" ]
permissive
use crate::common::*; use datamodel::{DefaultValue, ScalarType}; use prisma_value::PrismaValue; #[test] fn skipping_of_env_vars() { let dml = r#" datasource db { provider = "postgresql" url = env("POSTGRES_URL") } model User { id Int @id tags String[] ...
true
2541a04698e20759a88e0279a2b56fc1a0c595d1
Rust
ryanwcyin/rust_practice
/src/4_adjacent_elements_product.rs
UTF-8
603
3.421875
3
[]
no_license
/* Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. */ fn adjacent_elements_product(input_array: Vec<i32>) -> i32 { // window(): to iter with specific windows let product = input_array.windows(2) .map(|w| w[0]*w[1]...
true
c937cc53864b5365ed62a112b83ffa2199d1359d
Rust
rillrate-fossil/rillrate
/pkg-dashboard/rate-ui/src/shared_object.rs
UTF-8
3,895
2.875
3
[ "Apache-2.0" ]
permissive
use crate::storage::typed_storage::{Storable, TypedStorage}; use crate::widget::{Context, NotificationHandler}; use std::cell::{Ref, RefCell, RefMut}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::rc::Rc; use typed_slab::TypedSlab; use yew::Callback; pub trait RouterState: PartialEq + Storabl...
true
11bb138f22942d990f07d49f39f7cdf2ac1cbdf9
Rust
rustgd/gsf
/src/lib.rs
UTF-8
5,646
2.828125
3
[]
no_license
#![feature(core_intrinsics)] extern crate fnv; pub use any::{type_name_of, Any}; pub use builder::{Builder, PropertyBuilder, TyBuilder}; pub use conv::{FromValue, FromMultiValue, IntoValue, MultiVal}; use std::any::TypeId; use std::borrow::Cow; use std::error; use std::fmt; use std::sync::Arc; mod any; mod builder;...
true
bc436dbc0eb851196d8f4b4db003ef220d73bc7e
Rust
hahahayatoo/Introduction-to-Practical-Rust
/toy-vec/examples/toy_vec_02.rs
UTF-8
275
2.921875
3
[]
no_license
use toy_vec::ToyVec; fn main() { let _e: Option<&String>; { let mut v = ToyVec::new(); v.push("Java Finch".to_string()); v.push("Budgerigar".to_string()); let _e = v.get(1); } assert_eq!(_e, Some(&"Budgerigar".to_string())); }
true
3d5018db70511711f3c57aba9da204dd19ccbded
Rust
rcore-os-infohub/ossoc2020-VitalyAnkh-daily
/Rust/cookbook/examples/repeat.rs
UTF-8
314
3.40625
3
[]
no_license
// 复刻一个标准库中的repeat函数 fn repeat<T>(slice: &[T], n: usize) -> Vec<T> where T: Copy, { let mut v: Vec<T> = Vec::new(); for _ in 0..n { for x in slice { v.push(*x); } } v } fn main() { let x = [1, 2, 3]; println!("{:?}", repeat(&x, 3)); }
true
58dcb49a371e90c366fc5a4df63fc776bdb178ce
Rust
imbolc/perseus
/website/website/src/components/container.rs
UTF-8
3,452
2.609375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use perseus::{link, t}; use sycamore::prelude::Template as SycamoreTemplate; use sycamore::prelude::*; pub static COPYRIGHT_YEARS: &str = "2021"; #[component(NavLinks<G>)] pub fn nav_links() -> SycamoreTemplate<G> { template! { // TODO fix overly left alignment here on mobile li(class = "m-3 p-1")...
true
8794fc41f49028fb14c019a919bf25260d003950
Rust
mnts26/aws-sdk-rust
/sdk/translate/src/output.rs
UTF-8
49,966
2.546875
3
[ "Apache-2.0" ]
permissive
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT. #[non_exhaustive] #[derive(std::clone::Clone, std::cmp::PartialEq)] pub struct UpdateParallelDataOutput { /// <p>The name of the parallel data resource being updated.</p> pub name: std::option::Option<std::string::String>, /// ...
true
d860c8d3616e28ce792946a365dfa73acb1fa586
Rust
zzeroo/programmieren-in-rust-notes
/aufgaben/sheet07/sol1/fib.rs
UTF-8
471
3.328125
3
[]
no_license
struct Fib { curr: u64, last: u64, } impl Fib { fn new() -> Self { Fib { curr: 1, last: 0, } } } impl Iterator for Fib { type Item = u64; fn next(&mut self) -> Option<Self::Item> { let new = self.last + self.curr; self.last = self.curr; ...
true
c3834b7a04b94cb640a0b704576d74311577b0f6
Rust
Proggy-and-Techy-for-girls/spoilerowobot
/src/bot/spoiler_creation.rs
UTF-8
8,099
2.703125
3
[ "MIT" ]
permissive
//! Methods related to spoiler creation use std::sync::Arc; use tbot::{ contexts::fields::Message, contexts::methods::ChatMethods, contexts::{ Animation, Audio, Contact, Dice, Document, Location, Photo, Sticker, Text, Video, VideoNote, Voice, }, types::keyboard::inline::{Button, But...
true
a96c8d9fc93278b400ba3084feaf06ce476dee62
Rust
rjbergTU/smbios-lib
/src/windows/win_struct.rs
UTF-8
7,875
3.03125
3
[ "MIT" ]
permissive
use serde::{ser::SerializeStruct, Serialize, Serializer}; use std::{ convert::TryInto, fmt, io::{Error, ErrorKind}, }; use crate::core::{SMBiosData, SMBiosVersion}; /// # Raw SMBIOS Data /// /// When Windows kernel32 [GetSystemFirmwareTable](https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf...
true
081d562c0d4f35bc33ccef85246996313fff0c1b
Rust
eliasyaoyc/k8s-openapi
/src/v1_17/api/auditregistration/v1alpha1/policy.rs
UTF-8
3,787
2.796875
3
[ "Apache-2.0" ]
permissive
// Generated from definition io.k8s.api.auditregistration.v1alpha1.Policy /// Policy defines the configuration of how audit events are logged #[derive(Clone, Debug, Default, PartialEq)] pub struct Policy { /// The Level that all requests are recorded at. available options: None, Metadata, Request, RequestResponse ...
true
f1ecbd03c147e1cb26c24d8064167646ab96e9b0
Rust
Cxarli/rust-glass
/src/token.rs
UTF-8
1,101
3.640625
4
[ "MIT" ]
permissive
use std::ops::*; #[derive(Clone, Debug, PartialEq)] pub enum Token { String(String), Number(i32), Name(String), Comment(String), StartClass, // { EndClass, // } StartFunction, // [ EndFunction, // ] StartWhile, // / EndWhile, // \ PopValue, // , Return, // ^ As...
true
1af27563953355981394c400e90a2f48d1d4d61f
Rust
mandx/envreplace-rust
/src/main.rs
UTF-8
604
2.515625
3
[ "MIT" ]
permissive
extern crate regex; use std::env; use std::io::{self, Read, Write}; use regex::{Captures, Regex}; fn main() { let mut text = String::new(); io::stdin() .read_to_string(&mut text) .expect("Error reading from standard input"); let regex = Regex::new("\\$[\\w_]+").unwrap(); let replace...
true
58988125c1534cbd87e798c73047d9b54f15c493
Rust
mathieu-lemay/aoc-2020
/d14/src/main.rs
UTF-8
5,684
2.9375
3
[ "MIT" ]
permissive
#[macro_use] extern crate lazy_static; use std::fmt::Display; use std::time::Instant; use regex::Regex; use aoc_2020::get_input; use std::collections::HashMap; lazy_static! { static ref MASK_REGEX: Regex = Regex::new(r"mask = ([01X]+)").unwrap(); static ref MEMORY_REGEX: Regex = Regex::new(r"mem\[(\d+)\] = ...
true
8063655770fdda9bdf4cf62af2a29f8bc9093f89
Rust
Perseus101/RustDAG
/lib/src/security/hash/hasher.rs
UTF-8
1,543
3.078125
3
[]
no_license
use std::hash::Hasher; use std::mem::transmute; use security::hash::sha3::{Digest, Sha3_512}; pub struct Sha3Hasher { hasher: Sha3_512, } impl Default for Sha3Hasher { fn default() -> Self { Sha3Hasher::new() } } impl Hasher for Sha3Hasher { fn write(&mut self, bytes: &[u8]) { self....
true
6d27a4cacb7914bd1cc48ed9173b7e02a0a3f2db
Rust
samscott89/serde_urlencoded
/src/de.rs
UTF-8
11,953
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! Deserialization support for the `application/x-www-form-urlencoded` format. use serde::de; use std::collections::{ HashMap, }; use std::borrow::Cow; #[doc(inline)] pub use serde::de::value::Error; use serde::de::value::MapDeserializer; use std::io::Read; // use url::form_urlencoded::Parse as UrlEncodedParse;...
true
9dfd993aaac381c8ff6d0ede13915b73756d590e
Rust
devigned/rust-key-vault
/examples/key_operations.rs
UTF-8
3,893
2.828125
3
[ "MIT" ]
permissive
extern crate vault; extern crate crypto; extern crate rustc_serialize; use std::env; use vault::http::client::{Vault, AzureVault}; use rustc_serialize::base64::{FromBase64}; use rustc_serialize::hex::FromHex; use crypto::digest::Digest; use crypto::sha2::Sha512; fn main() { let mut vault = String::new(); l...
true
564d3fba1c51d24e9ac8f179f4b8ea89f7201124
Rust
wez/evremap
/src/mapping.rs
UTF-8
3,302
2.953125
3
[ "MIT" ]
permissive
use anyhow::Context; pub use evdev_rs::enums::{EventCode, EventType, EV_KEY as KeyCode}; use serde::Deserialize; use std::collections::HashSet; use std::path::Path; use thiserror::Error; #[derive(Debug, Clone)] pub struct MappingConfig { pub device_name: String, pub phys: Option<String>, pub mappings: Vec<...
true
558d4a7137b46bae30dc63a16e4a30b0c944d962
Rust
rust-random/rand
/src/seq/coin_flipper.rs
UTF-8
6,733
3.109375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2018-2023 Developers of the Rand project. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distribu...
true
81a575c362dddd6fa288e6cbba1e91b5abb11c0c
Rust
jakmeier/paddlers-browser-game
/paddlers-game-master/src/worker_actions.rs
UTF-8
11,339
2.640625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Tasks and task execution of workes //! //! Note: This module and submodules will sooner or later need some refactoring. //! For now, I am still don't really know how I want it to look like. mod worker_abilities; mod worker_updates; use crate::db::DB; use crate::game_master::event::*; use crate::game_master::town_...
true
82a12989e1ffd5fef86b1aee5884a00d898c3ea8
Rust
ZhangHanDong/rosrust
/rosrust/tests/derive_array_test.rs
UTF-8
860
2.90625
3
[ "MIT" ]
permissive
// Long arrays as message fields cause a structure to be unable to automatically derive. // // Compilation of this test makes sure this is handled for those cases. mod msg { rosrust::rosmsg_include!(geometry_msgs / PoseWithCovariance); } #[test] fn implementations_work() { let mut message1 = msg::geometry_msg...
true
a8467a82f68be1631b42b1024939ee8b46c39a9b
Rust
PhilboBaggins/ci-experiments
/src/main.rs
UTF-8
196
2.859375
3
[ "Unlicense" ]
permissive
fn main() { println!("Hello, world!"); } #[test] fn five_equals_five() { assert!(5 == 5); } #[test] #[should_panic(expected = "assertion failed")] fn it_panics() { assert!(false); }
true
ef5f9b3be65d97496a9b8f97cb232a271dbd9884
Rust
truelossless/ne2
/src/activity_bar.rs
UTF-8
3,164
2.859375
3
[]
no_license
//! The activity bar. it is the left bar used to open the file exporer, //! or the notification panel. use app_dirs2::{app_root, AppDataType}; use druid::{ widget::{Flex, SizedBox, Svg, ViewSwitcher}, Data, Widget, WidgetExt, }; use crate::{ app::AppState, editor::EDITOR_ID, file_explorer::{file_e...
true
f9fd47a1ed6580d956cc4c35b4940a94a49f0d4c
Rust
Anders429/shield
/src/components/walking_animation_state.rs
UTF-8
512
3.28125
3
[]
no_license
#[derive(Copy, Clone)] pub(crate) enum WalkingAnimationState { StandingA, StepA, StandingB, StepB, } impl Default for WalkingAnimationState { fn default() -> Self { Self::StandingA } } impl WalkingAnimationState { pub(crate) fn to_index(&self) -> usize { match self { ...
true
b6625dc2b83a6e6797d95b59af0853048ad9943d
Rust
sindreij/rouille
/src/input/json.rs
UTF-8
2,216
2.953125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) 2016 The Rouille 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. All files in the project carrying such // notice may not be co...
true
b58dd0b8ef405e339d802036ee8286dac918c930
Rust
VenmoTools/OperatingSystem
/kernel/system/src/console.rs
UTF-8
771
2.84375
3
[ "Apache-2.0" ]
permissive
use crate::alloc::boxed::Box; use crate::Mutex; pub trait Writer { fn print_to(&mut self, arg: ::core::fmt::Arguments); } pub static mut CONSOLE: Mutex<Option<Box<dyn Writer + Sync>>> = Mutex::new(None); pub unsafe fn set_console(printer: Box<dyn Writer + Sync>) { CONSOLE = Mutex::new(Some(printer)); } #[ma...
true
797978b458dab2c64e381f13b21d36dfa7f1d691
Rust
AlexPikalov/cassandra-proto
/src/macros.rs
UTF-8
15,188
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
#[macro_export] macro_rules! query_values { ($($value:expr),*) => { { use cdrs::types::value::Value; use cdrs::query::QueryValues; let mut values: Vec<Value> = Vec::new(); $( values.push($value.into()); )* QueryValues::S...
true
25122d3299d9670829c1f8eb08cbe04ec7486242
Rust
Konstantce/redshift_circuit
/src/experiemental/aes_speed.rs
UTF-8
5,593
2.921875
3
[]
no_license
use aes::block_cipher_trait::generic_array::GenericArray; use aes::block_cipher_trait::BlockCipher; use aes::Aes128; use crate::lazy_static; use bellman::multicore::*; lazy_static! { static ref IV : [u8; 16] = [201, 188, 213, 95, 239, 147, 188, 147, 229, 63, 10, 70, 95, 120, 76, 255]; } pub type BLOCK = [u8; 16...
true
f43559eb888c098159bd94fc4e06f150b542efd0
Rust
k0pernicus/rust_examples
/rust_capacity/rust_test.rs
UTF-8
274
3.140625
3
[]
no_license
trait Everyone { fn capacity(&self); } impl <T> Everyone for T { fn capacity(&self) { println!("we are all one"); } } fn main() { let vec = vec![1,2,3]; println!("{}", vec.capacity()); Everyone::capacity(&vec); }
true
05bd267bbace2bccb3977bd7e7548699ef18facb
Rust
brentward/rustos
/lib/bw_allocator/src/allocator/util.rs
UTF-8
776
3.953125
4
[]
no_license
/// Align `addr` downwards to the nearest multiple of `align`. /// /// The returned usize is always <= `addr.` /// /// # Panics /// /// Panics if `align` is not a power of 2. pub fn align_down(addr: usize, align: usize) -> usize { assert!(align.is_power_of_two()); addr & !(align - 1) } /// Align `addr` upwards...
true
1be0b7f863ff7592a3107593d5e53fde8e0b8fb6
Rust
gissleh/aoc2019
/src/day15.rs
UTF-8
2,719
2.78125
3
[]
no_license
use common::aoc::{load_input, run_many, run_many_mut, print_result, print_time}; use common::intcode::VM; fn main() { let input = load_input("day15"); let (mut vm, dur_parse) = run_many(1000, || VM::parse(&input.trim_end_matches("\n"))); let (res_part1, dur_part1) = run_many_mut(100, || part1_dfs(&mut vm)...
true
ddd177d000c8b45c25a75aa69425f6e0bb6fbbb5
Rust
nextstrain/nextclade
/packages_rs/nextclade/src/run/params.rs
UTF-8
3,042
2.625
3
[ "MIT" ]
permissive
use crate::align::params::{AlignPairwiseParams, AlignPairwiseParamsOptional}; use crate::analyze::virus_properties::VirusProperties; use crate::run::params_general::{NextcladeGeneralParams, NextcladeGeneralParamsOptional}; use crate::tree::params::{TreeBuilderParams, TreeBuilderParamsOptional}; use clap::Parser; use se...
true
a3406908e7a589da152b2fe8e661543f95ef41aa
Rust
HarrisonMc555/euler-rust
/src/euler/euler7.rs
UTF-8
1,153
3.59375
4
[]
no_license
/* By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? */ fn primes_below(limit: usize) -> Vec<usize> { let mut is_composite = vec![false; limit]; let mut primes = Vec::new(); for num in 2..limit { if is_composite[...
true
5840bab06f1a4170d5ae04b830da5abee74dc220
Rust
muzudho/kifuwarabe-shogi-entry-model
/src/config/game_hash_seed.rs
UTF-8
8,294
2.640625
3
[ "MIT" ]
permissive
//! 局面ハッシュ。 //! use crate::{ config::{GameHashSeed, HAND_MAX}, cosmic::square::{BOARD_MEMORY_AREA, FILE10U8, FILE1U8, RANK10U8, RANK1U8, SQUARE_NONE}, law::speed_of_light::HandAddresses, log::LogExt, look_and_model::{ recording::{FireAddress, History, Movement, Phase, PHASE_LEN, PHASE_SECON...
true
79126b962a89808dc1fd5655d72058c08dc13ce4
Rust
megascrapper/rsgames
/src/gladiator_game/mod.rs
UTF-8
4,811
3.359375
3
[]
no_license
use std::io; use crate::errors::GameError; use crate::gladiator_game::army::{Army, FormationType}; mod fighter; mod army; pub struct GladiatorGame<'a> { army_1: Army<'a>, army_2: Army<'a>, round: i32, } impl<'a> GladiatorGame<'_> { pub fn new() -> Result<GladiatorGame<'a>, GameError> { let m...
true
d7a577ba64c5136fedb5dba5179f2242d5b56947
Rust
TheBlueMatt/Angora
/fuzzer/src/search/handler.rs
UTF-8
2,749
2.53125
3
[ "Apache-2.0" ]
permissive
use super::*; use crate::stats::Counter; pub struct SearchHandler<'a> { running: Arc<AtomicBool>, pub executor: &'a mut Executor, pub cond: &'a mut CondStmt, pub buf: Vec<u8>, pub max_times: Counter, pub skip: bool, } impl<'a> SearchHandler<'a> { pub fn new( running: Arc<AtomicBool...
true
b9c75ecc8fa65971f0bc290eee6531f142814e2e
Rust
rcarson3/Rust_Language_Trials
/ownership/src/main.rs
UTF-8
13,417
4.1875
4
[ "MIT" ]
permissive
fn main() { //Rust deals with stack and heaps for memory managment no gc or direct memory management //The stack memory is a first in last off type queue //Stack data must take up a known and fixed size //In rust the heap is used for when we don't know the size of the vector at compile time //or if ...
true
ec752e6e07469311d77ce94637c2dec8d8d70260
Rust
or17191/texlab
/tests/formatting.rs
UTF-8
1,848
2.515625
3
[ "MIT" ]
permissive
#![feature(async_await)] use lsp_types::*; use std::collections::HashMap; use texlab::formatting::bibtex::BibtexFormattingOptions; use texlab::scenario::{Scenario, FULL_CAPABILITIES}; pub async fn run( scenario: &'static str, file: &'static str, options: Option<BibtexFormattingOptions>, ) -> (Scenario, Ve...
true
8485a77d1324954f4e25ddb6b57da8af5840b71a
Rust
ssundarr3/simple-torrent
/src/handshake.rs
UTF-8
3,825
3.046875
3
[ "MIT" ]
permissive
use crate::type_alias::*; use anyhow::Result; use bytes::{BufMut, Bytes, BytesMut}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; /// A message to initiate a connection with a peer. #[derive(Debug, PartialEq, Eq)] pub struct Handshake { pub protocol: Bytes, // TODO: Just use a u64 instead. pub reserved: [u...
true
d3a5a1292b53305bafe7f2ecf9a6cb61c61ae43d
Rust
dansgithubuser/playground
/languages/rust/panic-in-thread/src/main.rs
UTF-8
186
2.59375
3
[]
no_license
fn main() { std::thread::spawn(|| { panic!("Oh no!"); }); std::thread::sleep(std::time::Duration::from_secs(1)); println!("Main thread finishing gracefully."); }
true
0668ff3f11e5ef302aa08b033c559f9e75c744d4
Rust
DeMille/encrusted
/src/rust/ui_web.rs
UTF-8
3,614
3.140625
3
[ "MIT" ]
permissive
use std::boxed::Box; use std::ffi::CString; use std::fmt::Write; use serde_json; use js_message; use traits::UI; #[derive(Debug)] enum Token { Newline, Text(String), Object(String), Debug(String), } #[derive(Debug)] pub struct WebUI { buffer: Vec<Token>, } impl UI for WebUI { fn new() -> Bo...
true
5e41b1bcc41da203585e55dd78e3ce74c860680b
Rust
m1so/advent-of-code-2020
/day-22/src/main.rs
UTF-8
4,507
3.203125
3
[]
no_license
#![feature(str_split_once)] use std::{collections::{HashSet, VecDeque}, error::Error, fs::read_to_string}; type Result<T> = std::result::Result<T, Box<dyn Error>>; type Card = u64; type Deck = VecDeque<Card>; #[derive(Debug)] struct Combat { id: u64, first_deck: Deck, second_deck: Deck, history: Has...
true
5a29d6ad559d6f77669a859f55b1193e3d60a505
Rust
JakubGawron1/embedded-layout
/src/view_group/object_chain.rs
UTF-8
2,634
2.890625
3
[ "MIT" ]
permissive
//! ViewGroup implementation for object chains. use embedded_graphics::{ draw_target::DrawTarget, pixelcolor::PixelColor, prelude::Point, primitives::Rectangle, Drawable, }; use crate::{ object_chain::{Chain, ChainElement, Link}, prelude::RectExt, view_group::ViewGroup, View, }; impl<'a, C, V...
true