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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3077fe349c943fc3a64fc707bd5d7405e110a2e5 | Rust | gfxpg/gpu-studies | /vulkan/1-triangle/build.rs | UTF-8 | 1,360 | 2.53125 | 3 | [] | no_license | use std::{env, fs};
use std::path::{Path, PathBuf};
use shaderc;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let mut shaders_dir = env::current_dir().unwrap();
shaders_dir.push("shaders");
let shader_paths: Vec<PathBuf> = fs::read_dir(shaders_dir).unwrap()
.map(|entry| entry.unwra... | true |
8c39a41950cd8c1029a78d52eede5a3be9582376 | Rust | cah6/rust-euler | /src/p9.rs | UTF-8 | 534 | 3.46875 | 3 | [] | no_license |
pub fn solve(n : i32) -> i32 {
let max_len = n / 2;
for a in 1..max_len {
for b in 1..max_len {
let c = n - a - b;
if (a + b + c == n) && (a.pow(2) + b.pow(2) == c.pow(2)) {
println!("Triple was: a={}, b={}, c={}", a, b, c);
return a * b * c;
... | true |
2931df5e2adb7aacb98658eab67f1483ddfb60a4 | Rust | nonk123/bloodbath | /src/builtins.rs | UTF-8 | 2,433 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::object::Object;
pub fn add(args: Vec<Object>) -> Object {
if let Some(a) = args[0].get_integer() {
if let Some(b) = args[1].get_integer() {
return Object::Integer(a + b);
} else if let Some(b) = args[1].get_float() {
return Object::Float(a as f64 + b);
}
... | true |
9cc38b0bc8c032bb91c8df665451c19c62ec448f | Rust | fourohfour/enquel | /src/parse.rs | UTF-8 | 2,425 | 3.0625 | 3 | [] | no_license | use token;
pub use token::Number;
#[derive(Debug)]
pub enum ArgClass {
Modify,
Map ,
Pivot ,
}
#[derive(Debug)]
pub enum LogicalBlock {
Any ,
All ,
Either ,
Neither,
}
#[derive(Debug)]
pub enum EvaluatorType {
DoDrop,
Warn ,
Panic ,
}
#[derive(Debug)]
pub enum Compa... | true |
738bd0be61875161d49ac6cb1cc835638b159a73 | Rust | SolarLiner/minigc.rs | /src/interpreter.rs | UTF-8 | 10,566 | 3.03125 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::Write;
use std::ops::{Add, Mul, Sub};
use generational_arena::{Arena, Index};
use tracing::{error, instrument, trace};
use crate::traits::{DisplayArena, Tree};
use crate::vm::{Object, VM};
use std::fmt;
use thiserror::Error;
#[derive(Clone, Debug)]
pub enum Value {
Int... | true |
7f66a7c5f397b9aeb082aad1d0e6273aaf9cb571 | Rust | SpectralSequences/sseq | /ext/crates/algebra/src/dense_bigraded_algebra/mod.rs | UTF-8 | 17,125 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive |
#![allow(dead_code)]
#![allow(unused_variables)]
use bivec::BiVec;
use once::OnceBiVec;
use fp::prime::ValidPrime;
use fp::matrix::{Matrix, Basis, Subspace};
use fp::vector::{FpVector};
use std::sync::{RwLock, RwLockWriteGuard, Mutex};
use std::collections::{BTreeMap, HashMap};
pub type Indecomposabl... | true |
075a428f5a7b4de2179714fbc5c92464601879dd | Rust | AliAryanTech/rust-tg-bot | /src/types/user.rs | UTF-8 | 1,207 | 3.015625 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct User {
/// Unique identifier for this user or bot. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significa... | true |
c10ac49fda4298a8d2fa536fb68de9da45d6b713 | Rust | SINHASantos/exonum-btc-anchoring | /src/proto/binary_map.rs | UTF-8 | 3,097 | 2.625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2019 The Exonum Team
//
// 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 to i... | true |
f4c56e39a49a924ee8c79831e5eb12e4c4c9e154 | Rust | arprv/homectl | /homectl_macros/src/lib.rs | UTF-8 | 6,259 | 2.640625 | 3 | [] | no_license | #![recursion_limit="128"]
extern crate proc_macro;
use crate::proc_macro::TokenStream;
use quote::quote;
use syn::{DeriveInput, Data, Meta, Fields, Type, Lit, MetaNameValue,NestedMeta};
extern crate proc_macro2;
use proc_macro2::{Ident, Span};
use std::collections::HashMap;
/// Extracts attribute property values fro... | true |
18eec5b6891fd1e4361abd398cd83594d3f27784 | Rust | laxect/kosmos | /kosmos/src/planet.rs | UTF-8 | 1,741 | 3.078125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use std::{cmp::PartialEq, matches, time};
fn get_random_str() -> anyhow::Result<String> {
let timestamp = time::SystemTime::now()
.duration_since(time::SystemTime::UNIX_EPOCH)?
.as_secs();
let randint: u32 = rand::random();
let fmt = format!("{}-{}", tim... | true |
722d7f06f4d611e3a5ce66bc12070fc9b668a21b | Rust | adrien-ben/gltf-viewer-rs | /crates/viewer/src/loader.rs | UTF-8 | 4,876 | 3.15625 | 3 | [] | no_license | //! Non-blocking model loader
//!
//! The loader starts a worker thread that will wait for load messages.
//! Once a message is received the thread will load the model and send the
//! loaded model through another channel.
//!
//! When dropping the loader, a stop message is sent to the thread so it can
//! stop listeni... | true |
3fedd96673775efa97a60e795858e7f8a42c4b54 | Rust | bcmyers/sway-utils | /sway-run-or/src/main.rs | UTF-8 | 2,183 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[macro_use]
extern crate clap;
use std::process::{Command, Stdio};
use failure::Error;
use structopt::StructOpt;
use sway_tree::get_tree;
arg_enum! {
#[derive(Debug)]
enum Instruction {
Focus,
Kill,
}
}
#[derive(Debug, StructOpt)]
struct Opt {
/// Command that launches the applicati... | true |
373dd81a8d1d04a63392231af63893541103e09f | Rust | pkmn-api/pkmnapi | /pkmnapi-sql/src/sql/user_rom_data.rs | UTF-8 | 1,873 | 2.875 | 3 | [
"MIT"
] | permissive | use diesel::prelude::*;
use crate::error::Result;
use crate::models::*;
use crate::utils;
use crate::{PgPooledConnection, PkmnapiSQL};
impl PkmnapiSQL {
/// Select row in `rom_data`
///
/// # Panics
///
/// Panics if the `SECRET_KEY` environment variable is not set
///
/// # Example
//... | true |
97937416c350f5ddba8a6f1eefddec93b602cb3a | Rust | ityy/rust_async_chat | /src/t02_receiving_messages.rs | UTF-8 | 4,717 | 3.53125 | 4 | [] | no_license | use async_std::{
net::{TcpListener, ToSocketAddrs}, // 3
prelude::*, // 1
task, // 2
};
use async_std::{
io::BufReader,
net::TcpStream,
};
use futures::{AsyncReadExt, Future, FutureExt, StreamExt};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
/// 让我们实现协议的接收部分。... | true |
ea78092448763718e1ef3ecc373b2bca2171cb17 | Rust | rcore-os/zCore | /linux-syscall/src/vm.rs | UTF-8 | 8,691 | 2.890625 | 3 | [
"MIT"
] | permissive | use super::*;
use bitflags::bitflags;
use zircon_object::vm::{pages, MMUFlags, VmObject};
/// Syscalls for virtual memory.
///
/// # Menu
///
/// - [`mmap`](Self::sys_mmap)
/// - [`mprotect`](Self::sys_mprotect)
/// - [`munmap`](Self::sys_munmap)
impl Syscall<'_> {
/// Map files or devices into memory
/// (see... | true |
cd126072414572cdfb3825962328a8c3422d80e4 | Rust | infinyon/fluvio | /crates/fluvio-cluster/src/cli/error.rs | UTF-8 | 2,297 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use std::io::Error as IoError;
use fluvio::FluvioError;
use fluvio_extension_common::output::OutputError;
use fluvio_extension_common::target::TargetError;
use crate::check::ClusterCheckError;
use crate::{LocalInstallError};
use crate::ClusterError;
/// Cluster Command Error
#[derive(thiserror::Error, Debug)]
pub enu... | true |
20fe63f871ed6eac6e6783feadc8adf75e25745e | Rust | oxalica/nil | /crates/ide/src/ty/infer.rs | UTF-8 | 21,716 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::union_find::UnionFind;
use super::{known, AttrSource, TyDatabase};
use crate::def::{
BindingValue, Bindings, Expr, ExprId, Literal, NameId, NameResolution, ResolveResult,
};
use crate::{FileId, Module};
use la_arena::ArenaMap;
use smol_str::SmolStr;
use std::collections::btree_map::{BTreeMap, Entry};
use... | true |
77ee32249db41f6ce15a8893870e0a6b2bd179ef | Rust | dbcc/twitchchat | /src/twitch/capability.rs | UTF-8 | 1,543 | 3.390625 | 3 | [
"0BSD"
] | permissive | /// Capabilities allow you to get more data from twitch
///
/// The default, `generic` is very simplistic (basically just read/write PRIVMSGs for a channel)
///
/// While enabling `membership` + `commands` + `tags` will allow you to get a much more rich set of messages
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd... | true |
7642189940c9dec8b0886fcf818ee94d59fd8aa1 | Rust | Luthaf/log-once | /tests/logger/mod.rs | UTF-8 | 971 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use log::{LevelFilter, Metadata, Record};
use std::fmt::Write;
use std::sync::{Mutex, Once};
lazy_static::lazy_static! {
static ref LOGGED_DATA: Mutex<String> = Mutex::new(String::new());
}
/// A simple in memory logger, using
pub struct MemoryLogger;
impl ::log::Log for MemoryLogger {
fn enabled(&self, _: ... | true |
4b9589e4e34395e58fec7d773bba9a4d6f5e12b1 | Rust | Mureke/Advent-of-code | /2021/rAoC/src/lib/day2.rs | UTF-8 | 1,555 | 3.265625 | 3 | [] | no_license | use crate::lib::file_reader::read_file;
use crate::lib::file_reader::parse_input;
struct SubMarine {
depth: i32,
horizontal: i32,
aim: i32
}
impl SubMarine {
fn new() -> Self {
SubMarine {
horizontal: 0,
depth: 0,
aim: 0
}
}
pub fn go_forwa... | true |
02cc0e35d4f56bbb63b8cf95099722bdf73bef40 | Rust | crumblingstatue/TD-Project | /src/main.rs | UTF-8 | 2,953 | 2.84375 | 3 | [] | no_license | use macroquad::prelude::*;
#[derive(Default)]
struct Path {
nodes: Vec<Vec2>,
}
impl Path {
fn debug_draw(&self) {
for w in self.nodes.windows(2) {
let (n1, n2) = (w[0], w[1]);
draw_line(n1.x, n1.y, n2.x, n2.y, 2.0, RED);
}
}
fn project_next_at_mouse(&self) {
... | true |
eb6e66c8e0677586f25629439a02774662229c91 | Rust | okeri/rstatus | /src/base.rs | UTF-8 | 9,113 | 2.90625 | 3 | [
"MIT"
] | permissive | use super::block_builder::{BlockBuilder, RenderFlags, SubBlock};
use super::utility::read_color;
use serde::{Deserialize, Deserializer};
use std::collections::BTreeMap;
#[derive(Deserialize, Default)]
pub enum Value {
#[default]
Invalid,
Int(u32),
Str(String),
}
pub trait ValueConstructor {
fn bui... | true |
329c3f50de8cea8351b8d4e7184f3e2b7c391096 | Rust | pawroman/torchbear | /src/bindings/text/scl.rs | UTF-8 | 8,017 | 3.0625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use rlua::{ToLua, FromLua, prelude::{LuaError, LuaResult}};
fn to_rlua_value(lua: rlua::Context, val: scl::Value) -> rlua::Value {
match val {
scl::Value::Boolean(b) => b.to_lua(lua).unwrap(),
scl::Value::Integer(i) => i.to_lua(lua).unwrap(),
scl::Value::Float(f) => f.to_lua(lua).unwrap(),
... | true |
4bd6593b028ddfe491e6024053f49be05af48646 | Rust | wu-lang/wu | /src/wu/compiler/compiler.rs | UTF-8 | 35,521 | 2.984375 | 3 | [
"MIT"
] | permissive | use super::*;
use std::collections::HashMap;
use std::path::Path;
use std::ffi::OsStr;
#[derive(Clone, PartialEq)]
pub enum FlagImplicit {
Return,
Global,
Assign(String),
}
#[derive(Clone, PartialEq)]
pub enum Inside {
Loop,
//Nothing,
Then,
}
pub struct Generator<'g> {
source: &'g Sourc... | true |
1a35b0b732a03673a140810205c7ec17ff518fe7 | Rust | ReiMatsuzaki/web-rust | /src/request/error.rs | UTF-8 | 710 | 3.125 | 3 | [] | no_license | use std::io;
use std::num::ParseIntError;
use std::fmt;
#[derive(Debug)]
pub enum Error {
Io(io::Error),
ParseInt(ParseIntError),
ParseLine {line: String, description: String},
InvalidVersion {version: String}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | true |
71ce221b4541ab824310a4d4b40efdc6b5448591 | Rust | MikkelPaulson/advent-of-code-2019 | /src/day17/mod.rs | UTF-8 | 1,971 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::intcode::Intcode;
pub fn part1(input: &str) -> Result<u64, String> {
let mut intcode: Intcode = input.parse()?;
intcode.run();
let map = intcode.output_string();
println!("{}", map);
println!("{:?}", get_intersections(&map));
Ok(get_intersections(&map)
.iter()
.map... | true |
60d3ee95e4973cf279e8bc7c0dc5f8267ce8435b | Rust | lelandjansen/rust-playground | /book/oop/averaged_collection/src/lib.rs | UTF-8 | 1,867 | 3.90625 | 4 | [] | no_license | pub struct AveragedCollection {
list: Vec<i32>,
average: Option<f64>,
}
impl AveragedCollection {
pub fn new() -> AveragedCollection {
AveragedCollection { list: vec![], average: None }
}
pub fn add(&mut self, value: i32) {
self.list.push(value);
self.update_average();
... | true |
e1a35b4b96660ddfa540cabd941d4513cb7b9f27 | Rust | jpalip/RustGlass | /src/lang/lexer/char_state.rs | UTF-8 | 1,350 | 3.53125 | 4 | [] | no_license | #[derive(PartialEq)]
pub enum CharState {
Whitespace,
Newline,
Number,
Operator,
Quotation,
SingleConsumable,
Letter,
Period,
Underscore,
Escape,
Comment,
Eof,
}
impl CharState {
pub fn matches(&self, other: &[CharState]) -> bool {
return other.contains(self)... | true |
beb071d7f448fec29f9ff78a5a029cb782adfb65 | Rust | xgillard/ddo | /ddo/examples/misp/main.rs | UTF-8 | 15,734 | 2.9375 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Xavier Gillard
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, di... | true |
02a250f5ca66dbefbd68ae227ce11eb8ed947a9b | Rust | Medsko/study-crate | /src/collections/vectors.rs | UTF-8 | 2,584 | 3.640625 | 4 | [] | no_license | #![allow(dead_code)]
use std::collections::HashMap;
use rand::Rng;
/// Finds the 'middle' number of the given list of numbers; the number that is in the middle
/// position when the list is sorted.
pub fn find_median(vec: &Vec<i32>) -> i32 {
let mut vec = vec.to_vec();
vec.sort();
vec[vec.len() / 2]
}
/... | true |
42497e31ce344224681750e3f36640b88c3eb937 | Rust | djg/kioto-rs | /src/lib.rs | UTF-8 | 26,397 | 3.109375 | 3 | [] | no_license | extern crate bincode;
extern crate bytes;
#[macro_use]
extern crate futures;
#[macro_use]
extern crate log;
extern crate serde;
extern crate tokio_core;
#[macro_use]
extern crate tokio_io;
pub mod codec {
use bincode::{self, Bounded, deserialize, serialize_into, serialized_size};
use bytes::{BufMut, BytesMut, ... | true |
f13680d5c60be0bacd63b92cd99c9eb1c7b8129e | Rust | SiegeEngine/siege-math | /src/vector/direction.rs | UTF-8 | 4,443 | 2.96875 | 3 | [
"MIT"
] | permissive |
use std::ops::{Deref, Neg};
use serde::{Serialize, Deserialize};
use float_cmp::ApproxEq;
use super::{Vec2, Vec3, Vec4};
use crate::{Angle, FullFloat};
/// Direction vector in 2-dimensions (normalized)
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Serialize, Deserialize)]
pub struct Direction... | true |
a1d2d478371a48f2a1ff301d0e455c8a3ea629d4 | Rust | edev/groupby | /src/command_line/write_results.rs | UTF-8 | 21,140 | 3.453125 | 3 | [
"MIT"
] | permissive | //! Outputs the final results from processing a set of inputs according to [GroupByOptions].
//!
//! # Examples
//!
//! ```
//! use groupby::command_line;
//! use groupby::command_line::options::*;
//! use groupby::command_line::write_results::write_results;
//! use groupby::command_line::run_command::run_command;
//! ... | true |
687435e6662d93e689289c25bde8f97273f3f28b | Rust | Shirataki2/competitive_submissions | /future-contest-2018-qual/src/bin/a.rs | UTF-8 | 8,206 | 2.796875 | 3 | [] | no_license | #![allow(unused_imports)]
use proconio::{input, fastout};
use std::cmp::*;
use std::time::Instant;
use rand::prelude::*;
const N: usize = 100;
const POINT_N: usize = 1_000;
const TIME_LIMIT: u128 = 5_970_000_000;
struct Solver {
a: Vec<Vec<i64>>,
rng: ThreadRng
}
fn clamp(x: i64, a: i64, b: i64) -> i64 {
... | true |
fcc18826d131c5875db504f8b337d7075042bc82 | Rust | maxcell/discord-slash-commands | /crates/discord_interactions/src/netlify.rs | UTF-8 | 2,870 | 2.59375 | 3 | [] | no_license | use crate::discord::{
reply_with, validate_discord_signature, DiscordEvent,
EventType, InteractionResponse,
InteractionResponseType,
};
use aws_lambda_events::encodings::Body;
use ed25519_dalek::PublicKey;
use http::{header::CONTENT_TYPE, StatusCode};
use lamedh_http::{IntoResponse, Request, Response};
use ... | true |
f744dfdc5ccdbf79beb4525e742bea5206634df6 | Rust | adamsky/planet-sim | /src/sim/calendar.rs | UTF-8 | 12,925 | 2.828125 | 3 | [] | no_license | use crate::{FloatNum, Int};
use std::ops::Rem;
#[derive(Clone)]
pub struct Calendar {
pub mondays: [Int; 13],
pub mona365: [Int; 13],
pub monaccu: [Int; 13],
pub ny400d: Int,
pub ny100d: Int,
pub ny004d: Int,
pub ny001d: Int,
pub nud: Int,
// TODO ?
// These values are copied ... | true |
5ef99ed66aee217c941bc797e5f371f12452ab7c | Rust | ChinX/myrust | /adder_part/tests/test_greet.rs | UTF-8 | 485 | 3.359375 | 3 | [] | no_license | // 在tests目录就可以建立任意的test文件,进行集成测试
extern crate adder_part;
#[test]
fn test_greet() {
assert_eq!(1 + 1, 2);
let result = adder_part::greet("abc");
// assert!宏可以指定测试的条件表达式是否为true,如果不为true,第二个参数可以指定打印的信息,第三个参数是格式化字符串
assert!(
result.contains("abc"),
"Greeting did not contain name, value was ... | true |
970a7de66584d22c253cf4b6cdea03111a2b3567 | Rust | jamuraa/advent2018 | /day20/src/main.rs | UTF-8 | 9,244 | 3.234375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::{
collections::{BinaryHeap, HashMap, HashSet},
fmt,
fs::File,
io::{self, prelude::*, BufReader},
};
struct Map {
doors: HashSet<(usize, usize)>,
rooms: HashSet<(usize, usize)>,
}
/// Build sets of the doors and rooms attached to an open space at x, y given the (partial) regex.
fn buil... | true |
07e1542b3e0d2a92d70032f1d76963dd92baf715 | Rust | mildlyfunctionalgays/mucc | /src/lex/tests.rs | UTF-8 | 9,443 | 3.046875 | 3 | [] | no_license | use super::types::{LexItem, NumberType};
use super::Lexer;
use crate::lex::errors::LexErrorType;
#[cfg(test)]
fn test_lexer_str(s: &str, tokens: &[LexItem]) {
let lexer = Lexer::new(s.chars());
let vec = lexer.map(|res| res.unwrap().item).collect::<Vec<_>>();
println!("got symbols {:?}", vec);
asser... | true |
51d9fed15d6877581fe051b8acc2eb8eccd7f1cb | Rust | RutgerMoons/advent_of_code_2020 | /day3/src/main.rs | UTF-8 | 1,632 | 3.40625 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, prelude::*, BufReader};
fn solve_part_2(landscape: &Vec<String>) -> u64 {
let mut total = 1;
let x = solve(landscape, 1, 1);
println!("a {} {}", x, total);
total *= x;
let x = solve(landscape, 1, 3);
println!("b {} {}", x, total);
total *= x;
let... | true |
fa07d4105103783cb433d796c946d7a3ff9808aa | Rust | danambrogio/RustDailies | /Easy/challenge_11/src/main.rs | UTF-8 | 2,532 | 3.796875 | 4 | [] | no_license | /*
Calculates the day of the week, given a d/m/y input
I believe there's an issue with certain dates -- 1/2/2001 fails, for instance
*/
use std::io;
enum DaysOfWeek {
Sunday = 0,
Monday = 1,
Tuesday = 2,
Wednesday = 3,
Thursday = 4,
Friday = 5,
Saturday = 6,
}
fn get_user_input()... | true |
b2c0bca97753c38ea2ca25c02b5cdf5e5bcbd4ee | Rust | origel/origel | /programs/ion/src/shell_expand/variables.rs | UTF-8 | 8,551 | 3.78125 | 4 | [
"MIT"
] | permissive | /// Given an `input` string, this function will expand the variables that are discovered, using the closure provided
/// as the `action`. In the case of this program specifically, that action will be `self.get_var(&variable)`.
pub fn expand<V, C>(output: &mut String, input: &str, expand_variable: V, expand_command: C)
... | true |
e4955b3aa47967b1678d91955d64f99491de0a8e | Rust | JackAllTrades-MoN/x86emu | /src/emulator/pc9801vm/cpu.rs | UTF-8 | 2,292 | 3.0625 | 3 | [] | no_license | mod register;
//use crate::binary;
use register::Register;
pub struct Cpu {
pub register: Register,
}
impl Cpu {
pub fn init() -> Cpu {
Cpu { register: Register::init() }
}
pub fn to_string(&self) -> String {
format!("{}\n{} = 0x{:X}", self.register.to_string(), "EIP", self.register.... | true |
f12e6e6ac1fb2d6e80432bf96b75cfc65cf26139 | Rust | LPeter1997/Cacti | /cacti_archive/examples/test.rs | UTF-8 | 688 | 2.734375 | 3 | [
"Zlib"
] | permissive |
use std::fs;
use std::io::Read;
use cacti_archive::*;
fn main() {
let f = fs::File::open("C:/TMP/testzippy.ZIP").expect("Could not open file!");
let mut archive = zip::ZipArchive::parse(f).expect("Could not parse zip!");
let mut file = archive.entry_at_index(3).expect("Could not get entry!");
let crc ... | true |
39fba524ca695811bef65461e8dfe5b1fe1aec35 | Rust | PoorlyDefinedBehaviour/blockchain | /src/controller.rs | UTF-8 | 2,680 | 2.546875 | 3 | [] | no_license | use crate::block::{Sender, Transaction};
use crate::chain::Chain;
use crate::consensus;
use crate::proof_of_work;
use crate::viewmodel;
use std::sync::RwLock;
use actix_web::{get, post, web, HttpResponse, Responder};
#[post("/mine")]
async fn mine(chain: web::Data<RwLock<Chain>>, node: web::Data<String>) -> impl Resp... | true |
b5220f55ac0bec7a87b2a75c42cb5e464b83c916 | Rust | SergejJurecko/easyfibers | /src/builder.rs | UTF-8 | 4,009 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::cmp;
use std::time::Duration;
// Shamelessly taken from tokio-timer
// Copyright Tokio contributors
/// Configures and builds a `Timer`
///
/// A `Builder` is obtained by calling `wheel()`.
#[derive(Debug)]
pub struct Builder {
tick_duration: Option<Duration>,
num_slots: Option<usize>,
initial_ca... | true |
118b972849a01d118976b1dd92fc7075f137f713 | Rust | daboross/rust-screeps-api | /src/data/rooms.rs | UTF-8 | 7,401 | 3.328125 | 3 | [
"MIT"
] | permissive | //! Room result structures.
use serde::{Deserialize, Serialize};
use crate::{decoders::timespec_seconds, error};
/// A room state, returned by room status.
///
/// Note that the API itself will return timestamps for "novice end" and "open time" even when the room is no longer
/// novice, so the current system's knowl... | true |
a7adfa925a27fbd15122d2892d1e9702b31cc74e | Rust | jairoandre/my-nannou | /sketches/perlin/perlin_2.rs | UTF-8 | 2,619 | 2.953125 | 3 | [] | no_license | use nannou::prelude::*;
use noise::{NoiseFn, Perlin, Fbm, Seedable};
use nannou::app::{Draw};
use rand::Rng;
struct Model {
_particles: Vec<Particle>,
}
fn main() {
nannou::app(model)
.update(update)
.run();
}
fn model(_app: &App) -> Model {
let _window = _app
.new_window()
... | true |
4da2efe8c00d5914e8e28bb62e114fabf940d707 | Rust | AJTJ/rust_fib_loop | /src/main.rs | UTF-8 | 274 | 3.09375 | 3 | [] | no_license | fn fib(steps: u32) -> Vec<i32> {
let mut cur_steps = steps - 2;
let mut v: Vec<i32> = vec![0, 1];
while cur_steps > 0 {
v.push(v[v.len() - 1] + v[v.len() - 2]);
cur_steps = cur_steps - 1
}
v
}
fn main() {
println!("{:?}", fib(20))
}
| true |
4ca487d8caff2e39b283d63e303f2d90507dd521 | Rust | chromium/chromium | /third_party/rust/rstest_macros/v0_17/crate/src/render/inject.rs | UTF-8 | 6,445 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] | permissive | use std::borrow::Cow;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{parse_quote, Expr, FnArg, Ident, Stmt, Type};
use crate::{
refident::{MaybeIdent, MaybeType},
resolver::Resolver,
utils::{fn_arg_mutability, IsLiteralExpression},
};
pub(crate) fn resolve_aruments<'a>(
args: impl Iterator... | true |
cab73f9dc3cce23e32b7ae3a140b50616cba0c72 | Rust | Myrannas/rusted-nio | /src/signals.rs | UTF-8 | 1,252 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use libc::consts::os::posix88::{SIGTERM,SIGQUIT,SIGINT};
use libc;
use errors;
extern {
fn signal(signal: libc::c_int, callback: extern fn(i32)) -> libc::c_int;
}
#[deriving(Eq, PartialEq)]
pub enum SignalType {
SignalTerminate,
SignalQuit,
SignalInterrupt,
None
}
static mut current_signal : SignalType = None;
... | true |
6964fb7f1440e12c57e26662fe7b338f4f06c99d | Rust | micouy/plotka | /src/parse/csv.rs | UTF-8 | 5,059 | 3.5 | 4 | [] | no_license | //! CSV parsing.
use ::csv::{
ReaderBuilder as CsvReaderBuilder,
StringRecord as CsvStringRecord,
};
use std::io;
use super::{record::Record, ParseError, Parser, ReadError};
/// CSV parser.
#[derive(Debug)]
pub struct CsvParser {
headers: csv::StringRecord,
}
impl CsvParser {
/// Create a CSV parse... | true |
409339dd4a528e89bacdd68ddcf8889636ded62e | Rust | FIL1994/rust-examples | /2/macros.rs | UTF-8 | 462 | 2.96875 | 3 | [] | no_license | macro_rules! foo {
(x => $e:expr) => (println!("mode X: {}", $e));
(y => $e:expr) => (println!("mode Y: {}", $e));
}
fn main() {
let _x_without_macro: Vec<u32> = {
let mut temp_vec = Vec::new();
temp_vec.push(1);
temp_vec.push(2);
temp_vec.push(3);
temp_vec
};
... | true |
208c7e7c72b49187e24bbea5f467c486c302c890 | Rust | pantonov/ordcode | /src/varint.rs | UTF-8 | 10,679 | 3.1875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //!
//! Fast variable length serialization of unsigned integers with [`VarUInt`] trait.
//!
//! This trait is implemented by this crate for [`u32`], [`u64`] integer types.
use crate::{buf::{ReadBytes, WriteBytes, TailReadBytes, TailWriteBytes, WriteToTail, ReadFromTail},
params::LengthEncoder, Result, Error... | true |
db23d1391d521996d4dd7e6629cee5f8a9b79e1c | Rust | EFanZh/LeetCode | /src/problem_0783_minimum_distance_between_bst_nodes/recursive.rs | UTF-8 | 1,284 | 3 | 3 | [] | no_license | use crate::data_structures::TreeNode;
pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::cell::RefCell;
use std::rc::Rc;
impl Solution {
fn helper(node: Option<&RefCell<TreeNode>>, prev: &mut Option<i32>, result:... | true |
fbca81ef667f84d46c2bf577fd06cea1db960eef | Rust | julioolvr/rusty-league | /src/api/responses.rs | UTF-8 | 2,433 | 2.65625 | 3 | [] | no_license | // TODO: Consider moving this somewhere else
pub type PlayerId = String;
pub type PlayerTitle = String;
#[derive(Deserialize, Debug)]
pub struct PlayerSkillResponse {
pub user_id: Option<String>,
pub user_name: String,
pub player_skills: Vec<PlaylistSkillResponse>,
// TODO: Add season_rewards field
}
... | true |
3abe25e6c671528297e9945d47de6f33411bbadc | Rust | Globidev/corewa-rs | /corewa-rs/src/vm/memory.rs | UTF-8 | 2,840 | 2.890625 | 3 | [] | no_license | #![allow(clippy::identity_op)]
use super::wrapping_array::WrappingArray;
use crate::spec::*;
use byteorder::{BigEndian, ByteOrder};
use std::mem;
// We will store player indices as owner information
// we can use a u8 to save some space since there will be no more than
// MAX_PLAYERS players, which should easily fit... | true |
a91a930c0b7d79b837e912b17585e6a9e307722b | Rust | maciek-rr/object_space_navigator | /src/deserialize_utils.rs | UTF-8 | 1,615 | 3 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Deserializer};
use crate::heap_address::HeapAddress;
pub struct DeserializeUtils {}
impl DeserializeUtils {
pub fn hex_to_heap_address(value: String) -> Option<HeapAddress> {
let hex_number = value.replace("\"", "").replace("0x", "");
let uvalue = u64::from_str_radix(hex_n... | true |
4b35952efa8ca390b8e1ac6b41b472e52fefeebb | Rust | monomadic/jsonrpc-cli | /src/rpc.rs | UTF-8 | 1,366 | 2.90625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
/// Perform an RPC socket request
pub(crate) fn socket_request(
host: &str,
request: &str,
) -> Result<String, Box<dyn std::error::Error>> {
use websocket::{ClientBuilder, Message};
// println!("request -> {}", request);
let mut client = ClientBuilder::new(hos... | true |
6861881aea03b1badd19497f2003eaf157bad442 | Rust | Kimundi/generic-str-lib | /src/lib.rs | UTF-8 | 6,785 | 2.9375 | 3 | [] | no_license | #![feature(macro_rules)]
pub use self::traits::{Matcher, LeftMatcher, Pattern};
pub use self::matches::{Matches, MatchIndices};
pub use self::splits::{Splits, NSplits, RNSplits, TermSplits};
// Helper macro for unit tests
macro_rules! iter_eq {
($i:expr, $s:expr) => {
{
let i: Vec<_> = $i.coll... | true |
b583088c69c20761ea1e8928597779d2054a435e | Rust | lmj01/rust-meijie | /mjlib/src/punctuation/range.rs | UTF-8 | 730 | 3.640625 | 4 | [] | no_license | pub fn test1() {
let x = std::ops::Range{ start: 0, end: 10};
let y = 0..10;
assert_eq!(x, y);
println!("range from for in 1..11");
for i in 1..11 {
print!(" {}", i);
}
print!("\n");
println!("range from for in 3..");
for i in 3.. {
if i==10 {
break;
... | true |
70a7ff755716392860c5e3901027d8239df2397a | Rust | emallson/waluigid | /src/bin/pairs.rs | UTF-8 | 1,176 | 3.09375 | 3 | [] | no_license | extern crate docopt;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use std::fs::File;
use std::io::{Write, BufWriter};
use std::collections::HashMap;
const USAGE: &str = "
Simple test program to generate \"log\" files.
Usage:
pairs <id> (<key> <value>)... --log <log>
pairs (-h | --help)
O... | true |
09636adc2f715275e813fac5b8b76eda3a905caa | Rust | IThawk/rust-project | /rust-master/src/test/ui/tuple/tuple-arity-mismatch.rs | UTF-8 | 497 | 3 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Issue #6155
fn first((value, _): (isize, f64)) -> isize { value }
fn main() {
let y = first ((1,2.0,3));
//~^ ERROR mismatched types
//~| expected type `(isize, f64)`
//~| found type `(isize, f64, {integer})`
//~| expected a tuple with 2 elements, found one with 3 elements
let y = first ((... | true |
a2f5f0bbf50ed16bfb7b38f17341bf70f6ff917e | Rust | Stratus51/rust_dash7_alp | /src/spec/v1_2/operand/query.rs | UTF-8 | 33,623 | 2.5625 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
use crate::test_tools::test_item;
use crate::{
codec::{Codec, StdError, WithOffset, WithSize},
spec::v1_2::{
operand::{FileOffset, FileOffsetDecodingError},
varint,
},
};
#[cfg(test)]
use hex_literal::hex;
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum QueryComparisonType {
... | true |
b4943922288d5ba2902cf59348bbdd0f3ddc1c11 | Rust | jclulow/action-agogo | /tools/src/main.rs | UTF-8 | 1,308 | 2.703125 | 3 | [
"MIT"
] | permissive | use anyhow::{anyhow, bail, Result};
use std::process::Command;
use std::os::unix::process::CommandExt;
fn getenv(n: &str) -> Result<String> {
std::env::var(n).map_err(|e| anyhow!("env var {}: {:?}", n, e))
}
fn main() -> Result<()> {
println!("ENVIRONMENT:");
for (k, v) in std::env::vars() {
print... | true |
81b82c181e3cee3c020885e37fc7d395c8fe0f7b | Rust | jalbert-dev/coffee | /src/input.rs | UTF-8 | 2,100 | 3.171875 | 3 | [
"MIT"
] | permissive | //! Allow players to interact with your game.
use crate::graphics::window::winit;
pub use winit::ElementState as ButtonState;
pub use winit::MouseButton;
pub use winit::VirtualKeyCode as KeyCode;
/// An input event.
///
/// You can listen to this type of events by implementing [`Game::on_input`].
///
/// There are ma... | true |
df1dec58f1f4db26e266ba18ff47590199b5adf8 | Rust | bifrost-rs/bifrost | /bifrost-stun/src/message/method.rs | UTF-8 | 323 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[derive(Debug, Eq, PartialEq)]
pub struct Method([u8; 2]);
impl Method {
pub const BINDING: Self = Self::from_low_12_bits([0, 1]);
pub const fn from_low_12_bits(mut bits: [u8; 2]) -> Self {
bits[0] &= 0b1111;
Self(bits)
}
pub const fn as_bytes(&self) -> [u8; 2] {
self.0
}... | true |
1e7df55a7e038ac61bd60e1a53650cf012aa1fa7 | Rust | billythedummy/merkle-tree-nostd | /tests/basic.rs | UTF-8 | 2,888 | 2.578125 | 3 | [] | no_license | #[cfg(test)]
use merkle_tree_nostd::*;
use ring::digest::Digest;
use std::matches;
mod common;
use common::Sha256Context;
#[test]
fn test_depth_0() {
const CAP: usize = 1;
let mt: MerkleTree<Digest, Sha256Context, CAP> = MerkleTree::from_slice(&["hello"]).unwrap();
let root = b"\x2c\xf2\x4d\xba\x5f\xb0... | true |
5b7ee4c03784dd4fb8e4af9674dc20062761fcd2 | Rust | alexdachin/adventofcode-2019 | /14/src/main.rs | UTF-8 | 4,224 | 3.390625 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs;
fn parse_input(input: &str) -> Vec<Reaction> {
input
.trim()
.lines()
.map(|reaction| {
let reaction_parts: Vec<&str> = reaction.split(" => ").collect();
let input_chemicals = reaction_parts[0]
.split(", ")... | true |
43145546cad3271c1ecb911784e996da3ae396c8 | Rust | Ray-Eldath/Telesteller | /src/message/codec.rs | UTF-8 | 2,418 | 2.890625 | 3 | [] | no_license | use std::io;
use bytes::{Buf, BytesMut};
use thiserror::Error;
use tokio_util::codec::{Decoder, Encoder, Framed};
use crate::get;
use crate::message::{Request, ResponseFrame};
pub(crate) struct MQTT311;
pub(crate) type Transport = Framed<tokio::net::TcpStream, MQTT311>;
#[derive(Error, Debug)]
pub(crate) enum Enco... | true |
aab80cd3a94f910e909fee8543dba8d0674abfb5 | Rust | sgdavies/aoc2019 | /rust/day1/src/main.rs | UTF-8 | 1,998 | 3.109375 | 3 | [] | no_license | fn main() {
println!("Part one:");
let test_masses = [(12u32,2u32,2u32), (14,2,2), (1969,654,966), (100756,33583,50346)];
let masses = [137503u32,60363,103031,141000,101650,76081,139069,63717,135021,66034,53912,83417,125978,73206,77497,108822,133339,113618,91973,88741,109942,96523,95973,56595,118638,63936,1... | true |
6ea39bf3cf3ffb37d5138d3e0f418677656614f1 | Rust | liguang-li/resctl-demo | /resctl-bench-intf/src/iocost.rs | UTF-8 | 2,324 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::Result;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct IoCostQoSOvr {
pub off: bool,
pub rpct: Option<f64>,
pub rlat: Option<u64>,
pub wpct: Option<f64>,
pub wlat: Option<u64>,
pub min: Option<f64>,
pub max: Op... | true |
f502ab095a9d31a6f6a6252ddbd0587d137d862b | Rust | jfredrickson/rust_book | /if_expressions/src/main.rs | UTF-8 | 837 | 3.9375 | 4 | [] | no_license | fn main() {
one();
two();
three();
four();
five();
}
fn one() {
let x = 5;
if x == 5 {
println!("x is five!");
}
}
fn two() {
let x = 5;
if x == 5 {
println!("x is five!");
} else {
println!("x is not five :(");
}
}
fn three() {
let x = 5;
... | true |
92c07b1f0da0d34c1652aff8e590ebbfb3fc40d5 | Rust | skicom/markup.rs | /markup/src/lib.rs | UTF-8 | 3,649 | 2.609375 | 3 | [] | no_license | pub use markup_proc_macro::{define, new};
mod escape;
pub trait Render {
fn render(&self, writer: &mut dyn std::fmt::Write) -> std::fmt::Result;
#[doc(hidden)]
#[inline]
fn is_none(&self) -> bool {
false
}
#[doc(hidden)]
#[inline]
fn is_true(&self) -> bool {
false
... | true |
3007a988f58e1529b7c31228d350220d0b070888 | Rust | maximumstock/Advent-of-Code-2020 | /day_07/src/main.rs | UTF-8 | 3,555 | 3.28125 | 3 | [] | no_license | use std::collections::{HashMap, HashSet, VecDeque};
fn main() {
let input = include_str!("../input.txt");
let result = part1(&input).expect("Error in part 1");
println!("Part 1: {}", result);
let result = part2(&input).expect("Error in part 2");
println!("Part 2: {}", result);
}
fn build_graph(i... | true |
8c38e89d056d4253801bc74f1d80dc1d251b5cd1 | Rust | svip/adventofcode | /2015/day03/day3-2.rs | UTF-8 | 858 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::io;
use std::io::prelude::*;
use std::collections::HashMap;
fn move_pos(c: char, mut pos: (i32, i32)) -> (i32, i32) {
pos = match c {
'<' => { (pos.0-1, pos.1) }
'>' => { (pos.0+1, pos.1) }
'^' => { (pos.0, pos.1-1) }
'v' => { (pos.0, pos.1+1) }
_ => { println!("{:?}", pos); pos }
};
pos
}
fn ma... | true |
88bc5a9aff5d20a8721dab3797231d861a81cb50 | Rust | spamwax/rusty-pin | /src/pinboard/mockito_helper.rs | UTF-8 | 1,810 | 2.609375 | 3 | [
"MIT"
] | permissive | use env_logger;
use std::path::PathBuf;
#[cfg(test)]
use mockito::{mock, Matcher, Mock};
#[cfg(test)]
pub trait MockBodyGenerate {
fn create_mockito_server(self, endpoint: &str, status: usize) -> Mock;
}
#[cfg(test)]
impl<'a> MockBodyGenerate for &'a str {
fn create_mockito_server(self, endpoint: &str, statu... | true |
3b1580a81a8961177ba09c63214f71ba039b9e27 | Rust | tschesky/projekt-ps | /src/main.rs | UTF-8 | 10,962 | 2.75 | 3 | [] | no_license | extern crate getopts;
extern crate hyper;
extern crate futures;
extern crate tokio_core;
extern crate hyper_tls;
extern crate pretty_env_logger;
extern crate ftp;
use std::io::Read;
use getopts::Options;
use std::str;
use std::error::Error;
use std::fs::File;
use std::path::Path;
use std::io::stdin;
use std::env;
use ... | true |
3e3939c177b1351397a080f49cf8c904ac175a78 | Rust | quodlibetor/lasagna-demo | /75-multi-cache-multi-trait/src/remote_cache.rs | UTF-8 | 1,608 | 3.1875 | 3 | [] | no_license | use {cache::Insert, Cache};
crate enum RemoteInsert<V> {
Present(V),
Inserted(V),
}
crate trait RemoteCache<K, V> {
type Err;
fn get(&self, key: &K) -> Result<Option<V>, Self::Err>;
fn insert(&mut self, key: &K, val: &V) -> Result<V, Self::Err>;
fn insert_if_missing(
&mut self,
... | true |
ea9cd5221b6bca3a3514af1945c0e222d38f1c74 | Rust | YaronWittenstein/exercism-rust | /crypto-square/src/lib.rs | UTF-8 | 1,275 | 3.453125 | 3 | [] | no_license | struct Rectangle {
r: usize,
c: usize,
pad: usize,
}
pub fn encrypt(input: &str) -> String {
let chars = input
.to_lowercase()
.chars()
.filter(|c| c.is_alphanumeric() || c.is_digit(10))
.collect::<Vec<_>>();
if chars.len() == 0 {
return String::from("");
... | true |
963f770251c01cd0f228a11662924713a396949d | Rust | KatsuyaKikuchi/programming_contest_rust | /src/VirtualContest/graph/017.rs | UTF-8 | 1,067 | 2.890625 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Usize1;
use std::collections::VecDeque;
struct Node {
to: Vec<usize>,
from: Vec<usize>,
}
impl Node {
fn new() -> Self
{
Node {
to: Vec::new(),
from: Vec::new(),
}
}
}
fn main() {
input! {
n:usize,
m:us... | true |
8302455496bd03dff1301d663b3c99acd4221ecf | Rust | ellington-project/tizol | /src/lib.rs | UTF-8 | 8,676 | 3 | 3 | [] | no_license | //! A small library for reliable, fast spectrogram generation and visualisation
//!
//! Tizol provides a `Spectrogram` object that allows the user to create spectrograms from raw audio data or audio files, and visualise said spectrograms. The computed spectrogram and visualised images are intended to be as-close-to ide... | true |
06df0e62d0dee395e02f6faf086e8da3912738b4 | Rust | polachok/rust-users | /examples/example.rs | UTF-8 | 756 | 2.640625 | 3 | [] | no_license | extern crate users;
use users::{Users, OSUsers};
fn main() {
let mut cache = OSUsers::empty_cache();
let current_uid = cache.get_current_uid();
println!("Your UID is {}", current_uid);
let you = cache.get_user_by_uid(current_uid).expect("No entry for current user!");
println!("Your username is {}", you.name);... | true |
1024d0728bf3efce93a779a7e90fd52fb5cea46f | Rust | aeubanks/itgrate | /src/rate/state.rs | UTF-8 | 6,256 | 2.734375 | 3 | [] | no_license | use crate::note::Note;
#[derive(Debug, PartialEq, Clone)]
pub struct StepParams {
pub base_fatigue_per_step: f32,
pub fatigue_per_step_ratio: f32,
pub fatigue_dist_ratio: f32,
pub fatigue_exp_decay_rate: f32,
pub fatigue_reciprocal_decay_rate: f32,
pub rest_time_add_constant: f32,
pub raw_r... | true |
868ff2b30cde83dcedbdee1c34d9d7ec23863a2c | Rust | terrorizer1980/Security-Hall | /src/admin.rs | UTF-8 | 3,989 | 2.890625 | 3 | [
"MIT"
] | permissive | use bincode;
use chrono::Utc;
use warp::{Reply, reply::Response, http::StatusCode};
use sled::Db;
use log::info;
use crate::{
AdminKey,
HallEntry,
RecordSubmission,
generate_response
};
pub fn add_record(new_record: RecordSubmission, user: &AdminKey, record_db: &Db) -> Response {
let new_id = rec... | true |
b099a0768f0190b89e619a619ab71a9142899b5a | Rust | jejung/blochs | /blochs-server/src/main.rs | UTF-8 | 1,284 | 2.578125 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate log;
extern crate simple_logger;
extern crate libblochs;
use std::net::{TcpListener, TcpStream};
use std::io::Read;
use libblochs::config::load_server_config;
fn main() {
simple_logger::init().unwrap();
let config = load_server_config();
info!("Starting blochs server listening ... | true |
ce4bb065f1185fd8999163d867a1607cc00009c1 | Rust | Integ/Hacker101CTF | /RollingCodeLock/bf_rng/src/main.rs | UTF-8 | 956 | 3.15625 | 3 | [
"MIT"
] | permissive | fn main() {
// let codes = [53494609, 56755322, 51004373];
for i in 0..0xFFFFFFFF {
if check(setup(i), 53494609) {
println!("seed:{0} --- code:{1}", i, 53494609);
}
}
}
fn setup(mut seed: u64) -> u64 {
let mut state = 0;
for _i in 0..16 {
let cur = seed & 3;
seed >>= 2;
... | true |
910d69eea22b044d397a26b3bad33c0ae6620e7d | Rust | Tubbz-alt/lrad | /lrad-lib/src/ipfs/mod.rs | UTF-8 | 3,758 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::error::Result;
use curl::easy::{Easy, Form};
use std::path::Path;
use std::path::PathBuf;
#[derive(Deserialize, Serialize)]
pub struct IpfsApiServerConfig {
host: String,
port: u16,
}
impl Default for IpfsApiServerConfig {
fn default() -> Self {
Self {
host: String::from("lo... | true |
cec42c00d594dcc547c864b9ba2fb27e4ae088e4 | Rust | Cykooz/libheif-rs | /src/image.rs | UTF-8 | 11,746 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::mem::MaybeUninit;
use std::os::raw::c_int;
use std::ptr;
use std::slice;
use libheif_sys as lh;
use crate::{
Channel, ColorProfileNCLX, ColorProfileRaw, ColorProfileType, ColorSpace, HeifError,
HeifErrorCode, HeifErrorSubCode, Result,
};
const MAX_IMAGE_SIZE: u32 = i32::MAX as _;
pub struct Plane<T... | true |
70462b0a5da4f5c90c617cc15fbb6393edaad667 | Rust | beamiter/leetcode-rust | /src/dd_challenge/s00336_palindrome_pairs.rs | UTF-8 | 1,886 | 3.375 | 3 | [] | no_license |
pub fn do_sth() {
let os1 = vec!["bat".to_string(), "tab".to_string(), "cat".to_string()];
let res1 = palindrome_pairs(os1);
println!("{:?}", res1);
let os2 = vec!["abcd".to_string(), "dcba".to_string(), "lls".to_string(),
"s".to_string(), "sssll".to_string()];
let exp2 = vec![(... | true |
63f826ca7b0d6e51a4e54c8399967a279151f384 | Rust | google/argh | /argh_derive/src/args_info.rs | UTF-8 | 12,062 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright (c) 2023 Google LLC 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::{
enum_only_single_field_unnamed_variants,
errors::Errors,
help::require_description,
parse_attrs::{check_enum_type_attrs, FieldAttrs,... | true |
3220012a73e24ab9d609d0953e1c44b1ebb48363 | Rust | ntex-rs/ntex | /ntex-bytes/tests/test_buf.rs | UTF-8 | 837 | 2.59375 | 3 | [
"MIT"
] | permissive | #![deny(warnings, rust_2018_idioms)]
use ntex_bytes::Buf;
#[test]
fn test_fresh_cursor_vec() {
let mut buf = &b"hello"[..];
assert_eq!(buf.remaining(), 5);
assert_eq!(buf.chunk(), b"hello");
buf.advance(2);
assert_eq!(buf.remaining(), 3);
assert_eq!(buf.chunk(), b"llo");
buf.advance(3)... | true |
50325ac9f36ee8d1797f22424671472ad489d13b | Rust | ifyouseewendy/artichoke | /artichoke-core/src/load.rs | UTF-8 | 2,024 | 2.953125 | 3 | [
"MIT"
] | permissive | //! Load Ruby and Rust sources into the VM.
use crate::file::File;
use crate::ArtichokeError;
/// Interpreters that implement [`LoadSources`] expose methods for loading Ruby
/// and Rust sources into the VM.
#[allow(clippy::module_name_repetitions)]
pub trait LoadSources {
/// Concrete type object to modify the i... | true |
da9cc25113339c5ff313732cb0634dfb60faa795 | Rust | rhysd/misc | /adventofcode/2021/09_1.rs | UTF-8 | 796 | 3.046875 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let board: Vec<Vec<_>> = io::stdin()
.lock()
.lines()
.map(|l| l.unwrap().chars().map(|c| c.to_digit(10).unwrap()).collect())
.collect();
let mut total = 0;
for y in 0..board.len() {
let row = &board[y];
for x in 0..r... | true |
add3d9147d48871e95623213d20ca4feb2e84451 | Rust | royalmustard/breadx | /examples/async.rs | UTF-8 | 7,227 | 2.578125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // MIT/Apache2 License
// This example requires the "async" feature to be activated.
// Note: I use smol here, as it is a). my personal favorite async runtime in the Rust ecosystem at the
// moment, and b). breadx is implemented in terms of its objects. You should be able to
// use async-std or an executo... | true |
43bff6a20dc6c387747a8b75fc19cacc13a844a2 | Rust | danshiovitz/adventofcode | /2022/day08/src/main.rs | UTF-8 | 3,803 | 2.765625 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | use std::collections::{HashMap, HashSet};
extern crate common;
use common::framework::{parse_grid, run_day, BaseDay, InputReader};
use common::grid::{add_direction, print_grid, Coord, Direction, Grid};
struct Day08 {
vals: Grid<i32>,
}
impl BaseDay for Day08 {
fn parse(&mut self, input: &mut InputReader) {
... | true |
d1ef6188251024d40a31df19f5b5985e56236eb9 | Rust | silathdiir/pg_wire | /src/result.rs | UTF-8 | 1,762 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Alex Dukhno
//
// 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 to in ... | true |
c03e0bdf1224614905f4c2c4cb5e759a5d35560f | Rust | gijs-s/pointctl | /src/view/ui/ui_state.rs | UTF-8 | 3,933 | 3.28125 | 3 | [
"MIT"
] | permissive | //! Module that with a definition of the UI state.
// First party imports
use super::widget_ids::*;
use crate::{exp::Neighborhood, search::UIPointData};
/// The state of the UI. This tracks the widgets on screen, which menus are open, and values that
/// have not been submitted yet.
pub struct UIState {
// All th... | true |
a3865e723ee4b7da0664435e7858540266e45f48 | Rust | DomCristaldi/TopDog | /src/Resources/spritesheet_loader.rs | UTF-8 | 831 | 2.578125 | 3 | [] | no_license | extern crate amethyst;
use amethyst::{
prelude::*,
assets::{
AssetStorage,
Handle,
Loader,
},
renderer::{
ImageFormat,
SpriteSheet,
SpriteSheetFormat,
Texture,
},
};
pub fn retrieve_spritesheet_handle(world: &mut World) -> Handle<SpriteSheet>
{
let texture_handle = {
let l... | true |
31da1be65979160cb214bbd03e82674b4e46d81e | Rust | PtaxLaine/enum-bits-rs | /enum_bits_derive/src/imp.rs | UTF-8 | 2,665 | 2.578125 | 3 | [
"MIT"
] | permissive | use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use syn::{Data, DeriveInput, Type};
pub fn impl_enum_bits_macro(ast: &DeriveInput) -> TokenStream {
let name = &ast.ident;
let variants = find_variants(&ast).expect("EnumBits applicable to enum only");
let type_ident = find_repr_ident(&ast).exp... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.