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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
472baa8a9a6aef9a6238f8df11455b93ccd84c1f | Rust | grabthequest/grabthequest-commons | /src/dto.rs | UTF-8 | 4,833 | 2.546875 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
use std::cmp::Ordering;
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct RegisterDTO {
pub full_name: String,
pub email: String,
pub password: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pu... | true |
4a081025d854a7a30d2cfa72fda0a209af7ab50b | Rust | teruuuuuu/kyoupro | /rust/src/atcoder/beginner/q165/a.rs | UTF-8 | 571 | 2.859375 | 3 | [] | no_license | use std;
pub fn main() {
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse::<T>().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap... | true |
808a1b421032f674139b627fe4dd4f2c8ccc6ecd | Rust | LukasKalbertodt/cantucci | /build.rs | UTF-8 | 2,660 | 2.796875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::{fs, path::Path};
use anyhow::{anyhow, bail, Context as _, Result};
use shaderc::{Compiler, ShaderKind};
fn main() -> Result<()> {
compile_shaders()?;
Ok(())
}
const SHADERS: &[&str] = &[
"dome.vert",
"dome.frag",
"surface.vert",
"surface.frag",
];
fn compile_shaders() -> Result... | true |
6cc86d9dda5f16b62871670ccccd05ef5dd1bd74 | Rust | galenelias/AdventOfCode_2017 | /src/Day1/mod.rs | UTF-8 | 653 | 3.21875 | 3 | [] | no_license | use std::io::{self, BufRead};
pub fn solve() {
println!("Enter input to checksum:");
let stdin = io::stdin();
let input = stdin.lock().lines().next().unwrap().unwrap();
let input_ints = input.chars().filter_map(|c| { return c.to_digit(10);}).collect::<Vec<u32>>();
let sum1 : u32 = input_ints.iter()
.zip(input_... | true |
05d9895db96ecdb7ee34756d1e8c9efc7d89d9cc | Rust | ArneBouillon/ultimate_ttt | /src/game/game_state.rs | UTF-8 | 7,789 | 2.953125 | 3 | [] | no_license | use super::board::{Board, Owned};
use super::player::Player;
use super::action::Action;
use crate::game::game_result::GameResult;
use rand::seq::SliceRandom;
use rand::Rng;
#[derive(Clone)]
pub struct GameState {
pub board: Board,
pub current_player: Player,
pub current_sub_x: Option<usize>,
pub curre... | true |
175e1ca76fcf8047e096c37ea9a34d8d45703a12 | Rust | sgbstaking/SGBStakingDapp | /src/lib.rs | UTF-8 | 8,692 | 2.515625 | 3 | [] | no_license | //! SubGame Stake Dapp
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode};
use frame_support::{
decl_error, decl_event, decl_module, decl_storage, dispatch, ensure,
traits::{Get, Currency, ReservableCurrency, ExistenceRequirement, Vec},
weights::{Weight, Pays, DispatchClass},
};
use f... | true |
38b7f741a79370f67e8463a7ed77c9b9f1473cac | Rust | roelvanduijnhoven/adventofcode-2020 | /day4/src/main.rs | UTF-8 | 567 | 3.015625 | 3 | [] | no_license | mod password;
mod validator;
use password::Password;
use validator::is_valid_pasword;
use std::fs;
fn main() {
let content = fs::read_to_string("assets/day4.in").expect("Something went wrong reading the file");
let passwords: Vec<Password> = content
.split("\n\n")
.map(|input| Password::from_s... | true |
559e60a6f159f702415950fe3c481a78cf20250d | Rust | timothee-haudebourg/bottle | /src/remote.rs | UTF-8 | 6,939 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::marker::Unsize;
use std::ops::{DispatchFromDyn, CoerceUnsized};
use std::sync::{Arc, Weak};
use std::cell::RefCell;
use std::mem::MaybeUninit;
use std::hash::{Hash, Hasher};
use std::collections::VecDeque;
use crate::{
Output,
Receiver,
Event,
EventQueueRef,
Handler,
Future,
future::LocalFuture,
Local,... | true |
d16700e3aaf6ff4f32b40ca23eafa8fed90009cc | Rust | robjsliwa/mem_query | /wasm/src/memory.rs | UTF-8 | 1,257 | 2.734375 | 3 | [
"MIT"
] | permissive | use memquery::errors::Error;
use serde_json::{json, Value};
#[no_mangle]
pub fn alloc(len: usize) -> *mut u8 {
let mut buf = Vec::with_capacity(len);
let ptr = buf.as_mut_ptr();
std::mem::forget(buf);
ptr
}
#[no_mangle]
pub unsafe fn dealloc(ptr: *mut u8, size: usize) {
// take ownership and deallocates
l... | true |
f09ebd52868a303657c589a783e22f08885f7c2b | Rust | elizlotto/relay | /compiler/crates/graphql-transforms/src/skip_unreachable_node.rs | UTF-8 | 8,090 | 2.703125 | 3 | [
"MIT"
] | permissive | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use fnv::FnvHashMap;
use graphql_ir::{
Condition, ConditionValue, FragmentDefinition, FragmentSpread, Program, Selection, Trans... | true |
a4099574fdeb1da1a782cf6ce7bfe2012acb8f19 | Rust | ibvd/app_config | /src/config.rs | UTF-8 | 9,220 | 3.015625 | 3 | [] | no_license | use shellexpand::tilde;
use std::fs;
use crate::hooks::{CommandConf, FileConf, Hook, RawConf, TemplateConf};
use crate::providers::{AppCfgConf, MockConf, ParamStoreConf, Provider};
type TResult<T> = Result<T, toml::de::Error>;
// This is a bit hard to read, but here is the deal.
// There is a BTree in <maps> that co... | true |
e8848762735d2306b253523c3fdc1f09a7a15934 | Rust | lythesia/leet | /rs/src/quests/zero_one_matrix.rs | UTF-8 | 2,042 | 3.453125 | 3 | [] | no_license | /**
* [542] 01 Matrix
*
* Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
The distance between two adjacent cells is 1.
Example 1:
Input: mat = [[0,0,0],[0,1,0],[0,0,0]]
Output: [[0,0,0],[0,1,0],[0,0,0]]
Example 2:
Input: mat = [[0,0,0],[0,1,0],[1,1,1]]
Output: [[0,0,0],[0,1,... | true |
e034d1c41eea095fcdd2fe3a8e708021fc36fa74 | Rust | IThawk/rust-project | /rust-master/src/librustc_target/spec/x86_64_unknown_uefi.rs | UTF-8 | 2,697 | 2.671875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // This defines the amd64 target for UEFI systems as described in the UEFI specification. See the
// uefi-base module for generic UEFI options. On x86_64 systems (mostly called "x64" in the spec)
// UEFI systems always run in long-mode, have the interrupt-controller pre-configured and force a
// single-CPU execution.
/... | true |
e814cb700f059db3d71a58e6755a708fcc2389be | Rust | ogoestcc/database | /src/models/wherables/user_ratings.rs | UTF-8 | 1,608 | 2.828125 | 3 | [] | no_license | use crate::{
database::{Filter, Wherable},
models::{
self,
wherables::{Rating, User},
},
services::types::ratings::WhereClause,
};
#[cfg(feature = "postgres")]
use queler::clause::Clause;
#[derive(Debug, Clone, Default)]
pub struct UserRatings(User, Rating);
impl Wherable for UserRati... | true |
129d85fbb43499387a93954c707b46a7fe270f5e | Rust | mactsouk/introRustLC | /day2/L5/http_server/src/main.rs | UTF-8 | 543 | 2.6875 | 3 | [] | no_license | extern crate hyper;
extern crate rand;
use rand::Rng;
use hyper::Server;
use hyper::server::Request;
use hyper::server::Response;
fn hello(_: Request, res: Response) {
let number = rand::thread_rng().gen_range(0, 100);
let data = format!("{}\r\n", number);
res.send(data.as_bytes()).expect("Failed to send dat... | true |
6794de5f0987c7af25a3e1d008b5c33ff23df93f | Rust | MutexUnlocked/Sinope | /src/block.rs | UTF-8 | 2,692 | 3.09375 | 3 | [] | no_license | use std::time::{SystemTime, UNIX_EPOCH};
use serde::{Deserialize, Serialize};
use sha2::{Sha256, Digest};
use crate::proof::Proof;
use crate::transcation::Transaction;
pub enum BarErr {
Nothing
}
#[derive(Serialize, Deserialize, Clone)]
pub struct Block {
nonce: Option<u64>,
timestamp: Option<u128>,
... | true |
a5c25d1b89008b8c39e781a71119a5da1c4d5b0b | Rust | matthew-mcallister/playstation-emulator | /src/cpu/operations/sltu.rs | UTF-8 | 1,327 | 3.390625 | 3 | [] | no_license | use crate::cpu::delay::Delay;
use crate::cpu::exception::Exception;
use crate::cpu::interconnect::Interconnect;
use crate::cpu::operations::Operation;
use crate::cpu::registers::Registers;
use crate::instruction::Instruction;
/// After that we encounter the instruction 0x0043082b which encodes the
/// “set on less tha... | true |
51d360fa2882cf902cbdf30a83f0f8f563d0210e | Rust | gnoliyil/fuchsia | /src/lib/storage/vfs/rust/src/service/common.rs | UTF-8 | 8,832 | 2.515625 | 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.
//! Code shared between several modules of the service implementation.
use {
fidl_fuchsia_io as fio,
fuchsia_zircon::Status,
libc::{S_IRUSR, S... | true |
ae5e498414b2103a462c34dc7c5bca7a2e82fb93 | Rust | IThawk/rust-project | /rust-master/src/test/ui/regions/regions-nested-fns.rs | UTF-8 | 427 | 2.875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | fn ignore<T>(t: T) {}
fn nested<'x>(x: &'x isize) {
let y = 3;
let mut ay = &y; //~ ERROR E0495
ignore::<Box<dyn for<'z> FnMut(&'z isize)>>(Box::new(|z| {
ay = x;
ay = &y;
ay = z;
}));
ignore::< Box<dyn for<'z> FnMut(&'z isize) -> &'z isize>>(Box::new(|z| {
if fals... | true |
644f86c7802c4316f45f256bc1dcec1f98b4ac28 | Rust | karliss/bitflip | /src/encoding.rs | UTF-8 | 4,557 | 3.296875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fs;
use std::io::{Error, ErrorKind};
use std::path::{Path, PathBuf};
use std::str;
pub struct Encoding {
pub byte_to_char: [char; 256],
pub char_to_byte: HashMap<char, u8>,
}
impl Encoding {
fn new() -> Encoding {
Encoding {
byte_to_char: ['?'; 2... | true |
8ab23f14d9db3690a66fffe0b6da6bffd9bd1f17 | Rust | byronwilliams/code-samples | /status.rs | UTF-8 | 1,642 | 2.90625 | 3 | [] | no_license | extern mod std;
extern mod extra;
use std::io;
use std::path;
use std::run::process_output;
use std::str;
use extra::time;
use std::rt::io::timer::sleep;
static GREEN: &'static str = "#00EE55";
static GREY: &'static str = "#DDDDDD";
fn load(filename: ~str) -> ~str {
let read_result: Result<@Reader, ~str>;
read_... | true |
d08973a9822ee29bad47a6b21e04e23e45ba1283 | Rust | maekawatoshiki/XScript | /src/vm.rs | UTF-8 | 2,212 | 2.9375 | 3 | [
"MIT"
] | permissive | use vm_base::VMInst;
use ansi_term::{Colour, Style};
#[derive(Clone)]
pub struct VM {
pub stack: [i64; 1024],
pub bp_stack: Vec<usize>,
pub sp: usize,
pub bp: usize,
}
impl VM {
pub fn new() -> VM {
VM {
stack: [0; 1024],
bp_stack: Vec::new(),
sp: 0,
... | true |
65f80c9acbfe31f3ee50eb9ee82b04f61ba3ddf6 | Rust | gnoliyil/fuchsia | /src/lib/diagnostics/inspect/rust/src/writer/types/int_array.rs | UTF-8 | 4,649 | 2.765625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 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 crate::writer::{ArithmeticArrayProperty, ArrayProperty, Inner, InnerValueType, InspectType};
use tracing::error;
#[cfg(test)]
use inspect_format::{Blo... | true |
6abaed94aca9deac2bbfa4d504e65139194be72a | Rust | vermaneerajin/jql | /src/group_walker.rs | UTF-8 | 2,222 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::apply_filter::apply_filter;
use crate::flatten_json_array::flatten_json_array;
use crate::get_selection::get_selection;
use crate::truncate::truncate_json;
use crate::types::{Group, MaybeArray, Selection};
use serde_json::json;
use serde_json::Value;
/// Walks through a group.
pub fn group_walker(
(spr... | true |
b54137c9f881b2be78bb20207bab3afddd8b7129 | Rust | callensm/wksp | /src/workspace.rs | UTF-8 | 1,331 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::fs::{create_dir_all, File};
use std::path::Path;
use super::logger;
use super::template::{Template, TemplateError};
#[derive(Debug)]
pub struct Workspace {
template: Template,
file_name: String,
root: String,
}
impl Workspace {
pub fn new(template_file: &str, home: &str, root: &str) -> Result<Worksp... | true |
ad24239a5b40c7679ee10117c9d077123b6f6fcc | Rust | BurtonQin/yamux | /src/frame/header.rs | UTF-8 | 4,747 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2018 Parity Technologies (UK) Ltd.
//
// Licensed under the Apache License, Version 2.0 or MIT license, at your option.
//
// A copy of the Apache License, Version 2.0 is included in the software as
// LICENSE-APACHE and a copy of the MIT license is included in the software
// as LICENSE-MIT. You may also ... | true |
0f102e23e149bce9c0d8806215a34e86fb7d39a9 | Rust | Lokathor/bytemuck | /tests/checked_tests.rs | UTF-8 | 12,942 | 2.78125 | 3 | [
"Zlib",
"Apache-2.0",
"MIT"
] | permissive | use core::{
mem::size_of,
num::{NonZeroU32, NonZeroU8},
};
use bytemuck::{checked::CheckedCastError, *};
#[test]
fn test_try_cast_slice() {
// some align4 data
let nonzero_u32_slice: &[NonZeroU32] = &[
NonZeroU32::new(4).unwrap(),
NonZeroU32::new(5).unwrap(),
NonZeroU32::new(6).unwrap(),
];
/... | true |
ff9dd1693416c7db384dde9b0f0f10804eafb795 | Rust | ippSD/raytracing | /src/radiation.rs | UTF-8 | 4,819 | 2.890625 | 3 | [] | no_license | //! Radiation module. Includes structures, traits and implementations
//! for computing the View Factors inside the world.
use std::f32::consts::PI;
use std::fmt::{Display, Formatter, Error};
use rand::random;
use crate::vectors::{Vec3, Vec3Methods};
use crate::rays::Ray;
use crate::objects::{Form, SurfaceFunctions, ... | true |
c41d652e494d6d2c5f07a55a94117fdce615299c | Rust | acmcarther/space_coop | /prototype2/client/infra/dag/src/lib.rs | UTF-8 | 7,419 | 2.765625 | 3 | [] | no_license | extern crate daggy;
extern crate itertools;
use daggy::NodeIndex;
use daggy::Walker;
use daggy::petgraph::graph::DefIndex;
use itertools::Itertools;
use std::collections::HashMap;
use std::convert::From;
use std::fmt::{Debug, Display, Error, Formatter};
use std::hash::Hash;
pub trait DagConstraints: Clone + Debug + ... | true |
ea5d50f93e4f86efb42a63b32480fa358ecba9b1 | Rust | hecrj/ggez | /src/graphics/mod.rs | UTF-8 | 36,501 | 2.78125 | 3 | [
"MIT"
] | permissive | //! The `graphics` module performs the actual drawing of images, text, and other
//! objects with the [`Drawable`](trait.Drawable.html) trait. It also handles
//! basic loading of images and text.
//!
//! This module also manages graphics state, coordinate systems, etc.
//! The default coordinate system has the origin... | true |
fca2b1ca07718a93b0324a84061b75adc0d591c9 | Rust | m4b/goblin | /src/pe/options.rs | UTF-8 | 366 | 2.65625 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | /// Parsing Options structure for the PE parser
#[derive(Debug, Copy, Clone)]
pub struct ParseOptions {
/// Wether the parser should resolve rvas or not. Default: true
pub resolve_rva: bool,
}
impl ParseOptions {
/// Returns a parse options structure with default values
pub fn default() -> Self {
... | true |
4b357690d35ab3650e277d8ee03300bbdd7ef10e | Rust | thenixan/advent-of-code-2018 | /src/days/third.rs | UTF-8 | 5,467 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::fmt;
use std::fmt::Formatter;
use std::io::BufRead;
use std::str::FromStr;
use days::print_header;
use days::read_file;
pub fn run_first_task() {
print_header(3, 1);
match read_file("days/3/input")
.map(|reader| first_task_job(reader)) {
Ok(x) => println... | true |
c8e74548ece00be41a9ee8383c6080ac1fbd2e95 | Rust | arcnmx/specialize-rs | /src/lib.rs | UTF-8 | 20,280 | 3.328125 | 3 | [
"MIT"
] | permissive | #![cfg_attr(test, feature(specialization))]
/*!
* Experimental specialization macros.
*
* Syntax is highly volatile and subject to change. The use of these macros
* requires an unstable rust compiler and the `#![feature(specialization)]`
* crate attribute.
*
* ## constrain!()
*
* `constrain!()` attempts to ad... | true |
63e333f257e33ed22ea9fdf61d90e434ce9291b4 | Rust | LEEDASILVA/rust | /reference.rs | UTF-8 | 759 | 4.21875 | 4 | [] | no_license | // another way to refere to variables
// for example: someone thats called Julia and you call Jul, you are
// refering to the same person but in different ways
fn main() {
let mut x = 10;
let xr = &x; // get a reference to x
println!("x is {} and xr is {}", x, xr);
// xr += 1; // does not work!
... | true |
c441e2020fb338983c8f4a88a6d81ce0619dd178 | Rust | xnti/keci-mobile-api | /src/action/user.rs | UTF-8 | 5,820 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::model::basket::{Basket, BasketItem};
use crate::model::user::{Claims, User};
use crate::service::basket::BasketService;
use crate::service::user::UserService;
use crate::traits::service::Creator;
use bcrypt::hash;
use bcrypt::verify;
use bson::oid::ObjectId;
use bson::{from_bson, to_bson};
use jsonwebtoken::... | true |
ff16e5f0c498fe1543d685108ae3b0bc8addbb1c | Rust | blasrodri/matecito-example | /src/main.rs | UTF-8 | 1,243 | 3.109375 | 3 | [] | no_license | use actix_web::{web, get, post, App, HttpRequest, HttpServer};
use matecito::Matecito;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let data = web::Data::new(Matecito::<String, String>::new(10_000));
HttpServer::new(move || {
App::new()
// .route("/", web::get().to(greet))
... | true |
829b436a783e324bf762420cf89644abf2b3588f | Rust | JohnTitor/stdsimd | /crates/core_simd/src/masks/full_masks.rs | UTF-8 | 12,171 | 3.28125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Masks that take up full SIMD vector registers.
/// The error type returned when converting an integer to a mask fails.
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct TryFromMaskError(());
impl core::fmt::Display for TryFromMaskError {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {... | true |
273368f1366bc4a3d2718570ee54df9acc084092 | Rust | MarcusTL12/AdventOfCode2016Rust | /src/day8.rs | UTF-8 | 2,680 | 3.265625 | 3 | [] | no_license | use std::{
fs::File,
io::{BufRead, BufReader},
};
use arrayvec::ArrayVec;
pub const PARTS: [fn(); 2] = [part1, part2];
fn render_screen(screen: &[Vec<bool>]) {
for row in screen {
for &cell in row {
print!("{}", if cell { '█' } else { ' ' });
}
println!();
}
}
fn ... | true |
e385f5384a86d80c951d3f9bf5f73167ab3f3457 | Rust | seppaleinen/hellorust | /src/main.rs | UTF-8 | 230 | 2.625 | 3 | [] | no_license | extern crate module;
///# Main
///1. Does nothing.
///2. Continue doing nothing.
///3. Print hello world
#[cfg(not(test))]
fn main() {
let result = module::yo("Hello".to_string());
println!("Hello, world! {:?}", result);
}
| true |
e41c258a96a02c28e2ee68772b3f4d8243cf6258 | Rust | dante-signal31/test_common | /src/random/strings.rs | UTF-8 | 919 | 3.90625 | 4 | [
"BSD-3-Clause"
] | permissive | /// Random operations with strings.
use rand::prelude::*;
use rand::distributions::Alphanumeric;
/// Generate a random string of desired length.
///
/// # Parameters:
/// * len: Desired character length for generated string.
///
/// # Returns:
/// * Generated random string.
pub fn random_string(len: usize)-> String {... | true |
216adfd2eae3a3e799c7446929472bfd4bd51a15 | Rust | bouzuya/rust-atcoder | /atcoder-problems-virtual-contests/4aa0347f-2081-47ef-a459-e9ee82768539/src/bin/4.rs | UTF-8 | 786 | 3.078125 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
}
if n < 357 {
println!("0");
return;
}
let mut cs: Vec<usize> = vec![];
for len in 3..=n.to_string().len() {
let mut curr = vec![3, 5, 7];
for _ in 0..len - 1 {
let mut next = vec![];
... | true |
9a8d7ea958865185d7b9ad47f7e329b492e7014b | Rust | Orca-bit/DataStructureAndAlgorithm | /src/dp/_123_best_time_to_buy_and_sell_stock_3.rs | UTF-8 | 873 | 3.59375 | 4 | [] | no_license | struct Solution;
impl Solution {
pub fn max_profit(prices: Vec<i32>) -> i32 {
let mut first_buy = i32::MIN;
let mut first_sell = 0;
let mut second_buy = i32::MIN;
let mut second_sell = 0;
for price in prices {
first_buy = first_buy.max(-price);
first_... | true |
428d00f93e92320ddace8068730913bf1d72b140 | Rust | Resonious/adventureformer | /af/src/assets/mod.rs | UTF-8 | 5,356 | 2.53125 | 3 | [] | no_license | extern crate gl;
extern crate glfw;
use gl::types::*;
use std::mem::{zeroed, size_of, transmute};
use render;
use render::{GLData, ImageAsset, Texcoords};
use std::ffi::CString;
use vecmath::*;
#[macro_use]
mod macros;
image_assets!(
ccbdy crattlecrute_body: SpriteType2Color2 [9][90;90] "assets/crattlecrut... | true |
5aa1fc0139b8abffed6af71261e25deef3fed144 | Rust | clpi/dapi | /di-db/src/query.rs | UTF-8 | 14,596 | 2.6875 | 3 | [] | no_license | ///query.rs
///Construct sqlx queries from a model and parameters of form
use chrono::{DateTime, Utc};
use divc::models::Model;
use sqlx::prelude::*;
use sqlx::postgres::{PgPool, PgConnection, PgDone};
use std::boxed::Box;
use divc::models::{User, Record, Item};
use serde::{Serialize, Deserialize};
//TODO let's try th... | true |
2497b3ba673e85eb488fc77e4390d83911f489b3 | Rust | jsdelivrbot/euler_criterion.rs | /src/language.rs | UTF-8 | 3,186 | 2.765625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fs::{File, PathExt, self};
use std::io::{Read, Write};
use std::path::Path;
use rustc_serialize::json;
use compiler::Compiler;
use interpreter::Interpreter;
#[derive(RustcDecodable)]
pub struct Language {
compiler: Option<Compiler>,
extension: String,
interpreter: Option<Interpreter>,
name: ... | true |
2002cdf5b09c5fc010e4e9fe917c9bce60c81d4a | Rust | imawhale/blog | /src/slug.rs | UTF-8 | 1,505 | 3.484375 | 3 | [] | no_license | use crate::common::*;
#[derive(Debug, Clone)]
pub(crate) struct Slug {
text: String,
}
impl Slug {
pub(crate) fn from_text(text: String) -> Result<Slug, Error> {
let mut dash = false;
for (i, c) in text.chars().enumerate() {
if c.is_ascii_lowercase() {
dash = false;
} else if c == '-'... | true |
e2df7a4af5ada78577572bea836a18ec4295c4d1 | Rust | hawkingrei/hackerrank | /rust/compare-the-triplets/src/main.rs | UTF-8 | 728 | 3.40625 | 3 | [] | no_license | use std::io;
fn get_input() -> String {
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).expect("Failed");
buffer
}
fn main() {
let numbersA: Vec<i32> = get_input().split_whitespace()
.map(|x| x.parse::<i32>().expect("parse error"))
.collect::<Vec<i32>>();
let numbersB... | true |
e76ab9beb8baa73781629797a35b3269fe6dbaec | Rust | AD1024/cdcl-rust | /src/clause.rs | UTF-8 | 3,331 | 2.984375 | 3 | [] | no_license | use crate::clause::AST::*;
use std::fmt::{Debug, Formatter, Display};
#[derive(Clone)]
#[derive(Debug)]
pub enum AST {
Var(String),
Not(BoxAST),
And(BoxAST, BoxAST),
Or(BoxAST, BoxAST),
Implies(BoxAST, BoxAST),
Iff(BoxAST, BoxAST)
}
type BoxAST = Box<AST>;
pub struct VariableS... | true |
27bcd6e8a24d5a1054bfeb383841de609c661cd2 | Rust | blofroth/border | /border-tch-agent/src/util.rs | UTF-8 | 3,116 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Utilities.
use crate::model::ModelBase;
use log::trace;
use serde::{Deserialize, Serialize};
mod mlp;
mod quantile_loss;
pub use mlp::{create_actor, create_critic, MLPConfig, MLP, MLP2};
pub use quantile_loss::quantile_huber_loss;
/// Interval between optimization steps.
#[derive(Debug, Deserialize, Serialize, Par... | true |
23849d7abeeb24242e355592b29def7605b5314a | Rust | Rexagon/vrs | /src/rendering/validation.rs | UTF-8 | 4,373 | 2.546875 | 3 | [] | no_license | use super::prelude::*;
use super::Instance;
pub struct Validation {
is_enabled: bool,
debug_utils_ext: ash::extensions::ext::DebugUtils,
debug_utils_messenger: vk::DebugUtilsMessengerEXT,
}
impl Validation {
pub fn new(entry: &ash::Entry, instance: &Instance, is_enabled: bool) -> Result<Self> {
... | true |
7814edf0f1ec7d440c5a32b8f60f4501b14cb946 | Rust | jgdavey/advent_of_code_2020 | /aoc09/src/main.rs | UTF-8 | 1,288 | 3.3125 | 3 | [] | no_license | use std::cmp::Ordering;
fn main() {
let input = std::fs::read_to_string("input.txt").unwrap();
let numbers: Vec<_> = input.lines().map(|s| s.parse::<isize>().unwrap()).collect();
let (idx, target) = numbers.iter().enumerate().skip(25).find(|&(i, target)| {
let previous = &numbers[(i - 25)..i];
... | true |
6c5d3650f46b309b31fd64f1f3041641554fd922 | Rust | ldfdev/Exercises-from-the-book-Beginning-Rust-From-Novice-To-Expert | /Chapter 16/iterating_over_chars_in_str.rs | UTF-8 | 504 | 3.640625 | 4 | [] | no_license |
fn display_by_iterating(slice: &str) {
// iterators for str type are accessed via chars() function
let mut iter = slice.chars();
loop {
match iter.next() {
Some(value) => {
print!("Curent value {}. Remaining {}\n", value, iter.as_str());
},
None ... | true |
a024e2bda77d53a7434424bd7688fb42e174248e | Rust | k0nserv/advent-of-code-2017 | /src/day13.rs | UTF-8 | 3,497 | 3.375 | 3 | [] | no_license | use std::collections::HashMap;
use std::ops::Range;
#[derive(Debug)]
struct State {
levels: HashMap<u32, u32>,
scanner_locations: HashMap<u32, (u32, i32)>,
packect_location: i32,
severity: u32,
final_location: u32,
}
impl State {
fn parse(input: &str) -> Self {
let levels = input
... | true |
b73785dc8216ba23145b899f7d6da6d67d2d41fa | Rust | tykel/retrogram | /src/platform/gb.rs | UTF-8 | 11,019 | 2.71875 | 3 | [] | no_license | //! Platform implementation for Game Boy and it's attendant memory mapper chips
use std::io;
use crate::{reg, memory};
use crate::reg::New;
use crate::arch::sm83;
/// Any type which decodes the banked memory region (0x4000) of a Game Boy ROM
/// image.
trait Mapper {
fn decode_banked_addr(&self, ptr: &memory::Po... | true |
60471f6bb40332e154588270fa3caa425e45b612 | Rust | house-mouse/my-iot-rs | /src/core/thread.rs | UTF-8 | 597 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use std::time::Duration;
/// Spawns a service thread which just periodically invokes the `loop_` function.
/// This is a frequently repeated pattern in the services.
pub fn spawn_service_loop<F>(service_id: String, interval: Duration, loop_: F) -> Result
where
F: Fn() -> Result,
F: Send ... | true |
79bb65e20e9865ad1de416fc70a0bcff79d93919 | Rust | tene/silmaril | /src/effect/rainbow.rs | UTF-8 | 1,934 | 3.21875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{Color, Effect, PixelIndexable};
use core::marker::PhantomData;
use palette::Hue;
#[derive(Clone, Copy)]
pub enum Orientation {
Horizontal,
Vertical,
Spiral,
}
impl Orientation {
pub fn next(self) -> Self {
use Orientation::*;
match self {
Horizontal => Vertical,... | true |
e8f3f9048b8f0215df05a46ee0b9e96b06cd7867 | Rust | mdalbello/seqkit | /src/sam_count.rs | UTF-8 | 3,280 | 2.515625 | 3 | [
"MIT"
] | permissive |
use crate::common::{parse_args, BamReader};
use std::str;
use std::thread;
use std::fs::{File, remove_file};
use std::process::{Command, Stdio};
use std::io::{BufReader, BufWriter, BufRead, Write};
const USAGE: &str = "
Usage:
sam count [options] <bam_file> <regions.bed>
Options:
--frac-inside=F Minimum overla... | true |
0162430db3f887ad1e49ec41bfdb9309d0f929da | Rust | filippixavier/AoC2019 | /src/days/day14.rs | UTF-8 | 3,669 | 3.140625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fs;
use std::path::Path;
use regex::Regex;
use std::collections::HashMap;
#[derive(Debug, Clone)]
struct Recipe {
qut_produced: u64,
composition: HashMap<String, u64>,
}
fn get_recipes(input: String) -> HashMap<String, Recipe> {
let reg = Regex::new(r"(\d+) (\w+)").unwrap(... | true |
9ae327bb3f62484aafd03758e6f0498483014557 | Rust | mtXTJocj/rosetta_code | /code_generator/src/lib.rs | UTF-8 | 30,274 | 2.890625 | 3 | [
"Unlicense"
] | permissive | use std::collections::HashMap;
use std::string::ToString;
use instruction::*;
use lexical_analyzer::error::*;
use syntax_analyzer::ast_node::*;
mod instruction;
pub struct CodeGenerator<'a> {
data_addr: HashMap<&'a str, u32>,
string_pool: Vec<&'a str>,
pc: u32,
instructions: Vec<Instruction>,
}
impl... | true |
47371144fef83f10a09f2e5b1bc5bd27331a06d1 | Rust | NicoVIII/galaxy-server-rust | /src/gamegen/mod.rs | UTF-8 | 24,675 | 2.96875 | 3 | [
"MIT"
] | permissive | use rand::Rng;
use std::cmp;
use std::convert::TryFrom;
use std::convert::TryInto;
mod print;
mod t;
fn add_border(space: &t::DotSpace, filler: t::Dot) -> t::DotSpace {
let x_size = space.len();
let y_size = space[0].len();
let mut new_space: t::DotSpace = Vec::new();
// Create border line
let mu... | true |
ea05129911513ef472e43ee3640405d73be62db4 | Rust | ReggieMarr/audio-oxide | /docs/reference_src/unused/callbacks.rs | UTF-8 | 4,894 | 2.75 | 3 | [] | no_license | use signal_processing::{Sample, AnalyzedSample};
use rustfft::{FFTplanner, FFT};
use num::complex::Complex;
#[derive(Copy, Clone, Debug)]
pub struct Vec4 {
pub vec: [f32; 4],
}
implement_vertex!(Vec4, vec);
struct input_parameters {
fft_size : usize,
buffer_size : usize,
use_analytic_filter : bool,
... | true |
87423349194ddf7a6ea69b8cf0103856d972185f | Rust | hur/advent-of-code-2020 | /day10/src/main.rs | UTF-8 | 1,552 | 3.421875 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::collections::HashMap;
fn part1(data: &[u32]) {
// Diffs is a mapping of the magnitude of difference between two elements in data and the count
// of the difference
let mut diffs = HashMap::<u32,u32>::new();
let mut prev = 0u32;
for d in data.iter() {
l... | true |
41aa496539b3efc866bce0e3767cd802428d1f43 | Rust | itang/tests | /test-rusts/test_2018_mod_paths/src/paths.rs | UTF-8 | 1,026 | 3.15625 | 3 | [] | no_license | //see: https://rust-lang-nursery.github.io/edition-guide/rust-2018/module-system/path-clarity.html
// Rust 2018 (uniform paths variant)
//a path starting from an external crate name
use futures::Future;
use self::foo::Bar;
mod foo {
pub struct Bar;
}
// use a relative path from the current module
//a path sta... | true |
e2b477160b908a01aedb28a417a953efdf24dc2d | Rust | nicksrandall/serde_dynamo | /src/de/deserializer_seq.rs | UTF-8 | 2,855 | 2.6875 | 3 | [
"MIT"
] | permissive | use super::{AttributeValue, Deserializer, Error, Result};
use crate::de::deserializer_bytes::DeserializerBytes;
use crate::de::deserializer_number::DeserializerNumber;
use serde::de::{DeserializeSeed, IntoDeserializer, SeqAccess};
pub struct DeserializerSeq {
iter: std::vec::IntoIter<AttributeValue>,
}
impl Deser... | true |
1f497a8ca9f04c1a047703c65a72662d632b1e63 | Rust | sooda/advent-of-code | /19/9.rs | UTF-8 | 3,994 | 2.984375 | 3 | [] | no_license | use std::io::{self, BufRead};
fn step<'a, 'b, I: Iterator<Item = &'b i64>>(program: &'a mut [i64], ip: usize, base: i64, input: &mut I) -> Option<(usize, i64, Option<i64>)> {
let opcode = program[ip] % 100;
if opcode == 99 {
// short circuit this, the discontinuity is annoying
return None;
... | true |
c0323bebb8495df6efb6e235614f279e03240995 | Rust | Connicpu/boop | /src/main.rs | UTF-8 | 4,948 | 3.0625 | 3 | [] | no_license | use std::io::{Cursor, Write};
use async_std::net::UdpSocket;
pub mod tts;
#[async_std::main]
async fn main() {
let mut args = std::env::args().skip(1);
let result = match args.next().as_deref() {
Some("--help") | None => {
eprintln!("USAGE: boop [name] broadcast a boop packet t... | true |
9ad7ac837a0c1a579dd4ab389655de029b7b10ac | Rust | athre0z/color-backtrace | /src/lib.rs | UTF-8 | 29,059 | 3.3125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Colorful and clean backtraces on panic.
//!
//! This library aims to make panics a little less painful by nicely colorizing
//! them, skipping over frames of functions called after the panic was already
//! initiated and printing relevant source snippets. Frames of functions in your
//! application are colored in a... | true |
0ea10b8d38f349210768075b647b8350bb3d1299 | Rust | LaplaceKorea/sml-compiler | /crates/sml-util/src/interner.rs | UTF-8 | 4,270 | 2.625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::pin::Pin;
macro_rules! globals {
(@step $idx:expr, ) => {
pub const S_TOTAL_GLOBALS: usize = $idx;
};
(@step $idx:expr, $it:ident, $($rest:ident,)*) => {
pub const $it: Symbol = Symbol::Builtin($idx as u32);
globals!(@step $idx+1usize, $($rest... | true |
76c328e57b17da1bf8fadaa3a348173b0fdc19d6 | Rust | pkafma-aon/LeetCode-Rust | /src/rotate_list.rs | UTF-8 | 3,852 | 3.71875 | 4 | [
"WTFPL"
] | permissive | impl Solution {
pub fn rotate_right(head: Option<Box<ListNode>>, mut k: i32) -> Option<Box<ListNode>> {
if head.is_none() {
return head;
}
let mut cur = &head;
let mut length = 0;
while let Some(next) = cur {
cur = &next.next;
length += 1;... | true |
c27451e17f9c9889316032b3653b4cde84674871 | Rust | siku2/russ | /russ-internal-macro/src/derive/css_value/css_field.rs | UTF-8 | 8,623 | 2.8125 | 3 | [] | no_license | use super::args::{self, Args, FromArgs};
use proc_macro2::TokenStream;
use quote::{quote, quote_spanned, ToTokens};
use syn::{Attribute, ExprPath, Field, Ident, LitStr, Path, Type};
pub struct FieldAttr {
attr: Attribute,
pub prefix: Option<LitStr>,
pub suffix: Option<LitStr>,
pub write_fn: Option<LitS... | true |
c207b0b463d3d45a211e5e82d4c9110c28483168 | Rust | Nauscar/determinate | /src/lib.rs | UTF-8 | 3,199 | 2.515625 | 3 | [] | no_license | use proc_macro::TokenStream;
use quote::quote;
use syn::fold::Fold;
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::token::Comma;
use syn::{parse_macro_input, parse_quote, ItemFn, Pat};
struct Determinate;
impl Parse for Determinate {
fn parse(_input: ParseStream) -> Result<... | true |
9462c307861c71dec476ef813c097d032ca91132 | Rust | kunalb/AoC2020 | /src/bin/day6.rs | UTF-8 | 1,240 | 3.34375 | 3 | [] | no_license | use std::collections::HashSet;
use std::env;
use std::error::Error;
use std::io::{self, Read};
fn process<F>(buffer: &str, f: F) -> usize
where
F: Fn(&str) -> usize,
{
buffer.split("\n\n").map(f).fold(0, |a, b| a + b)
}
fn solve1(buffer: &str) -> usize {
process(buffer, |x| {
x.chars()
... | true |
ea77e8347a7f98005f12f061b68dd8af4fa2795e | Rust | Censkh/Maxwell | /src/compiler/transform/plugin.rs | UTF-8 | 760 | 2.703125 | 3 | [] | no_license | use super::super::{Chunk};
use super::super::ast::statement::StatementNode;
use super::super::ast::expression::ExpressionNode;
use std::result::Result;
use std::error::Error;
use std::hash::{Hash,Hasher};
pub trait Plugin {
fn handle(&self, pass: &mut PluginPass) -> Result<String, Box<Error>>;
fn get_name(&... | true |
1d7c9da32b35d85aaf8f97e9b9ea80b22f5ca66c | Rust | shobhitchittora/learn-rust | /variables/src/main.rs | UTF-8 | 1,038 | 3.984375 | 4 | [] | no_license | fn main() {
// Mutability
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
// Constants
const MY_CONST: u32 = 100_00;
println!("MY_CONT = {}", MY_CONST);
// Shadowing
let spaces = " ";
let spaces = spaces.len();
p... | true |
5e9b8c2eac061345206947695411ee8e381d6b19 | Rust | input-output-hk/vit-kedqr | /src/lib.rs | UTF-8 | 4,660 | 2.8125 | 3 | [
"MIT"
] | permissive | use chain_crypto::{Ed25519Extended, SecretKey, SecretKeyError};
use image::{DynamicImage, ImageBuffer, Luma};
use qrcode::{
render::{svg, unicode},
EcLevel, QrCode,
};
use std::fmt;
use std::fs::File;
use std::io::{self, prelude::*};
use std::path::Path;
use symmetric_cipher::{decrypt, encrypt, Error as Symmetr... | true |
fed32eea1a569395a5d8762d36196ef00152e286 | Rust | MPTGits/QuestGiverRustGame | /target/debug/build/wayland-protocols-ac1a20a560d181a7/out/wlr-foreign-toplevel-management-v1_c_client_api.rs | UTF-8 | 35,011 | 2.515625 | 3 | [
"MIT"
] | permissive | #[doc = "list and control opened apps\n\nThe purpose of this protocol is to enable the creation of taskbars\nand docks by providing them with a list of opened applications and\nletting them request certain actions on them, like maximizing, etc.\n\nAfter a client binds the zwlr_foreign_toplevel_manager_v1, each opened\n... | true |
93c29c81a15a7db86e429b7ba7d090df557c8a6d | Rust | izelnakri/mber-rust | /src/commands/new.rs | UTF-8 | 4,759 | 2.84375 | 3 | [
"MIT"
] | permissive | // TODO: rewrite this in tokio
use super::super::utils::console;
use super::super::injections::new_ember_application;
use mustache::MapBuilder;
use serde::{Deserialize, Serialize};
use serde_json;
use std::collections::HashMap;
use std::env;
use std::fs;
use std::path::PathBuf;
use std::process;
use yansi::Paint;
#[de... | true |
97856f0cc6b518882dc942b917268ad7399d220a | Rust | rkanati/sleeper | /src/assembler.rs | UTF-8 | 7,457 | 2.859375 | 3 | [] | no_license |
use {
crate::{
instruction::{self, Reg},
},
std::{
cmp::{min, max},
collections::HashMap,
iter::repeat,
slice,
},
};
type SymTab = HashMap<&'static str, i32>;
#[derive(Clone, Copy)]
pub enum Imm {
Lit(i32),
Ref(&'static str),
HiB(&'static str),
... | true |
7fdfbfb78b970a2a2a8af65201b34f5cea4e88d5 | Rust | MDeiml/nextflix | /src/model.rs | UTF-8 | 409 | 2.640625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Serialize, Deserialize, Debug)]
pub struct User {
pub username: String,
pub password_hash: String,
pub friends: HashMap<u64, FriendData>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct FriendData {
pub movies: Vec<u64>... | true |
b7e52e57c6d34f0b868074187a65140a527c6598 | Rust | seanchen1991/rune | /crates/rune/src/ast/stmt.rs | UTF-8 | 314 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::ast;
use crate::{Spanned, ToTokens};
/// A statement within a block.
#[derive(Debug, Clone, ToTokens, Spanned)]
pub enum Stmt {
/// A declaration.
Item(ast::Item),
/// An expression.
Expr(ast::Expr),
/// An expression followed by a semicolon.
Semi(ast::Expr, ast::SemiColon),
}
| true |
dfb754f83d2c85f2ab4775383c3f21c82673ae25 | Rust | jgdavey/advent_of_code_2020 | /aoc05/src/main.rs | UTF-8 | 814 | 3.640625 | 4 | [] | no_license | pub fn decode(seat: &str) -> usize {
let binary: String = seat
.chars()
.map(|c| match c {
'B' | 'R' => '1',
'F' | 'L' => '0',
_ => c,
})
.collect();
usize::from_str_radix(&binary, 2).unwrap()
}
fn main() {
let input = std::fs::read_to_str... | true |
c78807bd57df95ae5028a7a42c7b52520629fc9d | Rust | harpsword/tex-rs | /src/tex_the_program/section_0498.rs | UTF-8 | 3,075 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! @ A condition is started when the |expand| procedure encounters
//! an |if_test| command; in that case |expand| reduces to |conditional|,
//! which is a recursive procedure.
//! @^recursion@>
//
// @p procedure conditional;
#[allow(unused_variables)]
pub(crate) fn conditional(globals: &mut TeXGlobals) -> TeXResult<... | true |
18e06dd40833b4accee1aca504f04440b3017c28 | Rust | XuShaohua/nc | /src/platform/darwin-types/sys/ipc.rs | UTF-8 | 1,425 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) 2022 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
// Use of this source is governed by Apache-2.0 License that can be found
// in the LICENSE file.
//! From `sys/ipc.h`
use crate::{gid_t, key_t, mode_t, uid_t};
/// Information used in determining permission to perform an IPC operation
#[der... | true |
652dda8ebab123e14b31696975099539d6177257 | Rust | bazelbuild/rules_rust | /test/rust_test_suite/tests/integrated_test_b.rs | UTF-8 | 86 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use math_lib::add;
#[test]
fn add_three_and_four() {
assert_eq!(add(3, 4), 7);
}
| true |
977f35a82a09ed9c2e6ed732a15383654a742ef0 | Rust | wveitch/greenhouse-rs | /src/server/http.rs | UTF-8 | 1,889 | 2.671875 | 3 | [] | no_license | use crossbeam::channel::Sender;
use log::info;
use rocket::config::LoggingLevel;
use rocket::config::{Config, Environment, Limits};
use std::io;
use std::path::PathBuf;
use std::thread;
use crate::config::CachePath;
use crate::router;
pub struct HttpServe {
http_handle: Option<thread::JoinHandle<()>>,
http_ad... | true |
e20c9dcfb15239e93000cc3371f58b7ecd911c26 | Rust | Mathspy/unsafe-now | /index.rs | UTF-8 | 5,922 | 2.703125 | 3 | [] | no_license | use geiger::{find_unsafe_in_file, Count, CounterBlock, IncludeTests, ScanFileError};
use git2::Repository;
use http::{header, Request, Response, StatusCode};
use serde::Serialize;
use std::{collections::HashMap, path::Path};
use tempdir::TempDir;
use url::Url;
use walkdir::{DirEntry, Error as WalkDirError, WalkDir};
#... | true |
7881b9b1817251d52633f49da1ab9edbb4151700 | Rust | haraldmaida/advent-of-code-2018 | /src/day14/tests.rs | UTF-8 | 2,547 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
const INPUT: &str = include_str!("../../input/2018/day14.txt");
mod score_seq {
use super::*;
#[test]
fn fmt_display() {
assert_eq!(
ScoreSeq(vec![5, 1, 5, 8, 9, 1, 6, 7, 7, 9]).to_string(),
"[5, 1, 5, 8, 9, 1, 6, 7, 7, 9]"
);
}
}
mod scoreboard ... | true |
9f1fdf85a89b490693558b60dfff7d60b4fd6a31 | Rust | drainiard/rr8 | /src/rr8/ui/prompt.rs | UTF-8 | 1,051 | 2.6875 | 3 | [
"CC-BY-3.0"
] | permissive | use crate::*;
#[derive(Debug, Default, Eq, PartialEq)]
pub struct Prompt;
impl System for Prompt {
fn update(&mut self, ctx: &mut Context, game: &mut Game) -> GameResult {
todo!()
}
fn draw(&self, ctx: &mut Context, game: &Game) -> GameResult {
let ui = &game.ui;
if let GameMode::... | true |
18699d753f27a66af5e9e0be2508c91df4748510 | Rust | mitnk/h2okv | /src/cli/cli.rs | UTF-8 | 1,146 | 2.8125 | 3 | [] | no_license | use std::net::TcpStream;
use crate::do_delete;
use crate::do_get;
use crate::do_put;
use crate::do_scan;
pub fn query(line: &str, stream: &mut TcpStream) {
if line.starts_with("del ") {
let tokens: Vec<&str> = line.split_whitespace().collect();
do_delete::delete(tokens[1], stream);
return;... | true |
29e5285023c5a00519b102657cfa9f1183277635 | Rust | CPerezz/Corretto | /src/backend/u64/scalar.rs | UTF-8 | 26,912 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Arithmetic mod `2^249 - 15145038707218910765482344729778085401`
//! with five 52-bit unsigned limbs
//! represented in radix `2^52`.
use core::fmt::Debug;
use core::ops::{Index, IndexMut};
use core::ops::{Add, Sub, Mul, Neg};
use std::cmp::{PartialOrd, Ordering, Ord};
use num::Integer;
use crate::backend::u64:... | true |
5fa49c2cdc373e29c2566069b44de7cb23242a57 | Rust | d-plaindoux/celma | /core/tests/parser/option.rs | UTF-8 | 1,214 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | /*
Copyright 2019-2023 Didier Plaindoux
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed... | true |
c11696102b9b31b3d38a937fd6f9baf8c82915b4 | Rust | jugglerchris/aoc2017 | /examples/day5.rs | UTF-8 | 1,155 | 2.90625 | 3 | [
"MIT"
] | permissive | #![feature(conservative_impl_trait)]
extern crate aoc2017;
fn solve(input: &str) -> isize {
let mut data = aoc2017::parse_lines::<isize>(input);
let mut count = 0;
let mut pc = 0;
loop {
let newpc = pc + data[pc as usize];
data[pc as usize] += 1;
count += 1;
if (newpc a... | true |
a36ff07ed4e69971dbcfffd4d3376303304bf69c | Rust | ZcashFoundation/librustzcash | /zcash_client_sqlite/src/lib.rs | UTF-8 | 26,572 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! *An SQLite-based Zcash light client.*
//!
//! `zcash_client_sqlite` contains complete SQLite-based implementations of the [`WalletRead`],
//! [`WalletWrite`], and [`BlockSource`] traits from the [`zcash_client_backend`] crate. In
//! combination with [`zcash_client_backend`], it provides a full implementation of a ... | true |
5690194a79be769bf81a7dd514c412d3e77cfba2 | Rust | GregBowyer/rust-ar | /src/lib.rs | UTF-8 | 77,765 | 3.328125 | 3 | [
"MIT"
] | permissive | //! A library for encoding/decoding Unix archive files.
//!
//! This library provides utilities necessary to manage [Unix archive
//! files](https://en.wikipedia.org/wiki/Ar_(Unix)) (as generated by the
//! standard `ar` command line utility) abstracted over a reader or writer.
//! This library provides a streaming int... | true |
fdda4a41bcc21919e95472dc2882f381b1aeaf36 | Rust | Lireer/ricochet-robot-solver | /ricochet_solver/src/lib.rs | UTF-8 | 1,783 | 3.265625 | 3 | [] | no_license | mod a_star;
mod breadth_first;
mod iterative_deepening;
mod mcts;
pub mod util;
use getset::Getters;
use ricochet_board::{Direction, Robot, RobotPositions, Round};
pub use a_star::AStar;
pub use breadth_first::BreadthFirst;
pub use iterative_deepening::IdaStar;
pub use mcts::Mcts;
pub trait Solver {
/// Find a s... | true |
8f8c5eab907432bec70eff0b4779fcbfe08575ff | Rust | patallen/BitRomney | /src/gameboy/operations.rs | UTF-8 | 89,499 | 2.984375 | 3 | [] | no_license | #![allow(unused_variables)]
#![allow(non_snake_case)]
use gameboy::cpu::Cpu;
use gameboy::mmu::Mmu;
use gameboy::registers::FlagRegister;
use bitty::BitFlags;
pub struct Operation {
pub dis: &'static str,
pub func: Box<Fn(&mut Cpu, &mut Mmu)>,
pub cycles: u8,
pub mode: ValueMode,
}
impl Operation {
... | true |
44098a3c7355910bf4d420e1b84bd7a6a31ac60e | Rust | dprentiss/caddis | /caddis/src/geometry.rs | UTF-8 | 10,922 | 2.59375 | 3 | [] | no_license | use std::ops::{
Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign,
};
use std::f64;
use std::f64::consts;
use num_traits::identities::{One, Zero};
pub use alga::linear::{
AffineSpace, EuclideanSpace, FiniteDimInnerSpace, FiniteDimVectorSpace, InnerSpace,
NormedSpace, Ve... | true |
260d115edbd0b27b60bb77db9fc8b2eb5cbfcccc | Rust | gbersac/computorv1-42 | /src/solver.rs | UTF-8 | 7,051 | 3.203125 | 3 | [] | no_license | use solution::Solution;
use parser::Parser;
use std::fmt::Write;
use std::cmp::Ordering;
use x_part::{XPart};
use nbr_complex::NbrComplex;
pub struct Solver
{
pub xs: Vec<XPart>,
pub discriminant: Option<f32>,
pub sol: Solution,
pub degree: f32,
}
impl Solver
{
pub... | true |
05757c97a7d9462da64c3bc946adbbb8bd2b0bc4 | Rust | x37v/puredata-rust | /external/src/atom.rs | UTF-8 | 4,866 | 2.59375 | 3 | [] | no_license | use crate::symbol::Symbol;
use std::convert::TryInto;
#[repr(transparent)]
pub struct Atom(pub pd_sys::t_atom);
impl Atom {
pub fn slice_from_raw_parts(
argv: *const pd_sys::t_atom,
argc: std::os::raw::c_int,
) -> &'static [Atom] {
unsafe {
let (argv, argc) = if argv.is_nul... | true |
506080ebb12a0146fc3c879bc55a830c9fc07ba4 | Rust | weiwei-lin/fieldmask-rs | /fieldmask/tests/one_of.rs | UTF-8 | 3,901 | 3.0625 | 3 | [] | no_license | use std::convert::TryFrom;
use fieldmask::{FieldMask, FieldMaskInput, Maskable};
#[derive(Debug, PartialEq, Maskable)]
enum OneOf {
A(String),
B(String),
AnotherCase(String),
}
impl Default for OneOf {
fn default() -> Self {
Self::A(String::default())
}
}
#[derive(Debug, PartialEq, Maska... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.