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
4a08765c03f7e17abc87467518e426cb28c6dfdf
Rust
jonkgrimes/lox
/src/interpreter.rs
UTF-8
10,243
3.0625
3
[]
no_license
use std::cell::RefCell; use std::collections::HashMap; use std::rc::Rc; use uuid::Uuid; use crate::environment::Environment; use crate::expr::{ Assign, Binary, BoxedExpr, Call, Grouping, Literal, Logical, Unary, Variable, Visitor as ExprVisitor, }; use crate::lox_callable::LoxCallable; use crate::lox_error::Lo...
true
b949b6ce03d30982cbced31acbf6148872141367
Rust
TK-R/abc_challenge
/abc104/b/src/main.rs
UTF-8
2,381
3.640625
4
[]
no_license
use std::io; /// 一行を読み込んで、空白で区切ったベクタにして返す #[allow(dead_code)] fn read<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug, { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); buf.trim() .split_whitespace() .map(|s| s.parse().unwrap()) .col...
true
b97e09fce3d48507deb3b12e66e0425c6b6a7332
Rust
milliams/plotlib
/src/errors.rs
UTF-8
398
2.625
3
[ "MIT" ]
permissive
#[derive(thiserror::Error, Debug)] pub enum Error { #[error("Cannot save page to svg!")] FailedToSave(#[from] std::io::Error), #[error( "Invalid {name:?} range: {lower} <= {upper}. Please specify the {name:?} range manually." )] InvalidRange { name: String, lower: f64, ...
true
fb04421358596507561a89655beb3da8eb2ed260
Rust
Noah2610/deathframe
/deathframe_physics/src/collision/data/side.rs
UTF-8
1,269
3.515625
4
[ "MIT" ]
permissive
use std::convert::TryFrom; #[derive(Clone, PartialEq, Debug)] pub enum CollisionSide { Left, Right, Top, Bottom, Inner { x: Option<CollisionInnerSideX>, y: Option<CollisionInnerSideY>, }, } #[derive(Clone, PartialEq, Debug)] pub enum CollisionInnerSideX { Left, Right, }...
true
c53b4ebe0ef11787c2080b4208dab42b45064a8f
Rust
mtak-/swym
/src/internal/phoenix_tls.rs
UTF-8
7,254
3.25
3
[ "MIT" ]
permissive
//! Utilities for creating always present thread locals. //! //! `phoenix_tls` combines everything in this module to create a `thread_local!` style variable that //! is lazily initialized. If the `thread_local` is accessed after it's destroyed, a new temporary //! will be created using the same initialization expressio...
true
2aa0253b58a6cc02738e59be4cbbd076ec32edeb
Rust
isgasho/perseus
/packages/perseus-actix-web/src/page_data.rs
UTF-8
1,499
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::conv_req::convert_req; use crate::Options; use actix_web::{http::StatusCode, web, HttpRequest, HttpResponse}; use perseus::{err_to_status_code, get_page, ConfigManager}; use std::collections::HashMap; /// The handler for calls to `.perseus/page/*`. This will manage returning errors and the like. pub async f...
true
7d5733521ccc664faf122c030478d2834d1c3081
Rust
homeisfar/lofi-rasterizerr
/src/img_data.rs
UTF-8
668
3.25
3
[]
no_license
#[derive(Debug)] pub struct Pixel { pub r: u8, pub g: u8, pub b: u8, pub a: u8, pub l: u8 } pub struct ImageDetails { pub width: u32, pub height: u32 } impl Pixel { pub fn new(r: u8, g: u8, b: u8, a: u8, l: u8) -> Pixel { Pixel { r, g, b, a, l } } ...
true
28b502e96e229385dd5d69a6799b41baeb12026d
Rust
AnvilMC/anvil_bedrock
/mcpe_protocol/src/packets/server/creative_content.rs
UTF-8
4,183
2.53125
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use packet_derive::{packet, MCPEPacketDataAuto}; use crate::prelude::ItemDef; use crate::prelude::{Le, UnsignedVarInt, VarInt, VecIndexed}; #[packet(0x91)] #[derive(MCPEPacketDataAuto)] pub struct CreativeContentPacket { pub inventory: VecIndexed<Slot, UnsignedVarInt>, } #[derive...
true
6843c03e31ae5ffe9e92bd42667da7e5649d1b7a
Rust
qingshi163/leetcode_rust
/src/lc203.rs
UTF-8
619
3.34375
3
[ "MIT" ]
permissive
use super::utils::ListNode; #[allow(dead_code)] fn remove_elements(head: Option<Box<ListNode>>, val: i32) -> Option<Box<ListNode>> { let mut head = head; let mut curr = &mut head; while curr.is_some() { if curr.as_ref().unwrap().val == val { *curr = curr.take().unwrap().next; } ...
true
a59ee2d3dac093b23043af917859ae80dcd2e7cb
Rust
TriplEight/ink
/crates/lang/macro/tests/ui/contract/pass/08-flipper-as-dependency-trait.rs
UTF-8
732
2.78125
3
[ "Apache-2.0" ]
permissive
use ink_lang as ink; #[ink::contract(compile_as_dependency = true)] mod flipper { #[ink_lang::trait_definition] pub trait FlipperTrait { #[ink(constructor)] fn new() -> Self; #[ink(message)] fn flip(&mut self); #[ink(message)] fn get(&self) -> bool; } ...
true
3e47ef3732668813eb2d73964ae91656c07dfa32
Rust
EFanZh/LeetCode
/src/problem_0420_strong_password_checker/mod.rs
UTF-8
745
3.1875
3
[]
no_license
pub mod greedy; pub trait Solution { fn strong_password_checker(password: String) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ("a", 5), ("aA1", 3), ("1337C0d3", 0), ("hoAISJDBVWD09232UHJEPOD...
true
7a79437de124bd98cc786b5ed152297e5033774d
Rust
sameer/uhid-fs
/src/uhid_device.rs
UTF-8
2,713
2.78125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::convert::TryFrom; use std::fs::{File, OpenOptions}; use std::io::{self, prelude::*}; use std::os::unix::fs::OpenOptionsExt; use std::path::Path; use arrayvec::{ArrayString, ArrayVec}; use uhid_sys as sys; use crate::codec::*; pub struct UHIDDevice<T: Read + Write> { handle: T, } /// Contains informati...
true
632a1570ac9cbcdfb3f88bd55227ce150e1dba6f
Rust
saebs/rusty_money
/src/exchange.rs
UTF-8
3,419
3.96875
4
[ "MIT" ]
permissive
use crate::currency::*; use crate::{Money, MoneyError}; use rust_decimal::Decimal; use std::collections::HashMap; /// A struct to store `ExchangeRate`s. #[derive(Debug, Default)] pub struct Exchange { map: HashMap<String, ExchangeRate>, } impl Exchange { pub fn new() -> Exchange { Exchange { ...
true
b5791aab85f9f7d35db0d3cfa6886374862b6a3d
Rust
kosticmarin/rust_book
/ownership/clone_copy/src/main.rs
UTF-8
811
4.1875
4
[]
no_license
fn main() { // clone let s1 = String::from("hello"); let s2 = s1.clone(); dbg!(&s1); dbg!(&s2); // copy let x = 5; let y = x; dbg!(x); dbg!(y); // ownership and functions let s = String::from("hello"); takes_ownership(s); // won't compile > dbg!(s); make...
true
e1814335d2bd2dededccbc6e5d0b081ed1b6ac7b
Rust
maroider/rsmixer
/src/ui/draw.rs
UTF-8
4,382
2.71875
3
[ "MIT" ]
permissive
use crate::{ draw_rect, entry::{Entries, Entry, EntryType}, ui::{ models::PageEntries, output::{RedrawType, UIState}, util::{entry_height, get_style, PageType, Rect, Y_PADDING}, widgets::{BlockWidget, ContextMenuWidget, VolumeWidget, Widget}, }, RSError, }; use std::...
true
1e2d851096a1baa682425789598e84cedbfed1fe
Rust
tehsmeely/particles
/src/grid.rs
UTF-8
3,689
3.125
3
[]
no_license
use crate::particle::{Particle, ParticleType}; use array2d::Array2D; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Direction { Up, Down, Left, Right, DownRight, DownLeft, } #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct GridPosition { x: i32, y: i32, } impl GridPositi...
true
b98085ec648c3de351f99a8874afe49027dfc55a
Rust
natasha-codes/sonar
/server/src/models/api/error.rs
UTF-8
1,751
3.15625
3
[]
no_license
use rocket::{ http::Status, response::{Responder, Result as ResponderResult}, Request, }; use crate::{auth::AuthError, storage::MongoError}; /// An enum wrapping sub-error types and mapping them to an HTTP status code, /// to simplify returning errors from a route handler. /// /// This type implements `Fr...
true
15c1c88afd7a160a75449a589c68d77b4554dcfc
Rust
Syncroness-Inc/rust-tiva-blinky
/src/systick.rs
UTF-8
1,077
2.65625
3
[]
no_license
/* Configure the SysTick to generate a periodic interrupt. This is super hardware dependent because it depends on the clock configuration (including crystal). */ use super::event; const SYSCTL_SYSDIV_1: u32 = 0x07800000; const SYSCTL_USE_OSC: u32 = 0x00003800; const SYSCTL_OSC_MAIN: u32 = 0x00000000; const SY...
true
cda67b0d5398d095afce09df7cf2d71baaf22b37
Rust
isabella232/cc13x2-cc26x2-pac
/src/aux_sysif/opmodereq.rs
UTF-8
9,061
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::OPMODEREQ { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
true
f86f9e721e64598b1054014ab7e60ec6cac6dbf4
Rust
EFanZh/LeetCode
/src/problem_1499_max_value_of_equation/mod.rs
UTF-8
655
3.03125
3
[]
no_license
pub mod monotonic_stack; pub trait Solution { fn find_max_value_of_equation(points: Vec<Vec<i32>>, k: i32) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ((&[[1, 3], [2, 0], [5, 10], [6, -10]] as &[_], 1), 4), ((&[[0,...
true
4da8e5132307b4c4732aba04ae60663831a57b47
Rust
rschmukler/rust-cassandra-playground
/src/main.rs
UTF-8
3,314
2.953125
3
[]
no_license
extern crate time; extern crate cassandra; use cassandra::*; use std::env; #[cfg_attr(rustfmt, rustfmt_skip)] static CREATE_KEYSPACE:&'static str = " CREATE KEYSPACE IF NOT EXISTS benchmark WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 2 }"; #[cfg_attr(rustfmt, rustfmt_skip)] static CREAT...
true
77066e2626614b19a42083070b726089666048f3
Rust
jonkgrimes/artichoke
/artichoke-backend/src/extn/core/kernel/require.rs
UTF-8
9,754
2.78125
3
[ "MIT", "BSD-2-Clause" ]
permissive
//! [`Kernel#require`](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-require) use bstr::ByteSlice; use std::path::{Path, PathBuf}; use crate::extn::prelude::*; use crate::ffi; use crate::fs::RUBY_LOAD_PATH; use crate::state::parser::Context; const RUBY_EXTENSION: &str = "rb"; pub fn load(interp: &mut Articho...
true
dd116fc24c4e055a9e95a1de2a13bab10a762170
Rust
elichai/Lorenz
/src/logic.rs
UTF-8
3,957
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::x25519::*; use crate::*; use encryption::Scheme; use std::fs::*; use std::io::{self, Read, Seek, SeekFrom, Write}; use x25519_dalek::PublicKey; fn file_len(file: &File) -> usize { file.metadata().map(|m| m.len() as usize + 1).unwrap_or(0) } pub fn encrypt_file_with_keys(input_file: &mut File, keys: Vec...
true
c2093ec956e3067a471a4ea0f6b373e2cb7225ba
Rust
mshetairy/OpenSK
/examples/nfct_test.rs
UTF-8
4,988
2.53125
3
[ "Apache-2.0" ]
permissive
#![no_std] #![allow(unused_imports)] extern crate alloc; extern crate lang_items; extern crate libtock_drivers; use core::fmt::Write; use libtock_core::result::CommandError; use libtock_drivers::console::Console; #[cfg(feature = "with_nfc")] use libtock_drivers::nfc::NfcTag; #[cfg(feature = "with_nfc")] use libtock_d...
true
e010c05ed0177ec9ef0843a60d653b3a8a12e5cf
Rust
IThawk/rust-project
/rust-master/src/test/run-pass/regions/regions-lub-ref-ref-rc.rs
UTF-8
775
3.15625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass #![allow(dead_code)] // Test a corner case of LUB coercion. In this case, one arm of the // match requires a deref coercion and the other doesn't, and there // is an extra `&` on the `rc`. We want to be sure that the lifetime // assigned to this `&rc` value is not `'a` but something smaller. In // other wo...
true
61b603e9c15b13d5df3e2fc0abcc396ef1cc04ed
Rust
luhuimao/morgan
/core/src/blockBufferPool/db.rs
UTF-8
11,110
2.515625
3
[ "Apache-2.0" ]
permissive
use crate::result::{Error, Result}; use bincode::{deserialize, serialize}; use serde::de::DeserializeOwned; use serde::Serialize; use std::borrow::Borrow; use std::collections::HashMap; use std::marker::PhantomData; use std::path::Path; use std::sync::Arc; pub mod columns { #[derive(Debug)] /// SlotMeta Col...
true
b78ed7ef41754efc9ed8ef0b8715ef4940069956
Rust
safrannn/leetcode_rust
/src/_1290_convert_binary_number_in_a_linked_list_to_integer.rs
UTF-8
651
3.1875
3
[]
no_license
use leetcode_prelude; struct Solution; impl Solution { pub fn get_decimal_value(head: Option<Box<leetcode_prelude::ListNode>>) -> i32 { let mut result = 0; let mut p = &head; while let Some(n) = p { result *= 2; result += n.val; p = &n.next; } ...
true
7c15a7216b0dd72eb753a285325fbc46b55d04f8
Rust
tokio-rs/tokio
/tokio-util/src/codec/framed.rs
UTF-8
14,004
3.09375
3
[ "MIT" ]
permissive
use crate::codec::decoder::Decoder; use crate::codec::encoder::Encoder; use crate::codec::framed_impl::{FramedImpl, RWFrames, ReadFrame, WriteFrame}; use futures_core::Stream; use tokio::io::{AsyncRead, AsyncWrite}; use bytes::BytesMut; use futures_sink::Sink; use pin_project_lite::pin_project; use std::fmt; use std:...
true
b5fc1e23d5595769633d53d8363a7e416a4e4d7a
Rust
eigmax/eigen-crypto
/src/account/address.rs
UTF-8
3,036
2.9375
3
[]
no_license
use std::prelude::v1::*; use crate::errors::{Error, ErrorKind, Result}; use crypto::digest::Digest; use crypto::ripemd160::Ripemd160; use rust_base58::{FromBase58, ToBase58}; use ring::digest; use std::collections::HashMap; pub enum CryptoType { NIST = 1, GM = 2, } impl CryptoType { pub fn from_u8(value:...
true
ace89650ab32222c5e4d7075facb5a4b09a2bd37
Rust
GayanathS/CSCI3055u_FinalProject
/main.rs
UTF-8
819
3.671875
4
[]
no_license
fn main() { let mut strings = ["Tim", "Cat", "Dog", "Fred"]; println!("Before: {:?}", strings); quick_sort(&mut strings, &|x,y| x < y); println!("After: {:?}\n", strings); } fn quick_sort<T,G>(v: &mut [T], g: &G) where G: Fn(&T,&T) -> bool { let len = v.len(); if len >= 2 { ...
true
4b82292de5d6d38405235dfb1b26d519eaee4423
Rust
PizzaShift/visual-system-simulator
/vss/src/devices/image_device.rs
UTF-8
3,107
2.953125
3
[ "Apache-2.0" ]
permissive
use std::cell::RefCell; use std::fs::File; use super::*; use crate::config::*; use crate::pipeline::*; /// A device for static RGBA image data. pub struct ImageDevice { window: WindowDevice, input_rgba: RefCell<gfx::handle::Texture<gfx_device_gl::Resources, RgbSurfaceFormat>>, input_view: RefCell<DeviceSo...
true
9f03fb018544fe6e3b4952d4684a1a5f0792fc62
Rust
lmolas/asn1rs
/asn1rs-model/src/ast/attribute.rs
UTF-8
9,918
2.984375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::range::ident_or_literal_or_punct; use super::range::IntegerRange; use super::tag::AttrTag; use crate::ast::constants::ConstLit; use crate::model::{ Charset, Choice, ChoiceVariant, Enumerated, EnumeratedVariant, Range, Size, Tag, Type, }; use std::fmt::Display; use std::marker::PhantomData; use std::ops::...
true
240ff641bb26f196f160324800a26d1f239fb2fb
Rust
dobkeratops/thRustEngine
/tiled.rs
UTF-8
5,263
3.078125
3
[]
no_license
use super::*; /// 4x4x4 cell Tile for simple compression: /// Has option of a single repeated value, or a real value; /// /// TODO - sparse content option #[derive(Clone,Debug)] pub enum Tile4<T> { Fill(T),Detail(Box<[[[T;4];4];4]>) } impl<T:Clone+PartialEq> Array3d<T>{ fn iter_from_to(&self,start:V3i, end:V3i)->It...
true
615a1e550a1654e097fb1aba446b138d2b32388d
Rust
IThawk/rust-project
/rust-master/src/test/ui/dep-graph/dep-graph-trait-impl-two-traits.rs
UTF-8
744
2.703125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Test that adding an impl to a trait `Foo` does not affect functions // that only use `Bar`, so long as they do not have methods in common. // compile-flags: -Z query-dep-graph #![feature(rustc_attrs)] #![allow(warnings)] fn main() { } pub trait Foo: Sized { fn foo(self) { } } pub trait Bar: Sized { fn b...
true
7557e19b27689ccb35e25088a4b81d6d4bb602ff
Rust
bkdaugherty-but-at-facebook/coup
/src/player/random_player.rs
UTF-8
2,705
3.09375
3
[]
no_license
use crate::{Action, GameState, Identity, PlayerID}; use crate::player::traits::Player; use anyhow::Result; use rand::seq::SliceRandom; use rand::thread_rng; pub struct RandomPlayer { // Not necessarily two? id: PlayerID, hand: Vec<Identity>, } impl RandomPlayer { pub fn new(id: PlayerID) -> Self { ...
true
c1eff33ed650fcdc26f12a6833422903d3848ee5
Rust
hayatoito/icfp2018
/src/nanobot/matrix.rs
UTF-8
1,171
2.921875
3
[]
no_license
use std; use super::model::*; use super::prelude::*; pub struct Matrix { pub r: usize, pub full: Vec<bool>, } impl Matrix { pub fn new(model: &Model) -> Matrix { let r = model.r; match model.id { ModelId::Assemble(_) => Matrix { r, full: vec![fa...
true
4bcf833dfa0ae535a3fe0044df55906c6a2732fe
Rust
utilForever/BOJ
/Rust/14003 - The Longest Increasing Partial Sequence 5.rs
UTF-8
2,118
3.28125
3
[ "MIT" ]
permissive
use std::{cmp, io}; fn input_integers() -> Vec<i32> { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let values: Vec<i32> = s .as_mut_str() .split_whitespace() .map(|s| s.parse().unwrap()) .collect(); values } fn binary_search(lis: &Vec<i32>, valu...
true
8e6a43e7c98e3496efcf9e88f062fe2c151bafdf
Rust
wwylele/chocopy-rs
/chocopy-rs-common/src/lib.rs
UTF-8
2,111
2.59375
3
[ "MIT" ]
permissive
use std::ptr::*; pub const POINTER_SIZE: u32 = 8; pub const FUNCTION_POINTER_SIZE: u32 = 8; #[repr(i32)] pub enum TypeTag { // Normal objects Other = 0, Int = 1, Bool = 2, // Array objects Str = 3, PlainList = -1, RefList = -2, } #[repr(C)] pub struct Prototype { pub size: i32, /...
true
c1e8f1947997b2f0f66a0b5549d84e0e0a427687
Rust
svenschmidt75/Rust
/DSandAlg/CodingProblems/AirBnBBookings/src/lib.rs
UTF-8
1,798
3.390625
3
[]
no_license
// https://www.reddit.com/r/CodingProblems/comments/fcdmg5/day_72020032_problem_of_the_day_asked_by/ use std::cmp; fn calc_max_profit(input: &[(u32, u32)]) -> u32 { // SS: Use dynamic programming to maximize the profit from AirBnB bookings let mut max_profit = 0; for row in 0..input.len() { let m...
true
ab3998d862332a02668f83e9cf785ad3cd6f86bc
Rust
abdullahwaqar/code-wars
/rust/Highest-and-Lowest/main.rs
UTF-8
342
3.625
4
[]
no_license
fn high_and_low(numbers: &str) { use std::cmp; let f = |(max, min), x| (cmp::max(max, x), cmp::min(min, x)); let answer = numbers.split_whitespace().map(|x| x.parse::<i32>().unwrap()).fold((i32::min_value(), i32::max_value()), f); format!("{} {}", answer.0, answer.1); } fn main() { print!(high_and...
true
8ad5909a366e672d709f81c854017e8089534a0c
Rust
RicoGit/rust-alg
/src/leetcode/search_2d_matrix.rs
UTF-8
957
3.421875
3
[]
no_license
//! 74. Search a 2D Matrix impl Solution { pub fn search_matrix(matrix: Vec<Vec<i32>>, target: i32) -> bool { if matrix.len() == 0 { return false; } let len = matrix.len() * matrix[0].len(); Self::search(&matrix, 0, len - 1, target) } fn search(mat: &[Vec<i32>],...
true
f145a3de8b45e7bede0f4669cf3e500405c7b98a
Rust
curiousTauseef/tako
/src/ast.rs
UTF-8
8,568
2.578125
3
[ "MIT" ]
permissive
use std::collections::HashSet; use std::fmt; use std::hash::{Hash, Hasher}; use crate::database::Compiler; use crate::database::DB; use crate::errors::TError; use crate::location::*; use crate::tree::*; use crate::types::*; #[derive(Debug, PartialEq, Eq, Clone)] pub struct Err { pub msg: String, pub info: Inf...
true
033b17defe8e16d25aa63abcfb4bcee4517f1a8f
Rust
raphaelcohn/security-keys-rust
/workspace/security-keys-rust/src/low_level/transmit/response_code/WrongParametersVariant1Error.rs
UTF-8
2,215
2.546875
3
[ "MIT" ]
permissive
// This file is part of security-keys-rust. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/raphaelcohn/security-keys-rust/master/COPYRIGHT. No part of security-keys-rust, including this file, may be copied, modified...
true
36cbe815fe01ab0d0a59d1e65536e84df9ce64b1
Rust
chessbr/rust-exchange
/matching-engine/src/engine/tests.rs
UTF-8
5,158
3.390625
3
[]
no_license
#[test] fn test_simple_order() { let mut engine = super::MatchingEngine::new(String::from("QWERTY")); assert_eq!(engine.get_asset().clone(), String::from("QWERTY")); let buy_order_results: Vec<super::OrderResult> = engine.add_order(super::OrderType::BUY, 100, 9.90); assert_eq!(buy_order_results.len()...
true
fcd0fc24dd4e2832253510ca34d9086be2e13f5a
Rust
jgoldschrafe/advent-of-code
/2020/day-7/src/main.rs
UTF-8
2,537
3.3125
3
[]
no_license
use std::collections::HashMap; use std::collections::hash_map::Entry; use std::io; use std::io::prelude::*; use petgraph::prelude::*; #[derive(Debug)] struct Adjacency { parent_name: String, child_name: String, quantity: i32, } fn parse_line(line: &str) -> Vec<Adjacency> { let mut splits = line.split...
true
b851e96b9a12e484862688aad862242e3250303a
Rust
xiuxiu62/noclist
/src/http.rs
UTF-8
2,063
2.71875
3
[]
no_license
use reqwest::header::{HeaderMap, HeaderName, HeaderValue}; use reqwest::Response; use reqwest::{Client, Url}; use std::error::Error; use std::str; use crate::crypt; pub type HttpRespone = Result<Response, Box<dyn Error>>; pub fn ensure_success(res: &HttpRespone) { match res { Ok(_) => {} Err(e) ...
true
8d59e3157afb228d37565da2e2ecf2a73488cb5d
Rust
clpi/dapi
/di-common/src/auth/mod.rs
UTF-8
2,478
2.65625
3
[]
no_license
use serde::{Serialize, Deserialize}; //use jsonwebtoken::{encode, decode, Header, EncodingKey, DecodingKey, Validation}; use jsonwebtoken::errors::Result as JWTResult; use crate::models::User; use chrono::{Utc, Duration}; use argonautica::{Hasher, Verifier, config::Variant, input::{Salt, SecretKey} }; #[deriv...
true
643e34f11f6afdb83308947e50dc18fdbb230f23
Rust
wisest30/AlgoStudy
/source/leetcode/2012/hyo.rs
UTF-8
719
3.265625
3
[]
no_license
use std::cmp::min; use std::cmp::max; impl Solution { pub fn sum_of_beauties(nums: Vec<i32>) -> i32 { let n = nums.len(); let mut right_mins = vec![nums[n-1]; n]; for i in (0..n-1).rev() { right_mins[i] = min(nums[i], right_mins[i+1]); } let mut left_max...
true
6487ca52a4f41cb72b2ff446381223d3cd03f9c0
Rust
ssttuu/pbrt-rs
/src/geometry/vector3.rs
UTF-8
9,622
3.234375
3
[]
no_license
use num; use num::Num; use std::ops::Add; use std::ops::AddAssign; use std::ops::Div; use std::ops::DivAssign; use std::ops::Index; use std::ops::IndexMut; use std::ops::Mul; use std::ops::MulAssign; use std::ops::Sub; use std::ops::SubAssign; use crate::math; use crate::types::{Float, Int}; use num::Integer; use num...
true
0d770f39e4214d2715c14239c663a48c44cce7a8
Rust
polyproline/x64rustOs
/rustos/src/display/screen.rs
UTF-8
3,340
2.71875
3
[]
no_license
use lazy_static::lazy_static; use spin::RwLock; use core::fmt::{Write,self}; use core::ptr::{write_volatile,read_volatile,NonNull}; use super::ascii::{FONT_ASCII,XCharSize,YCharSize,display_char}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(C)] pub struct ScreenColor(u32); impl ScreenColor{ pub fn new(resue...
true
11c472125ff9d739715f2c85a6fe8145a7d429cd
Rust
drojf/SpriteZip
/src/DoubleImageIterator.rs
UTF-8
6,460
2.921875
3
[]
no_license
//struct DoubleImageIterator<'s> { // original_image : &'s image::RgbaImage, // reference_image : &'s image::RgbaImage, // block_x : u32, // block_y : u32, // x: u32, // y: u32, // num_x_blocks : u32, // num_y_blocks : u32, // block_size : u32, //} // //impl<'s> DoubleImageIterator<'s> { // ...
true
3044021cceff994a35571dbd87a911cb5092a265
Rust
Samour/jobmatching-rust
/src/collections/tests/capped_heap.rs
UTF-8
5,233
3.09375
3
[]
no_license
use crate::collections::CappedHeap; fn expect_heap<T>(size: usize, heap: Vec<(f64, T)>) -> String where T: std::fmt::Debug, { let mut result = String::from("CappedHeap { size: "); result.push_str(&format!("{:?}", size)); result.push_str(", push_head: "); result.push_str(&format!("{:?}", heap.len())); resul...
true
4c859e2fc8865ad6ca50d0eba086f8e16dee4619
Rust
iCodeIN/advent-of-code-3
/crates/core/src/year2018/day21.rs
UTF-8
2,709
3.328125
3
[ "MIT" ]
permissive
use super::elfcode::Program; use crate::Input; use std::collections::HashSet; fn parse(input_string: &str) -> Result<Program, String> { let program = Program::parse(input_string)?; if program.instructions.len() != 31 { return Err("Expected 31 instructions in program".to_string()); } Ok(program)...
true
d95588c7f5e065f0592dd4cfc770af8e32ebccfb
Rust
Baoyx007/pna
/src/bin/kvs.rs
UTF-8
1,935
2.734375
3
[]
no_license
// use clap::App; use clap::{App, Arg, SubCommand}; use kvs::{KvStore, KvsCommand, Result}; use std::path::Path; use structopt::StructOpt; fn get_from_clap() { let matches = App::new(env!("CARGO_PKG_NAME")) .version(env!("CARGO_PKG_VERSION")) .about(env!("CARGO_PKG_DESCRIPTION")) .author(en...
true
f160ee042d18a5524d4ae0e8892042517e4723fa
Rust
tobni/inject-rs
/src/inject.rs
UTF-8
1,631
3.546875
4
[ "MIT" ]
permissive
//! Injectable types //! //! Any type which is `'static` implements `Inject`, meaning it can be resolved by a //! [`Provider`](../provider/trait.Provider.html). //! //! Any type which implements `Inject` and `Default` trivially implements `InjectExt`, which means //! that when no provider is present, and [`get!`](../ma...
true
7eac8036c8b30d5e5486645b344d493b3259ed9e
Rust
nushell/nushell
/crates/nu-command/tests/commands/for_.rs
UTF-8
958
3.125
3
[ "MIT" ]
permissive
use nu_test_support::nu; #[test] fn for_doesnt_auto_print_in_each_iteration() { let actual = nu!(" for i in 1..2 { echo 1 }"); // Make sure we don't see any of these values in the output // As we do not auto-print loops anymore assert!(!actual.out.contains('1')); } #[test] ...
true
cf1bce61a038ee45abdac2c4af6cc27fc3fc3743
Rust
kaepa3/rust2
/ch6/matcher/src/main.rs
UTF-8
731
3.8125
4
[]
no_license
enum Coin { Penny, Nickel, Dime, Quater(u32), } fn value_in_cents(coin: Coin) -> u32 { match coin { Coin::Penny => { println!("lucky!!"); 100 } Coin::Nickel => 5, Coin::Dime => 10, Coin::Quater(state) => { println!("state is...
true
9298fc3b082149c5fce8152e9c6799a2d0127515
Rust
nylar/xsd
/src/complex_type.rs
UTF-8
10,607
2.71875
3
[]
no_license
use std::convert::From; use std::default::Default; use std::str::FromStr; use crate::element::Element; use crate::errors::Error; use crate::restriction::Restriction; use crate::shared::Occurrence; use crate::traits::TryFrom; use roxmltree::Node; const SEQUENCE: &str = "sequence"; const ATTRIBUTE: &str = "attribute";...
true
1d54046e9b6b6c3c556c58d8d8134760e81da0b4
Rust
fenhl/rust-bitbar
/crate/bitbar/src/attr.rs
UTF-8
10,316
3.046875
3
[ "MIT" ]
permissive
//! Parameters for modifying the appearance or behavior of [`ContentItem`]s. use { std::{ convert::{ TryFrom, TryInto, }, fmt, str::FromStr, }, css_color_parser::ColorParseError, url::Url, crate::{ ContentItem, Menu, }, }; ...
true
c4c522d7e2fb29b3750f07c331a46b5570ab07c3
Rust
bokotomo/rust-api-sample
/src/repository/job.rs
UTF-8
2,370
2.640625
3
[]
no_license
use super::super::domain::{ job::DomainJob, company::DomainCompany, }; pub struct RepositoryJob {} impl RepositoryJob { pub fn new() -> RepositoryJob { RepositoryJob {} } // 仕事一覧を返す pub fn find_jobs(&self, page: i32, page_size: i32) -> Vec<DomainJob> { let mut jobs = Vec::new(...
true
385c0bdc997165170befc69712ad7abb6dd5dfd1
Rust
vangroan/rengine
/src/modding/runner.rs
UTF-8
3,674
2.890625
3
[ "MIT" ]
permissive
use super::cmd::ModCmd; use super::cmd::SceneHook; use crate::errors; use crate::sync::ChannelPair; use crossbeam::channel; use rlua::Lua; use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; pub struct ScriptRunner { pub(crate) lua: Lua, pub(crate) chan: ChannelPair<Vec<ModCmd>>, pub(crate)...
true
5f92e3d4d486333fc7d0cb382a0a5a802c38d22f
Rust
mgeisler/paper
/src/ui.rs
UTF-8
13,010
3.015625
3
[ "MIT" ]
permissive
//! Implements how the user interfaces with the application. pub(crate) use crate::num::{Length, NonNegativeI32}; use crate::{fmt, Debug, Display, Formatter, Mrc, TryFrom, TryFromIntError}; use pancurses::Input; use std::cell::RefCell; use std::error; use std::rc::Rc; /// The [`Result`] returned by functions of this...
true
b629395ed45717dc2fc575e48dfc8ffc0ec2f0ca
Rust
hellow554/breeze-emu
/src/breeze_core/record/mod.rs
UTF-8
2,809
3.140625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Input recording and replaying //! //! Contains submodules that implement specific recording formats. mod custom; mod smv; use input::Ports; use snes::Snes; use std::io::{self, Write, BufRead, Seek}; #[derive(Debug)] pub enum RecordingFormat { /// Custom RLE compressed format /// /// See the `custom`...
true
3597a1f4a66ce8cd1d0903831fe068e8d690e0fe
Rust
playit-cloud/playit-agent
/packages/agent_core/src/network/tcp_pipe.rs
UTF-8
1,000
2.734375
3
[ "BSD-2-Clause" ]
permissive
use std::time::Duration; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; pub async fn pipe<R: AsyncRead + Unpin, W: AsyncWrite + Unpin>( mut from: R, mut to: W, ) -> std::io::Result<()> { let mut buffer = Vec::new(); buffer.resize(2048, 0u8); loop { tokio::task:...
true
d0b33a776330fc939a90e0909c7841a86d45a488
Rust
damody/erps-test
/src/user.rs
UTF-8
7,405
2.75
3
[]
no_license
use log::{info, warn, error, trace}; use crate::msg::*; use crossbeam_channel::{bounded, tick, Sender, Receiver, select}; use rand::Rng; use std::cell::RefCell; use std::rc::Rc; use rand::seq::SliceRandom; use indexmap::IndexMap; #[derive(Debug, Default)] pub struct User { pub id: String, pub hero: String, ...
true
30ad9717dfcfe301861da5724719a4db622f9618
Rust
ArniDagur/pyo3
/tests/test_class_conversion.rs
UTF-8
618
2.6875
3
[ "Apache-2.0", "Python-2.0" ]
permissive
use pyo3::prelude::*; #[pyclass] #[derive(Clone, Debug, PartialEq)] struct Cloneable { x: i32, } #[test] fn test_cloneable_pyclass() { let c = Cloneable { x: 10 }; let gil = Python::acquire_gil(); let py = gil.python(); let py_c = Py::new(py, c.clone()).unwrap().to_object(py); let c2: Clone...
true
024121b21beffb72fc2a33bf83e21b151f559313
Rust
janaakhterov/s3
/src/request/get/bucket/analytics_config.rs
UTF-8
557
2.515625
3
[]
no_license
use crate::types::BucketAnalytics; impl_sub_resource!(GetBucketAnalyticsConfig => BucketAnalytics); impl<'a> GetBucketAnalyticsConfig<'a> { /// Create a new GetBucketAnalyticsConfig request with default parameters pub fn new(bucket: &'a str, id: &'a str) -> Self { GetBucketAnalyticsConfig(SubResource ...
true
3b5cbb2ebadbe1794dbdd978b58f0c5581095aa2
Rust
thallada/advent-of-code-2019
/day4/src/main.rs
UTF-8
2,090
3.203125
3
[]
no_license
const INPUT_MIN: u32 = 245318; const INPUT_MAX: u32 = 765747; fn solve_part1() -> u32 { let mut counter = 0; for num in INPUT_MIN..=INPUT_MAX { let num_string = num.to_string(); let mut previous = None; let mut has_double = false; let mut decreasing = false; for c in num...
true
8e04e8c1eb029d9ab8214c8d006d3d2c1eb2dd24
Rust
ctaylo21/rust_playground
/strings/src/pig_latin.rs
UTF-8
478
3.265625
3
[]
no_license
pub fn convert_to_pig_latin(text: &str) -> String { let mut pig_latin_text = String::from(""); for word in text.split_whitespace() { match word.chars().next().unwrap() { 'a' | 'e' | 'i' | 'o' | 'u' => { pig_latin_text += &format!(" {}-hay", word); } _...
true
e7f368b5cc11326e47025b4abc50f1953820296e
Rust
mikopits/rola
/src/dense/dense_vector.rs
UTF-8
2,536
3.15625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::cell::Cell; use std::fmt; use ::{Num, Vector, Zero}; #[derive(Clone, Debug)] pub struct DenseRow<T> where T: Copy { elems: Vec<Cell<T>>, } impl<T: Clone + Copy + Num> DenseRow<T> { pub fn zeros(size: usize) -> DenseRow<T> where T: Zero { DenseRow { elems: vec![Cell::new(T::zero()); size] } ...
true
98b69f8e7ad0a7c49b646beabb64383fd913be02
Rust
haxelion/bcmp-cli
/src/main.rs
UTF-8
6,901
2.734375
3
[]
no_license
extern crate bcmp; #[macro_use] extern crate clap; use std::char; use std::cmp::Ordering; use std::fs::File; use std::io::{Read, Write, stderr}; use std::usize; use bcmp::{AlgoSpec, longest_common_substrings, unique_strings, patch_set}; fn hex_dump(data: &[u8], start: usize, end: usize) { let mut i = start - (st...
true
cf008177c18d7d9a86530b6cea59d8fcc3da3911
Rust
bmatcuk/adventofcode2019
/day09/src/bin/part1.rs
UTF-8
13,746
3.421875
3
[ "MIT" ]
permissive
//! --- Day 9: Sensor Boost --- //! //! You've just said goodbye to the rebooted rover and left Mars when you receive a faint distress //! signal coming from the asteroid belt. It must be the Ceres monitoring station! //! //! In order to lock on to the signal, you'll need to boost your sensors. The Elves send up the //...
true
02c1a98d106c5055721d70563db1c6c179f29f8f
Rust
Blue-Pix/ezio
/src/cookbook/file_system/read_write/mod.rs
UTF-8
1,588
3.296875
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use std::io::{Write, BufReader, BufRead}; use same_file::Handle; use std::path::Path; use memmap::Mmap; pub fn read_lines() -> Result<(), std::io::Error> { let path = "lines.txt"; let mut output = File::create(path)?; write!(output, "Rust\n💖\nFun")?; let input = File::open(path)?; let bu...
true
60fe0790694faf6ab4ec4ad3393c8528f65eb61d
Rust
rcoh/angle-grinder
/src/operator/max.rs
UTF-8
852
2.90625
3
[ "MIT" ]
permissive
use crate::data; use crate::operator::{AggregateFunction, Data, EvalError, Evaluate, Expr}; pub struct Max { max: f64, column: Expr, } impl Max { pub fn empty<T: Into<Expr>>(column: T) -> Max { Max { max: std::f64::NEG_INFINITY, column: column.into(), } } } imp...
true
85eb59d24b26bf3485af780329d5dd06e5ce7ab1
Rust
letinh6498/vietcodes.github.io
/code/7/kara.rs
UTF-8
4,460
3.28125
3
[]
no_license
const B: u64 = 1000000000; // Base const SIZE: usize = 9; // Digit size const M: [u64; SIZE] = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]; fn alloc(n: usize) -> Vec<u64> { let mut r = Vec::with_capacity(n); r.resize(n, 0); r } // x += a * b fn mul(x: &mut [u64], a: &[u64], b: u64) { ...
true
a8b0496b110752a7b3e086847f6ada31991308bc
Rust
benanders/Canary
/src/driver/vga.rs
UTF-8
7,364
3.59375
4
[]
no_license
// // VGA Graphics Driver // use volatile::Volatile; use spin::Mutex; use core::fmt; use core::ptr::Unique; /// The width of the terminal window, in cells. const TERM_WIDTH: usize = 80; /// The height of the terminal window, in cells. const TERM_HEIGHT: usize = 25; /// The static Writer used to output characters...
true
f8b44680f7124b3d24c8f2065d236725bf21dc55
Rust
ani003/prusti_panic_test
/panics/8/extract_file_extension/extract_file_extension.rs
UTF-8
658
2.765625
3
[ "MIT" ]
permissive
use std::path::Path; fn main() { let filenames = &[ "http://example.com/download.tar.gz", "CharacterModel.3DS", ".desktop", "document", "document.txt_backup", "/etc/pam.d/login", ]; for filename in filenames { println!( "{:34} | {:8} | ...
true
891a404343a92ff8ede9f58babdb4089530ac94f
Rust
danhper/diem
/json-rpc/src/util.rs
UTF-8
3,555
2.625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Diem Core Contributors // SPDX-License-Identifier: Apache-2.0 use once_cell::sync::Lazy; use regex::Regex; use std::{fmt, str::FromStr}; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum SdkLang { Rust, Java, Python, Typescript, Go, CSharp, Cpp, Unknown, } imp...
true
7996f2e19886afb6c48af76d85ed193f690aebb4
Rust
vteremasov/brutessh
/src/ssh.rs
UTF-8
3,616
3.265625
3
[ "Apache-2.0" ]
permissive
use ssh2::{DisconnectCode, Session}; use std::fmt; use std::net::TcpStream; #[derive(Clone)] pub struct Config { host: String, port: String, } pub struct Handler { c: Option<Config>, t: Option<TcpStream>, s: Option<Session>, } impl Config { pub fn default() -> Config { Config { ...
true
d036e1765de7b7a3281a16d6b4ed492f7d7804fc
Rust
frol/actix-web-client-from-non-async
/src/main.rs
UTF-8
660
2.671875
3
[]
no_license
fn main() { let body = actix::System::builder().build().block_on(async { let client = actix_web::client::Client::new(); // Create request builder, configure request and send let mut response = client .get("https://www.rust-lang.org/") .header("User-Agent", "Actix-web...
true
be1ce5e8fa40d1f9168abfe0ed97f042e6699254
Rust
ldelriof/rust
/ch8/src/stats.rs
UTF-8
718
3
3
[]
no_license
use std::collections::HashMap; pub fn calc(num_list: &mut Vec<i32>) -> (f32, i32, i32) { num_list.sort(); let middle = num_list.len() / 2; println!("{:?}", num_list); let mut map = HashMap::new(); let mut mode = (0, 0); let mut mean = 0.; for num in num_list.iter_mut() { let count =...
true
b711a100b77fd7de15e8f2ff8fec4d362c4c6120
Rust
algoflow19/CS242
/project/code/src/main.rs
UTF-8
6,638
2.96875
3
[]
no_license
mod lib; use lib::*; use std::collections::HashSet; use std::iter::FromIterator; fn main() { // #[test] // fn node_eq() { let n01 = NodeType::new("node0"); let n02 = NodeType::new("node0"); let n11 = NodeType::new("node1"); assert_eq!(n01, n02); assert_ne!(n01, n11); ...
true
83c36d6f438404d7a1493e6cde1d11d430dd8d91
Rust
CyberFlameGO/abi_stable_crates
/abi_stable/src/type_layout/tl_enums.rs
UTF-8
19,059
2.84375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use super::*; use crate::{ abi_stability::{ abi_checking::{AbiInstability,push_err}, }, const_utils::log2_usize, std_types::{RSlice,RVec,RString}, }; /////////////////////////// /// The parts of the layout of an enum,that don't depend on generic parameters. #[repr(C)] #[derive(Copy, Clone, ...
true
d06a6bd4c5e370c14c394303a0afa4eb3c0ad57c
Rust
halazouna/stm32f429zi_tockos
/chips/sam4l/src/usbc/common/register.rs
UTF-8
1,542
3.71875
4
[ "Apache-2.0", "MIT" ]
permissive
/// Traits for types that manipulate memory-mapped registers pub trait RegisterRW { fn read(&self) -> u32; fn write(&self, val: u32); #[inline] fn set_bit(&self, bit_index: u32) { let w = self.read(); let bit = 1 << bit_index; self.write(w | bit); } #[inline] fn cl...
true
933cc09e3e8b28fca5f9d1faeb139c7b3ed196e7
Rust
danielzgtg/hackerrank-university-codesprint-5-solutions
/primegen/src/main.rs
UTF-8
503
3.140625
3
[]
no_license
fn main() { println!("{:?}", gen_high_primes()); } fn gen_high_primes() -> Vec<u64> { let mut result: Vec<u64> = Vec::with_capacity(1000000); 'outer: for x in 3..1000000_u64 { if x & 1 == 0 { continue; } let sqrt = (x as f64).sqrt() as u64 + 1; for &y in result.iter() { ...
true
4fe6e207783bd4ee60833aaa2ee1a9f45210e799
Rust
geropl/rust-go-node
/rust-lib/src/lib.rs
UTF-8
1,000
3.828125
4
[]
no_license
use thiserror::Error; #[derive(Error, Debug)] pub enum ConcatenateStringsError { #[error("could not concatenate strings, one or more arguments were empty")] ArgumentsEmtpy{} } /// Concatenates two strings pub fn concatenate_strings(a: &Option<&str>, b: &Option<&str>) -> Result<String, ConcatenateStringsErr...
true
5a2260ce99ab1b65eb19d90270bf62686cbbafe0
Rust
bamidev/gnunet-rs
/src/future.rs
UTF-8
2,170
3.3125
3
[]
no_license
use std::{ future::Future, mem, pin::Pin, task::{Context, Poll} }; /// This is a future which allows you to turn functions that provide results or signify completion through callbacks, into a future. /// A closure is provided to [`CallbackFuture::new`], which in turn provides a callable object to wake the future...
true
9bc8a2c0f2e8248d0f71873b11da1407c96ebd3e
Rust
tg-rs/tgbot
/src/types/passport/error.rs
UTF-8
22,756
3.109375
3
[ "MIT" ]
permissive
use crate::types::passport::element::EncryptedPassportElementKind; use serde::Serialize; use std::{error::Error as StdError, fmt}; /// Error in the Telegram Passport element which was submitted that should be resolved by the user #[derive(Clone, Debug, Serialize)] pub struct PassportElementError { #[serde(flatten)...
true
1b7912d7f98f911ac342595d227b60dddeadecf4
Rust
shigedangao/maomao
/src/kube/workload/container/pod/env_from.rs
UTF-8
1,336
2.53125
3
[]
no_license
use k8s_openapi::api::core::v1::{ EnvFromSource, ConfigMapEnvSource, SecretEnvSource }; use crate::lib::parser::workload::env::EnvFrom; /// Get Env Source From EnvFrom /// /// # Description /// Get the EnvFromSource struct /// /// # Arguments /// * `env` - EnvFrom /// /// # Return /// Vec<EnvFromSource> pu...
true
8237d957c42f0450e30522688f76d3ed71fe528b
Rust
bufrsh/bufrd
/src/conf.rs
UTF-8
2,817
3.15625
3
[]
no_license
use std::fmt::Write as FmtWrite; use std::fs; use std::fs::File; use std::io::{BufRead,BufReader}; use std::io::{stdin, stdout, Write}; use openssl::hash::{hash,MessageDigest}; pub struct Conf { pub user: String, pub pass: String, pub name: String, } impl Conf { pub fn new() -> Conf { Conf { user: "".to_stri...
true
60ea8e9c5f451b7465abdc67afed25a0e74531d7
Rust
snorrwe/xenos
/src/creeps/repairer.rs
UTF-8
1,099
2.9375
3
[ "MIT" ]
permissive
//! Repair structures //! use super::{find_repair_target, move_to, CreepState, LOADING}; use crate::prelude::*; use screeps::{ objects::{Creep, RoomObjectProperties, Structure}, ReturnCode, }; pub fn attempt_repair<'a>(state: &mut CreepState) -> ExecutionResult { let loading = state.creep_memory_bool(LOADI...
true
2405bcfc83f2242da9094940036d5dedbe8700db
Rust
TeodorVecerdi/rust_game_remake
/src/data/character.rs
UTF-8
3,614
2.796875
3
[ "MIT" ]
permissive
use lazy_static::lazy_static; use rand::Rng; use serde::{Deserialize, Serialize}; pub const CHARACTER_TYPE_COUNT: usize = 5; pub static ALL_CHARACTER_TYPES: &[&str] = &["adventurer", "female", "player", "soldier", "zombie"]; pub static ALL_CHARACTER_STATES: &[&str] = &["attack", "hurt", "idle"]; pub const CHARACTER_NA...
true
8f65a15ddde3c591ea178e3c4dc7020f1becbb41
Rust
tathanhdinh/objdisasm
/src/disasm.rs
UTF-8
2,728
2.9375
3
[]
no_license
use ansi_term::Colour; use capstone::{Capstone, Insn}; use std::io::{self, BufWriter, Write}; use tabwriter::TabWriter; use args::DisasmArg; use error::{Error, Result}; pub(self) struct Printer<Bw: Write> { writer: TabWriter<Bw>, verbosity: u8, inst_strings: Vec<String>, } impl<Bw> Printer<Bw> where ...
true
67288d3054eb86e983417b0767ddbe9f13ae76a1
Rust
Kixunil/rust-lnpbp
/src/cmt/committable.rs
UTF-8
1,925
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// LNP/BP Rust Library // Written in 2019 by // Dr. Maxim Orlovsky <orlovsky@pandoracore.com> // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warra...
true
ced7c0511acb1c0389641cf3b46b58e2cede32bc
Rust
Ben-PH/seL4_rust-doc
/src/kernel_api/types/err.rs
UTF-8
2,817
2.84375
3
[]
no_license
use crate::types::CapPtr; #[cfg(doc)] use crate::types::message; #[cfg(doc)] use core::convert::TryFrom; /// An invalid number used in a system call pub type InvalidNum = usize; /// The capability used with a system call in an invalid manner pub type InvalidCapPtr = CapPtr; /// Actual memory available pub type MemoryAv...
true
765ba4b9455c5c6f74ec6ab96ef2b88ab9cdf69e
Rust
Phala-Network/phala-blockchain
/crates/phala-scheduler/src/task_scheduler.rs
UTF-8
8,480
2.734375
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::fmt::Debug; use std::hash::Hash; use std::sync::{Arc, Mutex, Weak}; use std::time::Instant; use rbtree::RBTree; use std::task; pub type VirtualTime = u128; pub trait TaskIdType: Clone + Send + Eq + Hash + Debug + 'static {} impl<T: Clone + Send + Eq + Hash + Debug + 'static> T...
true
c1ad1c7432f586d1fb91b94bdec1ee73f97c51e4
Rust
enricobn/chessrw
/src/base/tag.rs
UTF-8
2,201
3.25
3
[]
no_license
#[derive(ToString,Debug)] #[derive(Copy, Clone, Hash, Eq, PartialEq)] pub enum Tag { Event, // the name of the tournament or match event. Site, // the location of the event. This is in "City, Region COUNTRY" format, where COUNTRY is the three-letter International Olympic Committee code for the country. ...
true
95e757ceee148c1c365f4691b59f5bf2bc6aedec
Rust
km-hussain-in/PyOOPDemos
/Misc/callfib.rs
UTF-8
287
2.625
3
[]
no_license
extern "C" { fn Fib(n: u64) -> u64; } fn main() { let args: Vec<String> = std::env::args().collect(); let mut n: u64 = 10; if args.len() > 1 { n = args[1].parse().unwrap(); } unsafe { println!("Result = {}", Fib(n)); } } //ar r libfib.a fib.o //rustc callfib.rs -L. -lfib
true
14a4dd67ef5982cbcd1391053912939525a42111
Rust
1Password/electron-hardener
/src/error.rs
UTF-8
4,176
3.40625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fmt; /// An error that the provided binary didn't contain the required information for /// an operation on it. #[derive(Debug, PartialEq)] #[non_exhaustive] pub enum BinaryError { /// No [sentinel byte marker]() could be found in the binary. /// /// [sentinel byte marker]: https://www.electronjs.o...
true
69a968bb0a655bff43ea06184c576c4735ab6144
Rust
fhools/raytracer-challenge-rs
/tests/ch12.rs
UTF-8
5,046
2.71875
3
[]
no_license
use utils::*; use types::*; use std::f64::consts::PI; extern crate raytracer_challenge_rs; use raytracer_challenge_rs::{Canvas, render_with_reflection}; use types::refractive_indices; #[test] fn test_ray_intersect_cube() { // (ray origin, ray direction, t1, t2) let test_cases: Vec<(Vector4D, Vector4D, f64, f64...
true