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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
760c5e9685cd65fe43bae008cbbcab1e0c984b13 | Rust | MidasLamb/async-graphql | /src/validation/rules/lone_anonymous_operation.rs | UTF-8 | 3,449 | 3.3125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::parser::query::{Definition, Document, OperationDefinition};
use crate::validation::visitor::{Visitor, VisitorContext};
use crate::Positioned;
#[derive(Default)]
pub struct LoneAnonymousOperation {
operation_count: Option<usize>,
}
impl<'a> Visitor<'a> for LoneAnonymousOperation {
fn enter_document(... | true |
8b906e56fc80c700df52e23a1d5e4cb147c68719 | Rust | TGITS/programming-workouts | /rust/codingame/practice/easy/power_of_thor_p1/src/main.rs | UTF-8 | 2,049 | 3.484375 | 3 | [
"MIT"
] | permissive | use std::io;
use std::fmt;
macro_rules! print_err {
($($arg:tt)*) => (
{
use std::io::Write;
writeln!(&mut ::std::io::stderr(), $($arg)*).ok();
}
)
}
macro_rules! parse_input {
($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap())
}
/**
* Auto-generated code b... | true |
6118c88c7fab24d133bbf6f93f7e18b8744e7dc2 | Rust | robinmoussu/pyrite | /src/main.rs | UTF-8 | 10,006 | 3.1875 | 3 | [] | no_license | use regex::Regex;
use std::str::FromStr;
#[derive(Debug)]
struct ParseError;
trait Grammar
where
Self: Sized,
{
fn parse<'a>(txt: &'a str) -> Result<(Self, &'a str), ParseError>;
}
trait Token {
fn regex() -> &'static str;
}
impl<T> Grammar for T
where
T: Token + Default,
{
fn parse<'a>(txt: &'a... | true |
1d39e10aa3a88004fb7aba5e2e81fdc6fa079c44 | Rust | santhoshselvan/advent-of-code | /2019/src/bin/day04.rs | UTF-8 | 4,854 | 3.34375 | 3 | [] | no_license | use std::collections::HashMap;
pub fn next_valid_password(num: i64) -> i64 {
let (_,
has_two_same_adjacent_digits,
has_digits_with_non_decreasing_value) = is_valid(num);
match (has_digits_with_non_decreasing_value, has_two_same_adjacent_digits) {
(true, false) => {
return n... | true |
e7e0415bc087a978aab3f076329d77ff39636d0c | Rust | huonw/float | /tests/exhaustive.rs | UTF-8 | 6,700 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate ramp;
extern crate float;
use float::Float;
use std::i64;
struct AtPrecision {
val: u32,
prec: u32,
}
impl AtPrecision {
fn new(p: u32) -> AtPrecision {
assert!(p >= 1);
AtPrecision {
val: 1 << (p - 1),
prec: p
}
}
}
impl Iterator for AtPr... | true |
13da8586fd26514ff25ee1060adddce5924e9c43 | Rust | bbradshaw/codeadvent | /2020/day14/src/main.rs | UTF-8 | 795 | 3.625 | 4 | [] | no_license | use std::convert::TryInto;
struct ThirtySixBit {
inner: [u8;5]
}
impl ThirtySixBit {
fn new() -> ThirtySixBit {
ThirtySixBit{inner: [0;5]}
}
fn get_value(&self) -> u64{
let mut temp = [0u8;8];
for i in 0..5{
temp[i+3] = self.inner[i].clone();
}
u64:... | true |
d2cf22b10c4d326076241d742e7363a1b37d3fd4 | Rust | MaulingMonkey/jni-bindgen | /jni-bindgen/src/config/runtime.rs | UTF-8 | 6,849 | 2.703125 | 3 | [
"MIT",
"Apache-2.0",
"MPL-1.1"
] | permissive | //! Runtime configuration formats. By design, this is mostly opaque - create these from tomls instead.
use crate::config::*;
use std::collections::*;
use std::ffi::*;
use std::path::*;
pub(crate) struct DocPattern {
pub(crate) class_url_pattern: String,
pub(crate) method_url_pattern: ... | true |
166ddc88c4ff38515d033993634b49c94d9aa79a | Rust | zzl133/my_rust_road | /learn-rust/the_rust_book/learn_crate2/src/main.rs | UTF-8 | 507 | 2.609375 | 3 | [] | no_license | // use mylib::factory::product_refigerator;
// use mylib::factory::product_washing_machine as A; // 使用了as
use mylib::factory::*;
fn main() {
// mylib::factory::product_refigerator::produce_refigerator();// 绝对路径
product_refigerator::produce_refigerator(); // 相对路径 使用use
// A::produce_washing_machine();
... | true |
3c555efe9d08a1464f664cbb2ae9c85e8d093c8b | Rust | OrangeBacon/adventofcode2019 | /src/day10b.rs | UTF-8 | 5,688 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::collections::HashSet;
use std::f32;
use num::Integer;
pub fn day10b() {
let path = Path::new("data/day10.txt");
let display = path.display();
let mut file = match File::open(&path) {
Err(why) => panic!... | true |
ab7f6ad1e9b143d9e9e5b5c2cba028b67fa4b192 | Rust | varu3dbox/rust-sandbox | /algorithm_and_data_structure/chap04/src/bin/code_4_4.rs | UTF-8 | 238 | 3.1875 | 3 | [] | no_license | fn GCD(m: i32, n: i32) -> i32 {
// ベースケース
if n == 0 {
return m;
}
// 再帰呼び出し
return GCD(n, m % n);
}
fn main() {
println!("{:?}", GCD(51, 15));
println!("{:?}", GCD(15, 51));
}
| true |
d28b712475a3e47e68e6c2c1534f9da448c15c56 | Rust | martinvd/playground-rust | /0301_variables/src/main.rs | UTF-8 | 189 | 3.1875 | 3 | [
"MIT"
] | permissive | fn main() {
let mut x = "100";
println!("The value of x is: {}", x);
x = "200";
println!("The value of x is: {}", x);
let x = x.len();
println!("The value of x is: {}", x);
}
| true |
35b4b8bcf12adcd17ef888fb8023120cc533b685 | Rust | HiDefender/ferric | /src/daikon/mod.rs | UTF-8 | 12,199 | 2.859375 | 3 | [
"MIT"
] | permissive | use fnv::FnvHashMap;
use daikon::types::{VarKind, DecType, RepType, PPTType};
mod types;
mod map;
// Need to instrument source code.
// Need to create a .decls file.
pub struct Instrumentor {
src_to_dectype: FnvHashMap<&'static str, DecType>,
dectype_to_reptype: FnvHashMap<DecType, RepType>,
decls: Strin... | true |
2285dd0a62e2d8a70fd09c5b00900463094e7e23 | Rust | ojhunt/rustrt | /src/vectors.rs | UTF-8 | 8,100 | 3.265625 | 3 | [] | no_license | use std::ops;
use packed_simd::shuffle;
use packed_simd::f32x4;
use packed_simd::m32x4;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vector {
pub data: f32x4,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Point {
pub data: f32x4,
}
#[derive(Debug, Clone, Copy)]
pub struct Vec4Mask(m32x4);
pub tra... | true |
94f8471c492ba2f7021d520b61da2f08218a4a42 | Rust | snakehand/dp-3t-client | /src/lib.rs | UTF-8 | 2,443 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate serde;
pub mod session;
#[cfg(test)]
mod tests {
use crate::session::{ReplayKey, Session, SessionKey};
use hex::FromHex;
use std::path::PathBuf;
#[test]
fn test_session() {
let mut session = Session::new();
let path = PathBuf::from("test_session.json");
assert... | true |
862d05f6d0456991ea08ae7258b14c7f4a32212b | Rust | benmaddison/rfz | /src/collection.rs | UTF-8 | 4,039 | 3.296875 | 3 | [
"MIT"
] | permissive | use std::collections::{hash_map, BTreeMap, HashMap};
use std::fs;
use std::path::PathBuf;
use std::slice;
use std::vec;
use crate::document::Document;
use crate::errors::{Error, Result};
#[derive(Clone)]
pub struct Collection(Vec<Document>);
impl Collection {
pub fn from_dir(path: PathBuf) -> Result<Self> {
... | true |
db15be699e5185071d85f2a125d18fd54b9b3d12 | Rust | sria91-rlox/RustLox-1 | /src/vm.rs | UTF-8 | 5,824 | 3.328125 | 3 | [] | no_license | use std::{
collections::HashSet,
ops::{Neg, Not},
rc::Rc,
};
use crate::{
assembler,
chunk::{Chunk, CodeIndex, OpCode},
object::{Object, ObjectList},
value::{print_vec_val, Value},
};
#[derive(Debug, PartialEq)]
pub struct RuntimeError {
pub msg: String,
}
pub struct VM {
chunk: C... | true |
bc3cf39c0d4adbea60b4d513ad513f3b722c6daa | Rust | dalance/svlint | /src/syntaxrules/function_with_automatic.rs | UTF-8 | 6,035 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::config::ConfigOption;
use crate::linter::{SyntaxRule, SyntaxRuleResult};
use sv_parser::{NodeEvent, RefNode, SyntaxTree};
#[derive(Default)]
pub struct FunctionWithAutomatic {
lifetimes: Vec<Lifetime>,
}
enum Lifetime {
Static,
Automatic,
}
impl SyntaxRule for FunctionWithAutomatic {
fn ch... | true |
e9bdacc3b4570ea7ce0212a632e5f7bc182a28da | Rust | pshc/exude | /client/src/render_loop.rs | UTF-8 | 822 | 2.609375 | 3 | [] | no_license | use g::gfx;
use g::WindowEvent;
use errors::*;
/// Called upon by the render loop.
pub trait Engine<R: gfx::Resources> {
type CommandBuffer: gfx::CommandBuffer<R>;
type Factory: gfx::Factory<R>;
type State;
fn draw(&mut self, &mut gfx::Encoder<R, Self::CommandBuffer>) -> Result<()>;
fn update(&mu... | true |
0dd359aeb3ec7aba4182b3083dce984fe14de885 | Rust | fluffware/stepper_paths | /src/stepper_config_parser.rs | UTF-8 | 1,290 | 2.890625 | 3 | [] | no_license | use std::fs::File;
use std::io::BufReader;
use stepper_config::XyStepperConfig;
pub struct Error {
descr: String,
}
impl Error {
pub fn new(descr: &str) -> Error {
Error {
descr: String::from(descr),
}
}
}
impl std::error::Error for Error {
fn description(&self) -> &str {
... | true |
80dbbbc091a6e176bccf1408acca1333e97668bd | Rust | syntacticsugarglider/light-sample-program | /src/util/colors.rs | UTF-8 | 10,569 | 2.59375 | 3 | [] | no_license | /// Defined in CSS3
pub const aliceblue: [u8; 3] = [0xf0, 0xf8, 0xff];
/// Defined in CSS3
pub const antiquewhite: [u8; 3] = [0xfa, 0xeb, 0xd7];
/// Defined in CSS3
pub const aqua: [u8; 3] = [0x00, 0xff, 0xff];
/// Defined in CSS3
pub const aquamarine: [u8; 3] = [0x7f, 0xff, 0xd4];
/// Defined in CSS3
pub const azu... | true |
1565dd491c72c52c9bcf6c91b30926e2bd24df1a | Rust | rrrbba/rust | /guessing_game/src/main.rs | UTF-8 | 2,304 | 4.21875 | 4 | [
"MIT"
] | permissive | use std::io; //standard library
use std::cmp::Ordering; //enum with variants - less,greater,equal
use rand::Rng;
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
loop {
println!("Please input your guess:");
//mutable variable because... | true |
ae03622141427949c76469a9a390b4746be85198 | Rust | kmooney/tetrix | /src/event.rs | UTF-8 | 1,074 | 2.953125 | 3 | [] | no_license | use crate::board::Board;
use crate::shape::Shape;
use crate::shape::Orientation;
use crate::shape::Point;
#[derive(Clone, PartialEq, Debug)]
pub enum Output {
GameOver,
GameStarted,
GameRunning,
BoardUpdate(Board),
HeldShape(Shape),
NextShape(Shape),
RotatedShape(Orientation),
MovedShap... | true |
fb5247c96dd09537a03620ad77def0a238a30e55 | Rust | jzbrooks/rox | /src/vm.rs | UTF-8 | 9,602 | 3.109375 | 3 | [] | no_license | use crate::bytecode::{Chunk, OpCode, Value};
use crate::compiler::Compiler;
pub struct VM {
ip: usize,
stack: Vec<Value>,
}
#[derive(Debug, PartialEq)]
pub enum InterpretError {
Compile,
Runtime,
}
impl std::fmt::Display for InterpretError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::... | true |
f7c33997c54f3b2b224b443266f490eff3c1224f | Rust | tlinford/raytracer-challenge-rs | /raytracer/src/geometry/shape/smooth_triangle.rs | UTF-8 | 5,410 | 3.4375 | 3 | [] | no_license | use std::{any::Any, vec};
use crate::{
bounding_box::BoundingBox,
geometry::{intersection::Intersection, BaseShape, Shape},
point::Point,
ray::Ray,
vector::{cross, dot, Vector},
EPSILON,
};
#[derive(Debug, PartialEq)]
pub struct SmoothTriangle {
base: BaseShape,
pub p1: Point,
pub ... | true |
18fba06f644131e11530c948675dfe49580fedbe | Rust | bottlerocket-os/bottlerocket | /sources/api/datastore/src/memory.rs | UTF-8 | 9,617 | 3.234375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! In-memory datastore for use in testing other modules.
//!
//! Mimics some of the decisions made for FilesystemDataStore, e.g. metadata being committed
//! immediately.
use std::collections::{HashMap, HashSet};
use super::{Committed, DataStore, Key, Result};
#[derive(Debug, Default)]
pub struct MemoryDataStore {
... | true |
95be95f4978b882b803180bad58dd09a199c1a66 | Rust | nanomad/chip8emu-rs | /src/peripherals.rs | UTF-8 | 2,396 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::convert::{From, TryFrom};
use video_engine::VideoEngine;
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub enum Key {
Key0,
Key1,
Key2,
Key3,
Key4,
Key5,
Key6,
Key7,
Key8,
Key9,
KeyA,
KeyB,
KeyC,
KeyD,
KeyE,
Ke... | true |
6e0b747a7ff5a0eae22d01f6383530f0c9229b27 | Rust | cshung/Competition | /rust_competition/src/leetcode/sort_an_array.rs | UTF-8 | 1,317 | 3.359375 | 3 | [] | no_license | use library::rand::Rand;
impl Solution {
fn sort(nums: &mut Vec<i32>, start: usize, end: usize) {
if end - start > 1 {
let mut i = start;
let mut j = start;
let mut k = end - 1;
let pivot = nums[start];
while j <= k {
if nums[j] < ... | true |
61ed897238a46648a8af7bac6cbbed0f6d37d48e | Rust | christ776/Rust-Z80 | /tests/opcodes.rs | UTF-8 | 73,357 | 2.625 | 3 | [] | no_license | #[allow(unused_imports)]
#[cfg(test)]
mod test_opcodes {
use ::Z80::memory::PlainMemory;
use ::Z80::memory::Memory;
use ::Z80::registers::{ Register16Bit, Flags };
use Z80::z80::Z80;
#[test]
fn test_ld_ihl_n() {
let mut cpu = Z80::new();
let mut mem = PlainMemory::new_64k();
cpu.r.sp = 0xFFFF;
... | true |
3666774bd88ed25032d82a005a4c4a41d79876a0 | Rust | con-f-use/yadmdotfiles | /devel/rust/learning_rust/8-collections/src/main.rs | UTF-8 | 1,137 | 3.875 | 4 | [] | no_license | fn main() {
let mut v = Vec::new();
v.push(1);
v.push(2);
v.push(3);
v.push(4);
let first = &v[0];
// cannot do the following, because value is already borrowed immutably
// and pushing might re-allocate the entire `v`, invalidating the old
// reference.
// v.push(6);
printl... | true |
eeab841c46c825f7ffb9e123941c065d71bac63e | Rust | zane-programs/librespot | /core/src/keymaster.rs | UTF-8 | 834 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use futures::Future;
use serde_json;
use mercury::MercuryError;
use session::Session;
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Token {
pub access_token: String,
pub expires_in: u32,
pub token_type: String,
pub scope: Vec<String>,
}
pub fn get_token(
sessi... | true |
19b8b397011d7f0535754ba47c1956e6f4bc07a6 | Rust | rtroxler/sexe | /src/parser.rs | UTF-8 | 11,538 | 2.75 | 3 | [
"Unlicense"
] | permissive | use expression::*;
use nom;
use nom::types::CompleteStr;
// This is a custom implementation of nom::recognize_float that does not parse
// the optional sign before the number, so that expressions like `x+3` parse
// correctly and not as `x(+3)`.
named!(recognize_float<CompleteStr, CompleteStr>,
recognize!(
tuple... | true |
ecbedf46c4afe500a705c1ac2b11b60072530c83 | Rust | rust-native-ui/libui-rs | /iui/src/draw/context.rs | UTF-8 | 2,037 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use draw::{Brush, Path, StrokeParams, Transform};
use ui_sys::{self, uiDrawContext};
/// Drawing context, used to draw custom content on the screen.
pub struct DrawContext {
ui_draw_context: *mut uiDrawContext,
}
impl DrawContext {
/// Create a Context from a ui_draw_context pointer.
///
/// # Unsafet... | true |
23f4099ec6600844e9c61f1b8866cd8c0d637f3d | Rust | Lapz/tox | /ir/src/block.rs | UTF-8 | 639 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::ir::{Instruction, Register};
#[derive(Debug, Clone, Hash, PartialEq, Eq, Copy)]
pub struct BlockID(pub u32);
#[derive(Clone,Debug)]
pub struct Block {
pub instructions: Vec<Instruction>,
pub end: BlockEnd,
}
#[derive(Debug, Clone, PartialEq)]
pub enum BlockEnd {
Jump(BlockID),
Return(Regis... | true |
1e6a7a58c2ac6c9ddcfdc0d307b5b70ff5a2415b | Rust | jasmaabox/AoC-2020-rust | /day03/src/main.rs | UTF-8 | 1,345 | 3.34375 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::vec::Vec;
/// Counts number of trees encountered going down slope.
fn count_trees(grid: &Vec<Vec<char>>, dx: usize, dy: usize) -> i32 {
let height = grid.len();
let width = grid[0].len();
let mut curr_row = 0;
let mut curr_col... | true |
0f6196c3bd2b8b33a8604706e352ea5e1732744e | Rust | archer884/watcher | /src/greetings.rs | UTF-8 | 3,158 | 3.71875 | 4 | [] | no_license | use regex::Regex;
use serde::{Deserialize, Deserializer};
use std::slice;
#[derive(Clone)]
pub struct Greeting {
passthru: bool,
filter: Option<Regex>, // filter is optional
message: String,
}
impl Greeting {
#[inline]
pub fn message(&self, nick: &str) -> String {
self.message.replace("{ni... | true |
042de5b13bfc51640a840afa8bed27eae2ee06fb | Rust | tweber12/slha-rs | /slha/src/modifier.rs | UTF-8 | 7,005 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2017 Torsten Weber
//
// 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 t... | true |
6e0efc15e29014c6f71eb7f63321099a407e383c | Rust | jakobbotsch/exp-epa | /src/type_checker.rs | UTF-8 | 13,632 | 2.96875 | 3 | [] | no_license | use scopeguard::{guard, ScopeGuard};
use super::model::Model;
use super::cwf::*;
use super::lang::ast::*;
pub struct TypeChecker<T: Model> {
model: T,
ctxs : Vec<CtxInfo>,
}
struct CtxInfo {
syntax: Ctx,
// morphism from previous (if any) context to current
weakening: Option<Morph>,
defs: Vec<... | true |
7c7783eabe0587ec301795e299d50d7f93b80ff6 | Rust | Happy-Ferret/git-appraise-rs | /src/request.rs | UTF-8 | 2,232 | 2.90625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde_json;
use std::str::FromStr;
use git2::{ Oid, Time, Note };
use super::{ Error, Result };
#[derive(Clone, Deserialize)]
pub struct Data {
timestamp: Option<String>,
#[serde(rename="reviewRef")]
review_ref: Option<String>,
#[serde(rename="targetRef")]
target_ref: Option<String>,
requester: Option... | true |
dca38f5d8d8aae30ab5f64523accc9857710d87a | Rust | michihupf/Arrow | /arrow-protocol/src/packets/version_specific/play/v464.rs | UTF-8 | 3,552 | 2.828125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /// All clientbound `play` packets for protocol versions 468 and above.
pub mod clientbound {
use serde::{Deserialize, Serialize};
use crate::packets::types::LevelType;
use crate::{
packets::{error::PacketError, Packet},
serde::ser::Serializer,
};
/// The [JoinGame](https://wiki.vg... | true |
68ef828d24caa6fb8fccf301fe4808e61bfe81d2 | Rust | Mungari/rust8 | /src/cpu.rs | UTF-8 | 4,829 | 2.9375 | 3 | [] | no_license | pub struct Cpu {
pub I: u16,
pub Vx: [u8; 16],
pub PC: u16,
pub SP: u8,
pub STACK: [u16; 16],
pub DT: u8,
pub ST: u8
}
impl Cpu {
pub fn new() -> Cpu {
Cpu {
I: 0x200,
Vx: [0; 16],
PC: 0x200,
SP: 0,
STACK: [0; 16],
... | true |
227f86fad025cd63a2ee8db28977e151cf9ee3da | Rust | zed0/advent-of-code | /2020/src/bin/aoc-08/main.rs | UTF-8 | 4,276 | 3.171875 | 3 | [] | no_license | use std::fs;
use std::env;
use std::time::SystemTime;
use std::collections::HashSet;
use itertools::Itertools;
use regex::Regex;
use std::convert::{TryInto,TryFrom};
use core::str::FromStr;
#[macro_use] extern crate scan_fmt;
#[derive(Debug, PartialEq, Clone)]
struct Instruction {
operation: String,
argument:... | true |
e946e899f5e346929bdb17bd2e6d187f29ee0b93 | Rust | RGafiyatullin/serde-pgrow | /tests/t11_same_type_columns_into_hashmap.rs | UTF-8 | 1,507 | 2.75 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
mod common;
#[tokio::test]
// #[ignore]
async fn t_text_columns_into_hashmap() {
// common::init_logger();
let out = common::pg_query_and_de::<HashMap<String, String>>(
"SELECT '1' one, '2' two, '3' three",
&[],
)
.await
.unwrap();
let expected_ha... | true |
b91d7a311b5bec681697f2a2f00d237a2dcafb53 | Rust | marcmos/mpkflow | /src/trip_registry.rs | UTF-8 | 1,081 | 2.640625 | 3 | [] | no_license | use actix::prelude::*;
#[path = "passage.rs"]
mod passage;
use std::collections::HashMap;
#[derive(Default)]
pub struct TripRegistry {
trips: HashMap<String, Addr<passage::Trip>>,
}
impl Actor for TripRegistry {
type Context = Context<TripRegistry>;
}
impl Supervised for TripRegistry {}
impl ArbiterService... | true |
44f328f04c46cac05945d2fc8e7de6bb6b67f86d | Rust | bluecube/planetjump | /src/shared/physics/particle.rs | UTF-8 | 2,875 | 2.96875 | 3 | [] | no_license | use geometry::*;
use physics::traits::*;
use physics::forces::FRICTION;
use std::rc::Rc;
// Time step.
static DT: f32 = 0.01;
#[derive(PartialEq,Clone,Debug)]
pub struct BasicParticleType {
pub inertia_mass: f32,
pub gravity_mass: f32,
pub d0: f32,
pub hardness: f32,
}
#[derive(Debug)]
pub struct Par... | true |
69f1e313964c473255c81ee3d4ed9bbf9bbbbbac | Rust | Co-Epi/app-backend-rust | /src/tcn_recording/observed_tcn_processor.rs | UTF-8 | 2,673 | 2.703125 | 3 | [
"MIT"
] | permissive | use super::tcn_batches_manager::TcnBatchesManager;
use crate::{
byte_vec_to_16_byte_array, database::tcn_dao::TcnDao, errors::ServicesError, expect_log,
reports_interval,
};
use log::*;
use reports_interval::UnixTime;
use std::sync::{Arc, Mutex};
use tcn::TemporaryContactNumber;
use timer::{Guard, Timer};
#[de... | true |
dab577f53ff5e601f4696b0cd7fe2b3987ed4851 | Rust | ibilon/AdventOfCode2020 | /src/utils.rs | UTF-8 | 282 | 2.953125 | 3 | [
"MIT"
] | permissive | pub fn remove_vec<T: std::cmp::PartialEq>(data: &mut Vec<T>, value: &T) -> bool {
let mut index = -1;
for (i, v) in data.iter().enumerate() {
if *v == *value {
index = i as i32;
break;
}
}
if index != -1 {
data.remove(index as usize);
true
} else {
false
}
}
| true |
1ff79ef01ce5caeb4ece8af6aeec5aa7795d4741 | Rust | SergioQuijanoRey/PracticasMetaheuristicas | /src/algorithms/multistart_local_search.rs | UTF-8 | 3,991 | 3.171875 | 3 | [] | no_license | use crate::problem_datatypes::Solution;
use crate::problem_datatypes::DataPoints;
use crate::problem_datatypes::Constraints;
use crate::fitness_evolution::FitnessEvolution;
use crate::arg_parser::ProgramParameters;
use crate::utils;
use crate::arg_parser::SearchType;
use crate::algorithms::local_search;
use rand::rngs... | true |
bffbd155f87552611f2f1d5e642e8cb61118a413 | Rust | bidhan-a/dream | /src/dataset.rs | UTF-8 | 9,253 | 3.21875 | 3 | [
"MIT"
] | permissive | use crate::flow::Flow;
use crate::processor::Processor;
use crate::sinks::Sink;
use crate::stats::Stats;
use crate::Message;
use std::mem;
use std::sync::mpsc::{self, Receiver, Sender};
use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use uuid::Uuid;
// `Channels` holds the channel for receiving data from up... | true |
7a8694c08f36b38a1140d16a27ca554331d0e21b | Rust | rasmusmerzin/recl | /src/record.rs | UTF-8 | 1,716 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::log::{log_bytes, Log};
use std::io::{stderr, stdout};
use std::process::{Command, Stdio};
use std::sync::Mutex;
use std::thread::spawn;
use std::time::Instant;
pub fn record(cmd: &[String]) -> Result<Log, String> {
match cmd.get(0) {
Some(exe) => match Command::new(exe)
.args(&cmd[1.... | true |
b3da8dfe5e4244fa77782702e2e837f126697d4a | Rust | Matrix-Groups/diem | /api/src/page.rs | UTF-8 | 1,207 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use diem_api_types::Error;
use anyhow::{format_err, Result};
use serde::Deserialize;
use std::str::FromStr;
const DEFAULT_PAGE_SIZE: u32 = 25;
const MAX_PAGE_SIZE: u32 = 1000;
#[derive(Clone, Debug, Deserialize)]
pub(crate) struct Pa... | true |
da736f9f2d6f2c756184535171a64e1a2484dcad | Rust | heikkari/kildin | /src/server/endpoints/add_manager.rs | UTF-8 | 1,556 | 2.96875 | 3 | [] | no_license | // crate
use crate::server::authorization::Authorization as Auth;
use crate::database::managers::{ManagerAuth, ManagerState};
// serde
use serde_derive::{Serialize, Deserialize};
// rocket
use rocket_contrib::json::Json;
use rocket::response::status::BadRequest;
// std
use std::iter;
// rand
use rand::distributions... | true |
76b006aacab78fe932a03b23de64174ed6b12c69 | Rust | microrack/coresynth | /fw/rust_lib/src/os/linux_os/mail.rs | UTF-8 | 1,136 | 2.84375 | 3 | [] | no_license | use std::sync::mpsc::{sync_channel, Receiver, RecvError, SendError, SyncSender};
use super::Duration;
#[derive(Clone)]
pub struct MailSender<T>(SyncSender<T>);
pub struct MailReceiver<T>(Receiver<T>);
impl<T> MailSender<T> {
pub fn send(&self, item: T) -> Result<(), SendError<T>> {
self.0.send(item)
... | true |
f6e31b339ee897fcc091c44174deee29f4b8ab97 | Rust | bloatoo/basedtyper | /src/server/server.rs | UTF-8 | 2,555 | 2.921875 | 3 | [] | no_license | use std::sync::Arc;
use serde_json::{Value, json};
use tokio::sync::Mutex;
use super::message::{Color, Forwardable, Message, UserData};
use super::client::Client;
use crate::utils::Word;
use tokio::io::AsyncWriteExt;
#[derive(Clone)]
pub struct Server {
pub clients: Arc<Mutex<Vec<Client>>>,
pub words: Vec<Wor... | true |
52a7619a5a48df8454823cac65cdd42abdac170c | Rust | hoodie/claude-rs | /examples/display.rs | UTF-8 | 365 | 3.390625 | 3 | [] | no_license | use claude::*;
fn main() {
let my_money = Currency {
symbol: Some('€'),
value: 4711,
};
println!("I have {:?}!", my_money);
//println!("I have {}!", my_money); // doesn't compile :D
println!("I have {}!", my_money.postfix()); // -> "I have 47,11€!"
println!("I have {}!", my_mon... | true |
523871e4e835e3df38513e911df1ef0562ed8344 | Rust | dewaka/advent-rust | /advent15/src/day14.rs | UTF-8 | 6,464 | 3.296875 | 3 | [] | no_license | // https://adventofcode.com/2015/day/14
/*
--- Day 14: Reindeer Olympics ---
This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must
rest occasionally to recover their energy. Santa would like to know which of his
reindeer is fastest, and so he has them race.
Reindeer can only either be flying (... | true |
b277667bd309f9b0176fdaf54b161fc3d4da3c2e | Rust | ValentinGourdon/libppm | /rust-lib/src/lib.rs | UTF-8 | 10,164 | 3.578125 | 4 | [] | no_license | // This crate is a library
#![crate_type = "lib"]
// This crate is named "pixel"
#![crate_name = "pixel"]
// Use +nightly to overpass this
#![feature(test)]
#[cfg(test)]
mod tests;
extern crate rand;
use std::ops::Not;
use std::path::Path;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use rand... | true |
f7dc86aec3b5638c01c5caa123f94641c7f81cbb | Rust | rustgd/glsl-layout | /src/array.rs | UTF-8 | 7,543 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::align::Align16;
use crate::uniform::{Std140, Uniform};
use std::{
marker::PhantomData,
slice::{Iter as SliceIter, IterMut as SliceIterMut},
};
pub(crate) trait MapArray<A, F> {
fn map_array(values: A, f: F) -> Self;
}
/// Aligning wrapper.
/// Elements for array are aligned to 16 bytes (size of... | true |
3de433ee0450b1d6d79afdc43d73c7eb2cddb635 | Rust | oxidecomputer/third-party-api-clients | /docusign/src/envelope_recipients.rs | UTF-8 | 20,835 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::Client;
use crate::ClientResult;
pub struct EnvelopeRecipients {
pub client: Client,
}
impl EnvelopeRecipients {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
EnvelopeRecipients { client }
}
/**
* Gets the status of recipients for an envelope.
*
* This func... | true |
4030fccd673595792a5510e9d526e91798aed14f | Rust | FauxFaux/ureq | /src/lib.rs | UTF-8 | 5,785 | 3.421875 | 3 | [
"MIT"
] | permissive | #![warn(clippy::all)]
//! ureq is a minimal request library.
//!
//! The goals of this library are:
//!
//! * Minimal dependency tree
//! * Obvious API
//!
//! ```
//! // requires feature: `ureq = { version = "*", features = ["json"] }`
//! #[macro_use]
//! extern crate ureq;
//!
//! fn main() {
//! // sync post re... | true |
32abc200f44ead6c1efd37c460acd0088b2b6c30 | Rust | frankbryce/ProjectEuler | /ProjectEuler_0034/main.rs | UTF-8 | 381 | 3.078125 | 3 | [] | no_license | fn main() {
let mut tot = 0;
let f = [1,1,2,6,24,120,720,5040,40320,362880];
for n in 10..10000000 {
let mut s = 0;
for c in n.to_string().chars() {
let d = c as usize - '0' as usize;
s += f[d];
}
if s == n {
tot += n;
println!(... | true |
5206944d2d71d2acc2ca60a2fd227e4fd70d9b77 | Rust | pklazy/lpc54628-rust | /src/usbhsh/last_ptd_inuse.rs | UTF-8 | 3,974 | 2.578125 | 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::LAST_PTD_INUSE {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOn... | true |
c13b2d2abbe7138849583576c3a1af7cb7b71d2a | Rust | callpraths/cshannon | /src/model.rs | UTF-8 | 4,722 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Prathmesh Prabhu
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed t... | true |
076fa7080dd8ea1cdf4b099ed7926fd1f040136b | Rust | mblonyox/adventofcode | /2021/src/day14.rs | UTF-8 | 6,809 | 3.328125 | 3 | [] | no_license | use std::{collections::HashMap, str::FromStr};
pub struct InsertionPair(String, u8);
pub struct InsertionPairParseError;
impl FromStr for InsertionPair {
type Err = InsertionPairParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut ins = s.split(" -> ");
let pair = match ins.... | true |
902a0c76b9b1f47e2fb2eb1c995d554e7e3f9542 | Rust | osphea/zircon-rpi | /src/connectivity/bluetooth/lib/fuchsia-bluetooth/src/profile.rs | UTF-8 | 6,577 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2020 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 {
anyhow::{format_err, Error},
fidl_fuchsia_bluetooth_bredr::{
Attribute, DataElement, ProfileDescriptor, ATTR_BLUETOOTH_PROFILE_DESCRI... | true |
ba182d0e2b0163775e0f61555dc23c21fba181ce | Rust | jamesmcm/sdfm | /src/init.rs | UTF-8 | 5,739 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::args::InitCommand;
use crate::args::RepoURL;
use crate::dotfiles::get_found_dotfiles;
use crate::repos;
use anyhow::Result;
use serde_derive::Serialize;
use std::env;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::io::Write;
use std::path::PathBuf;
use std::process::Command;
use d... | true |
70da221f4770d2055b119f9a3be75399b0a7060d | Rust | Tembocs/rome | /crates/rome_js_formatter/src/js/expressions/sequence_expression.rs | UTF-8 | 713 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::formatter_traits::FormatTokenAndNode;
use crate::{
format_elements, space_token, FormatElement, FormatResult, Formatter, ToFormatElement,
};
use rome_js_syntax::JsSequenceExpression;
use rome_js_syntax::JsSequenceExpressionFields;
impl ToFormatElement for JsSequenceExpression {
fn to_format_elemen... | true |
79f164d966b1771e360be788ea06f6f958f18f84 | Rust | ericbean/worklog | /src/timeclock/iterators.rs | UTF-8 | 8,133 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::iter::Iterator;
use std::mem;
use timeclock::DateRecord;
use timeclock::Direction;
use timeclock::IntoDateRecords;
use timeclock::TimeEntry;
use timeclock::TimeEntryPair;
use timeclock::now;
/// Iterator adapter to create `DateRecords`
pub struct DateRecordIter<I> {
v: I,
}
impl<I> DateRecordIter<I> {
... | true |
061f9a84764ca281086eb443d0e6cbf3019c7fe7 | Rust | nwtnni/advent-of-code | /aoc-22/src/day_21.rs | UTF-8 | 5,506 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fmt;
use aoc::*;
#[derive(Clone, Debug)]
pub struct MonkeyMath(HashMap<&'static str, Monkey>);
#[derive(Copy, Clone, Debug)]
enum Monkey {
Op(Op, &'static str, &'static str),
Value(i64),
}
#[derive(Clone, Debug)]
enum Tree {
Node(Op, Box<Tree>, Box<Tree>),
Lea... | true |
23e9b9a65f9c11f7576665c6de0a51ba35add3b6 | Rust | Canadadry/rTUI | /src/screen.rs | UTF-8 | 1,916 | 3.09375 | 3 | [] | no_license | use font;
use color;
use sub_screen;
pub struct Screen{
width:usize,
height:usize,
buffer:Vec<u32>,
font:font::GlyphMap,
dirty:bool
}
impl Screen
{
pub fn new(width:usize,height:usize,font_size:usize,bg:color::Color) -> Screen
{
let font = font::GlyphMap::load(font_size);
let glyph_size = font.glyph_size(... | true |
787d2752042038542701ce4a7583f5c1e113aee5 | Rust | Shadorain/Shadorogue | /src/map/mod.rs | UTF-8 | 4,429 | 2.75 | 3 | [
"BSD-3-Clause"
] | permissive | use rltk::{ BaseMap, Algorithm2D, Point };
use serde::{Serialize, Deserialize};
use std::collections::HashSet;
mod tiletype;
pub use tiletype::{TileType, tile_walkable, tile_opaque, tile_cost};
mod themes;
pub use themes::*;
pub mod dungeon;
pub use dungeon::*;
#[derive(Default, Serialize, Deserialize, Clone)]
pub st... | true |
05e38fb04aaae028849163918afab10494a7beb7 | Rust | k124k3n/competitive-programming-answer | /hackerrank/30 Days of Code/5. Loops.rs | UTF-8 | 250 | 2.84375 | 3 | [
"MIT"
] | permissive | /*input
2
*/
fn main() {
let mut input: String = format!("");
std::io::stdin().read_line(&mut input).expect("");
let n: u8 = input.trim().parse::<u8>().unwrap();
for i in 1..11 {
println!("{} x {} = {}", n, i, n * i);
}
}
| true |
04afd0b126371e3e3104cc8fa49bbf4b4d4b8699 | Rust | jimy-byerley/tri-mesh | /examples/dust/src/effects/debug.rs | UTF-8 | 1,699 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::*;
use num_derive::FromPrimitive;
#[derive(Copy, Clone, FromPrimitive)]
enum Type {POSITION = 0, NORMAL = 1, COLOR = 2, DEPTH = 3, NONE = 4}
pub struct DebugEffect {
gl: gl::Gl,
program: program::Program,
debug_type: Type
}
impl DebugEffect {
pub fn new(gl: &gl::Gl) -> Result<DebugEffect,... | true |
c6bdb82a5d2943384d290a0196632b520167a302 | Rust | awslabs/flowgger | /src/flowgger/record.rs | UTF-8 | 4,081 | 3.21875 | 3 | [
"BSD-2-Clause"
] | permissive | use std::fmt;
#[derive(Debug, Clone)]
pub enum SDValue {
String(String),
Bool(bool),
F64(f64),
I64(i64),
U64(u64),
Null,
}
#[cfg(feature = "ltsv")]
#[derive(Debug, Clone)]
pub enum SDValueType {
String,
Bool,
F64,
I64,
U64,
}
#[derive(Debug)]
pub struct StructuredData {
... | true |
40d831c4ab655db9c0ffc141c7b46a9eed421245 | Rust | LouisBrunner/advent2018 | /src/day08/puzzle1.rs | UTF-8 | 716 | 3.03125 | 3 | [] | no_license | use day08::common;
fn calculate_license(graph: &common::Graph) -> u32 {
graph.children.iter().fold(0, |acc, node| {
acc + calculate_license(node)
}) + graph.metadata.iter().sum::<u32>()
}
pub fn solve(session: &str) -> Result<String, common::Error> {
let data = try!(common::get_data(session));
... | true |
815625c5b8527ff57c01294638679abc436dd51e | Rust | jeremiah-crosby/rust-http-server | /rust-http-parse/src/lex.rs | UTF-8 | 14,181 | 3.109375 | 3 | [] | no_license | use lazy_static::lazy_static;
use log::trace;
use std::str::FromStr;
use tokio::io::AsyncReadExt;
use super::HttpMethod;
type LexResult = (Token, Option<LexState>);
const TOKEN_REGEX_STR: &str = r"^[!\#\$%\&'\*+-\.\^_`\|~a-zA-Z0-9]+";
const CRLF_REGEX_STR: &str = r"^\r\n";
const MAX_HEADER_SIZE: usize = 1... | true |
dc51aa074c1380ae5043d2efb8375688dfc762ca | Rust | Arnaz87/arna-organ | /src/pipe.rs | UTF-8 | 4,540 | 3.140625 | 3 | [] | no_license |
use std::f32::EPSILON;
use helpers::*;
const harmonics: [f32; 23] = [
0.25, 0.375, 0.5, 0.625, 0.75, // 5
1.0, 1.25, 1.5, 1.75, // 4
2.0, 2.5, 2.75, 3.0, 3.25, 3.5, // 6
4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, // 7
8.0 // 1
];
const WARM: f32 = 60.0;
const COLD: f32 = 300.0;
// Todas en segundos
const MIN_ATTA... | true |
2844e3420e235efdab3bcb703f3c622e6a09a743 | Rust | rasreee/rust-labs | /lab01/eccentrics.rs | UTF-8 | 851 | 3.609375 | 4 | [] | no_license | fn main() {
/* VARIABLES */
let V0: u8 = 0;
let V1 = 0u8;
let V2: bool = false;
let V3: u8 = 0u8;
/* DON'T CHANGE ANYTHING BELOW */
println!("Rust eccentrics:");
println!("================");
/* for loop */
for i in 0..V0 {
println!("Happy ");
}
/* switch state... | true |
edb6dcf1317938aa3e3412c056727f6777f5e67f | Rust | SarthakDandotiya/rust-ing | /007d/src/main.rs | UTF-8 | 471 | 3.8125 | 4 | [] | no_license | // Basic Casting
fn main() {
// Rust provides no implicit type conversion or coersion as its called. Between primitive types
// Instead there is whats called explicit conversion or casting which can be performed with the 'as' keyword
let f = 91.4321_f32;
let i = f as u8;
let c = i as char;
// ... | true |
1ae96084f2cef85d8320522a170eb40b80af477d | Rust | little-dude/netlink | /netlink-packet-route/src/rtnl/tc/nlas/stats.rs | UTF-8 | 1,834 | 2.8125 | 3 | [
"MITNFA",
"MIT"
] | permissive | // SPDX-License-Identifier: MIT
use crate::{
traits::{Emitable, Parseable},
DecodeError,
};
/// Generic queue statistics
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Stats {
/// Number of enqueued bytes
pub bytes: u64,
/// Number of enqueued packets
pub packets: u32,
/// Packets... | true |
11b15151f88dfe390335c0e9fe917bc3119ba414 | Rust | InputUsername/adventofcode | /2020/day13/src/main.rs | UTF-8 | 1,602 | 3.140625 | 3 | [] | no_license | use std::fs;
fn parse_1(s: &str) -> (i32, Vec<i32>) {
let mut lines = s.lines();
let t = lines.next().unwrap().parse().unwrap();
let b = lines.next().unwrap()
.split(',')
.filter_map(|id| id.parse().ok())
.collect();
(t, b)
}
fn part1(input: &str) {
let (t, b) = parse_1(inp... | true |
d4f3f4404411ad8796915f862a82dedf1e18b2e1 | Rust | vinaychandra/bootloader | /src/level4_entries.rs | UTF-8 | 1,357 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use core::convert::TryInto;
use fixedvec::FixedVec;
use x86_64::{
structures::paging::{Page, PageTableIndex},
VirtAddr,
};
use xmas_elf::program::ProgramHeader64;
pub struct UsedLevel4Entries {
entry_state: [bool; 512], // whether an entry is in use by the kernel
}
impl UsedLevel4Entries {
pub fn new(... | true |
9dde2785a998a1ff13809ce9037d6292e0d74033 | Rust | tafia/bitpacking | /src/tests.rs | UTF-8 | 12,511 | 2.8125 | 3 | [
"MIT"
] | permissive | extern crate rand;
extern crate test;
use self::rand::{Rng, SeedableRng, XorShiftRng};
use super::BitPacker;
use super::most_significant_bit;
use self::test::Bencher;
pub fn generate_array(n: usize, max_num_bits: u8) -> Vec<u32> {
let seed: &[u32; 4] = &[1, 2, 3, 4];
let max_val = 1 << max_num_bits;
let m... | true |
5fb96e9e1456e952b3947a8638ee2eb8a8f1c1e1 | Rust | saritag2020/rules_rust | /tools/rustfmt/srcs/test_main.rs | UTF-8 | 2,945 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
use runfiles;
use rustfmt_lib;
fn main() {
// Gather all and environment settings
let options = parse_args();
// Perform rustfmt for each manifest available
run_rustfmt(&options);
}
/// Run rustfmt on a set of Bazel targets
fn r... | true |
0d1a95bb75710e9497c48942da88a173cf261427 | Rust | allyn-bottorff/basic-computer-games | /81_Splat/rust/src/utility.rs | UTF-8 | 4,558 | 2.6875 | 3 | [
"Unlicense"
] | permissive | use crate::celestial_body;
use rand::Rng;
use std::io;
const DEATH_MESSAGES: [&str; 10] = [
"REQUIESCAT IN PACE.",
"MAY THE ANGEL OF HEAVEN LEAD YOU INTO PARADISE.",
"REST IN PEACE.",
"SON-OF-A-GUN.",
"#$%&&%!$",
"A KICK IN THE PANTS IS A BOOST IF YOU'RE HEADED RIGHT.",
"HMMM. SHOULD HAVE P... | true |
9647ff05ce3d78ba71a3e875ba839d3b550e30d4 | Rust | fdumontmd/adventofcode | /2016/day-25/src/main.rs | UTF-8 | 7,449 | 3.46875 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::{self, Read};
use std::str::FromStr;
#[derive(Copy, Clone, Debug)]
enum Register {
A,
B,
C,
D,
}
#[derive(Copy, Clone, Debug)]
enum Value {
Immediate(i64),
Register(Register)
}
#[derive(Copy, Clone, Debug)]
enum Instruction {
Copy(Value, Registe... | true |
76e0493d470cf86ac08eca4f8cadef0776accaa8 | Rust | marosluuce/rchip8 | /tests/ram_test.rs | UTF-8 | 325 | 2.953125 | 3 | [] | no_license | extern crate rchip8;
#[cfg(test)]
mod tests {
use rchip8::ram::Ram;
#[test]
fn creates_ram() {
assert_eq!(Ram::new(), Ram::new())
}
#[test]
fn sets_an_address() {
let mut ram = Ram::new();
ram.set(0x999, 0b11001110);
assert_eq!(0b11001110, ram.read(0x999))
... | true |
4e05f5fceb610e34995a47e8c2d8d334dd56ce09 | Rust | kerlilow/mrf | /src/formatter.rs | UTF-8 | 2,606 | 4.09375 | 4 | [
"MIT"
] | permissive | use std::fmt::Debug;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Formatter {
fill: char,
width: usize,
}
pub enum InputType {
/// String.
String,
/// Number. Leading zeros are trimmed on format.
Number,
}
impl Formatter {
/// Create a `Formatter`.
///
/// # Returns
///
... | true |
8d8002d51742c85800e059255560241bcfc0ec51 | Rust | dmiyakawa/rust-gcd-exp | /src/main.rs | UTF-8 | 387 | 3.3125 | 3 | [
"MIT"
] | permissive | fn gcd(mut n: u64, mut m: u64) -> u64 {
assert!(n != 0 && m != 0);
while m != 0 {
if m < n {
let t = m;
m = n;
n = t;
}
m = m % n;
}
n
}
#[test]
fn test_gcd () {
assert_eq!(gcd(14, 15), 1);
assert_eq!(gcd(3355, 2379), 61);
}
fn main()... | true |
0dd065d9a612f3865503c53e7d725fa9939e975a | Rust | mengsuenyan/rmath | /src/bigint/bigint_macro.rs | UTF-8 | 3,198 | 2.875 | 3 | [
"Apache-2.0"
] | permissive |
macro_rules! bigint_from_vec {
($Type0: ty) => {
impl From<$Type0> for BigInt {
fn from(x: $Type0) -> Self {
Self {
nat: Nat::from(x),
sign: Natural,
}
}
}
};
($Type0: ty, $($Type1: ty),+) => {
... | true |
de0a42dff4ad9a86952abd264f1e1593fc24f78b | Rust | yinshuwei/trying | /rust/hello_cargo/src/demo/hashmap_demo.rs | UTF-8 | 750 | 3.546875 | 4 | [] | no_license | use std::collections::HashMap;
pub fn run() {
let mut map = HashMap::new();
map.insert("A", "1");
map.insert("B", "2");
if let Some(v) = map.get(&"B") {
println!("insert get B: {}", v);
}
let keys = vec!["A", "B"];
let values = vec!["1", "2"];
let map: HashMap<_, _> = keys.iter... | true |
89e0d62277ed8c53b2860523d2e8b8ccf45c862e | Rust | raghu999/nb2 | /core/src/metrics.rs | UTF-8 | 4,219 | 2.78125 | 3 | [] | no_license | //! Exposes the following framework metrics.
//!
//! # Port Metrics
//!
//! * `port.packets`, total number of successfully received or transmitted
//! packets.
//! * `port.octets`, total number of successfully received or transmitted
//! bytes.
//! * `port.dropped`, total number of packets dropped because the receive
/... | true |
7c2f1578018c7a050329b80cb565a43e2a4f97ea | Rust | hrkzmnm/rust_z3prover | /z3prover/tests/symbol.rs | UTF-8 | 628 | 2.84375 | 3 | [
"MIT"
] | permissive | use z3prover;
mod common;
#[test]
fn test_string_symbol() {
let mut ctx = common::make_default_context();
let src = "SYM";
let sym = z3prover::Symbol::from_cstring(&mut ctx, &std::ffi::CString::new(src).unwrap());
let ret = sym.to_string().unwrap();
println!("{:?}.to_string() -> {}", &sym, &ret);
... | true |
2dd8306c7b73feed9c4140ae67d6d5369e048c20 | Rust | HerringtonDarkholme/leetcode | /src/main.rs | UTF-8 | 5,277 | 3.140625 | 3 | [] | no_license | #[macro_use]
mod util;
#[path = "./recursive_remove_adjacent_duplicates.rs"]
pub mod remove_adj;
fn main() {}
#[test]
fn test() {
// assert_eq!(Solution::people_aware_of_secret(6, 2, 4), 5);
// assert_eq!(Solution::people_aware_of_secret(4, 1, 3), 6);
}
struct Solution;
impl Solution {
pub fn repeated_... | true |
c16c6e41bd0153daae9d31e776dcc9ae3dba6458 | Rust | Laerciominozzo/RustProjectPatern | /State/src/purchase_order/states.rs | UTF-8 | 5,165 | 2.765625 | 3 | [] | no_license | /*
* Author: lminozzo
*
*/
use super::order::{InnerOrder,OrderOperations};
pub struct FirstApprover;
pub struct SecondApprover;
pub struct Purchasing;
pub struct Closed;
pub struct Concluded;
impl OrderOperations for FirstApprover {
fn get_name(&self) -> &'static str {
"Em aprovação do 1º analista"
... | true |
1b727a1befd9e33c62898c1a37f2d58dfda6de08 | Rust | rkrishn7/kinesis-client-rust | /src/main.rs | UTF-8 | 1,307 | 2.546875 | 3 | [] | no_license | use rusoto_kinesis::*;
use rusoto_core::Region;
use rusoto_core::RusotoError;
use futures::stream::StreamExt;
use tokio::time::{timeout};
#[tokio::main]
async fn main() -> Result<(), RusotoError<SubscribeToShardError>> {
let client = KinesisClient::new(Region::UsWest2);
let mut events: Vec<rusoto_kinesis:... | true |
438cfacea8864501a153a7672d10091bcfba26c2 | Rust | MindFlavor/azure-sdk-for-rust | /sdk/storage/examples/blob_range.rs | UTF-8 | 2,912 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LGPL-2.1-or-later"
] | permissive | use azure_core::prelude::*;
use azure_storage::blob::prelude::*;
use azure_storage::core::prelude::*;
use futures::stream::StreamExt;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
// First we retrieve the account name and master key from environment variables.
... | true |
9503dea87036f6fe322ffc0db56cc6df17636904 | Rust | AlacrisIO/mkb | /src/common_net.rs | UTF-8 | 589 | 2.96875 | 3 | [] | no_license | use std::net::{IpAddr, Ipv4Addr};
/*
pub fn get_ip_plus_port(ip_addr: &Vec<u8>, port: u16) -> String {
let str0 : String = ip_addr[0].to_string();
let str1 : String = ip_addr[1].to_string();
let str2 : String = ip_addr[2].to_string();
let str3 : String = ip_addr[3].to_string();
let str4 : String = p... | true |
da3487c359ef06d4e3a3b300f5a429d1159877a8 | Rust | MichaelRawson/lerna | /src/symbol.rs | UTF-8 | 489 | 2.84375 | 3 | [] | no_license | use std::fmt;
use unique::allocators::HashAllocator;
use unique::make_allocator;
#[derive(PartialEq, Eq, Hash)]
pub enum Symbol {
Original(String),
Introduced(usize),
}
make_allocator!(Symbol, SYMBOL_ALLOC, HashAllocator);
impl fmt::Debug for Symbol {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {... | true |
c3ccb4b350831bff92af683eeed1466152697663 | Rust | doytsujin/yew | /examples/communication_grandparent_to_grandchild/src/child.rs | UTF-8 | 1,512 | 3.21875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::*;
/// The `Child` component is the child of the `Parent` component, and will receive updates from the
/// grandparent using the context.
pub struct Child {
state: Rc<AppState>,
_listener: ContextHandle<Rc<AppState>>,
}
pub enum ChildMsg {
ContextChanged(Rc<AppState>),
}
impl Component for Chi... | true |
a28816d101ede3002e9d9d33176b0faba5e226d7 | Rust | coder543/metric | /src/constants.rs | UTF-8 | 485 | 2.8125 | 3 | [
"MIT"
] | permissive | //! Defines various constants with meaningful units
use mass::metric::{Kilogram, Kilograms};
use length::astronomical::{AU, AUs};
use length::metric::{Kilometer, Kilometers};
#[derive(Debug)]
pub struct PlanetInfo {
pub name: &'static str,
pub mass: Kilograms,
pub dist_from_sun: AUs,
pub radius: Kilom... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.