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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7dbafc413541a75f50d0b34be3c17ebb3da75d22 | Rust | Charles-Schleich/aoc-2020 | /src/libday1.rs | UTF-8 | 980 | 3.234375 | 3 | [] | no_license |
use std::fs::File ;
use std::io::prelude::*;
use std::io::BufReader;
use std::{thread, time};
use std::time::{Duration, Instant};
fn read_input(filename: &str) -> Vec<u32> {
let f = File::open(filename).unwrap();
let mut reader = BufReader::new(f);
let mut line = String::new();
let mut vec = Vec::ne... | true |
73f063e9f8c673a75780c4f574e7a8efc6f4a357 | Rust | jkaessens/TheVault | /src/models.rs | UTF-8 | 1,548 | 2.5625 | 3 | [] | no_license | use crate::schema::*;
use serde::Serialize;
use chrono::NaiveDate;
#[derive(Queryable,QueryableByName,Insertable,Debug,Serialize)]
#[table_name="run"]
pub struct Run {
pub name: String,
pub date: NaiveDate,
pub assay: String,
pub chemistry: String,
pub description: Option<String>,
pub investig... | true |
16125f6020606b8d011df004cb22273c75efc1a5 | Rust | jaysonsantos/lenient-semver | /src/lib.rs | UTF-8 | 22,105 | 3.203125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![warn(missing_docs)]
/*!
Lenient parser for Semantic Version numbers.
## Motivation
This crate aims to provide an alternative parser for [semver `Version`s](https://crates.io/crates/semver).
Instead of adhering to the semver specification, this parser is more lenient in what it allows.
The differenc include:
- M... | true |
88fccc2134859631d7b987cca29c3e688c8b91e6 | Rust | mottodora/contest | /yukicoder/7.rs | UTF-8 | 885 | 3.328125 | 3 | [] | no_license | fn getline() -> String{
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}
fn eratosthenes(n: i32) -> Vec<i32> {
let mut v: Vec<i32> = (2..n+1).collect();
let mut i:i32 = 0;
while i < v.len() as i32 {
let a = v[i as usize];
v.retain(|&x| x< a+1... | true |
b63f3d5b850c62709566212eaf5f6c617604c518 | Rust | rinde/aws-lambda-rust-runtime | /lambda-runtime-errors/src/lib.rs | UTF-8 | 6,707 | 3.484375 | 3 | [
"Apache-2.0"
] | permissive | //! The Lambda runtime errors crate defines the `LambdaErrorExt` trait
//! that can be used by libriaries to return errors compatible with the
//! AWS Lambda Rust runtime.
//!
//! This crate also exports the `lambda_runtime_errors_derive` crate to
//! derive the `LambdaErrorExt` trait.
//!
//! ```rust,no-run
//! use la... | true |
c226541ad8e62e455bbdf372f4c2749281d9baa9 | Rust | SchrodingerZhu/toylibc | /src/time/sys.rs | UTF-8 | 3,768 | 2.8125 | 3 | [] | no_license | use core::convert::TryInto;
use core::time::Duration;
use syscalls::syscall2;
use crate::{clockid_t, timespec};
use crate::constants::*;
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
struct Timespec {
t: timespec,
}
impl Timespec {
const fn zero() -> Timespec {
Timespec {
... | true |
0793de86af6a541d7792ca3a8c431615250ec4f5 | Rust | nbardiuk/rlox | /src/bin/interpreter/parser.rs | UTF-8 | 39,386 | 3.453125 | 3 | [] | no_license | use crate::ast::Expr;
use crate::ast::Stmt;
use crate::lox::Lox;
use crate::token::Literal;
use crate::token::Token;
use crate::token::TokenType;
const MAX_ARGS: usize = 255;
#[derive(Debug)]
struct ParserError {}
pub struct Parser<'a> {
tokens: Vec<Token>,
current: usize,
lox: &'a mut Lox,
}
impl<'a> P... | true |
744125f3ad641d37ce9f1d69a9a1e47d98db4f53 | Rust | ogham/exa | /src/fs/feature/git.rs | UTF-8 | 12,689 | 3.34375 | 3 | [
"MIT"
] | permissive | //! Getting the Git status of files and directories.
use std::ffi::OsStr;
#[cfg(target_family = "unix")]
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use log::*;
use crate::fs::fields as f;
/// A **Git cache** is assembled based on the user’s input arguments.
///
/// This... | true |
b7bcdccda56cad69c5acb40647e5ccf80277f1fe | Rust | mvarble/nutrition | /src/fdc/mod.rs | UTF-8 | 2,441 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | //! This module allows us to perform HTTP requests to the
//! [FoodData Central](https://fdc.nal.usda.gov/index.html) API though the [`FDCService`] struct.
pub mod api;
pub use api::*;
use anyhow::Result;
use reqwest::Client;
/// `FDCService` implements the http requests to the FDC API through an Actix client.
#[de... | true |
b03cec8883d2db62f41461e83d5f54c752b846b4 | Rust | timvermeulen/advent-of-code | /src/solutions/year2016/day08.rs | UTF-8 | 2,709 | 3.171875 | 3 | [] | no_license | use super::*;
#[derive(Copy, Clone)]
enum State {
On,
Off,
}
impl Debug for State {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::On => write!(f, "#"),
Self::Off => write!(f, "."),
}
}
}
#[derive(Debug)]
enum Operation {
Rect { wi... | true |
eccc7305b390303bcb6efa72464628798f262161 | Rust | bauhaus93/optimizer | /src/article.rs | UTF-8 | 472 | 3.25 | 3 | [] | no_license |
pub fn calculate_article_fitness(deck: &[Article]) -> u32 {
let mut sum = 0;
deck.iter().for_each(| ref e | sum += e.get_total_price());
sum
}
#[derive(Clone)]
pub struct Article {
id_article: u32,
count: u32,
price: u32
}
impl Article {
pub fn get_total_price(&self) -> u32 {
sel... | true |
ab1a4c89be82d450ef77a3420ef1bb2f3308db68 | Rust | transparencies/eventuals | /src/eventual/ptr.rs | UTF-8 | 3,065 | 3.34375 | 3 | [] | no_license | use by_address::ByAddress;
use std::{
borrow::Borrow, cmp::Ordering, convert::AsRef, error::Error, fmt, hash::Hash, ops::Deref,
sync::Arc,
};
/// This type is a thin wrapper around T to enable cheap clone and comparisons.
/// Internally it is an Arc that is compared by address instead of by the
/// implementat... | true |
59e8b8eb830610aaa45870fadb3788ed2615a9dc | Rust | SourangshuGhosh/v3 | /languages/rust/exercises/concept/options/.meta/example.rs | UTF-8 | 917 | 3.453125 | 3 | [
"MIT"
] | permissive | pub struct Player {
pub health: u32,
pub mana: Option<u32>,
pub level: u32,
}
impl Player {
pub fn revive(&self) -> Option<Player> {
match self.health {
// Player is dead!
0 => {
if self.level >= 10 {
Some(Player { health: 100, mana: S... | true |
606882c2e254177faae5d838febacc5bfbae5c18 | Rust | BartMassey/advent-of-code-2020 | /day17/soln.rs | UTF-8 | 2,889 | 3.046875 | 3 | [
"MIT"
] | permissive | // This program is licensed under the "MIT License".
// Please see the file LICENSE in this distribution
// for license terms.
//! Advent of Code Day 17.
//! Bart Massey 2020
use aoc::*;
use std::collections::HashSet;
type Board<const D: usize> = HashSet<[isize; D]>;
fn read_initial<const D: usize>() -> Board<D>... | true |
297e4710f33517aa4f9c4533edf4d94a26e5b3eb | Rust | gymore-io/stadium | /tests/tests.rs | UTF-8 | 6,366 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::cell::Cell;
use std::mem::ManuallyDrop;
use std::rc::Rc;
/// A simple structure that adds one to its inner counter when it gets dropped.
pub struct DropCounter(ManuallyDrop<Rc<Cell<usize>>>);
impl Drop for DropCounter {
fn drop(&mut self) {
self.0.set(self.0.get() + 1);
unsafe { ManuallyD... | true |
238005ce7d41fd03bbcf254a9ce426441941a6bb | Rust | loxp/kvs | /project-1/src/kv.rs | UTF-8 | 669 | 3.5625 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
/// key value store
pub struct KvStore {
store: HashMap<String, String>,
}
impl KvStore {
/// constructor of KvStore
pub fn new() -> Self {
KvStore {
store: HashMap::new(),
}
}
/// set a key value pair
pub fn set(&mut self, key: Strin... | true |
357a20a0515a3857c68ec7f15767bb067088d720 | Rust | KhemPoudel/mongo-explorer | /src-tauri/src/main.rs | UTF-8 | 7,473 | 2.671875 | 3 | [] | no_license | #![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
use mongodb::{ Client,
Collection,
options::{
ClientOptions,
ServerAddress::{Tcp},
Credential
},
bson::{
doc,
Document,
oid::ObjectId
}
};
use serde::{... | true |
830e5559baeaf998ae06c6ddd6dc7e78743d8f48 | Rust | Nugine/bpnn-rs | /src/bpnn.rs | UTF-8 | 3,953 | 2.53125 | 3 | [] | no_license | mod func;
mod types;
mod utils;
pub use self::func::*;
pub use self::types::*;
pub use self::utils::*;
use ndarray::Array;
pub struct BPNN {
weights: Vec<Matrix>,
changes: Vec<Matrix>,
activations: Vec<Activation>,
d_activations: Vec<DActivation>,
cost: Cost,
d_cost: DCost,
}
#[allow(non_sna... | true |
6bc14006e7fc4ec427d182f7924a1442d7c73dd0 | Rust | rcoh/angle-grinder | /src/typecheck.rs | UTF-8 | 16,674 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::data::Value;
use crate::errors::ErrorBuilder;
use crate::lang;
use crate::operator::{
average, count, count_distinct, expr, fields, limit, max, min, parse, percentile, split, sum,
timeslice, total, where_op,
};
use crate::{funcs, operator};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Type... | true |
09fc7f56c3ac6436a870b90e6bc284c265d5bb19 | Rust | cyber-meow/ReactiveRs | /src/signal/single_thread/spmc_signal.rs | UTF-8 | 6,087 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::rc::Rc;
use std::cell::RefCell;
use runtime::SingleThreadRuntime;
use continuation::ContinuationSt;
use signal::Signal;
use signal::signal_runtime::{SignalRuntimeRefBase, SignalRuntimeRefSt};
use signal::valued_signal::{ValuedSignal, SpSignal, CanEmit, GetValue, CanTryEmit, TryEmitValue};
/// A shared pointe... | true |
da2265944254441fa6c417c3f800dcc4af53cfc1 | Rust | sergeyboyko0791/redis-asio | /src/base/error.rs | UTF-8 | 1,463 | 3.25 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::error::Error;
#[derive(Debug, Clone, PartialEq)]
pub enum RedisErrorKind {
InternalError,
IncorrectConversion,
ConnectionError,
ParseError,
ReceiveError,
InvalidOptions,
}
#[derive(Debug, Clone)]
pub struct RedisError {
pub error: RedisErrorKind,
desc: String,
}
... | true |
3160f440876e95a53f0413bc48be15627f7a0cda | Rust | rstropek/rust-samples | /wasm-serverless/word_puzzle_spin/src/lib.rs | UTF-8 | 1,787 | 2.625 | 3 | [] | no_license | use anyhow::Result;
use http::response::Builder;
use spin_sdk::{
http::{Request, Response, Params},
http_component, http_router,
};
use word_puzzle_generator::{place_words, GeneratorOptions};
#[http_component]
fn handle_word_puzzle_spin(req: Request) -> Result<Response> {
if req.method() == http::Method::OP... | true |
89d6edff6e18f9e28675a936ff0cfe07b5120e7d | Rust | untoldwind/t-rust-less | /lib/src/memguard/zeroize_buffer.rs | UTF-8 | 1,737 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::io;
use std::ops;
use zeroize::Zeroize;
pub struct ZeroizeBytesBuffer(Vec<u8>);
impl ZeroizeBytesBuffer {
pub fn with_capacity(initial_capacity: usize) -> ZeroizeBytesBuffer {
ZeroizeBytesBuffer(Vec::with_capacity(initial_capacity))
}
}
impl ZeroizeBytesBuffer {
pub fn append(&mut self, byte: u8) ... | true |
5e7593313205ed5d0a6721995546b81d3f74c6d5 | Rust | finallyegg/cmsc330spring19-public | /discussions/discussion12/src/lib.rs | UTF-8 | 1,522 | 3.359375 | 3 | [] | no_license | // Discussion 12 exercises
use std::mem::swap;
use std::rc::Rc;
// Given a list of list of integers, return the sum. Use map and fold.
// sum_arr_arr(&[&[1, 2], &[3]] -> 6
pub fn sum_arr_arr(arr: &[&[i32]]) -> i32 {
// IMPLEMENT
0
}
#[derive (Debug, PartialEq)]
enum List<T> {
Nil,
Cons(T, Box<List<T>... | true |
3a7695d5b32a05d83125b8b8a3ebd81ec74d1a54 | Rust | koonopek/wat_plan_v2_backend | /src/scrap_wat.rs | UTF-8 | 6,839 | 2.640625 | 3 | [] | no_license | use std::prelude::v1::Vec;
use std::result::Result;
use std::thread;
use reqwest;
use s3::bucket::Bucket;
use scraper::{Html, Selector};
use tokio::fs::File;
use s3::credentials::Credentials;
use s3::region::Region;
use tokio::prelude::*;
use crate::s3_driver;
use std::error::Error;
const COOLDOWN: std::time::Duratio... | true |
24b1896d3ef972a1057eeca980d9a46bc1e3c597 | Rust | claderoki/Intergalactica-Discord-Bot-Rust | /src/modules/pigeon/commands/explore.rs | UTF-8 | 4,685 | 2.671875 | 3 | [] | no_license | use std::time::Duration;
use chrono::NaiveDateTime;
use serenity::builder::CreateComponents;
use serenity::client::Context;
use serenity::framework::standard::macros::command;
use serenity::framework::standard::CommandResult;
use serenity::model::channel::Message;
use serenity::model::channel::ReactionType;
use sereni... | true |
2f0959f55db6038a552552adb41244bdaf78a76a | Rust | scraeling/aoc2020 | /day10/src/main.rs | UTF-8 | 2,027 | 3.140625 | 3 | [] | no_license | use std::fs::read_to_string;
use timer::time;
use std::collections::HashMap;
use std::collections::HashSet;
fn main() {
let input = read_to_string("input.txt").unwrap();
let adapters = time!(parse_input(&input));
let p1 = time!(part_1(&adapters));
let p2 = time!(part_2(&adapters));
println!("Part ... | true |
8d69f8c6e833722eca9c0846de7f3a04aa1805ad | Rust | udoprog/OxidizeBot | /crates/oxidize-common/src/irc.rs | UTF-8 | 1,672 | 3.40625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /// Struct of tags.
#[derive(Debug, Clone, Default)]
pub struct Tags {
/// Contents of the id tag if present.
pub id: Option<String>,
/// Contents of the msg-id tag if present.
pub msg_id: Option<String>,
/// The display name of the user.
pub display_name: Option<String>,
/// The ID of the u... | true |
6f819d64a46894411abc3e75c8c427027caabb92 | Rust | gengjiawen/leetcode | /String/_1119_remove_vowels_from_a_string.rs | UTF-8 | 315 | 3.46875 | 3 | [] | no_license | // https://leetcode.com/problems/remove-vowels-from-a-string
pub fn remove_vowels(s: String) -> String {
return s
.chars()
.filter(|i| !vec!['a', 'o', 'e', 'i', 'u'].contains(i))
.collect();
}
#[test]
pub fn t1() {
assert_eq!(remove_vowels("aeiou".to_string()), "".to_string());
}
| true |
6b33947b744a41e8dc79340ad3448593fb25ba96 | Rust | jcawl/learning-rust | /ch4_ownership/dangling_pointer.rs | UTF-8 | 510 | 3.390625 | 3 | [] | no_license | // !!code causes error!!
fn main() {
let ref_to_nothing = return_something();
}
fn return_nothing() -> &String {
//bring string into scope
let s = String::from("hello");
//return reference to string
&s
//`drop` is called on the memory storing s
//as it goes out of scope
}
fn return_somet... | true |
d402cebd064947560bfa93cb855d3ec32ac3891b | Rust | mrkgnao/sqlx | /sqlx-core/src/postgres/types/bool.rs | UTF-8 | 821 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::decode::{Decode, DecodeError};
use crate::encode::Encode;
use crate::postgres::protocol::TypeId;
use crate::postgres::types::PgTypeInfo;
use crate::postgres::Postgres;
use crate::types::HasSqlType;
impl HasSqlType<bool> for Postgres {
fn type_info() -> PgTypeInfo {
PgTypeInfo::new(TypeId::BOOL)
... | true |
099b741c62573aa165098ff5f6ad47e6847f1dec | Rust | the-emerald/capra | /src/segment.rs | UTF-8 | 2,636 | 2.890625 | 3 | [
"MIT"
] | permissive | use crate::environment::Environment;
use crate::segment::DiveSegmentError::InconsistentDepth;
use crate::units::consumption::GasConsumption;
use crate::units::consumption_rate::GasConsumptionRate;
use crate::units::depth::Depth;
use crate::units::rate::Rate;
use thiserror::Error;
use time::Duration;
#[derive(Copy, Clo... | true |
7ac316b78327dc95636f184c3b617edc5cf818cf | Rust | opentimestamps/rust-opentimestamps | /src/attestation.rs | UTF-8 | 4,636 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright (C) The OpenTimestamps developers
//
// This file is part of rust-opentimestamps.
//
// It is subject to the license terms in the LICENSE file found in the
// top-level directory of this distribution.
//
// No part of rust-opentimestamps including this file, may be copied, modified,
// propagated, or distr... | true |
c5072d4bd7bb0371af21f024ec8cb00979664255 | Rust | JasonCreighton/raymond | /src/main.rs | UTF-8 | 6,407 | 2.875 | 3 | [
"MIT"
] | permissive | mod math;
mod ppm;
mod scene;
mod surface;
mod texture;
mod util;
use rand::random;
use std::time::Instant;
use structopt::StructOpt;
use math::*;
use scene::*;
use surface::*;
use texture::*;
#[derive(StructOpt)]
#[structopt(name = "raymond")]
struct CommandLineArguments {
/// Output file in PPM format (overwri... | true |
50ff7932f7eb0fb03a0a0a569b4555609666eb08 | Rust | strategist922/chia-plotmover-rs | /src/main.rs | UTF-8 | 4,713 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | mod cfg;
use cfg::Cfg;
use log::{debug, error, info};
use notify::{raw_watcher, RawEvent, RecursiveMode, Watcher};
use std::error::Error;
use std::sync::mpsc::channel;
use std::{
ffi::OsString,
fs::{self, DirEntry},
};
use sysinfo::{DiskExt, System, SystemExt};
#[macro_use]
extern crate lazy_static;
lazy_stati... | true |
e4d8e5c78d207c1ab19224fb2f8b06f1830215a8 | Rust | alex179ohm/nsq-client-rs | /src/state.rs | UTF-8 | 899 | 2.765625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use futures::{AsyncRead, AsyncWrite};
pub trait State {}
pub trait EndState {}
pub trait Transition<S>
where
S: State,
Self: State,
{
fn to(self, recv: &dyn AsyncRead, send: &dyn AsyncWrite) -> S;
}
pub trait Terminate
where
Self: EndState,
{
fn end(self);
}
pub struct Magic;
impl Magic {
p... | true |
b4aee045afc1e83ba40e895efc5ca35bef73d631 | Rust | 4e6/enso | /lib/rust/enso-logger/src/disabled.rs | UTF-8 | 918 | 2.765625 | 3 | [
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! Contains definition of trivial logger that discards all messages except warnings and errors.
use enso_prelude::*;
use crate::Message;
use crate::AnyLogger;
use crate::enabled;
use enso_shapely::CloneRef;
use std::fmt::Debug;
// ==============
// === Logger ===
// ==============
/// Trivial logger that discar... | true |
f52df41dafb263b300902a26ebae86ae477e29b7 | Rust | docweirdo/rOSt | /src/helpers.rs | UTF-8 | 604 | 3.359375 | 3 | [] | no_license | /// Writes u32 memory at the specified base + offset
pub fn write_register(base: u32, offset: u32, input: u32) {
unsafe { core::ptr::write_volatile((base + offset) as *mut u32, input) }
}
/// Reads u32 memory at the specified base + offset
pub fn read_register(base: u32, offset: u32) -> u32 {
unsafe { core::pt... | true |
6444b5a369ccb15b7e382a6e0c0fc0c12ee101b3 | Rust | Boscop/mincode | /src/rustc_serialize/writer.rs | UTF-8 | 15,196 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::io::Write;
use std::io::Error as IoError;
use std::error::Error;
use std::fmt;
use rustc_serialize_crate::Encoder;
use byteorder::WriteBytesExt;
use leb128;
use float::*;
pub type EncodingResult<T> = Result<T, EncodingError>;
/// An error that can be produced during encoding.
#[derive(Debug)]
pub enum E... | true |
802004b957670545bae39c5e9b8de0c65a649764 | Rust | Michael-F-Bryan/midl-rs | /midl/src/syntax/parser.rs | UTF-8 | 3,481 | 2.734375 | 3 | [
"MIT"
] | permissive | use codespan::{CodeMap, FileMap, FileName};
use failure_derive::Fail;
use slog::{Discard, Logger};
use std::env;
use std::fmt::{self, Display, Formatter};
use std::io;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
#[derive(Clone)]
pub struct Parser {
imports: Arc<ImportResolver>,
logger: Logger,... | true |
be4356e5c28146d06c01f05e7b4a4c9199d75fa6 | Rust | nisarhassan12/materialize | /src/transform/src/fusion/filter.rs | UTF-8 | 2,958 | 2.5625 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"CC0-1.0",
"BSD-3-Clause",
"MPL-2.0",
"0BSD",
"PostgreSQL",
"GPL-1.0-or-later",
"GPL-2.0-only",
"MIT",
"BUSL-1.1"
] | permissive | // Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by ... | true |
51a042f4230f33de2290bceb5a4f8bf88f8674e6 | Rust | hdtx/raytracer-comparison | /rust/src/vec3.rs | UTF-8 | 3,957 | 3.6875 | 4 | [
"MIT"
] | permissive | use std::cmp::PartialEq;
use std::ops;
#[derive(Debug, Clone, Copy)]
pub struct Vec3 {
x: f32,
y: f32,
z: f32,
}
impl Vec3 {
pub fn new(x: f32, y: f32, z: f32) -> Self {
Vec3 { x, y, z }
}
pub fn x(self) -> f32 {
self.x
}
pub fn y(self) -> f32 {
self.y
}
... | true |
135f50ac761d7758d071cb52a8e6f3873cfd7bd5 | Rust | peter-signal/dtls | /src/extension/extension_supported_signature_algorithms.rs | UTF-8 | 1,711 | 2.53125 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod extension_supported_signature_algorithms_test;
use super::*;
use crate::signature_hash_algorithm::*;
const EXTENSION_SUPPORTED_SIGNATURE_ALGORITHMS_HEADER_SIZE: usize = 6;
// https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1
#[derive(Clone, Debug, PartialEq)]
pub struct ExtensionSupportedSignatu... | true |
395469488158d80dc1ca0cf20643df94aa4b0cba | Rust | gitter-badger/dustbox-rs | /src/register.rs | UTF-8 | 1,045 | 3 | 3 | [
"MIT"
] | permissive | #[derive(Copy, Clone, Default)]
pub struct Register16 {
pub val: u16,
}
impl Register16 {
pub fn set_hi(&mut self, val: u8) {
self.val = (self.val & 0xFF) + (u16::from(val) << 8);
}
pub fn set_lo(&mut self, val: u8) {
self.val = (self.val & 0xFF00) + u16::from(val);
}
pub fn lo_... | true |
3ef5f8aa7277ab4eb101ceeac1f2415c6ac34ac7 | Rust | ruiramos/aoc2019 | /day_12/day_12.rs | UTF-8 | 7,238 | 3 | 3 | [] | no_license | // cargo-deps: num = "0.2"
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::Read;
fn main() {
let mut moons = create_moons(read_data());
let mut xs: Vec<Vec<isize>> = vec![vec![], vec![], vec![], vec![]];
let mut ys: Vec<Vec<isize>> = vec![vec![], vec![], vec![], vec![]];
l... | true |
00872306e7f35f894ece7315cefb21bd1a3d1392 | Rust | developer0116/slackrypt | /client/src/main.rs | UTF-8 | 2,304 | 2.578125 | 3 | [] | no_license | use std::convert::From;
use std::convert::Into;
use std::vec::Vec;
use rsa::RSAPublicKey;
use simple_logger::SimpleLogger;
mod crypto;
mod gui;
mod io;
mod prop;
mod util;
fn main() {
let dir: String = util::default_dir();
let version_header: String = String::from("Version: Slackrypt 0.3");
init(&dir);
... | true |
a3c7edb70cf5dfedfac5ec5d97b7315a5e8eee8f | Rust | MitchellTesla/vit-servicing-station | /vit-servicing-station-lib/src/v0/errors.rs | UTF-8 | 1,845 | 2.65625 | 3 | [] | no_license | use thiserror::Error;
use warp::{reply::Response, Rejection, Reply};
#[derive(Error, Debug)]
pub enum HandleError {
#[error("The data requested data for `{0}` is not available")]
NotFound(String),
#[error("Internal error")]
DatabaseError(#[from] diesel::r2d2::PoolError),
#[error("Unauthorized tok... | true |
e8d8992edf5d2f8eb7e57e3161e1be98a7525ddf | Rust | MidasLamb/async-graphql | /async-graphql-parser/src/pos.rs | UTF-8 | 2,732 | 3.4375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use serde::Serialize;
use std::borrow::{Borrow, BorrowMut};
use std::cmp::Ordering;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::ops::{Deref, DerefMut};
/// Original position of element in source code
#[derive(PartialOrd, Ord, PartialEq, Eq, Clone, Copy, Default, Hash, Serialize)]
pub struct Pos {
/// One... | true |
c3040ffd1cd166aa797236bdf0b5afb5dac18078 | Rust | occlum/occlum | /src/libos/src/fs/procfs/pid/mod.rs | UTF-8 | 4,509 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | use super::*;
use crate::process::table::get_process;
use crate::process::{ProcessRef, ProcessStatus};
use self::cmdline::ProcCmdlineINode;
use self::comm::ProcCommINode;
use self::cwd::ProcCwdSymINode;
use self::exe::ProcExeSymINode;
use self::fd::LockedProcFdDirINode;
use self::maps::ProcMapsINode;
use self::root::P... | true |
2fa40698df0d4f9ab63acd49cf993628b2f2a54a | Rust | m-rots/bernard-rs | /src/model/drive.rs | UTF-8 | 1,044 | 3.078125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::database::{Connection, Pool};
#[derive(Debug)]
pub struct Drive {
pub id: String,
pub page_token: String,
}
impl Drive {
pub(crate) async fn create(
id: &str,
page_token: &str,
conn: &mut Connection,
) -> sqlx::Result<()> {
sqlx::query!(
"INSERT I... | true |
2ea4bbbb70698d0d7223aa1be2f18a37267e9076 | Rust | kent-mcleod/samples | /flock/src/main.rs | UTF-8 | 910 | 2.765625 | 3 | [
"MIT"
] | permissive | extern crate nix;
use nix::fcntl;
use std::io::prelude::*;
use std::fs::File;
use std::os::unix::prelude::*;
use std::fs::OpenOptions;
fn main() {
let f = (File::create("foo.txt")).unwrap();
let mut file2 = OpenOptions::new()
.read(true)
.write(true)
... | true |
df1983e7abf4b7c1bdd5f0517910bceb2dd77906 | Rust | otov4its/ripple-address-codec-rust | /tests/api.rs | UTF-8 | 5,476 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use ripple_address_codec as api;
use utils::*;
mod utils {
use std::convert::TryInto;
use hex;
use rand::{thread_rng, Rng};
pub fn to_bytes(hex: &str) -> Vec<u8> {
hex::decode(hex).unwrap()
}
pub fn to_20_bytes(hex: &str) -> [u8; 20] {
to_bytes(hex).try_into().unwrap()
}... | true |
801a7c4fc62b6d89fc202331f51011a11c4aca9b | Rust | stevepryde/thirtyfour | /thirtyfour/src/common/command.rs | UTF-8 | 3,387 | 3.59375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::Locator;
use std::fmt;
use std::fmt::Debug;
/// The webdriver selector to use when querying elements.
#[derive(Debug, Clone)]
pub enum BySelector {
/// Query by element id.
Id(String),
/// Query by link text.
LinkText(String),
/// Query by CSS.
Css(String),
/// Query by XPath.
... | true |
66f04c1eaa943283fb32b2f861e13a821c360c23 | Rust | ryanpbrewster/jqi | /src/main.rs | UTF-8 | 5,243 | 2.984375 | 3 | [] | no_license | use serde_json::Value;
use std::io::Stdout;
use std::io::Write;
use std::path::PathBuf;
use std::{fmt::Display, io::BufReader};
use structopt::StructOpt;
use termion::cursor::{Goto, HideCursor};
use termion::event::{Event, Key};
use termion::input::TermRead;
use termion::raw::{IntoRawMode, RawTerminal};
use termion::st... | true |
23425a682c9446f8c0122421c383a0f950ae44c9 | Rust | Tenebryo/coin | /bitboard/src/board.rs | UTF-8 | 17,786 | 3.375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fmt;
use bit_ops::*;
use std::ops::Not;
use std::hash::*;
pub const MAX_MOVES : usize = 30;
pub type MoveList = [Move; MAX_MOVES];
pub type MoveOrder = [(i32, usize); MAX_MOVES];
#[derive(Copy, Clone, PartialEq, Hash, Eq, Serialize, Deserialize)]
pub struct Turn(bool);
impl Turn {
pub const BLACK : Tu... | true |
343d053256046309cfd7c6ee068035f2da63f0c2 | Rust | Unaidedsteak/rustlings-solutions | /src/exercise.rs | UTF-8 | 1,862 | 3.328125 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use std::fmt::{self, Display, Formatter};
use std::fs::remove_file;
use std::path::PathBuf;
use std::process::{self, Command, Output};
const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"];
fn temp_file() -> String {
format!("./temp_{}", process::id())
}
#[derive(Deserialize)]
#[serde(... | true |
38d7f0721374e4828fd6a244e47d1c85f3dc20ec | Rust | MihirLuthra/discriminant_hash_derive | /tests/discriminant_hash_derive.rs | UTF-8 | 1,211 | 3.171875 | 3 | [] | no_license | use discriminant_hash_derive::DiscriminantHash;
use std::{
collections::hash_map::DefaultHasher,
hash::{Hash, Hasher},
};
#[derive(DiscriminantHash)]
enum Abc<'a, T> {
Simple,
Lifetime(&'a str),
HashNotImpl(Xyz),
Generic(T),
}
#[allow(unused)]
#[derive(Hash)]
enum Pqr<'a> {
Simple,
Lif... | true |
328e461eccfaac958f1515cf8ee1cc98926f599a | Rust | rustyforks/tendril-wiki | /libs/markdown/src/parsers/meta.rs | UTF-8 | 5,337 | 2.90625 | 3 | [] | no_license | use std::{collections::HashMap, path::Path};
use tasks::path_to_reader;
use crate::processors::tags::TagsArray;
#[derive(Debug)]
pub struct EditPageData {
pub body: String,
pub tags: Vec<String>,
pub title: String,
pub old_title: String,
pub metadata: HashMap<String, String>,
}
impl From<HashMap... | true |
555299b1a58aaec3ccca778d185d7bb1f9c09bc5 | Rust | himlpplm/rust-tdlib | /src/types/delete_supergroup.rs | UTF-8 | 2,142 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Deletes a supergroup or channel along with all messages in the corresponding chat. This will release the supergroup or channel username and remove all members; requires owner privileges in the supergroup or channel. Chats with more than 1000 members can't ... | true |
19f26f8652fbd78d1193151ccf924284fa840804 | Rust | opaps/sparkler | /src/main.rs | UTF-8 | 1,420 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate git2;
extern crate notify;
extern crate sparkler;
use notify::{watcher, RecursiveMode, Watcher};
use std::sync::mpsc::channel;
use std::time::Duration;
use sparkler::repo;
fn main() {
// Create a channel to receive the events.
let (tx, rx) = channel();
let path = "../tmp";
let the_repo... | true |
d152f8690330af0bf6ed88eac66641bec131bf1a | Rust | serverlesstechnology/cqrs | /src/test/mod.rs | UTF-8 | 939 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | //! This module provides a test framework for building a resilient test base around aggregates.
//! A `TestFramework` should be used to build a comprehensive set of aggregate tests to verify
//! your application logic.
//!
//! ```rust
//! # use cqrs_es::test::TestFramework;
//! # use cqrs_es::doc::{Customer, CustomerEv... | true |
e3918bc204ad6d5092ba4424cdb60d0ff3ebb6b2 | Rust | melotic/docx-rs | /src/macros.rs | UTF-8 | 1,853 | 2.703125 | 3 | [
"MIT"
] | permissive | #[macro_export]
#[doc(hidden)]
macro_rules! __string_enum {
($name:ident { $($variant:ident = $value:expr, )* }) => {
impl std::fmt::Display for $name {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
$( $name::$variant => wr... | true |
292d5520e6b4ff048c87acbe4291831f4a170991 | Rust | ianzhang1988/RustOneFileExample | /src/bin/algo_binary_tree.rs | UTF-8 | 2,152 | 3.859375 | 4 | [] | no_license | use std::cell::Cell;
#[derive(Debug)]
enum NodeType<T> {
Node(Box<Node<T>>),
Null,
}
use NodeType::Null;
use std::borrow::{BorrowMut, Borrow};
#[derive(Debug)]
struct Node<T> {
value: T,
left: NodeType<T>,
right:NodeType<T>,
}
#[derive(Debug)]
struct Foo {
v1: u32,
v2: u32,
v3: Strin... | true |
0662ed3c3f092f806eee262a753c1c8682d12ff2 | Rust | richarddowner/Rust | /rust-by-example/modules/visibility/visibility.rs | UTF-8 | 1,813 | 3.6875 | 4 | [] | no_license | // By default, the items in a module have private visibility, but this
// can be overridden with thepub modifier. Only the public items of a
// module can be accessed from outside the module scope.
fn function() {
println!("called `function()`");
}
mod my {
// A public function
pub fn function() {
println!("call... | true |
1efee4dee7f4decf0adeb12428a40de8051e1e36 | Rust | tmikus/rlox | /src/token.rs | UTF-8 | 1,234 | 3.484375 | 3 | [] | no_license | use std::any::Any;
use std::fmt;
use token_type::TokenType;
pub struct Token {
token_type: TokenType,
lexeme: String,
literal: Option<Box<Any>>,
line: i32,
}
impl Token {
pub fn new(token_type: TokenType, lexeme: String, literal: Option<Box<Any>>, line: i32) -> Token {
Token {
token_type: token_ty... | true |
d8c9ee153aeb0f0462a6178341091c396d824d73 | Rust | ycrypto/salty | /build.rs | UTF-8 | 2,462 | 2.578125 | 3 | [
"CC0-1.0",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | use std::env;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=build.rs");
// Cortex-M33 is compatible with Cortex-M4 and its DSP extension instruction UMAAL.
let target = env::var("TARGET")?;
let cortex_m4 = target.starts_with("thumbv7em") || target.starts_with("... | true |
05019171098db2209283b43f10bd63c951ee233d | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/arc022/src/bin/a.rs | UTF-8 | 461 | 2.90625 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
s: Chars,
};
let mut x = 0;
for s_i in s {
if x == 0 && (s_i == 'i' || s_i == 'I') {
x += 1;
}
if x == 1 && (s_i == 'c' || s_i == 'C') {
x += 1;
}
if x == 2 && ... | true |
b1e0d1fc90060b8face28e0ac224fd74761fbc9e | Rust | exercism/rust | /exercises/practice/armstrong-numbers/tests/armstrong-numbers.rs | UTF-8 | 1,588 | 3.28125 | 3 | [
"MIT"
] | permissive | use armstrong_numbers::*;
#[test]
fn test_zero_is_an_armstrong_number() {
assert!(is_armstrong_number(0))
}
#[test]
#[ignore]
fn test_single_digit_numbers_are_armstrong_numbers() {
assert!(is_armstrong_number(5))
}
#[test]
#[ignore]
fn test_there_are_no_2_digit_armstrong_numbers() {
assert!(!is_armstrong... | true |
436254bbffc76e62195484497be09df81a7c7a2e | Rust | leontoeides/google_maps | /src/roads/nearest_roads/request/new.rs | UTF-8 | 1,503 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::client::GoogleMapsClient;
use crate::types::LatLng;
use crate::roads::nearest_roads::request::Request;
// =============================================================================
impl<'a> Request<'a> {
// -------------------------------------------------------------------------
//
/// Ini... | true |
4e4b0e1b4802bb501dd0fc992c8aff53b718b653 | Rust | paritytech/substrate | /utils/frame/benchmarking-cli/src/extrinsic/extrinsic_factory.rs | UTF-8 | 2,307 | 2.59375 | 3 | [
"Apache-2.0",
"GPL-3.0-or-later",
"Classpath-exception-2.0",
"GPL-1.0-or-later",
"GPL-3.0-only"
] | permissive | // This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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.ap... | true |
da8f679b2ef0c305e22cdbae4762fe37421907aa | Rust | buttercrab/hyeo-ung-lang | /src/app/interpreter.rs | UTF-8 | 3,750 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::core::state::UnOptState;
use crate::core::{execute, parse};
use crate::util::error::Error;
use crate::util::io;
use crate::util::option::HyeongOption;
use std::io::{stdin, Write};
use std::process;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use termcolor::{Color, ColorSpec, StandardSt... | true |
f66df4f9f649c4f2e753c3dfc6033360864995ef | Rust | HideakiImamura/MyCompetitiveProgramming | /BeginnersSelection/ABC086C.rs | UTF-8 | 775 | 3.515625 | 4 | [] | no_license | fn read<T: std::str::FromStr>() -> T {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
n.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().split_whitespace()
.ma... | true |
2299e3330098ec34aaed9439924a9245732cb4a8 | Rust | yutiansut/sonnerie | /src/database_reader.rs | UTF-8 | 3,442 | 2.84375 | 3 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | use std::path::{Path,PathBuf};
use std::fs::File;
use std::io::Seek;
use crate::merge::Merge;
use crate::record::OwnedRecord;
use crate::key_reader::*;
use crate::Wildcard;
use byteorder::ByteOrder;
pub struct DatabaseReader
{
_dir: PathBuf,
txes: Vec<(PathBuf,Reader)>,
}
impl DatabaseReader
{
pub fn new(dir: &... | true |
844e58e125b26111e4f37cbec259eada66a2ea87 | Rust | TurtlePU/odlang-rs | /src/eval.rs | UTF-8 | 1,565 | 2.71875 | 3 | [] | no_license | use crate::{syntax::*, prelude::*, typeck};
pub fn eval(term: Term) -> Term {
match (*term).clone() {
TmApp(f, x) => match ((*eval(f)).clone(), eval(x)) {
(TmAbs(v, _, y), x) => eval(subst(x, y, v)),
(f, x) => de::app(f, x),
},
TmTyApp(f, t) => match (*eval(f)).clone... | true |
34c62de1c3c4ef79e1bbc6fc1db3af9304717401 | Rust | TheAlgorithms/Rust | /src/sorting/comb_sort.rs | UTF-8 | 1,322 | 3.5625 | 4 | [
"MIT"
] | permissive | pub fn comb_sort<T: Ord>(arr: &mut [T]) {
let mut gap = arr.len();
let shrink = 1.3;
let mut sorted = false;
while !sorted {
gap = (gap as f32 / shrink).floor() as usize;
if gap <= 1 {
gap = 1;
sorted = true;
}
for i in 0..arr.len() - gap {
... | true |
e17244d627a34540671d7e6112510e8ff251881a | Rust | dennisss/dacha | /pkg/common/src/collections.rs | UTF-8 | 2,320 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | use core::fmt::Debug;
use core::iter::Iterator;
use core::marker::PhantomData;
use core::mem::zeroed;
use core::mem::MaybeUninit;
use core::ops::{Deref, DerefMut};
use crate::const_default::ConstDefault;
#[derive(Clone, PartialEq)]
pub struct FixedString<A> {
data: A,
length: usize,
}
impl<A: AsRef<[u8]> + A... | true |
e145fdf818bf44c43312c8da3fd7a0c0b0ee2807 | Rust | tyu-ru/proconio_enum_query | /tests/compile_error/incollect_arg.rs | UTF-8 | 421 | 2.515625 | 3 | [
"CC0-1.0"
] | permissive | #[proconio_enum_query::proconio_enum_query(hoge)]
enum Query1 {
A,
}
#[proconio_enum_query::proconio_enum_query(fuga(piyo))]
enum Query2 {
A,
}
#[proconio_enum_query::proconio_enum_query(foo = 10)]
enum Query3 {
A,
}
#[proconio_enum_query::proconio_enum_query(start_index = abc)]
enum Query3 {
A,
}
#... | true |
3d0f18cc77507ad1807897f40bf9f2cc3cf2336f | Rust | abeaumont/disassemble.rs | /src/webassembly.rs | UTF-8 | 9,697 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use parity_wasm::el... | true |
36866d79a18c8f3e0a00ea067c253f65f630202d | Rust | alonn24/learnings | /rustlang/src/adventofcode2019/day6/part1.rs | UTF-8 | 953 | 3.421875 | 3 | [] | no_license | use std::collections::HashMap;
// Conver that key orbits value
pub fn convert_input(input: String) -> HashMap<String, String> {
let mut res: HashMap<String, String> = HashMap::new();
let lines: Vec<&str> = input.split("\n").collect();
for line in lines.iter() {
let parts: Vec<&str> = line.split(")").collect(... | true |
f199dda63c9958057c754382f8303f29bff29b76 | Rust | ferrous-systems/imxrt1052 | /src/iomuxc_gpr/gpr5/mod.rs | UTF-8 | 23,035 | 2.75 | 3 | [] | no_license | #[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::GPR5 {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
d4c51c9eb0ccabfdc0b6909f4af06f1e21c8419b | Rust | zaeleus/noodles | /noodles-vcf/examples/vcf_read_header_async.rs | UTF-8 | 689 | 2.671875 | 3 | [
"MIT"
] | permissive | //! Prints the header of a VCF file.
//!
//! The header is defined to be the meta lines (`##` prefix) and header line (`#`` prefix).
//!
//! The result is similar to or matches the output of `bcftools head <src>`. bcftools may add a
//! PASS FILTER to the meta if it is missing.
use std::env;
use noodles_vcf as vcf;
u... | true |
73d2d4152f91aeca18f68f121d8def1fb2b2a46d | Rust | curly-lang/comb-rust | /src/main.rs | UTF-8 | 2,647 | 2.890625 | 3 | [] | no_license | use std::env;
use std::fs;
use toml::Value;
use comb::toml::toml_parser;
use comb::toml::build_toml_generation;
use comb::dependencies::get;
use comb::dependencies::get::DependencyFail;
use comb::dependencies::toml_to_struct;
fn main() -> Result<(), ()> {
let mut args = env::args();
let name = args.next().unwrap(... | true |
8cffa12b0b41e1468ca520a583db22718d193cdd | Rust | dariedl/opgame | /src/game_state.rs | UTF-8 | 1,227 | 2.703125 | 3 | [
"MIT"
] | permissive | use rand::Rng;
use crate::data::Character;
use crate::data::Probe;
// use crate::domainMessage::Command;
use crate::domain_message::printCmd;
use crate::domain_message::printEvent;
use crate::domain_message::Command;
use crate::domain_message::Event;
pub fn handle_state(command: Command) {
printCmd(&command);
... | true |
cee9e3290125988eaa508726e0a88107d032350c | Rust | Ruddle/oxidator | /src/procedural_texels.rs | UTF-8 | 834 | 3.0625 | 3 | [
"MIT"
] | permissive | pub fn create_texels(size: usize) -> Vec<u8> {
let mut v = Vec::new();
for i in 0..size {
for j in 0..size {
let i = i as f32 / size as f32;
let j = j as f32 / size as f32;
v.push((i * 255.0) as u8);
v.push(((1.0 - j) * 255.0) as u8);
v.push(((... | true |
9589c0e2b1fc68cd4984ea6bd5eae11dde12cb8f | Rust | scottyla19/rust-book | /closures/src/main.rs | UTF-8 | 1,691 | 3.390625 | 3 | [] | no_license | use std::thread;
use std::time::Duration;
use std::collections::HashMap;
use std::hash::Hash;
use std::collections::hash_map::Entry;
fn main() {
let simulated_user_specified_value = 6;
let simulated_random_number = 3;
generate_workout(
simulated_user_specified_value,
simulated_random_numbe... | true |
9a5a9c26e2811787f27615d09bb479d7c36fce83 | Rust | legends2k/advent-of-code | /2018/day_22/src/main.rs | UTF-8 | 7,745 | 3.03125 | 3 | [
"Unlicense"
] | permissive | use std::{
cmp::Reverse,
collections::{BinaryHeap, HashMap},
error::Error,
fmt::Debug,
io::stdin,
ops::{Add, Index, IndexMut},
};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
struct Point(i32, i32);
impl Point {
fn non_negative(&self) -> bool {
(self.0 >= 0) && (self.1 >= 0)
... | true |
0db0b9dd49fcfb8b06ad531ec22adc1ad885dce9 | Rust | tock/tock | /chips/stm32f303xc/src/wdt.rs | UTF-8 | 5,263 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.
//! Window watchdog timer
use crate::rcc;
use core::cell::Cell;
use kernel::platform::chip::ClockInterface;
use kernel::utilities::registers::interfaces::ReadWriteab... | true |
7a64e9e773496d3d36321c5b9f9fbd754cb71b72 | Rust | theemathas/binary_turk | /game/src/pos/psudo_legal.rs | UTF-8 | 13,828 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::vec;
use std::iter;
use square::{Square, Rank, File};
use moves::Move;
use color::{White, Black};
use piece::Piece;
use piece::Type::{Pawn, King, Queen, Bishop, Knight, Rook};
use castle::{Kingside, Queenside};
use super::Position;
use super::bitboard::BitBoard;
pub struct Iter<'a>(iter::Chain<NoisyIter<'a>... | true |
ee06c69cadc052111c60bc7184f88c480dc80ae5 | Rust | GuildOfWeavers/winterfell | /math/src/field/traits.rs | UTF-8 | 9,184 | 3.25 | 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 core::{
convert::TryFrom,
fmt::{Debug, Display},
ops::{
Add, AddAssign, BitAnd, Div, DivAssign, Mul, MulAssign, Ne... | true |
4fba6f44154d2bf9dab97efdfb6901850a47aa0b | Rust | grilledwindow/mel-dl | /src/config.rs | UTF-8 | 1,740 | 3.171875 | 3 | [] | no_license | use serde::Deserialize;
use std::path::Path;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(bound(deserialize = "'de: 'a"))]
pub struct Module<'a> {
// module name
pub name: &'a str,
// the order of the course on the website
pub course_nth: u8,
// first week appears on t... | true |
db1e871aa4e2fb504ae76e9ccd021411884f28fa | Rust | Jvanrhijn/rustyrenderer | /src/model.rs | UTF-8 | 10,641 | 3 | 3 | [] | no_license | use std::cmp;
use std::vec::{Vec};
use std::vec;
use std::mem;
extern crate num;
use geo;
use geo::Vector;
use image;
pub trait Polygon<T>
{
fn draw(&self, img: &mut image::RgbImage, color: &[u8; 3]);
fn draw_filled(&self, img: &mut image::RgbImage, color: &[u8; 3], zbuf: &mut Vec<f64>);
fn inside(&self,... | true |
3ffd370fe6258948ad4189de5fce028f8cfe9102 | Rust | cloew/KaoBoy | /src/cpu/instructions/instructions.rs | UTF-8 | 3,890 | 3.25 | 3 | [] | no_license | use super::add;
use super::bit;
use super::compare;
use super::dec;
use super::inc;
use super::jump;
use super::load;
use super::rotate;
use super::stack;
use super::subtract;
use super::xor;
use super::instruction::Instruction;
use super::super::ProgramCounter;
use crate::as_hex;
use std::boxed::Box;
us... | true |
341f28f5cf6b2777a56e6278c007ba6598f1bbff | Rust | CodeSteak/hs_app | /hs_crawler/src/crawler/timetable.rs | UTF-8 | 4,511 | 2.828125 | 3 | [
"MIT"
] | permissive | use super::*;
use crate::util::*;
use std::io;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Read;
use std::collections::HashMap;
use select::document::Document;
use select::predicate::*;
use chrono::{Date, Local};
use reqwest;
type Timetable = HashMap<Date<Local>, Vec<String>>;
use std::sync::mpsc:... | true |
445fc2eace5164ebfc4e0e5f92a4ffec8684d32c | Rust | irrst/storage-poc | /src/alternative/single_element.rs | UTF-8 | 5,776 | 3 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Alternative implementation of `ElementStorage`.
use core::{
alloc::AllocError,
fmt::{self, Debug},
hint,
marker::Unsize,
mem,
mem::ManuallyDrop,
ptr::NonNull,
};
use rfc2580::Pointee;
use crate::traits::ElementStorage;
use super::{Builder, Inner};
/// SingleElement is a composite of... | true |
4f3470ee153fe1b356a754602bf40665cf363ea1 | Rust | NobodyNada/advent2020 | /day12/src/part2.rs | UTF-8 | 1,982 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::io::{self, BufRead};
#[derive(Copy, Clone)]
enum Direction {
North, South,
East,
West
}
impl Direction {
fn from_char(c: u8) -> Option<Direction> {
match c {
b'N' => Some(Direction::North),
b'S' => Some(Direction::South),
b'E' => Some(Direction::Eas... | true |
f281bcdd07c74f0ed59ccdc7934d6e7fba71e805 | Rust | sukawasatoru/rust-myscript | /src/model/sqlite_user_version.rs | UTF-8 | 6,046 | 2.59375 | 3 | [] | no_license | /*
* Copyright 2020, 2021, 2022, 2023 sukawasatoru
*
* 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 applicabl... | true |
a33f23f5f4239eecf304e2d437112c245583c662 | Rust | m4b/scroll | /src/lesser.rs | UTF-8 | 6,744 | 3.375 | 3 | [
"MIT"
] | permissive | use crate::ctx::{FromCtx, IntoCtx, SizeWith};
use std::io::{Read, Result, Write};
/// An extension trait to `std::io::Read` streams; mainly targeted at reading primitive types with
/// a known size.
///
/// Requires types to implement [`FromCtx`](ctx/trait.FromCtx.html) and [`SizeWith`](ctx/trait.SizeWith.html).
///
/... | true |
db1d467def91ec67c436897703c6194f23da1d13 | Rust | BitcoinUnlimited/ElectrsCash | /src/fake.rs | UTF-8 | 909 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::store::{ReadStore, Row, WriteStore};
use crate::util::Bytes;
pub struct FakeStore;
impl ReadStore for FakeStore {
fn get(&self, _key: &[u8]) -> Option<Bytes> {
None
}
fn scan(&self, _prefix: &[u8]) -> Vec<Row> {
vec![]
}
}
impl WriteStore for FakeStore {
fn write<I: Int... | true |
da7c075678744ff4c9c6fc668b359375c1c4d5e0 | Rust | EasyPost/linecmp | /src/main.rs | UTF-8 | 6,365 | 3.015625 | 3 | [
"MIT"
] | permissive | extern crate itertools;
extern crate clap;
use std::process::exit;
use std::io::{self,BufRead,BufReader,Write};
use std::fs::File;
use std::fmt;
use std::error::Error;
use itertools::Itertools;
use itertools::EitherOrBoth::{Both, Right, Left};
use clap::Arg;
#[derive(Debug)]
struct Difference {
line: usize,
... | true |
4fd083c4002d1de49589efb2dcb71cee4ad8c2f8 | Rust | Vanderkast/leetcode_rust | /biwise_and_range/src/main.rs | UTF-8 | 963 | 3.453125 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn range_bitwise_and(left: i32, right: i32) -> i32 {
if left == right {
return left;
}
let temp = left.leading_zeros();
if temp != right.leading_zeros() {
return 0;
}
let mut temp = 1 << (31 - temp);
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.