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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
10e4ec3304a2c60e3b0e2f38f4f61dd169b3e748 | Rust | qy3u/leetcode-rs | /src/string/decode_ways.rs | UTF-8 | 562 | 2.890625 | 3 | [] | no_license | // question 91
pub fn num_decodings(s: String) -> i32 {
let mut result = 0;
decode_helper(&s[..], &mut result);
result
}
fn decode_helper(s: &str, result: &mut i32) {
if s.len() == 0 {
*result += 1;
}
for i in 1..=2 {
if s.len() < i {
return;
}
if l... | true |
d897930c94862fbe29b984b7b012461ddb1eceb4 | Rust | bryanburgers/guillotine | /src/time/mod.rs | UTF-8 | 7,509 | 3.34375 | 3 | [
"MIT"
] | permissive | //! Time-related futures
//!
//! Sleep for a provided amount of time
//!
//! ```
//! use std::time::Duration;
//!
//! let runtime = guillotine::runtime::Runtime::new().unwrap();
//!
//! let future = async {
//! guillotine::time::sleep(Duration::from_millis(100)).await.unwrap();
//! println!("Slept for 100ms");
... | true |
a1acf4393c20fa0cbea6488a97faf8419bd9c4cf | Rust | brentongunning/rust-sv | /src/peer/peer.rs | UTF-8 | 14,859 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::messages::{Message, MessageHeader, Ping, Version, NODE_BITCOIN_CASH, NODE_NETWORK};
use crate::network::Network;
use crate::peer::atomic_reader::AtomicReader;
use crate::util::rx::{Observable, Observer, Single, Subject};
use crate::util::{secs_since, Error, Result};
use snowflake::ProcessUniqueId;
use std::f... | true |
fcbda97584dc0ce33930c8866d3bbaf840d7f7b5 | Rust | Happy-Ferret/combustion | /combustion_game/src/resources/projection.rs | UTF-8 | 2,448 | 2.96875 | 3 | [] | no_license | use specs;
use nalgebra::*;
#[derive(Copy, Clone, Debug)]
pub enum Kind {
Perspective(Perspective3<f32>),
Orthographic(Orthographic3<f32>)
}
impl Kind {
pub fn resize(&mut self, width: f32, height: f32, fovy: Option<f32>) {
match &mut *self {
&mut Kind::Orthographic(ref mut projection)... | true |
20761a1609c56657f0e5ed8f37b15d8f6723d7ca | Rust | blm768/gravity-wars | /src/rendering/texture.rs | UTF-8 | 563 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use image::RgbImage;
use crate::rendering::context::RenderingContext;
#[derive(Clone, Copy, Debug)]
pub struct SetTextureDataError;
impl Display for SetTextureDataError {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "U... | true |
619eda1760c36c469ae6d5409d843f083cfc1eea | Rust | robintiman/aoc2020 | /src/day8.rs | UTF-8 | 2,673 | 3.453125 | 3 | [] | no_license | use std::fs::read_to_string;
struct Instr {
op: String,
val: i32,
executed: bool,
}
struct Program {
instructions: Vec<Instr>,
accumulator: i32,
}
impl Program {
fn new(instructions: Vec<Instr>) -> Program {
Program { instructions, accumulator: 0 }
}
fn run(&mut self) -> bool... | true |
0a539261e07b3ee3242259871667d7bd187bc812 | Rust | mozilla/gecko-dev | /third_party/rust/icu_locid/tests/fixtures/mod.rs | UTF-8 | 8,420 | 2.546875 | 3 | [
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use std::collections::HashMap;
use std::convert::{TryFrom, TryInto};
use icu_locid::extensions::private;
use icu_loc... | true |
f4f1634b31c4d1ca6e5bfd146efed3243e74da60 | Rust | MarimeGui/ez_io | /src/error.rs | UTF-8 | 1,753 | 3.109375 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
use std::io;
#[derive(Debug)]
pub enum MagicNumberCheckError {
IoError(io::Error),
MagicNumber(WrongMagicNumber),
}
impl Error for MagicNumberCheckError {
fn description(&self) -> &str {
match *self {
MagicNumberCheckError::IoError(ref e) => e.descr... | true |
b658174fa2f70ad165f75ff8f922ae66313ae535 | Rust | elbe0046/tokio-compat | /src/runtime/current_thread/runtime.rs | UTF-8 | 14,473 | 2.796875 | 3 | [
"MIT"
] | permissive | use super::{compat, idle, Builder};
use tokio_02::{
runtime::Handle as Handle02,
task::{JoinHandle, LocalSet},
};
use tokio_executor_01 as executor_01;
use tokio_reactor_01 as reactor_01;
use tokio_timer_02 as timer_02;
use futures_01::future::Future as Future01;
use futures_util::{compat::Future01CompatExt, ... | true |
cceff3b219f056a95f946aec52eccf9d7935a39a | Rust | lauraleegunn/matasano | /set1/hex_to_base64/src/hex.rs | UTF-8 | 3,678 | 3.734375 | 4 | [] | no_license |
/// # Decoding Hex Strings
///
/// ## What could possibly go wrong?
///
/// Well, the string could contain non-hex characters (anything outside
/// the range of [a-zA-Z0-9]. In that case, we don't return anything.
///
/// Normally, we use two hex characters to represent a byte, so the
/// input string needs to have a... | true |
9c035e50fd220c38d0ceffca81ab47a7a1d417be | Rust | sinkuu/kyocode | /src/lib.rs | UTF-8 | 5,650 | 2.859375 | 3 | [] | no_license | //! Kyocode(経code) binary-to-text scheme implementation.
extern crate arrayvec;
#[cfg(test)]
#[macro_use]
extern crate quickcheck;
extern crate ring;
#[macro_use]
extern crate try_opt;
use ring::digest::{digest, SHA256};
use arrayvec::ArrayVec;
mod chars;
pub use chars::KYOCODE_CHARS;
fn div_roundup(lhs: usize, rhs... | true |
debbd1ee9f2172a5fb92a4a30026dcfef5956a49 | Rust | shioyama18/aoj | /dsl_1_a_disjoint_set/src/main.rs | UTF-8 | 2,431 | 2.90625 | 3 | [] | no_license | // http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
{... | true |
c579bc7846b621007ae9c77eb92a923b38882f69 | Rust | kaiakz/jvmrs | /src/instructions/math/xmul.rs | UTF-8 | 2,740 | 3.09375 | 3 | [] | no_license | use crate::instructions::ByteCode;
use crate::instructions::Instruction;
use crate::mem::frame::Frame;
use crate::mem::Slot;
use std::i32;
use std::i64;
use std::f32;
use std::f64;
// Despite the fact that overflow may occur, execution of an imul instruction never throws a run-time exception.
pub struct IMUL {}
impl... | true |
45f61114578e35f056d99546e0f64ee5aafac7a0 | Rust | saskenuba/SteamHelper-rs | /crates/steam-protobuf/src/main.rs | UTF-8 | 2,221 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::{ffi::OsString, fs};
use glob::glob;
use protoc_rust::Customize;
macro_rules! generate_protos_for {
($folder_name:literal) => {{
let mut entries: Vec<OsString> = Vec::new();
let mut filenames: Vec<OsString> = Vec::new();
for entry in glob(concat!("crates/steam-protobuf/assets/Pro... | true |
cb31de60542bff7e35945c4d34208b091176822d | Rust | ROki1988/k-iter | /src/main.rs | UTF-8 | 3,192 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use clap::{value_t_or_exit, values_t};
use ctrlc;
use rusoto_core::Region;
use tokio::time;
use crate::cli::{DataFormat, IteratorType};
use crate::kinesis::KinesisShardIterator;
use futures::sink::SinkExt;
use futures::{self, StreamExt, TryStreamExt}... | true |
86da00c06680a4dc56115d0cb2188de727764994 | Rust | YoungY620/trip-to-rCore | /##archive/lab4/lab4/os/src/main.rs | UTF-8 | 3,438 | 3 | 3 | [
"MIT"
] | permissive | //! # 全局属性
//!
//! - `#![no_std]`
//! 禁用标准库
#![no_std]
//!
//! - `#![no_main]`
//! 不使用 `main` 函数等全部 Rust-level 入口点来作为程序入口
#![no_main]
//!
//! - `#![deny(missing_docs)]`
//! 任何没有注释的地方都会产生警告:这个属性用来压榨写实验指导的学长,同学可以删掉了
#![warn(missing_docs)]
//! # 一些 unstable 的功能需要在 crate 层级声明后才可以使用
//!
//! - `#![feature(alloc_error_h... | true |
6e892159097348d2162e26d10a45dcb9193e8468 | Rust | JasonSmith/signal | /src/signal.rs | UTF-8 | 1,893 | 3 | 3 | [
"MIT"
] | permissive | use std::any::{Any, TypeId};
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::hash_map::HashMap;
pub type CallbackID = usize;
pub struct Event<T>
{
pub args: T
}
struct CallbackEntry<T>
{
callback: Rc<RefCell<FnMut(&Event<T>)>>
}
struct DataEntry<T>
{
target: Rc<Any>,
callback: Rc<RefCell<... | true |
2d15eff0049a602aecfc908fd9b50189edf420f2 | Rust | torkleyy/froggy | /examples/iter.rs | UTF-8 | 695 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | extern crate froggy;
fn main() {
let storage = froggy::Storage::new();
{
let mut s = storage.write();
for &v in [5 as i32, 7, 4, 6, 7].iter() {
s.create(v);
}
}
println!("Initial array:");
for value in storage.read().iter() {
println!("Value {}", *value);... | true |
7156c9d008aeaeacf89caf258d61f98eebd33dc6 | Rust | hedgar2017/dhcp | /protocol/src/v4/validator.rs | UTF-8 | 2,798 | 3.28125 | 3 | [] | no_license | //! DHCP message validation module.
use super::{constants::SIZE_MESSAGE_MINIMAL, options::MessageType, Message};
/// The error type returned by `Message::validate`.
#[derive(Fail, Debug)]
pub enum Error {
#[fail(display = "Validation error: {}", _0)]
Validation(&'static str),
}
/// Checks if required options... | true |
0411ae4de2bcc8d3bd512c45841ba99a251d74e8 | Rust | gaultier/kotlin-rs | /tests/range.rs | UTF-8 | 1,035 | 3.0625 | 3 | [] | no_license | use kotlin::compile::sexp;
use kotlin::error::*;
use kotlin::parse::Type;
#[test]
fn simple_range() {
let src = "1..5";
let mut out: Vec<u8> = Vec::new();
assert!(sexp(src, &mut out).is_ok());
assert_eq!(
std::str::from_utf8(&out).as_mut().unwrap().trim(),
"(range 1 5)"
);
}
#[tes... | true |
3ebc4670a60adb48090c29acc2744c7a15fa6f13 | Rust | LucasGobbs/trogue | /src/shape/line.rs | UTF-8 | 1,250 | 3.15625 | 3 | [] | no_license | use crate::shape::ShapeDrawable;
pub struct Line {
x0: i32,
y0: i32,
x1: i32,
y1: i32,
}
impl Line {
pub fn new(x0: i32, y0: i32, x1: i32, y1: i32) -> Line {
Line {
x0,
y0,
x1,
y1,
}
}
}
impl ShapeDrawable for Line {
fn get_cell... | true |
44f8e961d86f0e285e3b9044ee7f558528262c96 | Rust | OnlySharks/OnlySharks | /src/endpoints/posts.rs | UTF-8 | 5,952 | 2.625 | 3 | [] | no_license | use chrono::prelude::*;
use diesel::prelude::*;
use rocket_contrib::json::Json;
use rocket::http::Status;
use crate::{DbConn, models};
use crate::models::post::NewPost;
use regex::Regex;
#[get("/<postid>")]
pub fn posts_get(postid: String, conn: DbConn) -> Json<models::post::Post> {
use crate::schema::posts::dsl:... | true |
be2307951dcc15b3bb14dbd2d2daa53a2caa6811 | Rust | occlum/occlum | /src/libos/src/net/io_multiplexing/epoll/epoll_file.rs | UTF-8 | 18,568 | 2.578125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::any::Any;
use std::collections::{HashMap, VecDeque};
use std::fmt;
use std::mem::{self, MaybeUninit};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Weak;
use std::time::Duration;
use atomic::Atomic;
use super::epoll_waiter::EpollWaiter;
use super::host_file_epoller::HostFileEpoller;
use super... | true |
03d9014d7e9aea5fe47afd651465dc9cb2c91b4f | Rust | SitrusMint/MUHOTHI_lang | /muhothi/src/bf.rs | UTF-8 | 709 | 2.890625 | 3 | [
"MIT"
] | permissive | pub fn execute_bf(s :&String) -> Result<(), &str> {
let mut buf = [0usize; 30000];
let mut count :usize = 0;
let mut i :usize = 0;
// let mut note: usize;
while count != s.len() {
match s.chars().nth(count).unwrap() {
'+' => buf[i] += 1,
'-' => buf[i] -= 1,
... | true |
9d47ad3c5979fdbef1cfc53789acdf4563c17380 | Rust | dmit/nes-rs | /src/cpu_instr.rs | UTF-8 | 13,742 | 2.609375 | 3 | [] | no_license | use byteorder::{LittleEndian, ByteOrder};
use std::fmt;
pub struct Instr(pub Op, pub Mode, pub Cycles);
impl Instr {
pub fn from(code: &[u8]) -> Instr {
let opcode = code[0];
let oper = &code[1..];
match opcode {
0x00 => Instr(Op::Brk, Mode::Impl, Cycles::A(7)),
0x01... | true |
17aabbcff3e6289bfdf6a6e5abbc826edfaf6339 | Rust | fschutt/LudumDare40 | /src/player_state.rs | UTF-8 | 6,791 | 2.9375 | 3 | [
"MIT"
] | permissive | use camera::Camera;
use physics::{PhysicsWorld, PhysicsFinalizedData, PlayerResult, MAX_SPEED, CratePosition};
use input::GameInputEvent;
use std::time::{Duration, Instant};
/// The state of the player in the game world
#[derive(Debug, Clone)]
pub struct PlayerState {
/// 2D camera, relative to the game world
... | true |
fc7e64bfdacb617dc93d24378e04f80294ee92df | Rust | Liyixin95/carrier | /src/statistic/bundle.rs | UTF-8 | 1,491 | 3.203125 | 3 | [] | no_license | use crate::statistic::record::Record;
pub struct Bundle {
container: Vec<Record>,
index: usize,
}
impl Bundle {
pub fn new(cap: usize) -> Self {
Self {
container: Vec::with_capacity(cap),
index: 0,
}
}
pub fn reset(&mut self) {
self.index = 0;
}... | true |
8bd475fcb89201a9c2324d6fc3e449cee661291d | Rust | metmirr/city_api | /src/main.rs | UTF-8 | 1,412 | 2.875 | 3 | [
"MIT"
] | permissive | #![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate serde_json;
#[macro_use] extern crate rocket_contrib;
#[macro_use] extern crate serde_derive;
use rocket_contrib::{JSON, Value};
use rocket_contrib::Template;
#[derive(Serialize)]
struct TemplateContext {
name: String,
items: V... | true |
4ee1a74d48aca71f0140c7a435b5c25ae74d2c4d | Rust | ftsujikawa/rust-sample | /ch18/code18-1/src/main.rs | UTF-8 | 358 | 2.859375 | 3 | [] | no_license | use std::thread;
use std::time::Duration;
use std::io::Read;
fn main() {
let handle = thread::spawn(|| {
for i in 0..10 {
println!("thread #1 count {}", i);
thread::sleep(Duration::from_millis(1000));
}
});
println!("press enter key.");
std::io::stdin().read(&mut ... | true |
0fff8302b00bb7fa5e6c220aa31200c7654af348 | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-22312.rs | UTF-8 | 522 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use std::ops::Index;
pub trait Array2D: Index<usize> {
fn rows(&self) -> usize;
fn columns(&self) -> usize;
fn get<'a>(&'a self, y: usize, x: usize) -> Option<&'a <Self as Index<usize>>::Output> {
if y >= self.rows() || x >= self.columns() {
return None;
}
let i = y * se... | true |
27d2b5af484a8056ae4cb7b310f33d327ffc92fe | Rust | erdos-project/erdos | /erdos/src/dataflow/operators/ros/to_ros_operator.rs | UTF-8 | 4,326 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | use crate::dataflow::{context::SinkContext, operator::Sink, operators::ros::*, Data, Message};
use serde::Deserialize;
use std::sync::Arc;
/// Takes an input ERDOS stream and publishes to a ROS topic using the provided message conversion
/// function.
///
/// The conversion function transforms a [`Message`] into a ROS... | true |
c29be28343ade3a193edf77e1bae15a6a6f18d1c | Rust | EFanZh/LeetCode | /src/problem_0526_beautiful_arrangement/backtracking.rs | UTF-8 | 1,938 | 3.0625 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::num::NonZeroU8;
impl Solution {
fn helper(nums: &mut [NonZeroU8]) -> i32 {
if nums.is_empty() {
1
} else {
let n = nums.le... | true |
2f6460847d3ea86dc6a3a4d1a559059e0996e62e | Rust | Happy-Ferret/appimagezip | /bootstrap/fs.rs | UTF-8 | 9,680 | 2.6875 | 3 | [
"MIT"
] | permissive | //! Zip-based AppImage implementation of a FUSE file system.
use event::NotifyFlag;
use fuse::*;
use libc;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::fs::{File, Metadata};
use std::io::Read;
use std::os::unix::fs::*;
use std::path::*;
use time::Timespec;
use zip::ZipArchive;
/// Time-to-live for res... | true |
05f6f7354c4b245bc90867d45ae1a9d528551cf1 | Rust | sphinxc0re/rpg-rs | /src/world/campaign.rs | UTF-8 | 546 | 3.4375 | 3 | [
"MIT"
] | permissive | use super::World;
/// A collection of worlds. Usually used to create larger adventures
pub struct Campaign<T: World> {
/// The title of the campaign
pub title: String,
worlds: Vec<T>,
}
impl<T: World> Campaign<T> {
/// Creates a new instance of `Campaign`
pub fn new(title: &str) -> Campaign<T> {
... | true |
b85484cbf6b3dd8d1c2b5f7ce3fbb1b8331290a8 | Rust | IcanDivideBy0/async-graphql | /tests/serializer_uuid.rs | UTF-8 | 878 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use async_graphql::*;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[repr(transparent)]
#[serde(transparent)]
struct AssetId(pub uuid::Uuid);
async_graphql::scalar!(AssetId);
#[tokio::test]
/// Test case for
/// https://github.com/async-graphql/async-graphql/issues/603
pub async fn test_ser... | true |
239c8fef7444ab32b848b8068e96f8e7322761f5 | Rust | alexmachina/rust-temperature | /src/main.rs | UTF-8 | 506 | 3.296875 | 3 | [] | no_license | use std::io;
fn main() {
loop {
println!("Type in the fahrenheight temperature");
let mut fah = String::new();
io::stdin()
.read_line(&mut fah)
.expect("Oops");
if fah.trim() == "q" {
println!("Bye!");
break;
}
let ... | true |
9ccab2e370834d679e4938fd32fa306800a7d9a1 | Rust | ytyaru/Rust.Trait.20190628064721 | /src/5/main.rs | UTF-8 | 411 | 3.09375 | 3 | [
"CC0-1.0"
] | permissive | /*
* Rustのトレイト。(C#やJavaでいうインタフェースに類似)
* CreatedAt: 2019-06-28
*/
fn main() {
let v = vec![7, 3, 5, 1, 2];
println!("{:?}: {}", v, largest(&v));
}
fn largest<T>(list: &[T]) -> T {
let mut max = list[0];
for i in list.iter() {
if max < i { max = list[i]; } // error[E0369]: binary operation `<` ... | true |
3e80f62ed8fe2d973dccc9e2d4018a9bf152a1c0 | Rust | knutin/protostore | /src/bin/mk_data.rs | UTF-8 | 5,342 | 2.640625 | 3 | [] | no_license | // time cargo run --bin mk_data -- --path=/mnt/data/ --num-cookies=250000000 --min-size 1024 --max-size 4
extern crate rand;
extern crate uuid;
extern crate byteorder;
extern crate clap;
extern crate rayon;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::PathBuf;
use clap::{Arg, App};
use byteorder::{Li... | true |
0856465a1100ac52c0d8cd4215eae978fd0584bb | Rust | SuperiorJT/twilight | /http/src/request/guild/member/get_member.rs | UTF-8 | 1,032 | 2.859375 | 3 | [
"ISC"
] | permissive | use crate::{
client::Client,
request::Request,
response::{marker::MemberBody, ResponseFuture},
routing::Route,
};
use twilight_model::id::{GuildId, UserId};
/// Get a member of a guild, by id.
#[must_use = "requests must be configured and executed"]
pub struct GetMember<'a> {
guild_id: GuildId,
... | true |
2111162dc2846d7432303e7cae49ad8296e20e46 | Rust | togdon/adventofcode_2020 | /src/bin/day01-2.rs | UTF-8 | 1,145 | 3.078125 | 3 | [] | no_license | use std::fs;
fn main() {
let data = fs::read_to_string("data/day-01.txt").expect("Unable to read file");
let lines: Vec<&str> = data.split('\n').collect();
let mut answer = 0;
println!("{:?} lines", lines.len() - 1);
for line_first in 0..lines.len() - 1 {
let i: i32 = lines[line_first].pa... | true |
7fa81a7b739e51fffaa1e249122b3aa90dc315e7 | Rust | christiaan-janssen/AoC2020 | /rust/src/utils/map.rs | UTF-8 | 838 | 3.625 | 4 | [] | no_license |
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum TileType {
Wall,
Floor,
}
#[derive(Debug)]
pub struct Map {
pub map_width: i32,
pub tiles: Vec<TileType>,
}
impl Map {
pub fn new(map_width: i32, map_str: String) -> Self {
fn map_from_str(map_string: String) -> Vec<TileType>{
... | true |
f34ee558a7b4fcfb300456b4fc1da24a3302c93c | Rust | pandoraboxchain/rustheus | /src/mempool/src/memory_pool.rs | UTF-8 | 53,879 | 2.796875 | 3 | [] | no_license | //! Transactions memory pool
//!
//! `MemoryPool` keeps track of all transactions seen by the node (received from other peers) and own transactions
//! and orders them by given strategies. It works like multi-indexed priority queue, giving option to pop 'top'
//! transactions.
//! It also guarantees that ancestor-desce... | true |
cbe0db7a87c0eec64ef5561b509958697b7f86e6 | Rust | orakulam/pgsim | /src/main.rs | UTF-8 | 4,942 | 3 | 3 | [
"MIT"
] | permissive | use actix_web::{middleware, post, web, App, HttpResponse, HttpServer, Responder};
use std::env;
use std::fs;
use std::sync::Mutex;
mod parser;
use parser::Parser;
mod sim;
use sim::{Sim, SimConfig};
struct ActixState {
parser: Mutex<Parser>,
}
#[post("/api/v1/sim")]
async fn echo(mut config: web::Json<SimConfig>... | true |
1db14f5d7a5859a619fafd8e5ce1b43af16f7721 | Rust | ThomasdenH/adventofcode2019 | /src/day_01.rs | UTF-8 | 1,256 | 3.3125 | 3 | [] | no_license | use anyhow::Result;
pub fn parse_input(s: &str) -> Result<Vec<u32>> {
s.lines()
.map(|s| s.trim().parse::<u32>().map_err(|e| e.into()))
.collect()
}
fn base_fuel_requirement(mass: u32) -> u32 {
if mass < 6 {
0
} else {
(mass / 3) - 2
}
}
fn cumulative_fuel_requirement(... | true |
afbd9b2e5cc155da8e903c5b3210a25a83cc4d49 | Rust | asterycs/aoc2019 | /lib/common/src/lib.rs | UTF-8 | 1,520 | 2.984375 | 3 | [] | no_license | use std::{env, num::ParseIntError};
use std::fs;
use std::path::PathBuf;
pub fn get_input(input_file: &str) -> String {
let filename = &mut PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
filename.push( "inputs/".to_owned() + input_file);
println!("Reading {}", filename.display());
let input ... | true |
1b7297d080c0a848382c142064f45f3ff333923b | Rust | QPC-database/ion-rust | /ion-c-sys-macros/src/lib.rs | UTF-8 | 3,053 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::quote;
use syn::{parse_quote, FnArg, Ident, PatType, ReturnType};
/// This macro is intended to support the `IonCReaderHandle` type. When any
/// function returns an `IonCError`, the error should be populated with the
/// current reader position.
///
/// W... | true |
302977f3c7979194cd1ee46a46db0f8d5d46ebbc | Rust | andrei-toterman/medial_axis_3d | /src/tetrahedron.rs | UTF-8 | 4,173 | 3.03125 | 3 | [] | no_license | use super::point::Point;
use raylib::{
color::Color,
drawing::{RaylibDraw3D, RaylibDrawHandle, RaylibMode3D},
math::Vector3,
};
#[derive(Copy, Clone)]
pub struct Tetrahedron {
pub p1: Point,
pub p2: Point,
pub p3: Point,
pub p4: Point,
pub circumcenter: Point,
pub circumradius: f64,... | true |
8c315ffa82fa085481cbe1d2ff5afc151103570f | Rust | jonlamb-gh/pinephone-rs-display-prototype | /src/keypad/mod.rs | UTF-8 | 4,225 | 2.78125 | 3 | [] | no_license | use crate::{
config::*,
viewable::{ViewGroupId, Viewable},
};
use embedded_graphics::{
pixelcolor::Rgb888, primitives::Rectangle, style::PrimitiveStyleBuilder, DrawTarget,
};
use embedded_layout::{
layout::linear::{spacing::Tight, LinearLayout},
prelude::*,
};
mod button;
mod key;
pub use button::... | true |
f8e3eaab85fc6e8e2578db01e9b6e79be1eb1798 | Rust | step-flow/stepflow | /stepflow-data/src/error.rs | UTF-8 | 699 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use super::var::VarId;
#[derive(Debug, PartialEq, Clone, Copy)]
#[cfg_attr(feature = "serde-support", derive(serde::Serialize))]
pub enum InvalidValue {
WrongType,
BadFormat,
Empty,
WrongValue,
}
impl std::error::Error for InvalidValue {}
impl std::fmt::Display for InvalidValue... | true |
0cdb2e27928946a23cf4a57099736c7c422935ae | Rust | bottlerocket-os/bottlerocket | /sources/metricdog/src/args.rs | UTF-8 | 1,183 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use argh::FromArgs;
use log::LevelFilter;
use std::path::PathBuf;
fn default_logging() -> LevelFilter {
LevelFilter::Info
}
/// Command line arguments for the metricdog program.
#[derive(FromArgs)]
pub(crate) struct Arguments {
/// path to the TOML config file [default: /etc/metricdog]
#[argh(option, shor... | true |
c486f8dcf6841dd010a08e863b423274a51c7eef | Rust | DRvader/AOC2020 | /src/bin/7/1.rs | UTF-8 | 2,140 | 3 | 3 | [] | no_license | use std::{
collections::{HashMap, HashSet},
error::Error,
};
struct Node {
name: String,
parents: HashSet<usize>,
}
fn main() -> Result<(), Box<dyn Error>> {
let buf = AOC2020::read_datafile("7.txt")?;
let mut forest = HashMap::new();
let mut storage = Vec::new();
for line in buf.lines... | true |
297c034d9491c617b296b5ebb50b525728419c4d | Rust | himlpplm/rust-tdlib | /src/types/search_installed_sticker_sets.rs | UTF-8 | 2,629 | 2.890625 | 3 | [
"MIT"
] | permissive | use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Searches for installed sticker sets by looking for specified query in their title and name
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct SearchInstalledStickerSets {
#[doc(hidden)]
#[serde(rename(serialize = "@extra", deserial... | true |
362f4c446c2f97c9705cf3ff808d747744dd8c47 | Rust | Etenil/wait-for-rust | /src/main.rs | UTF-8 | 1,387 | 3.15625 | 3 | [] | no_license | use std::env;
use std::net::TcpStream;
use std::time::Duration;
use std::thread::sleep;
use std::process::exit;
use std::process::Command;
fn start_command(command: &String) {
Command::new("sh").arg("-c").arg(command).spawn().expect("failed to execute command");
}
fn detect_tcp(proto: &String, max: i32) -> Result... | true |
841d0bbbb1f37bbf36fecd89bee0a2337f1abd39 | Rust | c0deaddict/aoc2020 | /days/day_17/src/main.rs | UTF-8 | 3,809 | 3.359375 | 3 | [] | no_license | use lib::run;
use std::clone::Clone;
use std::cmp::{Eq, PartialEq};
use std::collections::HashSet;
use std::fmt::Debug;
use std::hash::Hash;
use std::marker::Copy;
#[derive(PartialEq, Eq, Hash, Debug, Clone, Copy)]
struct Point {
x: i64,
y: i64,
z: i64,
w: i64,
}
impl Point {
fn new(x: i64, y: i64... | true |
b69d65a0f32095578dc0a4cceb5e548a13a19476 | Rust | zmitchell/polarization | /src/jones/system.rs | UTF-8 | 23,007 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! An optical system that encapsulates a beam and the elements that it will pass
//! through.
use super::common::{Beam, ComplexMatrix, JonesError, JonesMatrix, JonesVector, Result};
use super::composite::CompositeElement;
use super::hwp::HalfWavePlate;
use super::identity::IdentityElement;
use super::polarizer::Polar... | true |
ebb74f191805860c21dbcebc04f96ef631625c58 | Rust | not-fl3/macroquad | /src/ui/key_repeat.rs | UTF-8 | 1,300 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Some hacks to emulate repeating flag from OS key events
use crate::ui::KeyCode;
#[derive(Default)]
pub(crate) struct KeyRepeat {
character_this_frame: Option<KeyCode>,
active_character: Option<KeyCode>,
repeating_character: Option<KeyCode>,
pressed_time: f32,
}
impl KeyRepeat {
pub fn new() -... | true |
43025eda877ecf4dfba1eb8aac7dd3edf3e62732 | Rust | tomjakubowski/rust-simd-noise | /src/lib.rs | UTF-8 | 21,645 | 3.140625 | 3 | [] | no_license | //! Fast, SIMD accelerated noise generation functions
//! with optional runtime feature detection.
//!
//! [Github Link](https://github.com/jackmott/rust-simd-noise)
//!
//!## Features
//!
//!* SSE2, SSE41, and AVX2 instruction sets, along with non SIMD fallback
//!* AVX2 version also leverages FMA3
//!* Runtime detect... | true |
adfbdac1dcab8069d648e3577aba23ce4d748582 | Rust | bieganski/distributed | /dslab04/examples/rustls.rs | UTF-8 | 3,489 | 2.703125 | 3 | [] | no_license | use std::io::{Read, Write};
use std::sync::Arc;
use rustls::{
Certificate, ClientSession, NoClientAuth, RootCertStore, ServerCertVerified,
ServerCertVerifier, ServerSession, StreamOwned, TLSError,
};
use std::net::{TcpListener, TcpStream};
use webpki::DNSNameRef;
const SERVER_ADDRESS: &str = "127.0.0.1:8081";... | true |
00888ce405b33e5eda58cb70034475b892dd2988 | Rust | kollch/rust-naive-bayes | /src/lib.rs | UTF-8 | 8,335 | 3.046875 | 3 | [] | no_license | use std::env;
use std::error::Error;
use std::fmt;
use std::fs;
#[derive(Debug)]
pub struct Config {
pub training: String,
pub testing: String,
}
impl Config {
pub fn new(mut args: env::Args) -> Result<Self, &'static str> {
args.next();
let training = match args.next() {
Some(... | true |
095920f2593f5e22fedb3b2928bc23e6c3f17bc7 | Rust | bheisler/RustaCUDA | /src/error.rs | UTF-8 | 9,834 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Types for error handling
//!
//! # Error handling in CUDA:
//!
//! RustaCUDA uses the [`CudaError`](enum.CudaError.html) enum to represent the errors returned by
//! the CUDA API. It is important to note that nearly every function in CUDA (and therefore
//! RustaCUDA) can fail. Even those functions which have no no... | true |
6d660d09988619b345850883894a58a541b88397 | Rust | cosmo0920/ruroonga_command | /src/dsl/table_rename_dsl.rs | UTF-8 | 489 | 3.078125 | 3 | [
"MIT"
] | permissive | use table_rename::TableRenameCommand;
pub fn table_rename(name: String, new_name: String) -> TableRenameCommand {
TableRenameCommand::new(name, new_name)
}
#[cfg(test)]
mod test {
use super::*;
use table_rename::TableRenameCommand;
#[test]
fn test_table_rename() {
let syntax = table_renam... | true |
74b02c2cc50aa5358554af8d79ccfff17ac70c40 | Rust | Svartstrom/AdventOfCode | /2022/rust/src/week1.rs | UTF-8 | 3,241 | 3.4375 | 3 | [] | no_license | use std::fs;
pub fn day1() {
println!("Day 1: ");
let contents = fs::read_to_string("./src/input/day1.txt").expect("Should have been able to read the file");
let mut first = 0;
let mut second = 0;
let mut third = 0;
let mut this_elf = 0;
for row in contents.split("\n") {
if row != ... | true |
366646a167201dbfcd8b2c7207eceac684400dac | Rust | PgBiel/rust-brawl-api | /src/http/routes.rs | UTF-8 | 5,366 | 3.359375 | 3 | [
"MIT"
] | permissive | //! Contains the `Route` enum, responsible for listing the available API endpoints and parsing
//! the given values into a valid URL.
use crate::b_api_concat;
/// An enum representing the possible Brawl API routes.
#[non_exhaustive]
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum Route {
/// Route for the ... | true |
c0002204b068d438317ca3505db9e8add9c1acd5 | Rust | suclogger/leetcode-rust | /chapter_2/can-place-flowers/src/main.rs | UTF-8 | 786 | 2.9375 | 3 | [] | no_license | fn main() {
let flowerbed = vec![1,0,0,0,1];
assert!(can_place_flowers(flowerbed, 1));
let flowerbed = vec![0,0,1,0,1];
assert!(can_place_flowers(flowerbed, 1));
let flowerbed = vec![0,1,1,0,0];
assert!(can_place_flowers(flowerbed, 1));
let flowerbed = vec![1,0,0,0,0,1];
assert!(!can_pla... | true |
10753e6a06543f6d5ececdda8d102210a0e6b4cd | Rust | cwmiller/rustboy | /src/cpu/registers.rs | UTF-8 | 5,115 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::fmt;
#[derive(Copy, Clone)]
#[allow(dead_code)]
pub enum Register {
A,
B,
C,
D,
E,
F,
H,
L,
AF,
BC,
DE,
HL,
SP,
PC
}
impl fmt::Display for Register {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Register::... | true |
62f51809826822f3c02c2c36471a8e24ba2849bd | Rust | arkworks-rs/algebra | /poly/src/polynomial/multivariate/mod.rs | UTF-8 | 4,907 | 3.34375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Work with sparse multivariate polynomials.
use ark_ff::Field;
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::{
cmp::Ordering,
fmt::{Debug, Error, Formatter},
hash::Hash,
ops::Deref,
vec::Vec,
};
#[cfg(feature = "parallel")]
use rayon::prelude::*;
mod sparse;
pub us... | true |
e3bc3bfc3ff8537c1ddf2a37273cbf36604daa0b | Rust | blmarket/icpc | /blmarket/2016/codejamQual/D.rs | UTF-8 | 1,185 | 2.921875 | 3 | [] | no_license | use std::io;
use std::fmt::Debug;
use std::fmt::Display;
use std::str::FromStr;
use std::collections::BTreeSet;
fn read_line<T: FromStr + Clone>() -> T where <T as FromStr>::Err: Debug {
let mut ret = String::new();
io::stdin().read_line(&mut ret);
return ret.trim().parse::<T>().unwrap().to_owned();
}
fn dbg<T:... | true |
69f2f8e8a836dfd9169337304691798c8e6abe2b | Rust | alexanderkarlis/csvcat | /src/clap_app.rs | UTF-8 | 2,497 | 2.890625 | 3 | [] | no_license | extern crate clap;
use clap::{App, Arg, ArgMatches};
#[derive(Debug)]
pub struct ClapArgs {
pub files: Vec<String>,
pub outfile: String,
pub use_file_index: usize,
}
impl From<ArgMatches> for ClapArgs {
fn from(m: ArgMatches) -> Self {
let incoming_files = m
.values_of("files")
... | true |
c3ec7072f1d70dad2e42ea5588545affb3c5e0d2 | Rust | rust-lang/futures-rs | /futures-util/src/stream/try_stream/try_collect.rs | UTF-8 | 1,382 | 2.640625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::mem;
use core::pin::Pin;
use futures_core::future::{FusedFuture, Future};
use futures_core::ready;
use futures_core::stream::{FusedStream, TryStream};
use futures_core::task::{Context, Poll};
use pin_project_lite::pin_project;
pin_project! {
/// Future for the [`try_collect`](super::TryStreamExt::try_col... | true |
50eed3717f0549a93dd9fbdd59a0f8c9e76b7943 | Rust | klieth/rust-pong | /paddle.rs | UTF-8 | 312 | 2.75 | 3 | [] | no_license |
extern crate sdl;
pub struct Paddle {
pub x: int,
pub y: int,
pub w: int,
pub h: int
}
impl Paddle {
pub fn draw(self, ctx: sdl::video::Surface ) {
ctx.fill_rect(Some(sdl::Rect {
x: self.x as i16,
y: self.y as i16,
w: self.w as u16,
h: self.h as u16
}), sdl::video::RGB(0, 255, 0));
}
}
| true |
879685d3a3e75437741f2b88f2f089d2087576af | Rust | rcore-os/arceos | /crates/axio/src/buffered/bufreader.rs | UTF-8 | 5,554 | 3.34375 | 3 | [
"Apache-2.0",
"AGPL-3.0-only",
"LicenseRef-scancode-mulanpubl-2.0",
"AGPL-3.0-or-later",
"GPL-3.0-only",
"MulanPSL-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-mulanpsl-2.0-en"
] | permissive | use crate::{BufRead, Read, Result};
#[cfg(feature = "alloc")]
use alloc::{string::String, vec::Vec};
const DEFAULT_BUF_SIZE: usize = 1024;
/// The `BufReader<R>` struct adds buffering to any reader.
pub struct BufReader<R> {
inner: R,
pos: usize,
filled: usize,
buf: [u8; DEFAULT_BUF_SIZE],
}
impl<R:... | true |
410ebfe76eb5b43fed20ba58c66301e67776a67b | Rust | gsoltis/ring | /src/agreement.rs | UTF-8 | 3,243 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-openssl",
"OpenSSL",
"LicenseRef-scancode-ssleay-windows",
"BSD-3-Clause",
"ISC"
] | permissive | // Copyright 2015-2016 Brian Smith.
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAI... | true |
541bca6034bb03f69be1f8f311f4174596ce1df2 | Rust | MarWit/University | /DataCompression/project/src/sequitur/tests.rs | UTF-8 | 3,807 | 3.0625 | 3 | [] | no_license | use std::io::Cursor;
use rand::distributions::Standard;
use rand::prelude::*;
use super::Sequitur;
fn test_single(string: &str) {
let mut sequitur = Sequitur::new();
for c in string.chars() {
sequitur.put(c);
}
let rebuilded = sequitur.rebuild().into_iter().collect::<String>();
assert_eq... | true |
639e4233d151c92a8857f0982eb6373067c6c616 | Rust | svmk/test-task-trlogic | /test-task-trlogic/src/domain/model/application_config/web_server.rs | UTF-8 | 957 | 2.90625 | 3 | [] | no_license | use std::default::Default;
use crate::domain::model::url::Url;
use std::net::SocketAddr;
use std::str::FromStr;
#[derive(Deserialize, Debug, Clone)]
pub struct WebServer {
#[serde(default = "WebServer::default_base_url")]
base_url: Url,
#[serde(default = "WebServer::default_bind_address")]
bind_address... | true |
68c611661f33b9ec5d5d3f461475a6618ede0069 | Rust | arata-nvm/readelf.rs | /src/elf/program_header.rs | UTF-8 | 2,733 | 2.78125 | 3 | [] | no_license | use crate::elf::common::get_flag_char;
use crate::elf::*;
use prettytable::{cell, format, row, Table};
#[repr(C)]
#[derive(Copy, Clone, Debug)]
pub struct ElfProgramHeader {
pub segment_type: ElfWord,
pub flags: ElfWord,
pub offset: ElfOff,
pub virtual_addr: ElfAddr,
pub physical_addr: ElfAddr,
... | true |
3d859a5e96cdf6402f07915a27635ad8fde3553a | Rust | tkygtr6/tutorials | /Rust-practice/ITP1_10_B.rs | UTF-8 | 542 | 3.046875 | 3 | [] | no_license | fn main() {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let nums = line
.trim()
.split_whitespace()
.map(|c| c.parse::<f64>().unwrap())
.collect::<Vec<_>>();
let a = nums[0];
let b = nums[1];
let theta = nums[2] / 360.0 * (2.0 * s... | true |
813b41147f6c9215d500bc466f9ad73a03ef4ea5 | Rust | pefish/create-rust-app-template | /src/main.rs | UTF-8 | 1,309 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive |
use std::time::Duration;
use tokio::{fs::File, io::AsyncReadExt, time};
use serde::{Serialize, Deserialize};
use anyhow::{Context, Result, Error};
mod util;
use util::hello;
mod util_test;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Config {
pub test: Option<String>,
}
#[tokio::main]
async fn m... | true |
a25bc4dda0e25943e12170e9b26e5cff9c205aab | Rust | itsdalmo/rusty-records | /src/mapper.rs | UTF-8 | 1,511 | 2.578125 | 3 | [] | no_license | #[macro_use]
extern crate clap;
extern crate csv;
extern crate rusty_records;
use clap::{App, Arg};
fn main() {
let matches = App::new("EMR Mapper")
.usage("cat <INPUT> | mapper > <OUTPUT>")
.version(crate_version!())
.author(crate_authors!())
.arg(Arg::with_name("input")
... | true |
af1f0251dd431f5376edb5306dfc1257ed9a8fca | Rust | jordanbray/chess | /src/bitboard.rs | UTF-8 | 7,214 | 3.484375 | 3 | [
"MIT"
] | permissive | use crate::file::File;
use crate::rank::Rank;
use crate::square::*;
use std::fmt;
use std::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Mul, Not};
/// A good old-fashioned bitboard
/// You *do* have access to the actual value, but you are probably better off
/// using the implemented operators... | true |
0544385af68832864aa6ae20ca2a3a0d0da15d1f | Rust | BinChengZhao/conc-map-bench | /src/adapters/btreemap.rs | UTF-8 | 1,093 | 2.8125 | 3 | [] | no_license | use std::collections::BTreeMap;
use std::sync::Arc;
use bustle::*;
use parking_lot::RwLock;
use super::Value;
#[derive(Clone)]
pub struct RwLockBTreeMapTable<K>(Arc<RwLock<BTreeMap<K, Value>>>);
impl<K> Collection for RwLockBTreeMapTable<K>
where
K: Send + Sync + From<u64> + Copy + 'static + Ord,
{
type Han... | true |
e91fe121869ab100e680bd836434521fed7b8c4f | Rust | Temeez/ra-state-walker | /src/sprite.rs | UTF-8 | 1,187 | 2.953125 | 3 | [
"MIT"
] | permissive | use amethyst::assets::{AssetStorage, Loader};
use amethyst::prelude::*;
use amethyst::renderer::{PngFormat, Texture, TextureHandle};
// https://github.com/amethyst/amethyst/blob/e99885926057e37e62dd27e88797a14e739ad136/examples/sprites/png_loader.rs
pub fn load<N>(name: N, world: &World) -> TextureHandle
where
N: ... | true |
59d1eeca8350ab34cd4f10bada40485b5194f775 | Rust | wlcx/aoc2020 | /src/day14.rs | UTF-8 | 7,332 | 2.953125 | 3 | [] | no_license | #![feature(destructuring_assignment)]
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::{char, digit1, newline};
use nom::combinator::{all_consuming, map, map_res};
use nom::multi::{count, many1};
use nom::sequence::{delimited, preceded, separated_pair, terminated};
use nom::IResult;
us... | true |
8e68faabde3f256905429dfd967da52e96c829d5 | Rust | triscuitcircuit/TextExcelPort | /textexcel_gui/src/backend/styles.rs | UTF-8 | 3,113 | 2.609375 | 3 | [] | no_license | use iced::{button, container, Background, Color, Vector};
// Colors
pub const COLOR_YELLOW: Color = Color::from_rgb(1., 0.812, 0.);
pub const COLOR_LIGHT_YELLOW: Color = Color::from_rgb(0.996, 0.952, 0.827);
pub const COLOR_LIGHTER_YELLOW: Color = Color::from_rgb(1., 0.992, 0.933);
pub const COLOR_GREEN: Color = Color... | true |
8cc9b46355941c208b26b04d3a76cf5d4e967e38 | Rust | isgasho/reproto | /src/errors.rs | UTF-8 | 1,124 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use backend::errors as backend;
use codeviz::errors as codeviz;
use parser::errors as parser;
#[derive(Debug)]
pub enum InternalError {
ParseError,
}
impl ::std::fmt::Display for InternalError {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
::std::fmt::Debug::fmt(self, f)
}
... | true |
dd12d60d8f67b12056899435c24eec2f0f7d08dd | Rust | NicolasResier/Codewars | /Rust/number01_good_vs_evil/src/main.rs | UTF-8 | 1,669 | 3.1875 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
assert_eq!(good_vs_evil("0 0 0 0 0 10", "0 0 0 0 0 0 0"), "Battle Result: Good triumphs over Evil");
assert_eq!(good_vs_evil("0 0 0 0 0 0", "0 0 0 0 0 0 10"), "Battle Result: Evil eradicates all trace of Good");
assert_eq!(good_vs_evil("0 0 0 0 0 10", "0 0 0 0 0 0... | true |
ecab3a8d192e52d092f89561f167e43c43b52cfa | Rust | p-jackson/how-do-i-escape | /escape_grapheme/src/lang/css.rs | UTF-8 | 1,463 | 3.53125 | 4 | [
"MIT"
] | permissive | use crate::{CharEncoder, Named};
pub struct Css;
impl CharEncoder for Css {
fn encode(iter: &mut dyn Iterator<Item = char>) -> Option<String> {
iter.next().map(|i| format!("\\{:01$X}", i as u32, 4))
}
fn wrap_in_quotes() -> bool {
true
}
}
impl Named for Css {
fn name() -> &'stat... | true |
c27eddd4a9bab9ac5bd1505c6c855aeef0c3f8f8 | Rust | yohandev/framework-rs | /src/draw/bitmap/mod.rs | UTF-8 | 3,816 | 3.625 | 4 | [] | no_license | mod draw;
mod iter;
mod buf;
pub use self::buf::{ PixelBuf, PixelBufMut, FlatPixelBuf, FlatPixelBufMut };
pub use self::iter::Chunk;
use crate::math::{ Vec2, Rgba, Extent2 };
// represents a bitmap, which can be iterated and
/// drawn to
///
/// the second generic argument `B` is the inner storage
/// for pixels(raw... | true |
2dbdc908daf09f1a48793d3aee94a5342a3cf1a0 | Rust | Voxelot/transaction-processor | /src/domain/ports.rs | UTF-8 | 3,364 | 2.734375 | 3 | [] | no_license | use crate::domain::model::{
AmountInMinorUnits, Client, ClientId, Transaction, TransactionId, TransactionStatus,
};
use async_trait::async_trait;
use futures::prelude::stream::BoxStream;
use thiserror::Error;
pub type EngineResult = Result<(), EngineErrors>;
#[async_trait]
pub trait Engine {
async fn process_... | true |
2cefc2ca1a51cb86e06a5ae6f42e223df79e89d2 | Rust | nahidaislam/Operatingsystem-ID1206 | /src/memory/area_frame_allocator.rs | UTF-8 | 4,896 | 3.375 | 3 | [] | no_license | // the frame allocator
use memory::{Frame, FrameAllocator};
use multiboot2::{MemoryAreaIter, MemoryArea};
pub struct AreaFrameAllocator {
next_free_frame: Frame, // counter that is increased every time we return a frame
current_area: Option<&'static MemoryArea>, //holds the memory area that next_free_fra... | true |
34e4180512c5a4d409f3a70f77cc28e4015e6101 | Rust | v3n/ProDBG | /src/prodbg/viewdock/src/rect/serialize.rs | UTF-8 | 6,224 | 3.359375 | 3 | [
"MIT"
] | permissive | extern crate serde;
use super::{Rect, Direction};
// Serialization of Rect
impl serde::ser::Serialize for Rect {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: serde::ser::Serializer {
serializer.serialize_struct("", RectMapVisitor { value: self }).map(|_| ())
}
}
struct ... | true |
88c30468d4996c6c5b439c0be6e1c68e7764c035 | Rust | danieldulaney/xkcdfs | /src/requests/api.rs | UTF-8 | 2,075 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::Comic;
use reqwest::header::USER_AGENT;
use serde::Deserialize;
use std::convert::TryInto;
#[derive(Deserialize, Debug)]
struct ApiComic {
num: u32,
day: String,
month: String,
year: String,
link: String,
news: String,
alt: String,
title: String,
safe_title: String,
... | true |
7aff242b466bde70e6265e7c7d0a4d0d3b9f2764 | Rust | drbh/boolbrick | /src/lib.rs | UTF-8 | 2,674 | 3.328125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Brick {
pub title: String,
pub cards: Vec<Card>,
}
type Card = Vec<Choice>;
type Choice = Vec<Unit>;
#[derive(Serialize, Deserialize, Debug)]
pub enum MatchType {
Exact,
OneOf,
}
#[derive(Serialize, Deserialize,... | true |
dc438056f94eaf29fbaa81b637c2c59403cd165f | Rust | AlbinoGazelle/Learning-Rust | /data_types/src/main.rs | UTF-8 | 2,989 | 4.40625 | 4 | [
"MIT"
] | permissive | fn main() {
//four data types in Rust
//integers, floating-points, booleans, and characters
// Integers
// Length Signed Unsigned
// 8-bit i8 u8
// 16-bit i16 u16
// 32-bit i32 u32
// 64-bit i64 u64
// 128-bit i128 u128
/... | true |
c5e0589790ad8b1113b4ad85fa6839dbe135ff7b | Rust | Xiantas/Labyrinth | /src/input_manager.rs | UTF-8 | 2,653 | 2.90625 | 3 | [] | no_license | /*
Fichier utilisé pour réagir dynamiquement au entrées clavier
*/
#![allow(non_snake_case)]
use std::collections::HashMap;
use std::collections::hash_map::RandomState;
use sdl2::keyboard::Scancode;
#[derive(Copy, Clone)]
pub struct InputField {
pub down: u8,
pub up: u8,
pub pressed: bool,
//Pour des raisons d... | true |
4ac39270bb888ce4f45c87e9dc67beb4001fb9d5 | Rust | gnoliyil/fuchsia | /src/developer/ffx/plugins/inspect/apply_selectors/src/test_utils.rs | UTF-8 | 2,813 | 3.015625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2022 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::{screen::Line, terminal::Terminal},
std::{
cmp::min,
io::Write,
sync::{Arc, Mutex},
},
};
#[derive(Debug,... | true |
4d09b3d3f14e4937774bbdd7c7b7ae5bceee1472 | Rust | mm0205/aizu-rust | /src/itp1_8/d.rs | UTF-8 | 2,212 | 3.3125 | 3 | [] | no_license | //! ITP1_8_Dの回答
//! [https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_D](https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_D)
use std::io::BufRead;
/// ITP1_8_Dの回答
#[allow(dead_code)]
pub fn main() {
loop {
if let Some(dataset) = read_dataset(std::io::stdin().lock()) {
... | true |
8285e9d096e714a9c1adcbc1c93b514d6c160a6b | Rust | rpjohnst/dejavu | /gml/tests/interpreter.rs | UTF-8 | 20,872 | 2.703125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-free-unknown"
] | permissive | use std::collections::HashMap;
use std::convert::TryFrom;
use std::io;
use std::ops::Range;
use gml::{Function, Item, symbol::Symbol, vm};
/// Read script arguments.
#[test]
fn arguments() -> vm::Result<()> {
let mut game = project::Game::default();
let items = HashMap::default();
let select = Function::... | true |
59dcec32b2d5e5f51c17330a08f16241ab0463bd | Rust | gaultier/kotlin-rs | /src/resolver.rs | UTF-8 | 22,434 | 2.59375 | 3 | [] | no_license | use crate::error::*;
use crate::lex::{Token, TokenKind};
use crate::parse::*;
use crate::session::{Session, Span};
use log::debug;
use std::collections::BTreeMap;
use std::fmt;
const LEXICAL_CONTEXT_TOP_LEVEL: u8 = 0;
const LEXICAL_CONTEXT_LOOP: u8 = 0b001;
const LEXICAL_CONTEXT_FUNCTION: u8 = 0b010;
const LEXICAL_CON... | true |
5c3dee6bfdfea8639e91699c47a0d404748651d2 | Rust | jakmeier/paddlers-browser-game | /paddlers-shared-lib/src/shared_types.rs | UTF-8 | 2,280 | 3.21875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A few basic types shared between crates.
//! Shared types related to API or other specific parts are defined in their corresponding module and not in here.
/// The default ID Type for referencing objects across the Paddlers services.
pub type PadlId = i64;
#[derive(Default, Debug, Copy, Clone, PartialEq, PartialO... | true |
3f54e6c73cd5e8f97fafbd4b7a057df054ff83d4 | Rust | nossrannug/adventofcode | /rust/day_10/src/main.rs | UTF-8 | 2,616 | 3.703125 | 4 | [] | no_license | use common::get_file_content;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let contents = get_file_content(args.last().unwrap().to_string()).expect("Failed to open file");
println!("Part 1: {}", part_1(&contents));
println!("Part 2: {}", part_2(&contents));
}
fn part_1(cont... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.