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
8f8d2581d8d70c2a86beca33a9cf671b5a6afa1a
Rust
umatbro/p-tutorials
/rust/advent-of-code/day13/src/main.rs
UTF-8
728
2.671875
3
[]
no_license
use itertools::Itertools; use packet::Pair; use std::{ fs::File, io::{BufRead, BufReader}, }; mod packet; mod parse; fn main() { let is_test = false; let filename = if is_test { "input.test" } else { "input" }; let file = File::open(filename).unwrap(); let reader = BufReader::new(file); l...
true
033b082a89e817f7e3fce2709cc5f874383f1cc0
Rust
DevHyperCoder/alpc
/src/constants.rs
UTF-8
478
2.65625
3
[]
no_license
pub fn get_terms() -> Vec<&'static str> { vec![ "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu", ...
true
6470dc2b0d08c7d3bdc2a47985b47d53ae38c6a5
Rust
drwilco/aoc
/2019/day9/src/bin/first.rs
UTF-8
8,269
2.96875
3
[]
no_license
use std::io; use std::fs; use std::collections::VecDeque; #[derive(Debug, PartialEq)] enum ParamMode { Position, Immediate, Relative, } fn param_mode(digit: isize) -> ParamMode { match digit { 0 => ParamMode::Position, 1 => ParamMode::Immediate, 2 => ParamMode::Relative, _ => panic!("i...
true
dcab2140ccbeda79d5c5206826bc8bc1b3d7fa92
Rust
jrybicki-jsc/rusty
/bren/src/main.rs
UTF-8
1,661
3.171875
3
[]
no_license
use std::fs; use std::str::FromStr; use std::collections::HashMap; const BENFORD:[f64; 9] = [30.1, 17.6, 12.5, 9.7, 7.9, 6.7, 5.8, 5.1, 4.6]; fn get_data(fname: &str) -> HashMap::<usize, usize> { let co = fs::read_to_string(fname).expect(&format!("Failed to open datafile {}", fname)); println!("Got data {}",...
true
2005e732132bf0af53730761a165a1c877d9ac54
Rust
fkohlgrueber/token-editor
/src/lib.rs
UTF-8
9,915
2.828125
3
[]
no_license
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender}; use yew::services::ConsoleService; use stdweb::web::event::KeyDownEvent; use stdweb::web::event::IKeyboardEvent; use stdweb::web::event::IEvent; mod content; use content::{Content, GetString}; const TEXT_SIZE: usize = 12; pub struct Model { ...
true
c9005b9386348162d7a00a76545de7af87e7fb99
Rust
l0x539/chess-0x539
/src/chess_core/perms.rs
UTF-8
49,844
2.6875
3
[]
no_license
extern crate array_tool; use super::board::Board; use super::piece::Piece; use super::square::Square; use super::utils::draw_ray; use array_tool::vec::Intersect; pub struct Perms; impl Perms { pub fn is_can_move(&self, board :&Board, piece :&Piece, square: &Square) -> bool{ if board.turn != piece.side {r...
true
2a2a7f54bfd572246e1400402107f0b7543a1587
Rust
aiden0z/snippets
/lang/rust/enums/src/main.rs
UTF-8
3,660
3.890625
4
[ "MIT" ]
permissive
#[derive(Debug)] enum IpAddrKind { V4, V6, } #[derive(Debug)] struct IpAddr { kind: IpAddrKind, address: String, } // 可以使得枚举成员关联到某一种类型 // 每个成员可以处理不同类型和数量的数据 #[derive(Debug)] enum IpAddrType { V4(String), V6(String), } // 可以将任意类型的数据放入枚举成员中:例如字符串、数字类型或者结构体。甚至可以包含另一个枚举 #[derive(Debug)] enum Mess...
true
f45c4abfe8a0821b97c81827431d3560b1c45665
Rust
ratijas/mess
/mess-stats/src/db.rs
UTF-8
6,875
2.65625
3
[]
no_license
use std::io::Read; use std::path::Path; use std::fs; use std::result; use std::sync::Mutex; use rusqlite::*; use mime::Mime; use mime_guess; const PATH: &str = "./stats.db"; const SCHEMA: &str = "./data/schema.sql"; lazy_static! { static ref GLOBAL_CONNECTION: Mutex<Connection> = Mutex::new(Connection::open(PAT...
true
3fcb56943fef870e47d58a6609949b31d2943207
Rust
dylatos9230/WaGraphic
/src/tools.rs
UTF-8
11,166
2.53125
3
[ "MIT" ]
permissive
use web_sys::WebGlRenderingContext as GL; use web_sys::*; use nalgebra::{Matrix4,Perspective3}; extern crate wasm_bindgen; use wasm_bindgen::prelude::*; use super::config::*; #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = console)] pub fn log(s: &str); } pub fn get_grid_normals(n: usize, y_vals: &...
true
d692579c94976cf51b863805e834fbe53311f61c
Rust
Lyndon-Mackay/ecology
/src/forests/simple_forest.rs
UTF-8
27,913
3.328125
3
[]
no_license
use crate::terrain::*; use std::fmt; use rand::Rng; #[derive(Clone, Debug, PartialEq, Eq)] pub struct Forest { layout: Vec<ForestFeature>, size: usize, } impl Forest { /// /// Generates a forest of specified size /// the height and width are always the same /// size /// pub fn new(siz...
true
c5885eed094400955434ebf49880e0454b742ffd
Rust
Kryndex/symbolic
/cabi/src/demangle.rs
UTF-8
1,364
2.96875
3
[ "MIT", "Apache-2.0" ]
permissive
use symbolic_demangle::Symbol; use symbolic_common::Language; use core::SymbolicStr; ffi_fn! { /// Demangles a given identifier. /// /// This demangles with the default behavior in symbolic. If no language /// is specified, it will be auto-detected. unsafe fn symbolic_demangle( ident: *con...
true
e298a04cce7949c25ae7d996f6a38ec16d3577d7
Rust
mredlek/rs-opentherm
/src/application/dataid0.rs
UTF-8
5,141
2.515625
3
[ "MIT" ]
permissive
use super::{DataClass, DataIdDefinition, Flags8}; use ::std::marker::PhantomData; use ::serde::{Serialize, Deserialize, Serializer, Deserializer}; pub type DataIdSimpleType = (Flags8, Flags8); pub(crate) static DATAID_DEFINITION : DataIdDefinition<DataIdSimpleType,DataIdType> = DataIdDefinition { data_id...
true
aad424a6fc497227ae59d8acd9f1c736a2ff4fd4
Rust
enso-org/enso
/app/gui/view/src/project/project_view_top_bar.rs
UTF-8
2,268
2.84375
3
[ "AGPL-3.0-only", "Apache-2.0", "AGPL-3.0-or-later" ]
permissive
//! Defines a UI container for the window control buttons and the "go to dashboard" button. This is //! merely here to make use of the auto-layout functionality. use ensogl::prelude::*; use enso_config::ARGS; use ensogl::application::Application; use ensogl::display; mod go_to_dashboard_button; pub mod window_cont...
true
fa6af3315d7314595fc1cbfe106ef3714478490e
Rust
That3Percent/twitter-sentiment-graphs
/src/webserver.rs
UTF-8
1,654
2.78125
3
[]
no_license
use crate::aggregator::Aggregator; use crate::prelude::*; use rocket::response::NamedFile; use rocket::{self, get, routes, State}; use rocket_contrib::json::Json; use serde::Serialize; use std::sync::{Arc, RwLock}; #[get("/")] fn index() -> Option<NamedFile> { NamedFile::open("index.html").ok() } #[get("/data")] ...
true
c7cc35032220b71a332051481839388b2f86ce01
Rust
Rust-SDL2/rust-sdl2
/src/sdl2/gfx/rotozoom.rs
UTF-8
3,985
3
3
[ "MIT" ]
permissive
//! Surface Rotozoomer use get_error; use libc::c_int; pub use std::f64::consts::PI; use surface::Surface; use sys::gfx::rotozoom; /// `RotozoomSurface` for work with rust-sdl2 Surface type pub trait RotozoomSurface { /// Rotates and zooms a surface and optional anti-aliasing. fn rotozoom(&self, angle: f64, z...
true
29c2f3892c00abf4d155de57c231ea0e0bad1301
Rust
johnstonskj/simple-locale
/src/settings/locale.rs
UTF-8
7,927
3.5625
4
[ "MIT" ]
permissive
/*! Provides ability to get/set the current process locale. This module allows the client to fetch and set locales for different `Category` values, or for all. This is a core capability for clients to be able to set the current locale for their process. If you only plan to set the locale, get settings, and then reset ...
true
a00bc7bd21609f0f8460e86b6cdcfa25dfa39ff7
Rust
alexburroughs/piston-test
/piston-test/src/Map/maploader.rs
UTF-8
573
3.171875
3
[]
no_license
pub mod Map { use std::fs::File; use std::io::prelude::*; pub struct Map { tile : Vec<Vec<u64>>, size : (i32, i32) } fn load_file(path : String) -> Option<String> { let file_path = File::open(path); let mut file : File; let mut map_string = String::new(); ...
true
479c19768df4f72fc196ad84bac40bc4c7265370
Rust
mrhatman/CoGeoRs
/src/primatives2d.rs
UTF-8
7,283
3.859375
4
[ "Apache-2.0" ]
permissive
use num_traits::Float; use num_traits::Zero; use std::cmp::Ordering; ///2D Point #[derive(Copy,Clone,Debug,PartialEq,Eq)] pub struct Point2D<T: Float+Zero>{ ///Point's x position pub x : T, ///Point's y position pub y : T, } impl<T: Float+Zero> Point2D<T >{ ///Creates a Point. pub fn new(x:T,y:T) -> Self{ Po...
true
482be142c7508b1b64f11d4a392898c075bbf40b
Rust
qapquiz/kairos
/src/packet_writer.rs
UTF-8
2,580
3.1875
3
[ "MIT" ]
permissive
use byteorder::{LittleEndian, WriteBytesExt}; use std::io::Result; pub struct PacketWriter { pub buffer: Vec<u8>, } impl PacketWriter { pub fn new() -> PacketWriter { PacketWriter { buffer: Vec::new() } } pub fn write_packet_id(&mut self, packet_id: u16) { self.buffer.write_u16::<Litt...
true
7513ff058b2c603644a8ffe0079a0b52c7af5f48
Rust
falk-h/apk.rs
/src/main.rs
UTF-8
5,912
2.6875
3
[]
no_license
use serde_json::{json, Value}; use std::env; use std::sync::{Arc, RwLock}; use systemet::{Product, Systemet}; use tera::{Context, Tera}; use warp::{reply::html, Filter}; const TEMPLATE_GLOB: &str = "templates/*"; const TEMPLATE: &str = "apk.html"; const KEY_ENV_VAR: &str = "APK_API_KEY"; const PORT_ENV_VAR: &str = "AP...
true
c9f05601d696c6e3ca097db4c35d941c30a23a08
Rust
n4j/kata-containers
/src/agent/rustjail/src/utils.rs
UTF-8
3,550
3.140625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) 2021 Ant Group // // SPDX-License-Identifier: Apache-2.0 // use anyhow::{anyhow, Context, Result}; use libc::gid_t; use libc::uid_t; use std::fs::File; use std::io::{BufRead, BufReader}; const PASSWD_FILE: &str = "/etc/passwd"; // An entry from /etc/passwd #[derive(Debug, PartialEq, PartialOrd)] pub ...
true
e6d1d38c1183868204463a80c3f2f7dd0cd9dcb1
Rust
kezenator/beam
/src/desc/veach.rs
UTF-8
5,546
2.609375
3
[ "MIT" ]
permissive
use crate::camera::Camera; use crate::color::SRGB; use crate::desc::{CameraDescription, SceneDescription, SceneSelection, StandardScene}; use crate::geom::{Aabb, Rectangle, Sphere, bounds::BoundedSurface, csg::Merge, csg::Difference}; use crate::lighting::LightingRegion; use crate::math::Scalar; use crate::material::Ma...
true
fcee4fdfd1199aeba59c9c29e8a3234aa0f85636
Rust
Wattyyy/LeetCode
/submissions/dungeon-game/solution.rs
UTF-8
2,642
2.953125
3
[ "MIT" ]
permissive
use std::cmp::max; use std::collections::VecDeque; impl Solution { pub fn calculate_minimum_hp(dungeon: Vec<Vec<i32>>) -> i32 { let mut ans = 40000001; let row_len = dungeon.len(); let col_len = dungeon[0].len(); let mut left = 1; let mut right = 40000001; while le...
true
f9e3e1e53a26851a1d1c03e4cb389d4e11d7148b
Rust
fruit-in/exercism-solution
/rust/xorcism/src/lib.rs
UTF-8
2,693
3.0625
3
[ "MIT" ]
permissive
use std::borrow::Borrow; use std::io::{Read, Result, Write}; #[derive(Clone)] pub struct Xorcism<'a> { key: &'a [u8], start: usize, } pub trait MungeOutput: Iterator<Item = u8> + ExactSizeIterator {} impl<T> MungeOutput for T where T: Iterator<Item = u8> + ExactSizeIterator {} pub struct CustomedIterator<I>(...
true
6b41c40a0811f6d9deb51067dca99598add10c86
Rust
ciaran2/feo3boy
/feo3boy-player/src/executor_selector.rs
UTF-8
6,600
2.921875
3
[ "MIT" ]
permissive
//! Defines types for selecting between different executors. use std::marker::PhantomData; use std::mem; use clap::ValueEnum; use feo3boy::gbz80core::direct_executor::DirectExecutor; use feo3boy::gbz80core::direct_executor_v2::DirectExecutorV2; use feo3boy::gbz80core::executor::{Executor, ExecutorConfig, ExecutorState...
true
d6f735a2e8e1c819bc8309857e3408441cbda255
Rust
d3lio/lexpar
/examples/ml.rs
UTF-8
860
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
#[macro_use] extern crate lexpar; mod ml_family; const SRC: &str = r#" fn f a b c d e f = a + 2 * (f 1) + 3 123 fn id x = x id 1 fn main args = let a = 1 let b = 2 let c = |x| x if a == 1 then c a else c b if a == 1 then c a else if b == 1 then c b else c ...
true
1066e43a2bf4b89c3977b41b3bb80afd550d0514
Rust
shigedangao/lymui
/lymui/src/util.rs
UTF-8
960
3.59375
4
[ "MIT" ]
permissive
use std::f64::consts::PI; pub(crate) trait AsFloat { /// Return inner struct field as a tuple of float64 fn as_f64(&self) -> (f64, f64, f64); } pub trait AsVec { type Item; /// Return a struct as a vector of inner field fn as_vec(&self) -> Vec<Self::Item>; } pub trait FromVec<K> { fn from_vec...
true
a716cffdad036a1af3e4e47a6f804042db811d78
Rust
tifennf/rust-todoapp-backend
/src/schemas.rs
UTF-8
559
2.828125
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] pub struct ApiResponse<T> { pub status: String, pub data: T, } #[derive(Serialize, Deserialize)] pub struct ApiError { pub error: String, } #[derive(Serialize, Deserialize)] pub struct Todo { pub content: Option<String>, pub chec...
true
e7515fb4cc4752523c8aec025ec5b08612921e8a
Rust
gharib85/toys
/leetcode/79-word-search.rs
UTF-8
3,458
3.578125
4
[ "MIT" ]
permissive
// 79. Word Search // https://leetcode.com/problems/word-search/ struct Solution {} impl Solution { pub fn exist(board: Vec<Vec<char>>, word: String) -> bool { SolutionHelper::new(board, word).exist() } } struct SolutionHelper { board: Vec<Vec<char>>, x_len: usize, y_len: usize, point...
true
e89d10232ec04b172f475cc4bcca278add5e809f
Rust
quinn-rs/quinn
/quinn-udp/src/cmsg.rs
UTF-8
3,941
3.125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::{mem, ptr}; #[derive(Copy, Clone)] #[repr(align(8))] // Conservative bound for align_of<cmsghdr> pub(crate) struct Aligned<T>(pub(crate) T); /// Helper to encode a series of control messages ("cmsgs") to a buffer for use in `sendmsg`. /// /// The operation must be "finished" for the msghdr to be usable, eith...
true
647c467c50a5dc4d8583816aa42a6ab376a5d3a0
Rust
nabijaczleweli/bloguen
/src/ops/descriptor.rs
UTF-8
24,395
2.703125
3
[ "MIT" ]
permissive
use self::super::{MachineDataKind, ScriptElement, StyleElement, CenterOrder, LanguageTag, FeedType, feed_type_footer, feed_type_header}; use self::super::super::util::{concat_path, path_depth, mul_str}; use std::collections::{BTreeMap, BTreeSet}; use toml::de::from_str as from_toml_str; use self::super::super::Error; u...
true
4707889e42ba326c9f3cec03ed0046b6a978ef67
Rust
mishaszu/RUST-INTRO
/src/ex1/if_while_for/src/while_loop.rs
UTF-8
404
3.328125
3
[]
no_license
fn while_and_loop() { let mut x = 1; while x < 1000 { x *= 2; if x == 64 { continue; } println!("while loop x = {}", x) } let mut y = 1; loop { y *= 2; println!("loop loop y = {}", y); if y == 1 << 10 { break; } ...
true
9924add003ba89d5828469a25d445e8a509f837e
Rust
dennisss/dacha
/pkg/protobuf/core/src/reflection.rs
UTF-8
9,338
2.875
3
[ "Apache-2.0" ]
permissive
use alloc::boxed::Box; use alloc::string::String; use alloc::vec::Vec; use core::convert::Infallible; use core::default::Default; use core::ops::{Deref, DerefMut}; use common::bytes::BytesMut; use common::collections::FixedString; use common::fixed::vec::FixedVec; use common::list::List; use crate::message::Enum; use...
true
f94c5a5205b91716786a5fc2a6dfa65df66bf109
Rust
hardvain/yata
/src/indicators/woodies_cci.rs
UTF-8
3,782
2.625
3
[ "Apache-2.0" ]
permissive
#[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::core::{Error, Method, PeriodType, Source, ValueType, OHLCV}; use crate::core::{IndicatorConfig, IndicatorInstance, IndicatorResult}; use crate::helpers::signi; use crate::methods::{Cross, CCI}; const SCALE: ValueType = 1.0 / 1.5; /// Woodies C...
true
9be6668f5cbac4a6bb76925d77b0c97cfb32ef59
Rust
Jibbow/arrow2
/src/array/growable/boolean.rs
UTF-8
3,098
3.203125
3
[ "Apache-2.0" ]
permissive
use std::sync::Arc; use crate::{ array::{Array, BooleanArray}, bitmap::MutableBitmap, }; use super::{ utils::{build_extend_null_bits, ExtendNullBits}, Growable, }; /// A growable PrimitiveArray pub struct GrowableBoolean<'a> { arrays: Vec<&'a BooleanArray>, validity: MutableBitmap, values...
true
26fc8ad975410fb2f9aaea60f12d840f0a983d07
Rust
tobyjsullivan/print-srv
/src/printer/compression.rs
UTF-8
447
2.953125
3
[]
no_license
#[derive(Copy, Clone, Debug)] pub enum Compression { None, Deflate, GZip, Compress, } impl From<Compression> for String { fn from(c: Compression) -> Self { match c { Compression::None => String::from("none"), Compression::Deflate => String::from("deflate"), ...
true
8d8f7d3c00fc10f715cf7cd64b59ce47b64e0614
Rust
NaurizAitbai/distant
/tests/cli/action/metadata.rs
UTF-8
9,442
2.53125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::cli::{ fixtures::*, utils::{random_tenant, regex_pred, FAILURE_LINE}, }; use assert_cmd::Command; use assert_fs::prelude::*; use distant::ExitCode; use distant_core::{ data::{Error, ErrorKind, FileType, Metadata}, Request, RequestData, Response, ResponseData, }; use rstest::*; const FILE_CON...
true
bac713605cd1d9ea3a423ad9949f886b20347320
Rust
cogciprocate/ocl
/ocl-core/src/error.rs
UTF-8
2,654
2.921875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Standard error type for ocl. //! use crate::functions::{ApiError, ApiWrapperError, ProgramBuildError, VersionLowError}; use crate::util::UtilError; use crate::{EmptyInfoResultError, Status}; /// Ocl error result type. pub type Result<T> = ::std::result::Result<T, Error>; /// An enum one of several error types. #...
true
36f23d761addd2731a0659a38abbe316820ee859
Rust
vincenthz/rust-pvss
/src/scrape.rs
UTF-8
7,807
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
// implementation of SCRAPE: Scalable Randomness Attested by Public Entities // https://eprint.iacr.org/2017/216.pdf use super::crypto::*; use super::dleq; use super::math; use super::pdleq; use super::types::*; pub type Secret = Point; // a new escrowing context. // this contains secret values (polynomial & secret)...
true
7bd5f105c92a94bd860d38db12a6c5aae1766ac9
Rust
ihrwein/actiondb
/src/parsers/int.rs
UTF-8
2,722
3.46875
3
[]
no_license
use std::hash::{SipHasher, Hash, Hasher}; use parsers::{Parser, ObjectSafeHash, SetParser, ParseResult, HasLengthConstraint}; #[derive(Clone, Debug, Hash)] pub struct IntParser { delegate: SetParser, } impl IntParser { pub fn with_name<S: Into<String>>(name: S) -> IntParser { let delegate = SetParser...
true
f610cd4da6ff9a0b1a0764bb07acfc8f95ea48bd
Rust
zerfix/music-compressor
/src/converters/path.rs
UTF-8
1,163
3.015625
3
[ "MIT" ]
permissive
use std::ffi::OsStr; use std::path::PathBuf; use crate::constants::LOSSLESS; use crate::types::config::Dir; //-//////////////////////////////////////////////////////////////////////////// // Path Transforms //-//////////////////////////////////////////////////////////////////////////// /// Convert input path to its ...
true
ca65d6619255e458c4ca8ac7b3bc5e813fbe22c6
Rust
isgasho/em-refactor
/em-refactor-examples/split_conflicting_match_arms/match_expr.rs
UTF-8
206
2.5625
3
[ "Apache-2.0" ]
permissive
fn main() { match (S {f: 0, g: 1}) { S {f, g: 1} | S {f: 1, g: f} => {let _: i32 = f;}, _ => {} } } struct S {f: i32, g: i32} // in match arm body of line 3: f binds to either f or g
true
f5cb5ebca9e9693e151dde71c19d9c8a9943ec9e
Rust
mango-cell/dropbox-sdk-rust
/src/client_helpers.rs
UTF-8
6,594
2.8125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) 2019-2020 Dropbox, Inc. use std::fmt::Debug; use std::marker::PhantomData; use crate::Error; use crate::client_trait::*; use serde::de::{self, Deserialize, DeserializeOwned, Deserializer, MapAccess, Visitor}; use serde::ser::Serialize; // When Dropbox returns an error with HTTP 409, it uses an implic...
true
8f9c2d94d2639948d5cf9fba63d29a87ed834914
Rust
isgasho/doku
/doku/examples/arrays.rs
UTF-8
336
2.9375
3
[ "MIT" ]
permissive
use doku::prelude::*; #[derive(Doku)] struct Type { #[doku(example = "one")] foos: Vec<String>, #[doku(example = r#"["one", "two", /* ... */]"#)] bars: Vec<String>, #[doku(example = "[\n\t\"one\",\n\t\"two\",\n\t/* ... */\n]")] zars: Vec<String>, } fn main() { println!("{}", doku::to_jso...
true
1185a2dcb799104b13b70a4e43a594a8f54fb916
Rust
joshradin/modular_lang
/virtual_machine/src/instruction_set/arithmetic.rs
UTF-8
8,255
3.03125
3
[]
no_license
use super::*; pub struct OverflowingResult(pub Result<(Immediate, bool), Fault>); impl From<(u8, bool)> for OverflowingResult { fn from(t: (u8, bool)) -> Self { OverflowingResult(Ok((U8(t.0), t.1))) } } impl From<(u16, bool)> for OverflowingResult { fn from(t: (u16, bool)) -> Self { Overf...
true
0cbc546d7465dbbc0426aa5f5b0f680e859992fb
Rust
JPMoresmau/rust-linear
/src/nn.rs
UTF-8
11,663
2.765625
3
[]
no_license
//! Neural networks use crate::matrix::*; /// a network #[derive(Debug)] pub struct Network { // activation functions activations: Vec<Box<dyn Activation>>, // topology topology: Vec<usize>, // weights weights: Vec<Matrix> } impl Network { /// create a new random network with the given top...
true
35e44618e43e02a0d7e07024bd307b2a204a939b
Rust
sdamashek/chip8
/src/cpu.rs
UTF-8
15,725
3.125
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::ErrorKind; use std::{thread, time}; use rand; use rand::Rng; use graphics::{Graphics, DrawResult}; use parsing::Instruction; // A CPUState struct represents the internal state of a Chip8 CPU. // It includes a Graphics struct implemented in graphics.rs. #[allow(...
true
ff15c668f4bac0116ba35d602ce78140074df8a9
Rust
simonfromwales/lxp-bridge
/src/lxp/packet_decoder.rs
UTF-8
1,492
2.6875
3
[ "MIT" ]
permissive
use crate::prelude::*; use bytes::{Buf, BytesMut}; use std::io::{Error, ErrorKind}; use tokio_util::codec::Decoder; pub struct PacketDecoder(()); impl PacketDecoder { #[allow(clippy::new_without_default)] pub fn new() -> Self { Self(()) } } impl Decoder for PacketDecoder { type Item = Packet...
true
edf319260f9bcccc6e0cc67cb488df74cb09125f
Rust
dndll/dockerui
/src/components/volumes.rs
UTF-8
2,500
2.625
3
[ "BSD-3-Clause" ]
permissive
use anyhow::Error; use bollard::models::{ImageSummary, Volume}; use bollard::service::ContainerSummaryInner; use itertools::Itertools; use tui::backend::Backend; use tui::Frame; use tui::layout::{Rect}; use tui::style::{Color, Modifier, Style}; use tui::text::{Span, Spans}; use tui::widgets::{Block, Borders, List, List...
true
3350b483a46fceebc9d3822ca43b917e690ab53a
Rust
valekar/rust-web-app
/rust-backend/src/tests/test_helpers.rs
UTF-8
3,679
2.953125
3
[ "MIT" ]
permissive
mod test_db; use crate::State; use crate::{server, Server}; use futures::prelude::*; use serde::de::DeserializeOwned; use serde::Serialize; pub use serde_json::{json, Value}; use std::collections::HashMap; use std::pin::Pin; use test_db::TestDb; use tide::{ http::{Method, Request, Response, Url}, StatusCode, }...
true
5ed8135059a16434c404fe3c6690d6f1ccf49463
Rust
HackGT/enzo
/src/todos/ui.rs
UTF-8
2,913
2.65625
3
[]
no_license
use crate::todos::app::App; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, widgets::{Block, Borders, List, Paragraph, Text}, Frame, }; pub fn draw<B: Backend>(f: &mut Frame<B>, app: &mut App) { let chunks = Layout::default() .direc...
true
2ff068eed6bf222ca463a54c8404696c2d6bac1d
Rust
matthieu-m/stysh
/stysh-compile/src/basic/com.rs
UTF-8
14,552
3.03125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Common utilities //! //! A standard vocabulary used throughout the code. use std::{self, cmp, convert, fmt, hash, iter, marker, num, ops, sync}; use crate::basic::sea::TableIndex; /// A fragment of source code. #[derive(Clone)] pub struct CodeFragment(sync::Arc<Vec<u8>>); impl CodeFragment { /// Creates a n...
true
9162eb5d45a50cf38210bc6ed90503672d3feab4
Rust
marcogroppo/rs_mxf
/src/klv/value/element.rs
UTF-8
1,112
2.90625
3
[ "MIT" ]
permissive
use klv::ul::Ul; use klv::value::value_data::*; #[derive(Debug, Clone, PartialEq)] pub struct Element { pub identifier: Ul, pub value: Option<ValueData>, } #[macro_export] macro_rules! build_element { ($ul:expr, uint16 => $value:expr) => ( Element { identifier: $ul, value: Some( ValueData::Uint16{ ...
true
3270322d5980491b02961aeaa60c9f790d679007
Rust
idheepan/max31856-rs
/src/registers.rs
UTF-8
2,821
2.890625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/// Registers that can be written to and read from. Uses different addresses pub struct ReadWriteRegister { pub read_address: u8, pub write_address: u8, pub factory_default: u8, } /// Registers that can only be read from pub struct ReadOnlyRegister { pub read_address: u8, } pub struct Registers {} im...
true
92276f483189ed42c4adc92da2f11e44aaf413f9
Rust
JakDar/nlp-lab-2019
/lab5/rust/src/tag.rs
UTF-8
8,313
2.609375
3
[]
no_license
use crate::utils; use core::borrow::Borrow; use core::fmt::Pointer; use itertools::Batching; use rand::Rng; use serde::{Deserialize, Serialize}; use serde_json; use std::collections::{HashMap, HashSet}; use std::fs::read_to_string; use std::fs::write; use std::process::exit; use std::thread; use std::thread::JoinHandle...
true
da04f4da1a4cf12e150bf4c0cbba63fe8b92052d
Rust
WaltersDilemma/fibo
/src/main.rs
UTF-8
1,618
3.5625
4
[]
no_license
extern crate rand; use std::io; use std::cmp::Ordering; use rand::Rng; fn main() { /* let x = rand::random::<u8>(); println!("{}", x); let y = rand::random::<f64>(); println!("{}", y); if rand::random() { // generates a boolean println!("Better lucky than good!"); } */ println!("Fibonacci-Zahle...
true
cedd6e7ce3a69f1705fddf017d7334ea0133435f
Rust
CoZZmOnAvT/42-Piscine-C-In-Rust
/sqrt/src/main.rs
UTF-8
754
3.484375
3
[]
no_license
fn safe_sqrt(n: f64) -> Result<f64, String> { let result = n.sqrt(); if result.is_nan() { Err(format!("Can't compute square root for {}", n)) } else { Ok(result) } } #[cfg(test)] mod tests { #[test] fn test_safe_sqrt() { assert_eq!(crate::safe_sqrt(4.0), Ok(2.0)); ...
true
57f680909d56443e8afd6ba275879948e186ec11
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/serde_yaml/src/number.rs
UTF-8
10,233
3.015625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::Error; use serde::de::{Unexpected, Visitor}; use serde::{forward_to_deserialize_any, Deserialize, Deserializer, Serialize, Serializer}; use std::cmp::Ordering; use std::fmt::{self, Debug, Display}; use std::hash::{Hash, Hasher}; use std::i64; #[derive(Clone, PartialEq, PartialOrd)] pub struct Number { ...
true
55461f0c2af25b06a76cb5e6746bea02c7fd064b
Rust
rudolphalmeida/raytrac
/src/io/write.rs
UTF-8
811
2.953125
3
[ "MIT" ]
permissive
extern crate image; use std::path::Path; use cgmath::Vector3; // Refer: https://github.com/ranveeraggarwal/rust-raytracer/blob/master/src/io/write.rs pub fn write_img(img: &[Vec<Vector3<f64>>], filename: &str) { let path = Path::new(&filename); let display = path.display(); let size_y = img.len() as u32;...
true
364301ff63567665fd668210c7d68dec93e03844
Rust
shigedangao/lymui
/lymui/src/xyz/srgb.rs
UTF-8
4,865
2.828125
3
[ "MIT" ]
permissive
use super::{ matrices::xyz::{RX65, RY65, RZ65, X65, Y65, Z65}, transfer::GammaCorrection, Xyz, }; use crate::{ rgb::Rgb, util::{AsFloat, AsVec, FromVec}, }; #[cfg(feature = "js")] use crate::js::prelude::*; /// Implementation of the sRGB colorspace. /// The foruma can be found on the link below //...
true
9476a5448e856a5a21513c0779728d0f428b1319
Rust
cswinter/prom-attire-rs
/tests/flag_value.rs
UTF-8
2,376
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
#[macro_use] extern crate prom_attire; #[macro_use] extern crate quote; extern crate syn; use std::net::{IpAddr, Ipv4Addr}; #[test] fn default_flag_value_bool() { #[derive(PromAttire)] struct A { // bool without a `flag_value` setting should default to true b: bool, } let input = quote...
true
5ddfa8cd7321606622d254a8c1b50a09bc6d82d2
Rust
rust-chainblock/blockchain7
/peers/src/error.rs
UTF-8
3,954
2.515625
3
[]
no_license
// Copyright (c) 2018-2021 The MobileCoin Foundation //! A Peer-to-Peer networking error. use crate::ConsensusMsgError; use displaydoc::Display; use grpcio::Error as GrpcError; use mc_connection::AttestationError; use mc_consensus_api::ConversionError; use mc_consensus_enclave_api::Error as EnclaveError; use mc_trans...
true
6bf0c56e0623f1c3b65801ce25874e2e26c53e76
Rust
wkcn/leetcode
/1501-1600/1546-maximum-number-of-non-overlapping-subarrays-with-sum-equals-target.rs
UTF-8
985
3.5625
4
[]
no_license
struct Solution {} impl Solution { pub fn max_non_overlapping(nums: Vec<i32>, target: i32) -> i32 { let mut presum = vec![0]; nums.iter().fold(0, |acc, x| { let s = acc + x; presum.push(s); s }); // 假设当前遍历的值为某个右区间,它是否是最终结果的区间? // 肯定是。贪心 +...
true
d8d15c32dffbc5158f57666159152b4a2da5ab32
Rust
Dentosal/aw-server-rust
/aw-models/src/timeinterval.rs
UTF-8
3,220
3.5
4
[]
no_license
use std::fmt; use serde::de::{self, Visitor, Deserialize, Deserializer}; use chrono::DateTime; use chrono::Duration; use chrono::Utc; #[derive(Clone,Debug)] pub struct TimeInterval { start: DateTime<Utc>, end: DateTime<Utc> } #[derive(Debug)] pub enum TimeIntervalError { ParseError() } impl TimeInterva...
true
701cb7de1b254e711f9155306791429935ed7e22
Rust
vinaychandra/relic-os
/crates/common/relic-std/src/raw_syscall.rs
UTF-8
2,298
2.78125
3
[]
no_license
use core::convert::TryInto; use relic_abi::{cap::CapabilityErrors, syscall::SystemCall}; /// Make a raw syscall. /// This first converts the syscall into its register representation and then sends the info /// to the kernel. #[inline] pub fn make_syscall(syscall: &SystemCall) -> Result<(u64, u64), CapabilityErrors> {...
true
64974d346cfdffbb6d71ce8a003e7ec6077ce29f
Rust
solipsis/advent-of-code-2020
/day_22/src/main.rs
UTF-8
3,481
3.3125
3
[]
no_license
use std::collections::VecDeque; use std::collections::HashSet; fn main() { let input: Vec<String> = std::fs::read_to_string("input.txt").unwrap() .trim() .split("\n\n") .map(|x| x.to_owned()) .collect(); let p1: VecDeque<u8> = input[0].split("\n").skip(1).map(|x| x.parse()...
true
ba06758e752e053ad5223e5361f1e588c73f80fa
Rust
Dooskington/LD46-Lighthouse-Keeper
/gfx-lib/src/input.rs
UTF-8
3,617
2.984375
3
[ "Zlib" ]
permissive
use crate::Point2d; use ::winit::{event::ElementState, event::KeyboardInput, dpi::PhysicalPosition}; use std::collections::HashMap; pub use ::winit::event::{MouseButton, VirtualKeyCode}; #[derive(Default, Clone)] pub struct InputState { current_keys: HashMap<VirtualKeyCode, bool>, pressed_keys: HashMap<Virtua...
true
e4b986292a220ab5e38d40c81c36a8be2f2e8cc8
Rust
chiliseed/cli
/src/api_client/endpoints/resources.rs
UTF-8
1,999
2.6875
3
[]
no_license
use serde::{Deserialize, Serialize}; use crate::api_client::types::ApiResult; use crate::api_client::utils::deserialize_body; use crate::api_client::ApiClient; use crate::schemas::{Bucket, Resource}; impl ApiClient { pub fn get_resource_details(&self, resource_slug: &str) -> ApiResult<Resource> { let (res...
true
5282fac8d591a53c3cbf5a189c91c217dd1474bf
Rust
Dedda/regal
/src/net/web/gallery.rs
UTF-8
1,322
3.28125
3
[]
no_license
use askama::Template; use rocket::Rocket; use rocket::response::status::NotFound; use crate::database::model::Gallery; pub fn mount(rocket: Rocket) -> Rocket { rocket.mount("/web/gallery", routes![by_id, new]) } #[derive(Template)] #[template(path = "web/gallery.html", escape = "none")] struct GalleryPage { g...
true
2874d9a31e1bdbcbade6fe5c9d9781dc2f41be68
Rust
Fomys/rustracer
/src/raytracer/integrators/parallel_integrator.rs
UTF-8
2,740
2.796875
3
[ "MIT" ]
permissive
use std::sync::{mpsc, Arc}; use threadpool::ThreadPool; use crate::raytracer::camera::Camera; use crate::raytracer::color::BLACK; use crate::raytracer::integrators::Integrator; use crate::raytracer::scene::Scene; pub struct ParallelIntegrator { camera: Camera, scene: Arc<Scene>, } impl ParallelIntegrator { ...
true
b7ae02512bc0b19e707dbd7d70c6ae0b55f064a2
Rust
rcarson3/Rust_Language_Trials
/Final_Project/mt_server/src/lib.rs
UTF-8
5,433
3.875
4
[ "MIT" ]
permissive
use std::thread; use std::sync::mpsc; use std::sync::Arc; use std::sync::Mutex; //We're doing a little bit of refactoring to have a vector of workers which has an //id and a JoinHandle. It will also be what handles the closure //We want our workers to either fetch a job or terminate depending on what message is being ...
true
150ac5b1166651366e5b23e04389e4e9b097ac8a
Rust
carrolita/shelfdb
/memory_cache/src/memory_cache_schema.rs
UTF-8
4,054
3
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::memory_cache_collection::MemoryCacheCollection; use failure::Error; use futures::{ future::BoxFuture, stream, stream::BoxStream, FutureExt, StreamExt, }; use shelf_database::{ CacheCollection, CacheSchema, Collection, Schema, }; use std::{ collections::HashMap, syn...
true
8a84c5b7c3ae0a30a4285f4546087e2a2664878c
Rust
gjz010/smartpi
/src/livestream.rs
UTF-8
10,726
2.546875
3
[]
no_license
use std::collections::{HashMap, BTreeMap}; use tokio::sync::mpsc::*; use std::{thread, fs}; use crate::camera::CameraProvider; use std::sync::Arc; use std::cell::RefCell; use tokio::sync::mpsc::error::TrySendError; use tokio::sync::mpsc::error::ErrorKind; use std::io::Write; use std::sync::mpsc as bchan; pu...
true
b27b4492dde9880d4985aabbf9564bf2ae541ba1
Rust
libellis/survey-manager
/survey-manager-core/src/value_objects/description.rs
UTF-8
739
3.046875
3
[]
no_license
use domain_patterns::models::ValueObject; use crate::errors::{Error, Result}; use crate::value_objects::ValidationError; #[derive(ValueSetup)] pub struct Description { value: String, } impl ValueObject<String> for Description { type ValueError = Error; fn validate(value: &String) -> Result<()> { ...
true
f17daf0e233e39a99bcb605d055d4238917efa6a
Rust
xiuxiu62/wasm-cgol
/src/lib.rs
UTF-8
930
2.671875
3
[]
no_license
// #![feature(wasm_custom_section, wasm_import_module)] use wasm_bindgen::prelude::*; #[wasm_bindgen] extern "C" { fn alert(s: &str); type HTMLDocument; type Element; static document: HTMLDocument; #[wasm_bindgen(method)] fn createElement(this: &HTMLDocument, tagName: &str) -> Element; ...
true
784c44d74435075748f8dcd5429d3db081c6f1be
Rust
ustulation/packager
/src/config.rs
UTF-8
2,686
2.546875
3
[]
no_license
use std::path::PathBuf; #[derive(Debug, RustcDecodable, Clone)] pub struct Config { output_dir: String, demo_app: Option<DemoApp>, safe_launcher: Option<SafeLauncher>, } #[derive(Debug)] pub struct ConfigImpl { pub output_dir: PathBuf, pub demo_app: Option<DemoAppImpl>, pub safe_launcher: Opti...
true
bb46347ef39954d9ccaa0b36ff8c215c24e584bb
Rust
plus7wist/Rust
/src/sorting/mod.rs
UTF-8
900
2.765625
3
[]
no_license
mod bubble_sort; mod counting_sort; mod heap_sort; mod insertion_sort; mod merge_sort; mod quick_sort; mod selection_sort; pub use self::bubble_sort::bubble_sort; pub use self::counting_sort::counting_sort; pub use self::counting_sort::generic_counting_sort; pub use self::heap_sort::heap_sort; pub use self::insertion_...
true
93bba1a68ab42e4751a32682e9488e2b76d957e1
Rust
doubt72/doubtful
/src/encoding_impl.rs
UTF-8
10,447
2.875
3
[]
no_license
use std::collections::HashMap; use evaluator; use primitives; use encoding::Block; use encoding::Expression; use encoding::List; use encoding::Call; use encoding::Definition; use encoding::Scope; use encoding::FunctionOrValue; use encoding::Evaluation; use encoding::ListEval; use encoding::Function; use encoding::Ex...
true
336b23b3e9df703a644d717dd174205e7919f8c4
Rust
ahmednooor/mr_huffy
/src/mr_huffy/mod.rs
UTF-8
4,130
2.6875
3
[]
no_license
mod helpers; use self::helpers::*; mod get_freq_map; use self::get_freq_map::*; mod make_tree; use self::make_tree::*; mod get_comrpessed_bits_map; use self::get_comrpessed_bits_map::*; mod make_bitstring; use self::make_bitstring::*; mod bitstring_to_encoded_bytes; use self::bitstring_to_encoded_bytes::*; mod freq_ma...
true
005ad5fc6ee9b2634a0b62fd0bf4908cf34ff649
Rust
ekarademir/rust-learning
/sdl2-base-project/src/pacman/scene.rs
UTF-8
1,002
3.046875
3
[]
no_license
use sdl2::surface::Surface; use sdl2::pixels::PixelFormatEnum; use sdl2::rect::Rect; use crate::rotatingwave::paint::Drawable; pub struct Container<T> { pub width: u32, pub height: u32, pub contents: Vec<T>, } impl <T: Drawable> Container <T> { pub fn new(width: u32, height: u32) -> Container<T> { ...
true
b9337b6d89e43ecac258881162688a78f5e65835
Rust
caibirdme/leetcode_rust
/src/prob_109.rs
UTF-8
2,494
3.46875
3
[ "MIT" ]
permissive
#[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>> } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub ...
true
7e34b329aac4da6300fe1fcddf0325bd44b6a1e9
Rust
section77/snippets
/src/bin/snippets.rs
UTF-8
2,267
2.59375
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro, custom_attribute)] use chrono::NaiveDateTime; use rocket::config::Environment; use rocket::*; use rocket_contrib::templates::tera::{self, Tera}; use rocket_contrib::templates::Template; use std::collections::HashMap; use std::env; use std::path::Path; use std::sync::Mutex; u...
true
44f923f62e09882ddcc0197e7f7564953637fc04
Rust
hoangpq/minigame-rust
/src/entity.rs
UTF-8
2,885
2.96875
3
[ "MIT" ]
permissive
extern crate cgmath; use component::Component; use componentlist::ComponentList; use collider::Collider; use colliderlist::ColliderList; use std::vec::Vec; use std::rc::Rc; use self::cgmath::Vector2; pub type IdNumber = u32; pub trait EntityTrait { /* fn added(scene: &Scene); fn removed(scene: &Scene); ...
true
8143705a6be8a8a04286b4ebe608fe45c2d4d53c
Rust
rust-tw/modernweb-booth-question
/src/main.rs
UTF-8
1,481
3.140625
3
[]
no_license
use std::fs::File; use std::io; use colored::*; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] struct Subject { question: String, answer: String, } fn main() { let questions_file = File::open("src/question.json").expect("Failed to reading file: question.json."); ...
true
3a3a8651a4e460d46caf6a31687b9dfddf642f24
Rust
nappa85/sea-orm-macro
/src/lib.rs
UTF-8
7,142
2.6875
3
[]
no_license
use proc_macro::TokenStream; use proc_macro2::{Ident, Span, TokenStream as TokenStream2}; use quote::quote; use syn::{Data, DeriveInput, Fields, Lit, Meta, parse_macro_input, punctuated::Punctuated, token::Comma}; use convert_case::{Case, Casing}; fn ident_to_case(ident: &Ident, case: Case) -> Ident { Ident::new...
true
02c7d1c7e03e5862b6a55b6792867ec2cfa757df
Rust
mons-pico/rpico
/src/pico.rs
UTF-8
24,278
3.34375
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-2-Clause" ]
permissive
//! Core data structure for the Pico library. //! //! # Pico File Layout //! //! ^ Offset ^ Data ^ Meaning ^ Code ^ //! | 0x00 - 0x01 | Magic Number || //! | 0x02 - 0x03 | Major Version Number | `get_major()` | //! | 0x04 - 0x05 | Minor Version Number | `get_minor()` | //! | 0x06 - 0x09 | Data Offset | `get_offse...
true
863c6f61aa449c76e8b6f03ad21cd3e162f7b07e
Rust
IThawk/rust-project
/rust-master/src/test/ui/error-codes/E0507.rs
UTF-8
210
3.09375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use std::cell::RefCell; struct TheDarkKnight; impl TheDarkKnight { fn nothing_is_true(self) {} } fn main() { let x = RefCell::new(TheDarkKnight); x.borrow().nothing_is_true(); //~ ERROR E0507 }
true
206584778bd14a11874874357957aacbff95a56d
Rust
JonnyWalker81/rusty_lamp
/rusty_lamp_lib/src/parser/parser.rs
UTF-8
31,028
2.75
3
[ "MIT" ]
permissive
/* * Copyright © 2002-2017 Bluebeam Software, Inc. All Rights Reserved. * Creator: Jonathan Rothberg */ use parser::token::{Token, DataType}; use parser::lexer::Lexer; use parser::ast::{BlockStatement, Statement, StatementKind, Identifier, DataTypeStatement, InterfaceType, Parame...
true
02e0e3b77995986efa56ca14b1c07c1e2d6f1b97
Rust
pengowen123/cmaes
/src/plotting/options.rs
UTF-8
705
3.078125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Configuration of data plot generation /// Configuration of the data plot. #[derive(Clone, Debug)] pub struct PlotOptions { /// Minimum function evaluations between each data point. Can be used to adjust the granularity /// of the recorded data points, with `0` recording a data point every generation. p...
true
db8cb1885c39e590d0bcb868aecee7f414206ac4
Rust
archer884/advent-of-code-2018
/day03/src/main.rs
UTF-8
883
2.578125
3
[ "Unlicense" ]
permissive
#[macro_use] extern crate pest_derive; mod claim; use crate::claim::{Claim, ParseClaimError, Unit}; use hashbrown::HashMap; use std::error; fn main() -> Result<(), Box<error::Error>> { let claims = claims()?; let unit_map = build_unit_map(&claims); let viable_claims = claims.iter().filter(|claim| { ...
true
f919cbc5f3a66a349a7e72b8fa1b7dec8f97a50f
Rust
hmeyer/GabrieleTerm
/src/cyclo_keyboard.rs
UTF-8
7,597
3.15625
3
[]
no_license
use std::io::{stdout, Write}; use wiringpi::pin::Value::{High, Low}; const W_PINS: [u16; 3] = [6, 10, 11]; const R_PINS: [u16; 8] = [22, 23, 24, 25, 26, 27, 28, 29]; struct KeyboardHardware { w_pins: Vec<wiringpi::pin::OutputPin<wiringpi::pin::WiringPi>>, r_pins: Vec<wiringpi::pin::InputPin<wiringpi::pin::Wir...
true
5bf0549c809641029aae8da61d4f0b45d842b13d
Rust
alex-dukhno/rust-tdd-katas
/old-katas-iteration-01/src/map_kata/day_6.rs
UTF-8
2,987
3.296875
3
[ "MIT" ]
permissive
#![allow(transmute_ptr_to_ref)] use std::mem; use std::boxed::Box; use std::option::Option; use std::ops::Deref; use std::ops::DerefMut; use std::clone::Clone; use std::marker::Copy; #[allow(dead_code)] struct Bucket { key: Option<i32>, value: Option<i32>, next: Option<Link> } impl Bucket { fn new(k...
true
54c0316439a4858aba188f52ec17757f94db07c4
Rust
jtaylorsoftware/rust-raytracer
/src/material/diffuse.rs
UTF-8
757
2.734375
3
[]
no_license
use super::Material; use crate::hittable::HitRecord; use crate::math::{Color, Point3, Ray}; use crate::texture::{SolidColor, Texture}; use std::sync::Arc; pub struct DiffuseLight { emit: Arc<dyn Texture>, } impl DiffuseLight { pub fn new(color: Color) -> Self { Self { emit: Arc::new(SolidC...
true
170e63b06ebd70d250c1bde10d90ca6905b3ed4a
Rust
Mromson/agg
/src/color.rs
UTF-8
13,002
3.453125
3
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
//! Colors use crate::Color; use crate::math::multiply_u8; /// Convert an f64 [0,1] component to a u8 [0,255] component fn cu8(v: f64) -> u8 { (v * 255.0).round() as u8 } /// Convert from sRGB to RGB for a single component fn srgb_to_rgb(x: f64) -> f64 { if x <= 0.04045 { x / 12.92 } else { ...
true
7b2fccac55018e1d907a3f5b00fca1b9a16b9d43
Rust
domsim1/rusty-old-maid
/src/fiftytwo/old_maid.rs
UTF-8
2,064
3.234375
3
[]
no_license
use super::Card; use rand::Rng; pub fn remove_all_pairs(hand: &mut Vec<Card>) { hand.clone_from(&remove_pairs(0, hand.to_vec())); } fn remove_pairs(index: usize, hand: Vec<Card>) -> Vec<Card> { let mut new_hand = hand.clone(); if new_hand.len() > index { let selected_card = new_hand.remove(index);...
true
5c50b82120eb9fb3b4836e8ed2e96a475274a0df
Rust
CryptoThibault/hello-rust
/loops-iterations/src/main.rs
UTF-8
952
3.8125
4
[]
no_license
fn main() { let x = 42; if x < 42 { println!("plus petit que 42"); } else if x == 42 { println!("42 tout rond"); } else { println!("plus grand que 42"); } let mut x = 0; loop { x += 1; if x == 42 { break; } } println!("{}", ...
true
1ceafa75daf9d94322b2252c04a948aa879b2677
Rust
jtara1/bullet_monchos
/src/components/owner.rs
UTF-8
300
3.171875
3
[ "Apache-2.0" ]
permissive
pub enum Owner { Player, Enemy, } impl Clone for Owner { fn clone(&self) -> Self { match self { Owner::Player => Owner::Player, Owner::Enemy => Owner::Enemy, _ => panic!("Owner clone() needs to implement for the give type"), } } }
true
0ff291ad76162fe31fa35d7f5a74896bb064781a
Rust
mishun/minisat-rust
/src/sat/minisat/budget.rs
UTF-8
963
2.75
3
[ "MIT" ]
permissive
use std::sync::atomic; // Resource contraints: pub struct Budget { conflict_budget: i64, // -1 means no budget. propagation_budget: i64, // -1 means no budget. asynch_interrupt: atomic::AtomicBool, } impl Budget { pub fn new() -> Budget { Budget { conflict_budget: -1, ...
true
8fc7879c99ae2a85382eec6ac181c590716c3bad
Rust
cybertrust1/cfengine-promise-rust
/src/attribute.rs
UTF-8
1,318
2.9375
3
[]
no_license
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2021 Normation SAS use serde_json::Value; use std::path::Path; /// First-level type of attributes /// /// Allows providing typing information #[derive(Debug, PartialEq, Clone)] pub enum AttributeType { Bool, String, Integer, Float...
true
35b41a2371d9bb06b90b7a866771d6f43204c0c1
Rust
deifactor/ninomiya
/src/hints.rs
UTF-8
7,542
3.203125
3
[ "MIT" ]
permissive
use anyhow::{anyhow, Context, Result}; use dbus::arg; use derivative::Derivative; use log::debug; use std::collections::HashMap; use std::fmt; use std::path::PathBuf; use std::str::FromStr; use url::Url; fn show_pixel_count(image_data: &Vec<u8>, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(f, "{} byt...
true