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
af6a42551b5ea97a11f4e8f59724da6b1031aba3
Rust
adambozzo1/Rust-Programming-Basics
/basic-syntax/conditional_statement.rs
UTF-8
251
3.421875
3
[]
no_license
fn main(){ let y = 2; let x = 10; if x+y > 13{ println!("x and y together are greater than 13!"); }else if x+y > 10{ println!("x and y together are greater than 10!"); }else{ println!("x and y together are less than 10!"); } }
true
0b3c2e148f2f84d62fee14b374547d38f14abb3f
Rust
ysk24ok/leetcode-submissions
/0054/recursive.rs
UTF-8
2,376
3.59375
4
[]
no_license
struct Solution; impl Solution { pub fn spiral_order(matrix: Vec<Vec<i32>>) -> Vec<i32> { let (m, n) = (matrix.len(), matrix[0].len()); let mut ret = Vec::with_capacity(m * n); Solution::recursive(matrix, &mut ret, 0, m, n); return ret; } pub fn recursive(matrix: Vec<Vec<i3...
true
e43ee9e0dea0e19a08493f8eccce3b4abd7b44fd
Rust
kakoeimon/macro_kako_tools
/src/noise.rs
UTF-8
2,249
3
3
[ "MIT" ]
permissive
use macroquad::prelude::Texture2D; pub fn get_noise_texture_solid(width: usize, height: usize, seed: u32) -> Texture2D { use noise::{OpenSimplex, Seedable, utils::*}; use macroquad::prelude::{Image, load_texture_from_image}; let open_simplex = OpenSimplex::new(); let open_simplex = open_sim...
true
986e1e63cef24e5e1737b1e092e768eb9d4929f3
Rust
tjones879/RustiNES
/nes-cpu/src/mem.rs
UTF-8
3,145
3.234375
3
[ "MIT", "Apache-2.0" ]
permissive
use ppu::Ppu; use apu::Apu; use ioport::IoPort; use std::ops::Deref; pub trait Mem { // Retrieve a byte at the given 0-based address // such that the initial address of each subsystem is 0 fn loadb(&mut self, addr: u16) -> u8; // Write a byte to the given 0-based address // such that the initial a...
true
a85a7d1020237060b0c562d8f0c35ac0f1c518f6
Rust
VulkanWorks/korangar
/src/graphics/vertices/model.rs
UTF-8
741
2.890625
3
[]
no_license
use cgmath::{ Vector2, Vector3 }; #[derive(Default, Debug, Clone, Copy)] pub struct ModelVertex { pub position: [f32; 3], pub normal: [f32; 3], pub texture_coordinates: [f32; 2], pub texture_index: i32, } impl ModelVertex { pub const fn new(position: Vector3<f32>, normal: Vector3<f32>, texture_co...
true
cc1bcba4159ca67d890b93e3f4f6fd8429e60ae4
Rust
GrochalaLukasz/intervalTree
/src/lib.rs
UTF-8
6,029
3.015625
3
[]
no_license
use std::cmp::max; use std::time::{SystemTime, UNIX_EPOCH}; #[derive(Debug)] #[derive(Clone)] pub struct Node { max: isize, add: isize } pub struct IntervalTree { elements: Vec<Node>, size: usize, real_size: usize } impl IntervalTree { pub fn new(size: usize) -> IntervalTree { let ...
true
a4734cb1212b09c6b2cf5030e38f72769310efca
Rust
dareagle/Strategy-Card-Game-AI-Competition
/referee1.2-rust/src/agents/mod.rs
UTF-8
1,255
2.796875
3
[ "MIT" ]
permissive
mod baseline2; mod greedy; mod noop; mod random; pub use crate::agents::baseline2::AgentBaseline2; pub use crate::agents::greedy::AgentGreedy; pub use crate::agents::noop::AgentNoop; pub use crate::agents::random::AgentRandom; use crate::engine::{Action, Actions, State}; use rand::Rng; use std::fmt; pub trait Agent {...
true
1369da561d533b14cabe1405b4a445523942a0fc
Rust
richardwesthaver/gstreamer-lab
/src/bin/example-gtk-video-overlay.rs
UTF-8
9,678
2.703125
3
[]
no_license
// This example demonstrates another type of combination of gtk and gstreamer, // in comparision to the gtksink example. // This example uses regions that are managed by the window system, and uses // the window system's api to insert a videostream into these regions. // So essentially, the window system of the system ...
true
da2098bcc1687127c6ff70ac521f15506706a471
Rust
MingweiSamuel/Riven
/riven/src/req/rate_limit_type.rs
UTF-8
728
3.09375
3
[ "MIT" ]
permissive
/// The type for a [RateLimit](super::RateLimit). Either a rate limit for the /// entire app (`Application`) or for a specific method (`Method`). /// Method rate limit will handle service violations. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum RateLimitType { Application, Method, } impl RateLimitType...
true
fee686c0d6ea4b95ea7dbd1b1e98aa6157f63078
Rust
sonalirungta/exercises-for-programmers
/ex11/main.rs
UTF-8
817
3.609375
4
[]
no_license
use std::io; use std::process; fn main() { let mut stdin = io::stdin(); let mut buffer = String::new(); println!("How many euros are you exchanging?"); stdin.read_line(&mut buffer).unwrap(); println!("What is the exchange rate?"); stdin.read_line(&mut buffer).unwrap(); let amount = match...
true
3b19f168166b7c3f9c814975e5bd51631285f464
Rust
kdheepak/taskwarrior-tui
/src/calendar.rs
UTF-8
7,426
2.515625
3
[ "MIT" ]
permissive
// Based on https://gist.github.com/diwic/5c20a283ca3a03752e1a27b0f3ebfa30 // See https://old.reddit.com/r/rust/comments/4xneq5/the_calendar_example_challenge_ii_why_eddyb_all/ use std::fmt; const COL_WIDTH: usize = 21; use std::cmp::min; use chrono::{format::Fixed, DateTime, Datelike, Duration, FixedOffset, Local,...
true
7e17ea7e23d2d8223551168d64af1d4d6883a59d
Rust
coldFireworks/add_getters_setters
/tests/tests.rs
UTF-8
5,737
3.28125
3
[ "MIT" ]
permissive
#[macro_use] extern crate add_getters_setters; #[derive(AddGetter, AddGetterVal, AddGetterMut, AddSetter)] struct Ts { jaf: u8, #[set] #[get_val] field_1: u8, #[get] #[get_mut] field_2: String, } // these functions shouldn't be set since there are not attrs on jaf. if they are set th...
true
d04f41747e20d16ade47efc49ed4222c7d194edd
Rust
emamulandalib/cassandra-restore-keyspace
/src/parse_commands.rs
UTF-8
1,423
2.9375
3
[]
no_license
use std::{ path::Path, fs::{read_to_string}, }; use clap::{Arg, App}; use cassandra_restore_keyspace::Config; pub struct ParseCommand {} impl ParseCommand { pub fn new() -> Result<Config, String> { let args = App::new("Cassandra KeySpace Restore") .version("0.0.1") .author...
true
74d92fc5e6861b9b39e7993abd171764aaed8200
Rust
kpcyrd/cargo-deb
/src/ok_or.rs
UTF-8
338
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::error::*; pub trait OkOrThen<T> { fn ok_or_then<F: FnOnce() -> CDResult<T>>(self, cb: F) -> CDResult<T>; } impl<T> OkOrThen<T> for Option<T> { fn ok_or_then<F: FnOnce() -> CDResult<T>>(self, cb: F) -> CDResult<T> { if let Some(s) = self { Ok(s) } else { cb() ...
true
2906a0e3d5587c07f7ccb8e9ecb712780989f036
Rust
thuchede/aoc-2020-rust
/src/day03.rs
UTF-8
3,916
3.296875
3
[]
no_license
use std::fs::File; use crate::helpers; // ____________________ // Part 1 // ____________________ pub fn day3_1() -> usize { let value = helpers::read(File::open("src/input/day03.txt").unwrap()).unwrap(); let pattern: Vec<Vec<String>> = value.iter().map(|v| v.chars().map(|c| String::from(c)).collect::<Vec<Stri...
true
a4210b8eccb437de1ef96e2a81bec37c64dd2775
Rust
tiziano88/oak
/rust/oak_tests/src/lib.rs
UTF-8
3,207
2.9375
3
[ "Apache-2.0" ]
permissive
use std::cell::RefCell; use std::collections::VecDeque; #[cfg(test)] mod tests; struct MockChannel { /// If read_status is set, this status value will be returned for any read /// operations on the mock channel (and |messages| will be left /// undisturbed). pub read_status: Option<i32>, /// If wri...
true
240dcf9f0cce2c70c8082c9fd2c30c59069ae896
Rust
eduadiez/ethereum-keys-sgx
/enclave/src/error.rs
UTF-8
1,940
2.8125
3
[ "MIT" ]
permissive
use std::fmt; use secp256k1; use std::error::Error; use std::string::String; use sgx_types::sgx_status_t; use sgx_tservice::sgxtime::SgxTimeError; #[derive(Debug)] pub enum EnclaveError { SGXTimeError(), Custom(String), Fmt(fmt::Error), SGXError(sgx_status_t), Secp256k1Error(secp256k1::Error), } i...
true
c512dd1b4cb84fd65533e7cc9309c184903f566f
Rust
alexpana/enigma
/src/server/commands/echo.rs
UTF-8
591
2.84375
3
[]
no_license
use server::ServerCommand; use tags::TagDatabase; pub struct EchoCommand; impl EchoCommand { pub fn new() -> EchoCommand { EchoCommand {} } } impl ServerCommand for EchoCommand { fn can_execute(&self, command: &str) -> bool { return command.starts_with("echo "); } fn execute(&sel...
true
a14abb1dd8fc2ac6fcb524900aca2db9b9b83944
Rust
mvidner/adventofcode
/2015/05/src/main.rs
UTF-8
2,247
3.34375
3
[]
no_license
#![feature(pattern)] use std::io; use std::io::prelude::*; extern crate core; use core::str::pattern::Pattern; fn main() { let stdin = io::stdin(); // interesting; cannot inline it in the next line let lines = stdin.lock().lines(); // an iterator let mut nice_count = 0; let mut nice_bonus_count = 0; ...
true
17702d39f29d5c483d37afda062438b055bba12c
Rust
loganintech/one_time_pad
/keygen/src/main.rs
UTF-8
721
3.328125
3
[ "MIT" ]
permissive
// External crate includes extern crate rand; // External crate use's use rand::distributions::Alphanumeric; use rand::prelude::*; // Standard Library use's use std::env::args; fn main() { let length = args() .skip(1) .next() .expect("Usage: keygen <length>") .parse::<usize>() ...
true
7857ad742f4b92e2101196920207d8f23c541927
Rust
jmd/first_voxel_engine
/src/voxel_tools/quad.rs
UTF-8
3,388
2.875
3
[ "MIT" ]
permissive
use super::direction::Direction; use crate::color::Color; use cgmath::Vector3; use rand::Rng; pub struct Quad { pub color: Color, pub direction: Direction, // in world position pub corners: [Vector3<f32>; 4], } const HALF_SIZE: f32 = 0.5f32; impl Quad { pub fn from_direction(direction: Direction,...
true
f537da68e7c6453e97f0ac890ad03b3bf018fe87
Rust
wasmerio/cranelift
/cranelift-codegen/src/regalloc/diversion.rs
UTF-8
6,866
3.609375
4
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Register diversions. //! //! Normally, a value is assigned to a single register or stack location by the register allocator. //! Sometimes, it is necessary to move register values to a different register in order to satisfy //! instruction constraints. //! //! These register diversions are local to an EBB. No value...
true
b4eda7079ecb167a9efc578e5dfa9a27f66dbb42
Rust
willi-kappler/sq_noise
/src/noise.rs
UTF-8
3,821
3.109375
3
[ "MIT" ]
permissive
#![allow(non_camel_case_types)] pub trait NoiseT { type BaseT; fn set_seed(&mut self, seed: Self::BaseT); fn get_seed(&self) -> Self::BaseT; fn set_bit_noise(&mut self, bn1: Self::BaseT, bn2: Self::BaseT, bn3: Self::BaseT); fn set_primes(&mut self, p1: Self::BaseT, p2: Self::BaseT, p3: Self::Base...
true
1a837f1c96acedd496486a95c66dde22bbcdc319
Rust
mantarfish/some_other_stuff
/learn_rust/communicator/src/main.rs
UTF-8
733
3.390625
3
[]
no_license
extern crate communicator; use std::collections::HashMap; fn main() { // let s1 = String::from("Either the well is\ // very deep, or she fell very slowly"); // let mut h1 = HashMap::new(); // for word in s1.split_whitespace() { // let value = h1.entry(word).or_insert(0); // *value +=...
true
c91199eb53d52c3e9e1b91698ee8a15664f6c5ef
Rust
afrase/lib-ruby-parser
/src/reserved_words/mod.rs
UTF-8
466
2.609375
3
[ "MIT" ]
permissive
mod reserved_word; pub use reserved_word::ReservedWord; mod list; pub(crate) use list::RESERVED_WORDS; /// Returns a `ReservedWord` for a given string slice. /// /// Returns `None` if given word is not a reserved word in Ruby. pub fn reserved_word(tok: &[u8]) -> Option<&'static ReservedWord> { let bucket = RESERVE...
true
8463617e86975f238da87f2c5b07e8a6dcee7f44
Rust
gnoliyil/fuchsia
/src/settings/service/src/intl/types.rs
UTF-8
8,000
2.671875
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use fidl_fuchsia_settings::IntlSettings; use serde::{Deserialize, Serialize}; use crate::base::Merge; use settings_storage::fidl_storage::FidlStorageConve...
true
7699f7b5dd5e5f87ffce07da596897cbe0a8b1a4
Rust
technic/fluent-templates
/templates/src/loader/static_loader.rs
UTF-8
3,408
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::collections::HashMap; use fluent_bundle::concurrent::FluentBundle; use fluent_bundle::{FluentResource, FluentValue}; pub use unic_langid::{langid, langids, LanguageIdentifier}; /// A simple Loader implementation, with statically-loaded fluent data. /// Typically created with the [`static_loader!`] macro ///...
true
72efda412ea8cbb89a6a3d2fa4eb4680a5954bff
Rust
yutiansut/tanglism
/tanglism-web/src/ws/mod.rs
UTF-8
2,790
2.59375
3
[ "Apache-2.0" ]
permissive
mod session; use crate::DbPool; use futures::{FutureExt, StreamExt}; use jqdata::JqdataClient; use tokio::sync::mpsc; use warp::filters::BoxedFilter; use warp::reply::Reply; use warp::ws::{Message, WebSocket}; use warp::Filter; pub fn ws_filter(jq: JqdataClient, db: DbPool) -> BoxedFilter<(impl Reply,)> { let dep...
true
da883ddd7a2da7fb3eb57c6bd5250ed1917bebda
Rust
JCFlores93/rust-learning
/section13-generic-types/generic.rs
UTF-8
672
3.875
4
[]
no_license
#[derive(Debug)] struct Point<T> { x: T, y: T } #[derive(Debug)] struct Points<T> { x: T } // Generics in Enum Definition enum Option<T> { Some(T), None } enum Result<T,E> { Ok(T), Err(E) } impl <T> Point <T> { fn x(&self) -> &T { &self.x } } impl Points<f32> { fn nu...
true
32b68da362073b3c33f4c393b749126905f4c78e
Rust
BigNuoLi/fd
/src/exec/mod.rs
UTF-8
10,252
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
mod command; mod input; mod job; mod token; use std::ffi::OsString; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::{Arc, Mutex}; use anyhow::{anyhow, Result}; use lazy_static::lazy_static; use regex::Regex; use crate::exit_codes::ExitCode; use crate::filesystem::strip_current_dir;...
true
1f79b6d52c357cea7122eaa314e44bbb0b90aa78
Rust
chiamtc/rust-journey
/chap5_2/src/main.rs
UTF-8
1,418
3.828125
4
[]
no_license
/* fn main() { let width1 = 30; let height1 = 50; println!( "The area of the rectangle is {} square pixels.", area(width1, height1) ); } fn area(width: u32, height: u32) -> u32 { width * height } */ #[derive(Debug)] struct Rectangle { width: u32, height: u32, } #[derive(...
true
f42b62bdaf3ed4af42e76f59f921599b1b278627
Rust
wking/cincinnati
/vendor/hamcrest2/src/core.rs
UTF-8
998
2.640625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2014 Carl Lerche, Steve Klabnik, Alex Crichton // Copyright 2015 Carl Lerche // Copyright 2016 Urban Hafner // // 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 yo...
true
99ddac242b65249da7369ec8a764723c1bfcb70d
Rust
LaplaceKorea/simulation
/simulation/src/deterministic/network/socket/fault.rs
UTF-8
13,715
2.5625
3
[ "MIT" ]
permissive
//! Fault injection for AsyncRead/AsyncWrite types. use crate::TcpStream; use futures::{task::Waker, FutureExt, Poll}; use std::time; use std::{io, net, pin::Pin, sync, task::Context}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio::timer::Delay; #[derive(Debug)] struct FaultState { send_latency: time::Duratio...
true
efa80a466952065893134a34f15c7f77c3619bad
Rust
millerjs/rubbledb
/src/table/block_builder.rs
UTF-8
4,498
3.109375
3
[]
no_license
/// BlockBuilder generates blocks where keys are prefix-compressed: /// /// When we store a key, we drop the prefix shared with the previous /// string. This helps reduce the space requirement significantly. /// Furthermore, once every K keys, we do not apply the prefix /// compression and store the entire key. We ca...
true
d4612437339b37a7cec4aac6cbae9f0b76ba1507
Rust
sne-os3-rp2/rpki-rs
/src/cert/builder.rs
UTF-8
16,255
2.59375
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
use bcder::encode; use bcder::{BitString, Captured, ConstOid, Mode, OctetString, Tag}; use bcder::encode::PrimitiveContent; use crate::crypto::{PublicKey, SignatureAlgorithm, Signer, SigningError}; use crate::oid; use crate::resources::{ AsBlocksBuilder, AsResourcesBuilder, IpBlocksBuilder, IpResources, IpReso...
true
c2ff9b7a29ab16e7b582525846569bd2f37789be
Rust
Iaiao/commands
/src/dispatcher.rs
UTF-8
13,333
2.703125
3
[ "Apache-2.0" ]
permissive
use std::any::Any; use std::collections::HashMap; use std::fmt::{Debug, Formatter}; use slab::Slab; use crate::create_command::CreateCommand; use crate::node::{CommandNode, CompletionType}; use crate::varint::write_varint; pub type Args = Vec<Box<dyn Any>>; pub type Completer<T, Text> = Box<dyn Fn(&str, &mut T) -> T...
true
67682215d0e5d43edbb74923d1360c71c328b716
Rust
doy/vt100-test
/src/bin/explode.rs
UTF-8
5,144
2.984375
3
[]
no_license
use std::io::{Read as _, Write as _}; use unicode_width::UnicodeWidthStr as _; struct Printer { base: std::time::Instant, offset: std::time::Duration, chars: String, writer: ttyrec::Creator, frames: Vec<ttyrec::Frame>, } impl Printer { fn new() -> Self { Self { base: std::t...
true
c423c3b3fcd1ea1b023190ddfc3c5b14114050e1
Rust
arwinneil/wasm-router
/src/demo_data.rs
UTF-8
3,710
2.984375
3
[ "MIT" ]
permissive
pub struct DemoData { pub home_content: String, pub about_content: String, pub faq_content: String, pub lets_party_content: String, } impl DemoData { pub fn new() -> DemoData { DemoData{ home_content : r##" <section> <asi...
true
059fd2cc99c6b3bac4037be49e8483659ad9b0ed
Rust
xfbs/afp
/src/datastore/file.rs
UTF-8
4,667
3.171875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Data structures and methods for loading and storing a DataStore //! to and from a file. extern crate serde; extern crate serde_yaml; use serde::{Deserialize, Serialize}; use std::error::Error; use std::time::{Duration, SystemTime}; use crate::datastore::*; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub...
true
db0f01ba1ef859c24bdfcd55357ce7c3fd3cd79f
Rust
billy1624/ouroboros
/examples/src/fail_tests/borrowchk_custom_drop.rs
UTF-8
891
2.96875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::cell::RefCell; use ouroboros::self_referencing; struct Bar<'a>(RefCell<(Option<&'a Bar<'a>>, String)>); #[self_referencing] struct Foo { owner: (), #[borrows(owner)] #[not_covariant] bar: Bar<'this>, #[borrows(bar)] #[not_covariant] baz: &'this Bar<'this>, } impl Drop for Bar<'_...
true
a870da01679185ee0c1da1fab47ef9e440bf6a9c
Rust
Mercanuis/rss_reader
/src/readers/rss_reader.rs
UTF-8
1,859
3.390625
3
[]
no_license
use std::error::Error; use std::fmt; use std::fmt::{Display, Formatter}; use reqwest::blocking; use rss::Channel; use super::Reader; use super::MAX_LENGTH; ///Represents a Reader for an RSS feed pub struct RssReader { ///the title of the RSS feed title: String, ///the description of the RSS feed desc...
true
c2d5d36334b9bbffadd88601aa0b5dc3f2823b9a
Rust
victor-baumbach/Prime-Number-Generator---Rust
/main.rs
UTF-8
4,810
3.390625
3
[]
no_license
fn main() { println!("{:#?} ", sieve_of_eratosthenes(2, 100, 110)); /* for number in find_prime_numbers(100000) { print!("{}, ", number); } */ } fn find_prime_numbers(end_value: u64) -> Vec<u64> { let mut prime_numbers = vec![2u64]; let mut n = 3u64; while n <= end_value as u64 { let mut ...
true
3731e2d8c60f8f344315583920a51161886ea924
Rust
futurepaul/piet
/piet-test/src/lib.rs
UTF-8
1,107
2.984375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Test code for piet. // Right now, this is just code to generate sample images. use piet::{Error, RenderContext}; mod picture_0; mod picture_1; mod picture_2; mod picture_3; mod picture_4; use crate::picture_0::draw as draw_picture_0; use crate::picture_1::draw as draw_picture_1; use crate::picture_2::draw as dra...
true
b1fd97b9fb1a029dfb5b0f928fb8d5cf497636f6
Rust
rcarson3/Rust_Language_Trials
/Collections_Chapter/hash_maps/src/main.rs
UTF-8
4,488
4.1875
4
[ "MIT" ]
permissive
//HashMaps aren't used nearly as often and so they aren't automatically //brought into scope. Therefore, we need to manually call them in. #![allow(unused_variables)] fn main() { use std::collections::HashMap; //Hash maps store keys associated with values. We can think of them like //dictionaries in python...
true
21bc9b623bee793c68bda5365656cb2f3e290694
Rust
Ynstc/vertigo
/app/src/app/sudoku/render/mod.rs
UTF-8
6,019
2.640625
3
[]
no_license
use vertigo::{computed::Computed, VDomElement, Css}; use vertigo_html::{html, css_fn, css}; use self::config::Config; use super::state::{Cell, Sudoku, sudoku_square::SudokuSquare, tree_box::TreeBoxIndex}; pub mod config; pub mod render_cell_value; pub mod render_cell_possible; css_fn! { css_center, " display: fl...
true
8678671baa33ca60a33181055cf64c0951325118
Rust
robeirne/rlcalc
/src/parse.rs
UTF-8
1,684
3.015625
3
[]
no_license
use crate::*; use std::str::FromStr; use lazy_static::*; use regex::*; lazy_static! { static ref SIZE_REGEX: Regex = Regex::new(r#"(?x) ^(?P<value>[[:digit:]\.]+) (?P<space>\ +)? (?P<units>[[:alpha:]"']+) "# ).expect("SIZE_REGEX"); } fn parsley(s: &str) -> Option<(f64, Units)> { ...
true
cb138de6ecd8b2154ef1d1e9cacd43776a442426
Rust
yinshuwei/trying
/rust/hello_cargo/src/demo/rc_demo.rs
UTF-8
586
3.09375
3
[]
no_license
use std::rc::Rc; use List::{Cons, Nil}; enum List { Cons(i32, Rc<List>), Nil, } pub fn run() { let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); println!("count:{}", Rc::strong_count(&a)); { let b = Cons(3, Rc::clone(&a)); if let Cons(i, _) = b { println!("{}"...
true
495ff9be5479cf3e8e4cf07c369a8c4f3d6249ad
Rust
AliveEngine/jasmine-math
/src/vector.rs
UTF-8
22,409
2.859375
3
[ "MIT" ]
permissive
use num_traits::{Bounded, Float, NumCast}; #[cfg(feature = "rand")] use rand::{ distributions::{Distribution, Standard}, Rng, }; use std::fmt; use std::iter; use std::mem; use std::ops::*; use structure::*; use angle::Rad; use approx; use num::{BaseFloat, BaseNum}; use point::{Point1, Point2, Point3}; #[cfg(...
true
9ee9852561cbe899886e2791cfb4a73d86d2b753
Rust
regananalytics/RsPG
/rspg_server/src/srd/races.rs
UTF-8
816
2.640625
3
[ "MIT" ]
permissive
use crate::srd::properties; // Enum of Races from 5e SRD #[derive(Debug)] pub enum Races { Dragonborn, Dwarf, Elf, Gnome, HalfElf, HalfOrc, Halfling, Human, } // Racial Traits pub trait Modifiers { fn modifiers(&self) -> Vec<properties::ASMod>; } pub trait Age { fn age(&self) ...
true
84788794df28c70d78323404ccb178d05980e363
Rust
jrostand/bits-bobs
/rust/fib.rs
UTF-8
658
3.484375
3
[]
no_license
// Iterative fibonacci up to 64-bit unsigned int fn fib(n : u64) -> u64 { if n <= 1 { return n } else { // Assign these separately because of dead assignment warnings let mut tmp:u64; let (mut cur, mut next) = (0u64, 1u64); for _ in range(0, n) { tmp = cur + next; // Detect int overflo...
true
565ec3de3621d5d162a1a7f71591a2de5fad8b99
Rust
atthecodeface/utf8-read-rs
/src/reader.rs
UTF-8
12,705
3.390625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//a Imports use crate::{Char, Error, Result, StreamPosition}; //a Constants /// [BUFFER_SIZE] is the maximum number of bytes held in the UTF-8 /// character reader from the incoming stream. The larger the value, /// the larger the data read requests from the stream. This value must be larger than `BUFFER_SLACK`. /// ...
true
33ad7c7e064da95aef841d578227e1edf28daba7
Rust
checkmatez/learning-rust
/minigrep/src/main.rs
UTF-8
341
2.796875
3
[]
no_license
use std::env; use std::fs; fn main() { let args: Vec<String> = env::args().collect(); let query = &args[1]; let filename = &args[2]; println!("query: {}", query); println!("filename: {}", filename); let contents = fs::read_to_string(filename).expect("Can't read the file"); println!("Text:...
true
e2301dcdbf913a469fae03f7301ed4fd8520662d
Rust
AlienKevin/hack-assembler
/src/parser.rs
UTF-8
23,589
3.015625
3
[]
no_license
use std::fmt::*; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Located<A> { pub value: A, pub from: Location, pub to: Location, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Location { pub row: usize, pub col: usize, } #[derive(Debug, PartialEq, Eq)] pub enum ParseResult<'a, Output, State> ...
true
94ca466da83f19d4a654b06ee285486f82709d90
Rust
russelltg/srt-rs
/srt-tokio/src/listener/builder.rs
UTF-8
4,053
3.046875
3
[ "Apache-2.0" ]
permissive
use std::{convert::TryInto, io, time::Duration}; use tokio::net::UdpSocket; use crate::options::*; use super::{SrtIncoming, SrtListener}; #[derive(Default)] pub struct SrtListenerBuilder(SocketOptions, Option<UdpSocket>); /// Struct to build a multiplexed listener. /// /// This is the typical way to create instanc...
true
06c828ffdb9ebcd838bb1299d5b0b7f1e578ed0f
Rust
MaikKlein/rla
/src/quaternion.rs
UTF-8
2,372
3.6875
4
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use num::Float; use vector::Vec3; use unit::*; use std::ops::{Mul, Div}; #[derive(Copy, Clone)] pub struct Quaternion<T> where T: Float { v: Vec3<T>, w: T, } impl<T> Quaternion<T> where T: Float { pub fn new<R: ToRadians<T>>(axis: Vec3<T>, angle: R) -> Self { use num::NumCast; let h...
true
789270ae7485b575ddde16b90ea91e84145d0d79
Rust
alexkursell/subotai
/src/node/factory.rs
UTF-8
5,824
2.984375
3
[ "MIT" ]
permissive
//! #Factory //! //! The factory module allows you to create Subotai nodes with specific configuration options, //! such as network constants and different UDP ports. use {node, SubotaiResult}; use std::cmp; /// Allows the construction of nodes with custom network constants, specific ports, /// and other options. pub ...
true
efe845eb7067c7c645f001294a0d30e414557f46
Rust
IThawk/rust-project
/rust-master/src/test/ui/traits/cycle-cache-err-60010.rs
UTF-8
1,856
2.875
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Test that we properly detect the cycle amongst the traits // here and report an error. use std::panic::RefUnwindSafe; trait Database { type Storage; } trait HasQueryGroup {} trait Query<DB> { type Data; } trait SourceDatabase { fn parse(&self) { loop {} } } struct ParseQuery; struct RootDa...
true
592a5dc50e7ccae7fcefc8d1da8556d92f98b048
Rust
zeta0134/rusticnes-core
/src/unofficial_opcodes.rs
UTF-8
10,228
3.03125
3
[ "MIT" ]
permissive
use addressing; use cycle_cpu::Registers; use opcodes; use nes::NesState; use memory::read_byte; use memory::write_byte; // Note: Opcode names follow the undefined opcodes tabke here: // https://wiki.nesdev.com/w/index.php/CPU_unofficial_opcodes // Shift left and inclusive OR A pub fn slo(registers: &mut Registers, d...
true
108d067fa447905e29a34a4fca8fba01c08e5a3a
Rust
marco-c/gecko-dev-wordified
/third_party/rust/ffi-support/src/string.rs
UTF-8
7,469
2.796875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
/ * Copyright 2018 - 2019 Mozilla Foundation * * Licensed under the Apache License ( Version 2 . 0 ) or the MIT license * ( the " Licenses " ) at your option . You may not use this file except in * compliance with one of the Licenses . You may obtain copies of the * Licenses at : * * http : / / www . apache . org / lic...
true
eceb750b7d18e1c17f1a977456c5bad67b5ecdf7
Rust
kolmodin/advent-of-code-2020
/src/bin/day11.rs
UTF-8
2,738
3.03125
3
[ "Apache-2.0" ]
permissive
#![feature(iter_map_while)] use aoc2020::map::Map; use aoc2020::pos2d::Pos; use std::fs; use std::iter::successors; trait Rules { fn is_occupied_dir(&self, map: &Map, pos: Pos, dir: Pos) -> bool; fn new_cell(&self, is_occupied: bool, adjacent_occupied: usize) -> Option<u8>; } struct Part1; impl Rules for Pa...
true
0ff1994c44e88b6f99161e11d38c147de7136c43
Rust
TheNumerus/TVS-Renamer
/src/main.rs
UTF-8
5,291
2.703125
3
[]
no_license
use std::io; use ansi_term::Colour::{Green, Red}; use crate::args::args_parser::Mode; use structopt::StructOpt; use crate::api::show::ShowResult; use crate::api::tv_maze; use crate::tv_maze::TVMaze; use std::path::{Path, PathBuf}; use ansi_term::Style; use walkdir::WalkDir; use crate::database::database::Database; use...
true
335a60e1738411e08648c90dba0bfab430019da8
Rust
tzilistgoop/sqlx
/sqlx-core/src/database.rs
UTF-8
2,745
2.96875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! Traits to represent various database drivers. use std::fmt::Debug; use crate::arguments::Arguments; use crate::column::Column; use crate::connection::Connection; use crate::done::Done; use crate::row::Row; use crate::transaction::TransactionManager; use crate::type_info::TypeInfo; use crate::value::{Value, ValueR...
true
7e97558a0d2b20faddfe545ba2e7b1278e49f368
Rust
TimUntersberger/cimir
/src/main.rs
UTF-8
2,586
2.59375
3
[ "MIT" ]
permissive
pub use winit; use winit::{ event::VirtualKeyCode, event_loop::ControlFlow, }; use chrono::prelude::*; use crate::application::ApplicationWrapper; use crate::renderer::Renderer; use crate::key::Key; use crate::primitives::{TextInputStyle, TextInputState}; mod animation; mod appbar; mod application; mod key;...
true
a23454a052236f3b60c8b502c250a518d242acd0
Rust
amerelo/Computor_v1
/src/main.rs
UTF-8
2,093
2.875
3
[]
no_license
mod list_module; mod degree2_module; extern crate regex; use regex::Regex; use list_module::module::Module; use degree2_module::solver::Solver; use std::env; use std::process; fn execut(str: &String) { let re = Regex::new(r"(\+|\-|=)?\s*(\-?\d+\.?\d*)\s*\*\s*[Xx]\^(\-?\d+\.?\d*)\s*").unwrap(); let mut module = Mod...
true
0a2d2063deb2061a025de8fa3dda1bbd20056b46
Rust
scott113341/advent_of_code_2018
/day_4/src/main.rs
UTF-8
2,438
3.234375
3
[]
no_license
#![feature(dbg_macro)] extern crate regex; use std::collections::HashMap; mod shift; fn main() { let mut input: Vec<String> = include_str!("input.txt") .trim() .split("\n") .map(|s| s.to_string()) .collect(); input.sort(); println!("part_1: {}", part_1(&input)); pri...
true
c232942ede084f72ba5741425a19dc4500940e18
Rust
yfery/octopod
/src/models.rs
UTF-8
3,339
2.84375
3
[ "MIT" ]
permissive
use std::str; // needed for from_utf8 use std::str::FromStr; // needed for FromStr trait on Channel use rss::{Channel, Error}; use url::Url; use diesel::sqlite::SqliteConnection; use chrono; use diesel::prelude::*; use diesel::insert; use diesel::update; use schema::*; #[derive(Debug, Clone, Queryable, Serialize, Dese...
true
1540d0f2416e1b79d9c1a00734071680e3d0fc7d
Rust
alilee/arm-rust-clust
/src/pager/phys_addr.rs
UTF-8
5,310
2.953125
3
[ "Unlicense" ]
permissive
// SPDX-License-Identifier: Unlicense use crate::archs::{arch::Arch, PagerTrait}; use super::{Addr, AddrRange, VirtAddr, PAGESIZE_BYTES}; use core::fmt::{Debug, Error, Formatter}; /// A local physical address #[derive(Copy, Clone, PartialOrd, PartialEq, Eq, Ord)] pub struct PhysAddr(usize); impl Debug for PhysAddr...
true
43a1154932e1bb4074cdae58bd13e7ced90bcebe
Rust
nystrom/exercises
/src/main.rs
UTF-8
646
3.078125
3
[]
no_license
#![allow(unused_variables)] // DO NOT CHANGE THIS DEFINITION #[derive(Debug, PartialEq)] struct Foo(i32); // TODO: modify the argument type to make the compile errors in main go away. fn use_foo(foo: Foo) { println!("uses_foo: {:?}", foo); } // TODO: modify the argument type to make the compile errors in main go...
true
b2c51479c51b89712ab7dd1e109db59a7b1df263
Rust
wilgaboury/peg_rs
/src/peg_rs/grammar_nodes/zero_or_one.rs
UTF-8
1,370
3.125
3
[]
no_license
use peg_rs::interfaces::*; use peg_rs::grammar_nodes::production::*; pub struct ZeroOrOneNode { pub child: Box<GrammarNode>, } pub struct ZeroOrOne { child: Box<Buildable>, } impl ZeroOrOne { pub fn new(child: Box<Buildable>) -> Box<ZeroOrOne> { Box::new(ZeroOrOne{child}) } } impl GrammarNod...
true
969274442e75ab429aef683792a4b87805e41de9
Rust
tamaroning/rust-kaleidoscope
/src/codegen.rs
UTF-8
1,410
2.515625
3
[ "MIT" ]
permissive
extern crate llvm_sys as llvm; use crate::node; use std::ptr; use std::ffi::CString; use self::llvm::core::*; use self::llvm::prelude::*; use node::{AST, BinaryOp}; pub struct Codegen { context: LLVMContextRef, module: LLVMModuleRef, builder: LLVMBuilderRef, } impl Codegen { pub unsafe fn new(mod_na...
true
699fc51591cfd987703d0687d521815ddc4b9b0a
Rust
renato-zannon/rust-csv
/src/csv/lib.rs
UTF-8
2,837
2.890625
3
[]
no_license
#![crate_id = "csv"] #![crate_type = "lib"] #![desc = "CSV parser"] #![license = "MIT"] #![feature(phase)] #[phase(syntax, link)] extern crate log; use std::io; use std::str; use std::iter::Iterator; pub type Row = Vec<~str>; enum State { Continue, Wait, EOL } pub struct Parser<R> { count: uint, readlen:...
true
67f5e58a47d02aee5276016f0144b6daaba87195
Rust
museun/riirc
/src/ui/commands/mod.rs
UTF-8
4,000
2.65625
3
[ "Unlicense" ]
permissive
use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; use super::{colors::Color, keybinds::*, output::Output, request::*, state::State, *}; import!( bind, buffer, clear, clear_history, connect, echo, exit, join, list_buffers, part, quit, rehash ); #[d...
true
13c72a7883bbbdaf0828023805c3c65b44f0b8fd
Rust
momobel/raytracer
/src/ray.rs
UTF-8
1,578
3.28125
3
[]
no_license
use crate::material::Material; use crate::vec::{Point, Vector}; #[derive(Debug)] pub struct Ray { pub origin: Point, pub direction: Vector, } impl Ray { pub fn new(origin: Point, direction: Vector) -> Ray { Ray { origin, direction } } pub fn at(&self, t: f64) -> Point { self.origi...
true
100db44012492dac41e50d2bfb625376d3ad7796
Rust
ingolia-lab/CiBER_seq
/barcode_assign/src/barcode_assign/bc_tabulate.rs
UTF-8
11,190
2.875
3
[]
no_license
use std::io::Write; use failure; use counts::*; pub struct CLI { pub inputs: Vec<String>, pub output: String, pub mintotal: Option<usize>, pub minsamples: Option<usize>, pub mininsample: Option<usize>, pub omitfile: Option<String>, } impl CLI { pub fn run(&self) -> Result<(), failure::Er...
true
6c17fcccf90164baf6042b2ff33b5bfa8d3606be
Rust
tcsc/raygun
/lib/raygun-primitives/src/union.rs
UTF-8
1,618
2.90625
3
[]
no_license
use log::debug; use std::sync::Arc; use raygun_math::{Point, Ray, Transform, Vector}; use super::{AxisAlignedBox, Object, Primitive}; #[derive(Debug)] pub struct Union { pub children: Vec<Arc<Object>>, } impl Union { pub fn new() -> Union { Union::default() } } impl Primitive for Union { fn...
true
1f5cd4d473c5831e6fec03591a1d06560aae3132
Rust
Spaceface16518/ImageGoNord
/examples/random.rs
UTF-8
1,369
2.734375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use image::{imageops::overlay, io::Reader, GenericImageView}; use image_go_nord::{convert, Options, NORD}; use std::{ error::Error, io::{Cursor, Read}, time::Instant, }; fn main() -> Result<(), Box<dyn Error>> { let start = Instant::now(); let mut pic = { let req = ureq::get("https://source...
true
18c24331450329c938c9dd16d80040b7937fa3a2
Rust
akiles/embassy
/embassy-embedded-hal/src/shared_bus/mod.rs
UTF-8
1,221
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Shared bus implementations use core::fmt::Debug; use embedded_hal_1::{i2c, spi}; #[cfg(feature = "nightly")] pub mod asynch; pub mod blocking; /// Error returned by I2C device implementations in this crate. #[derive(Copy, Clone, Eq, PartialEq, Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub en...
true
3d11d7651751e731f58a8ec3a7d5229c94cb9b21
Rust
sexxi-goose/rust
/library/alloc/tests/const_fns.rs
UTF-8
1,337
2.9375
3
[ "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "MIT", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
// Test const functions in the library use core::cmp::Ordering; // FIXME remove this struct once we put `K: ?const Ord` on BTreeMap::new. #[derive(PartialEq, Eq, PartialOrd)] pub struct MyType; impl const Ord for MyType { fn cmp(&self, _: &Self) -> Ordering { Ordering::Equal } fn max(self, _: Se...
true
64dbbc5d48162db7db5a76f75e043ab1c307c800
Rust
AntonGepting/tmux-interface-rs
/src/styles/colour.rs
UTF-8
2,694
3.484375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use std::borrow::Cow; use std::fmt; const BLACK: &str = "black"; const RED: &str = "red"; const GREEN: &str = "green"; const YELLOW: &str = "yellow"; const BLUE: &str = "blue"; const MAGENTA: &str = "magenta"; const CYAN: &str = "cyan"; const WHITE: &str = "white"; const BRIGHTRED: &str = "brightred"; const BRIGHTGREE...
true
d6b3154b9e16bbe70f92ad541222c29dea2bde4c
Rust
kurtlawrence/cmdtree
/src/completion.rs
UTF-8
11,483
3.109375
3
[]
no_license
//! Completion of tree paths and action arguments. //! //! Completion is done functionally, see examples on github for how to implement. use super::*; #[cfg(feature = "runnable")] use colored::*; #[cfg(feature = "runnable")] pub use linefeed::{Completer, Completion, Interface, Prompter, ReadResult, Terminal}; impl<'r...
true
0bcafec2fec4b79b25c3b0bf0811cdb1b0b8da4a
Rust
chen116/fogsys
/src/datastore/app.rs
UTF-8
1,026
3.09375
3
[]
no_license
use std::collections::HashMap; use std::sync::{Arc, Mutex}; #[derive(Debug, Clone)] pub struct App { shared: Arc<Mutex<HashMap<String, String>>>, } impl App { pub fn new() -> App { let map: HashMap<String, String> = HashMap::new(); let shared = Arc::new( Mutex::new( map)); App { sh...
true
55c37c236904fcd5790de88a4bf9b75f494cca9f
Rust
clemensw/bn
/src/groups/mod.rs
UTF-8
8,866
2.65625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use fields::Field; use fields::fp::{PrimeFieldParams, Fp}; use params::G2Params; use super::{Fr,Fq,Fq2}; use rand::Rng; use std::ops::{Add,Mul,Sub,Neg}; use std::fmt; #[cfg(test)] pub mod tests; #[macro_use] mod macros; mod gt; pub use self::gt::Gt; pub trait GroupParams: Sized { type Base: Field; fn zero(...
true
51651f5600447d041cfe69c0856f6b8728a4297d
Rust
povilasb/snake
/src/game.rs
UTF-8
7,505
3.578125
4
[]
no_license
use std::clone::Clone; use rand::{thread_rng, Rng}; #[derive(Clone, PartialEq, Debug, Hash, Eq)] pub enum MovementDirection { Left, Right, Up, Down, } #[derive(Clone)] pub struct Cell { pub x: usize, pub y: usize, pub direction: MovementDirection, } impl Cell { fn new(x: usize, y: us...
true
0de72e4f3a39f6a3c93ff6ea3d5dadedf816679c
Rust
fossabot/stronghold.rs
/communication/examples/local-echo.rs
UTF-8
9,419
2.890625
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 //! A basic application for communication between peers in the same local network. //! //! Start the peers in different terminal windows. If the local network allows mDNS, they will automatically connect. //! //! ```sh //! cargo run --example ...
true
942c07b9da3127e9349b333767a4679f56de762a
Rust
pythias/leetcode
/algorithms/rust/src/s0485_find_max_consecutive_ones.rs
UTF-8
695
3.640625
4
[]
no_license
//485. Max Consecutive Ones //https://leetcode.com/problems/max-consecutive-ones/ impl Solution { pub fn find_max_consecutive_ones(nums: Vec<i32>) -> i32 { let mut c = 0; let mut max = 0; for n in nums { if n == 0 { c = 0; continue; } ...
true
3374e89c36c7ccfef00b588ee423a81214dda66b
Rust
xvxx/ldpl-rs
/src/error.rs
UTF-8
2,509
3.046875
3
[ "CC-BY-4.0", "Apache-2.0" ]
permissive
#![allow(unused_macros)] use crate::parser::Rule; use std::{error, fmt, io}; #[derive(Debug)] pub struct LDPLError { pub details: String, pub line: usize, pub col: usize, pub len: usize, } impl LDPLError { pub fn new(details: String, line: usize, col: usize, len: usize) -> LDPLError { LDPL...
true
dfc3983c269593dd13f7b3bf483353f8f47ff1a8
Rust
havardh/geckoboot.rs
/emlib/timer.rs
UTF-8
10,473
2.53125
3
[]
no_license
use core::intrinsics::transmute; use core::default::Default; pub const TIMER_IF_OF: u32 = (0x1 << 0); pub const TIMER_IF_UF: u32 = (0x1 << 1); pub const TIMER_IF_CC0: u32 = (0x1 << 4); pub const TIMER_IF_CC1: u32 = (0x1 << 5); pub const TIMER_IF_CC2: u32 = (0x1 << 6); pub const TIMER_IF_ICBOF0: u32 = ...
true
f591916cf227811da70f4e360818193222b9faf1
Rust
SarthakSingh31/ld47-actix
/src/main.rs
UTF-8
9,141
2.578125
3
[]
no_license
use std::env; use actix::prelude::*; use actix_web::{web, App, Error, HttpRequest, HttpResponse, HttpServer}; use actix_web_actors::ws; use serde::{Deserialize}; use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod}; mod models; mod config; mod server; mod simulator; struct GameWebSocket { id: usize, data...
true
467827872785784b96b5d1c35864db9ea40d378e
Rust
rtroxler/glrs
/src/chart_of_accounts.rs
UTF-8
2,060
3.078125
3
[]
no_license
use std::collections::HashMap; #[derive(Debug, Serialize, Deserialize)] pub enum AccountCode { Base(String), Daily(AccrualAccount), Periodic(AccrualAccount), Cash(CashAccount) } #[derive(Debug, Serialize, Deserialize)] pub struct AccrualAccount { pub revenue_code: String, pub accounts_receivab...
true
27dfee0bf8336989ee872257ec786427ac6dd9c7
Rust
unpluggedcoder/memory-profiler
/jemallocator/jemalloc-ctl/src/stats.rs
UTF-8
7,106
2.953125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Global allocator statistics. //! //! `jemalloc` tracks a wide variety of statistics. Many of them are cached, and //! only refreshed when the `jemalloc` "epoch" is advanced. See the [`::epoch`] type //! for more information. option! { allocated[ str: b"stats.allocated\0", non_str: 2 ] => libc::size_t | ops...
true
709c8168684e7b428c13d6d6abeb8afe27572471
Rust
AGS1130/Learning-Rust
/02-Guessing_Game/guessing_game/src/main.rs
UTF-8
1,753
4
4
[]
no_license
// * use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { println!("Guess the number!"); let secret_number = rand::thread_rng().gen_range(1, 101); // println!("The secret number is: {}", secret_number); loop { println!("Please input your guess."); // `::` => associated fu...
true
d3f4612281dda4e0c9de544a610c175f68300b27
Rust
romanb/hexkit
/hexacore/src/grid/shape.rs
UTF-8
10,409
3.71875
4
[]
no_license
//! Iterators over cube coordinates for creating maps with common shapes. //! //! The `.` in the ASCII-art indicates the origin, i.e. `(0,0,0)`. use super::coords::{ self, Cube }; #[derive(Clone)] pub struct Shape<I: IntoIterator<Item=Cube>> { pub data: I, pub total: usize, } impl<I: IntoIterator<Item=Cube>>...
true
c73ca01a6df58ef5482cc08ecb6bd7c9d24b0530
Rust
jduan/cosmos
/rust_sandbox/rust_sandbox/src/misc.rs
UTF-8
2,099
4.125
4
[ "MIT" ]
permissive
#[derive(Debug)] pub struct Rectangle { width: u32, height: u32, } impl Rectangle { pub fn can_hold(&self, other: &Rectangle) -> bool { self.width > other.width && self.height > other.height } } pub fn add_two(a: i32) -> i32 { a + 2 } pub fn greeting(name: &str) -> String { format!("H...
true
2160463e1f350c4cb3755f2eb057b8bb8ad94164
Rust
Devking/Rust-CFG-Parser-Assignment
/rust_practice/queries.rs
UTF-8
6,663
3.328125
3
[]
no_license
use std::io; use std::io::prelude::*; enum Type { List, ListString, Number, Pointer } impl Clone for Type { fn clone (&self) -> Type { match *self { Type::List => Type::List, Type::ListString => Type::ListString, Type::Number => Type::Number, Type::Pointer => Type::Pointer } } } struct Node { valu...
true
c830d7bc940972bf1bf4ad99bcc5df9b478517b1
Rust
reproto/reproto
/lib/core/src/option_entry.rs
UTF-8
405
2.765625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::errors::Result; use crate::RpNumber; pub trait OptionEntry { /// Get the name of the option. fn name(&self) -> &str; /// Get the value as a string. fn as_string(&self) -> Result<String>; /// Get the value as an 32-bit unsigned integer. fn as_number(&self) -> Result<RpNumber>; ...
true
d501460c8d92402c68c0812df5cad37faf1801f4
Rust
Marusiella/babucoin
/src/main.rs
UTF-8
10,916
2.703125
3
[]
no_license
#[macro_use] extern crate derive_new; use std::fmt::{self, Debug, Display}; use serde::{Deserialize, Serialize}; const PROOF: &str = "0"; #[derive(Serialize, Deserialize, Debug, Clone, new)] struct Block { index: u64, previus_hash: String, timestamp: String, data: Vec<Transaction>, hash: String,...
true
8c801dc6eb7122c028493e8b69ed7cb4177613cb
Rust
cjgriscom/plctag-rs
/src/builder.rs
UTF-8
13,376
3.140625
3
[ "MIT" ]
permissive
//! builders for tag path and tag use crate::DebugLevel; use std::fmt; pub use anyhow::Result; /// builder to build tag full path /// /// # Examples /// ```rust,ignore /// use plctag::builder::*; /// use plctag::RawTag; /// /// fn main() { /// let timeout = 100; /// let path = PathBuilder::de...
true
709b1ff260b2f09c3a7817fa7307274c5462955a
Rust
krzyz/quantum-plots
/plotter-wasm/src/lib.rs
UTF-8
1,731
2.78125
3
[]
no_license
use func_plot::{PlotData, Problem}; use plotters::coord::Shift; use plotters::prelude::*; use wasm_bindgen::prelude::*; mod func_plot; mod utils; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; pub type DrawResult<T> = Result<T, Box<dyn std::error::Error>>; #[wasm_bindgen] pub str...
true
3d6b8639bf8f9c35d9a8328082542254171a9087
Rust
vertexclique/amadeus
/amadeus-serde/src/csv.rs
UTF-8
6,275
2.53125
3
[ "Apache-2.0" ]
permissive
use csv::Error as SerdeCsvError; use serde::{Deserialize, Serialize}; use serde_closure::*; use std::{ error, fmt::{self, Display}, iter, marker::PhantomData }; use amadeus_core::{ dist_iter::DistributedIterator, file::{File, Page, Partition}, into_dist_iter::IntoDistributedIterator, util::ResultExpand, Source }; u...
true
051e3496e9b613bd56435bc9d7961ee33560ac93
Rust
m-r-hunt/wolfspider
/wolfspider/src/main.rs
UTF-8
5,315
2.765625
3
[]
no_license
extern crate regex; // wolfspidertag use-env use std::env; use std::fs::File; use std::io; use std::io::BufReader; use std::io::BufRead; use std::io::Read; use std::io::Write; use regex::Regex; use std::collections::HashMap; struct Chunk { tag: String, content: String, } struct WFSFileCache { file_chunks...
true