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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
50c35dc00a2185051fd83981c0bc6e3ecd1f3b95 | Rust | 2color/prisma-engines | /libs/datamodel/core/tests/attributes/unique.rs | UTF-8 | 7,448 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | #![allow(non_snake_case)]
use datamodel::{ast::Span, diagnostics::*, render_datamodel_to_string, IndexDefinition, IndexType};
use crate::common::*;
#[test]
fn basic_unique_index_must_work() {
let dml = r#"
model User {
id Int @id
firstName String
lastName String
@@... | true |
8191a2bed1521315ebc2a50ba20e0386c06efd99 | Rust | waywardmonkeys/app_units | /src/app_unit.rs | UTF-8 | 10,104 | 3.171875 | 3 | [] | no_license | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use num_traits::Zero;
use serde::de::{Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use std... | true |
97377fd1c2ef3aa928709a4a239ffc3f4d3b625d | Rust | pitpo/AdventOfCode2018 | /days/day24/src/lib.rs | UTF-8 | 8,513 | 3.15625 | 3 | [] | no_license | extern crate utils;
use utils::Day;
use std::cmp::Ordering;
use std::collections::HashMap;
pub struct Day24 {
groups: Vec<Group>,
}
#[derive(Debug, Clone)]
struct Group {
is_foe: bool,
units: usize,
hp: usize,
weak: Vec<String>,
immune: Vec<String>,
attack: usize,
attack_type: String,... | true |
f5c8d368b82de6313c8f910405030a025751ec84 | Rust | doraneko94/CA3-Rust | /pinsky-rinzel/src/neuron.rs | UTF-8 | 630 | 2.703125 | 3 | [] | no_license | use std::collections::HashMap;
use crate::compartment::*;
pub struct Neuron {
pub soma: Soma,
pub dend: Dend,
}
impl Default for Neuron {
fn default() -> Self {
Self::new(&HashMap::new())
}
}
impl Neuron {
pub fn new(params: &HashMap<&str, f64>) -> Self {
let soma = Soma::new(par... | true |
3e5781697cbd6cc517a014391461506aed02e374 | Rust | Vuenc/Advent-of-Code-2018 | /src/day4.rs | UTF-8 | 4,549 | 3.125 | 3 | [] | no_license | // use std::cmp::{max};
use regex::Regex;
use self::GuardAction::*;
use bit_vec::BitVec;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Eq)]
enum GuardAction {
BeginsShift,
WakesUp,
FallsAsleep
}
#[derive(Debug)]
struct GuardEvent {
date: String,
minute: i32,
guard_id: Option<i32>,
... | true |
ea715be5961eecb6f8ea7a10f68f1d31eadfb2e8 | Rust | async-raft/async-raft | /async-raft/tests/shutdown.rs | UTF-8 | 1,875 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod fixtures;
use std::sync::Arc;
use std::time::Duration;
use anyhow::{anyhow, Result};
use async_raft::Config;
use tokio::time::sleep;
use fixtures::RaftRouter;
/// Cluster shutdown test.
///
/// What does this test do?
///
/// - this test builds upon the `initialization` test.
/// - after the cluster has been in... | true |
1f3f52c1b890983078f1d66a0ba9ab24524e3cec | Rust | bvssvni/ncollide | /src/parametric/parametric.rs | UTF-8 | 1,727 | 3.1875 | 3 | [
"BSD-2-Clause"
] | permissive | // FIXME: support more than rectangular surfaces?
use math::Scalar;
/// Trait implemented by differentiable parametric surfaces.
///
/// The parametrization space is assumed to be `[0.0, 1.0] x [0.0, 1.0]`.
pub trait ParametricSurface<N: Scalar, P, V> {
// FIXME: rename those d0, du, etc. ? (just like in the `sym... | true |
dcef0169c6c99be4ca7a15f5b178f66bf2e1df8b | Rust | iqlusioninc/abscissa | /core/src/thread/name.rs | UTF-8 | 1,021 | 3.421875 | 3 | [
"Apache-2.0"
] | permissive | //! Thread names.
use crate::{FrameworkError, FrameworkErrorKind::ThreadError};
use std::{fmt, str::FromStr};
/// Thread name.
///
/// Cannot contain null bytes.
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct Name(String);
impl Name {
/// Create a new thread name
pub fn new(name: im... | true |
270c1eb1a45470b3dab44f6cfd54a6ee3caac1c9 | Rust | peku33/logicblocks | /Controller/src/devices/houseblocks/avr_v1/hardware/driver.rs | UTF-8 | 6,311 | 2.515625 | 3 | [] | no_license | use super::{
super::super::houseblocks_v1::{
common::{Address, Payload},
master::Master,
},
parser::Parser,
};
use anyhow::{ensure, Context, Error};
use std::time::Duration;
#[derive(Debug)]
pub struct PowerFlags {
wdt: bool,
bod: bool,
ext_reset: bool,
pon: bool,
}
#[deriv... | true |
c1fa22ba7f032f9b23c8e82328a6710d0342286b | Rust | higgsofwolfram74/rustcreditcardchecksum | /creditcheck/src/main.rs | UTF-8 | 1,519 | 3.578125 | 4 | [] | no_license | use std::io;
fn credit_checksum(number_check: &mut [u32; 16]) {
let test: u32 = number_check[15];
number_check[15] = 0;
for index in (0..15).step_by(2) {
let mut number = number_check[index] * 2;
if number > 9 {
number = 1 + (number - 10);
}
number_ch... | true |
e01787d07825c553a84a5c76024f6a5c266b8289 | Rust | TheBlueMatt/rust-lightning | /lightning-block-sync/src/utils.rs | UTF-8 | 941 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use bitcoin::util::uint::Uint256;
pub fn hex_to_uint256(hex: &str) -> Option<Uint256> {
if hex.len() != 64 { return None; }
let mut out = [0u64; 4];
let mut b: u64 = 0;
for (idx, c) in hex.as_bytes().iter().enumerate() {
b <<= 4;
match *c {
b'A'..=b'F' => b |= (c - b'A' + 10) as u64,
b'a'..=b'f' => b |=... | true |
de7cb8d52d367ddef807053a425e2253e8e799b5 | Rust | s-aran/nae | /src/natural_sort.rs | UTF-8 | 7,625 | 3.671875 | 4 | [] | no_license | use std::cmp::Ordering;
pub struct NaturalSort {}
impl NaturalSort {
/// internal common radix
const RADIX: u32 = 10;
/// strcmp with natural
/// # Arguments
/// * `a` - first string
/// * `b` - second string
/// # Return
/// * `Ordering` - result of comparison
/// # Example
/// ```
/// use std... | true |
ceb9615477eae540dce6be43fc8a9b18d03fdf58 | Rust | Emerentius/drain_experiments | /src/_try_drain.rs | UTF-8 | 635 | 2.828125 | 3 | [] | no_license | pub(crate) struct _TryDrain<'a, T: 'a> {
pub vec: &'a mut Vec<T>,
pub finished: bool,
pub idx: usize,
pub del: usize,
pub old_len: usize,
}
impl<'a, T: 'a> _TryDrain<'a, T> {
pub fn tail_len(&self) -> usize {
self.old_len - self.idx
}
}
impl<'a, T: 'a> _TryDrain<'a, T> {
pub fn... | true |
c4431e79f9f4751fcd73fee8b29cec34db27cfb6 | Rust | mcginty/snow | /src/error.rs | UTF-8 | 6,098 | 3.1875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! All error types used by Snow operations.
use std::fmt;
/// `snow` provides decently detailed errors, exposed as the [`Error`] enum,
/// to allow developers to react to errors in a more actionable way.
///
/// *With that said*, security vulnerabilities *can* be introduced by passing
/// along detailed failure info... | true |
ca3afa77fd4d2fa3275e2996416d425dcf3e5175 | Rust | Sword-Smith/rust-tutorial | /src/scoping_rules/aliasing.rs | UTF-8 | 1,686 | 3.9375 | 4 | [
"Unlicense"
] | permissive | struct Point {
x: i32,
y: i32,
z: i32,
}
pub fn aliasing() {
let mut point = Point { x: 0, y: 0, z: 0 };
let borrowed_point = &point;
let another_borrow = &point;
println!(
"Point has coordinates: ({}, {}, {})",
borrowed_point.x, borrowed_point.y, borrowed_point.z
);
... | true |
526875f2de9cf68692eb0842ffbcd673d534e6f8 | Rust | LesnyRumcajs/wakey | /wakey/src/lib.rs | UTF-8 | 8,182 | 3.3125 | 3 | [
"MIT"
] | permissive | //! Library for managing Wake-on-LAN packets.
//! # Example
//! ```
//! let wol = wakey::WolPacket::from_string("01:02:03:04:05:06", ':').unwrap();
//! if wol.send_magic().is_ok() {
//! println!("Sent the magic packet!");
//! } else {
//! println!("Failed to send the magic packet!");
//! }
//! ```
use std::err... | true |
a232e300facfddb1c1cdf3e918b9ed7271ab9e16 | Rust | jakewitcher/rusty_parsec | /tests/combinators_pipe_tests.rs | UTF-8 | 8,024 | 2.953125 | 3 | [] | no_license | mod common;
use common::*;
use rusty_parsec::*;
#[test]
fn tuple_2_run_simple_parserss_succeeds() {
let expected = Ok(ParserSuccess::new(
(123, String::from("hello")),
Position::new(1, 9, 8)
));
let actual = tuple_2(
p_u32(),
p_hello()
).run(String::from("123hello"));... | true |
4b8fcb648752536f375db1cfc68305433d23757c | Rust | morri2/leonardp-chess | /hansing_gui/src/texturepack.rs | UTF-8 | 1,041 | 2.984375 | 3 | [] | no_license | use ggez::graphics::*;
use ggez::Context;
pub struct Texturepack {
pub piece_texture: Vec<Image>,
pub placeholder: bool,
}
impl Texturepack {
pub fn new_placeholder() -> Self {
Self {
piece_texture: Vec::new(),
placeholder: true,
}
}
pub fn new() -> Self {
... | true |
90314fd979ff038c488ca7660245ef6f21d74452 | Rust | htk16/build_your_own_lisp_in_rust | /src/error.rs | UTF-8 | 811 | 3.078125 | 3 | [] | no_license | use crate::expression::{Expression, ExpressionType};
use anyhow::{anyhow, Error};
pub fn argument_error(name: &str, required: usize, passed: usize) -> Error {
anyhow!(
"Function '{}' required {} argument(s), but passed {}",
name,
required,
passed
)
}
pub fn type_error(required:... | true |
f3b440009a19c0b5955fe0a8c93c39cc5e7fb671 | Rust | oli-obk/stdsimd | /coresimd/ppsv/api/masks_select.rs | UTF-8 | 1,741 | 2.90625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Mask select method
#![allow(unused)]
/// Implements mask select method
macro_rules! impl_mask_select {
($id:ident, $elem_ty:ident, $elem_count:expr) => {
impl $id {
/// Selects elements of `a` and `b` using mask.
///
/// For each lane, the result contains the element... | true |
adc493372f1d80fce1493c1c4fe92be471cee502 | Rust | tov/succinct-rs | /src/rank/prim.rs | UTF-8 | 2,698 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use rank::{BitRankSupport, RankSupport};
use storage::BlockType;
macro_rules! impl_rank_support_prim {
( $t:ident )
=>
{
impl RankSupport for $t {
type Over = bool;
fn rank(&self, position: u64, value: bool) -> u64 {
if value {self.rank1(position)} else ... | true |
f47bc13d0a34d2272755d51dc23cea2753f2a5d7 | Rust | torourk/padding-oracle-visual | /src/main.rs | UTF-8 | 1,752 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use aes::Aes128;
use block_modes::block_padding::Pkcs7;
use block_modes::{BlockMode, Cbc};
use hkdf::Hkdf;
use sha2::Sha256;
use rand::rngs::OsRng;
use rand::RngCore;
use colored::*;
use std::io::{self, Write};
pub mod adversary;
pub mod oracle;
pub mod ui;
use adversary::Adversary;
use oracle::Oracle;
type Aes12... | true |
47c43205b241d5e519df64d54b334483fd9701e4 | Rust | zexa/json_gatherer | /src/main.rs | UTF-8 | 1,175 | 3.046875 | 3 | [
"MIT"
] | permissive | use serde_json;
use std::fs;
use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::collections::HashMap;
struct JsonFile {
stem: String,
content: String,
}
fn get_dir_json(P: &Path) -> io::Result<()> {
let entries = fs::read_dir(P)?
.map(|res| res.map(|e| e.path()))
.map(|path... | true |
7e4864b2fcd1fb13428c10492b3e0aa9f23ea016 | Rust | germolinal/PhD_Thesis_Simulations | /src/lib.rs | UTF-8 | 2,352 | 2.84375 | 3 | [] | no_license | use std::collections::HashMap;
use simulation_state::simulation_state::SimulationState;
use building_model::building::Building;
use communication_protocols::simulation_model::SimulationModel;
use calendar::date_factory::DateFactory;
use calendar::date::Date;
use people::people::People;
use multiphysics_model::multiphy... | true |
978dafdab1d99635532f89a8593fd37b773897e1 | Rust | karjonas/advent-of-code | /2016/day18/src/lib.rs | UTF-8 | 1,658 | 3.203125 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
fn is_trap(r: usize, c: usize, num_cols: usize, grid: &Vec<Vec<bool>>) -> bool {
let left = if c == 0 { false } else { grid[r - 1][c - 1] };
let center = grid[r - 1][c];
let right = if c == num_cols - 1 {
false
} else {
grid[r - 1][c + 1]
... | true |
1174ba0b92b569c91b5693a88cccfea48065e6cd | Rust | pisa-engine/trec-text-rs | /src/lib.rs | UTF-8 | 12,737 | 3.390625 | 3 | [
"Apache-2.0"
] | permissive | #![doc(html_root_url = "https://docs.rs/trec-text/0.1.0")]
//! Parsing TREC Text format.
//!
//! TREC Text is a text format containing a sequence of records:
//! `<DOC> <DOCNO> 0 </DOCNO> Text body </DOC>`
//!
//! # Examples
//!
//! Typically, document records will be read from files.
//! [`Parser`](struct.Parser.html... | true |
a17d0e7c65c96276a36315ebc13c91df38e416bd | Rust | jahfer/accountant | /src/transaction/presidents_choice.rs | UTF-8 | 2,413 | 2.71875 | 3 | [] | no_license | use std::path::Path;
use super::csv_import;
use super::{Transaction, ImportableTransaction, TransactionSource, Format, to_hash};
use ::money::Money;
use std::hash::{Hash, Hasher};
use chrono::{TimeZone, DateTime, UTC};
use regex::Regex;
#[derive(RustcDecodable)]
pub struct Csv {
transaction_date: String,
_post... | true |
bbd16c6b308ccc0430e960abe5e360a948ba00f1 | Rust | ZoeyR/wearte | /testing/tests/benchs.rs | UTF-8 | 1,566 | 3.34375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use wearte::Template;
#[test]
fn big_table() {
let size = 3;
let mut table = Vec::with_capacity(size);
for _ in 0..size {
let mut inner = Vec::with_capacity(size);
for i in 0..size {
inner.push(i);
}
table.push(inner);
}
let table = BigTable { table };
... | true |
56fda6a82c3e79e7d839680c73599d4e831c27a0 | Rust | Jaxelr/RustTutorial | /Rust Cookbook/12_01_1_read_and_write_files/src/main.rs | UTF-8 | 1,491 | 3.125 | 3 | [] | no_license | use std::fs::File;
use same_file::Handle;
use memmap::Mmap;
use std::io::{Write, BufReader, BufRead, Error, ErrorKind};
use std::path::Path;
fn main() -> Result<(), Box <dyn std::error::Error>> {
read_write_file()?;
same_file()?;
random_memory()?;
Ok(())
}
fn read_write_file() -> Result<(), Error> {
... | true |
16d2253599b3a1fa9c3ec0e7e1a316a4ba3b4b27 | Rust | modelflat/twitchbot | /src/state.rs | UTF-8 | 1,414 | 2.765625 | 3 | [] | no_license | use async_std::sync::RwLock;
use std::collections::{BTreeSet, HashMap};
use crate::executor::ShareableExecutableCommand;
use crate::irc;
use crate::permissions::PermissionList;
pub type Commands<T> = HashMap<String, ShareableExecutableCommand<T>>;
pub struct BotState<T: 'static + Send + Sync> {
pub username: Str... | true |
07bc5a3bb6501e0fabcb458956b399a89779f61e | Rust | tertsdiepraam/vrp | /vrp-core/src/models/common/load.rs | UTF-8 | 8,491 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(test)]
#[path = "../../../tests/unit/models/domain/load_test.rs"]
mod load_test;
use crate::models::common::{Dimensions, ValueDimension};
use std::cmp::Ordering;
use std::iter::Sum;
use std::ops::{Add, Mul, Sub};
const CAPACITY_DIMENSION_KEY: &str = "cpc";
const DEMAND_DIMENSION_KEY: &str = "dmd";
const LOAD_DI... | true |
99dbc187a9b4dcacd3a9134ed884b8a22db1d95f | Rust | dpchamps/rust-exercism | /raindrops/src/lib.rs | UTF-8 | 459 | 3.125 | 3 | [] | no_license | pub fn raindrops(n: u32) -> String {
let result = vec![3, 5, 7].iter().fold(String::new(), |str, factor| {
if n % factor != 0 {
return str;
}
let noise = match factor {
3 => "Pling",
5 => "Plang",
7 => "Plong",
_ => unreachable!(),... | true |
7104fc0ed3eb38c354b90eb680965622f46fc511 | Rust | RedEyedMars/AutoClaw | /src/game/entities/combat.rs | UTF-8 | 5,528 | 2.890625 | 3 | [] | no_license | use crate::game::battle::system::movement::MovementPath;
use crate::game::entities::skills::Skill;
use crate::game::entities::traits::TraitId;
use crate::game::entities::{Change, Entity, Idable, State};
use crate::game::{Event, Events, GameParts};
use generational_arena::Index;
#[derive(Debug, Clone, Copy)]
pub enum C... | true |
5d5ec2b359cb4beaa13d08839ba6057d8492bd46 | Rust | mkeeter/advent-of-code | /2021/15/src/main.rs | UTF-8 | 2,164 | 3.0625 | 3 | [] | no_license | use std::cmp::Reverse;
use std::collections::BinaryHeap;
use std::io::BufRead;
#[derive(Ord, PartialOrd, Eq, PartialEq)]
struct Task {
score: Reverse<usize>,
pos: (usize, usize),
}
struct Tile {
weight: usize,
score: Option<usize>,
}
fn search(map: &[Vec<u8>]) -> usize {
let mut map: Vec<Vec<Tile... | true |
2767ab826e2d1bf764a4c81631511d7641d4c003 | Rust | Deskbot/Advent-of-Code-2020 | /src/day/day07.rs | UTF-8 | 5,480 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs;
use substring::Substring;
#[derive(std::fmt::Debug)]
struct Rule<'a> (i32, &'a str);
pub fn day07() {
let file = fs::read_to_string("input/day07.txt").expect("input not found");
println!("Part 1: {}", part1(&file));
println!("Part 2: {}", part2(&file));
}
fn p... | true |
d122241b1a5f2da0c0458e989b8813720783add5 | Rust | nampdn/prisma-engines | /query-engine/core/src/executor/interpreting_executor.rs | UTF-8 | 2,339 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use super::{pipeline::QueryPipeline, QueryExecutor};
use crate::{Operation, QueryGraphBuilder, QueryInterpreter, QuerySchemaRef, Response, Responses};
use async_trait::async_trait;
use connector::{ConnectionLike, Connector};
/// Central query executor and main entry point into the query core.
pub struct InterpretingEx... | true |
04b6682d49dbf63b9576fb241f686404d1a04d3f | Rust | manuelleduc/awesome-software-language-engineering | /ci/src/lib.rs | UTF-8 | 4,816 | 2.953125 | 3 | [
"CC0-1.0"
] | permissive | // `error_chain!` can recurse deeply
#![recursion_limit = "1024"]
#[macro_use]
extern crate failure;
#[macro_use]
extern crate lazy_static;
extern crate regex;
use failure::{Error, err_msg};
use regex::Regex;
use std::fmt;
use std::cmp::Ordering;
lazy_static! {
static ref TOOL_REGEX: Regex = Regex::new(r"\*\s\... | true |
7e359a5fc15b6bc0d512244d9217e24a8923a440 | Rust | abhijat/invalidator | /benches/benchmark.rs | UTF-8 | 953 | 2.828125 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate criterion;
use std::collections::HashSet;
use criterion::Criterion;
use rand::distributions::Alphanumeric;
use rand::Rng;
use rand::thread_rng;
use bloom_filter::BloomFilter;
fn data_set_of_size(size: usize, word_size: usize) -> HashSet<String> {
let mut data = HashSet::with_capacity(s... | true |
91b02a5a09ad5a9979113b7dfd51da71b27a4cdc | Rust | tobisako/rust-memo | /rust_tutorial/s414/src/main.rs | UTF-8 | 5,053 | 4.3125 | 4 | [] | no_license | struct Point {
x: i32,
y: i32,
}
// use std::result::Result;
fn main() {
// パターン
// パターンには一つ落とし穴があります。
// 新しい束縛を導入する他の構文と同様、パターンはシャドーイングをします。例えば:
let x = 'x';
let c = 'c';
match c {
x => println!("x: {} c: {}", x, c), // 元のxがシャドーイングされて、別のxとして動作している。
}
println!("x: {}", x);
// x => ... | true |
8926b758fe04817f945d6b6738733e09b81a05ed | Rust | elipmoc/Ruscall | /src/compile/semantic_analysis/variable_table.rs | UTF-8 | 1,738 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[derive(Clone)]
pub struct VariableTable {
local_var_names: Vec<Vec<String>>,
global_var_names: HashMap<String, ()>,
nest_level: usize,
}
use super::super::ir::ast::VariableAST;
use super::type_inference::type_env::TypeEnv;
use super::mir::ExprMir;
//変数の管理
impl VariableTab... | true |
194d5312513ad7060b2c4dc623f33fbdf1ae4875 | Rust | pwwolff/RussianRust | /src/settings_factory.rs | UTF-8 | 474 | 2.625 | 3 | [] | no_license | extern crate glob;
extern crate config;
use std::collections::HashMap;
use config::*;
use glob::glob;
pub fn get_settings() -> HashMap<String, String>{
let mut settings = Config::default();
settings
.merge(glob("config/*")
.unwrap()
.map(|path| File::from(path.unwrap()))
... | true |
dad6bfdbdf27b7f5223322bdee6c1fbc32195b04 | Rust | payload/asciii-rs | /src/actions/mod.rs | UTF-8 | 11,758 | 2.53125 | 3 | [] | no_license | //! General actions
#![allow(unused_imports)]
#![allow(dead_code)]
use chrono::*;
use std::{env,fs};
use std::time;
use std::fmt::Write;
use std::path::{Path,PathBuf};
use util;
use super::BillType;
use storage::{Storage,StorageDir,Storable,StorageResult};
use project::Project;
#[cfg(feature="document_export")]
u... | true |
26801c3acd5afe03a2f81242e2d991bf6fc3b719 | Rust | Strum355/lsif-lang-server | /src/reader/interner.rs | UTF-8 | 5,093 | 3.734375 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::marker::Sync;
use std::sync::{Arc, Mutex};
/// Interner converts strings into unique identifers. Submitting the same byte value to
/// the interner will result in the same identifier being produced. Each unique input is
/// guaranteed to have a unique output (no two inputs share... | true |
d04135f099f39bfa1d16d4b9fd189ce9e97ad955 | Rust | JesterOrNot/Rust-Playground | /functimer.rs | UTF-8 | 299 | 2.859375 | 3 | [] | no_license | fn main() {
timeFunction(&printer);
}
fn timeFunction(func: &dyn Fn()) {
let time1 = std::time::Instant::now();
func();
let time2 = std::time::Instant::now().duration_since(time1);
println!("{:?}", time2);
}
fn printer() {
for i in 0..100 {
println!("{}", i);
}
} | true |
fdbfd5baeee2106b2b6fc3e9f75a672229b84644 | Rust | IGBC/Cursive | /src/backend/mod.rs | UTF-8 | 1,176 | 2.71875 | 3 | [
"MIT"
] | permissive | use event;
use theme;
#[cfg(feature = "termion")]
mod termion;
#[cfg(feature = "bear-lib-terminal")]
mod blt;
#[cfg(any(feature = "ncurses", feature = "pancurses"))]
mod curses;
#[cfg(feature = "bear-lib-terminal")]
pub use self::blt::*;
#[cfg(any(feature = "ncurses", feature = "pancurses"))]
pub use self::curses::*;... | true |
c7fc2c95c9f9f77f9516ad734f36661fd188d607 | Rust | Agile-Llama/Ackermann | /ackermann.rs | UTF-8 | 1,727 | 3.453125 | 3 | [] | no_license | use std::collections::HashMap;
use std::cmp::max;
// Naive approach
fn ack(m: isize, n: isize) -> isize {
if m == 0 {
n + 1
} else if n == 0 {
ack(m - 1, 1)
} else {
ack(m - 1, ack(m, n - 1))
}
}
// More optimzed approach using a cache
fn ack_with_cache(m: u64, n: u64) -> u64 {... | true |
8f476860cad08c7542d752279426b2b2e2708f58 | Rust | mfarzamalam/Rust | /Rust_challenge/divisible/src/main.rs | UTF-8 | 587 | 3.171875 | 3 | [] | no_license | use read_input::prelude::*;
fn main() {
let number = input::<u32>()
.msg("Enter numerator : ")
.err("Please input positive integer")
.get();
let divisible = input::<u32>()
.msg("Enter denominator : ")
.err("Please input positive ... | true |
a5320d31e9d5b7833e7236c58c84865f0c51b007 | Rust | zhaoyao/rust-lab | /dns-server/src/packet/record_type.rs | UTF-8 | 1,199 | 2.890625 | 3 | [] | no_license | use super::error::*;
#[derive(Debug)]
pub enum RecordType {
A,
NS,
MD,
MF,
CNAME,
SOA,
MB,
MG,
MR,
NULL,
WKS,
PTR,
HINFO,
MINFO,
MX,
TXT,
AXFR,
MAILB,
MAILA,
Any
}
impl RecordType {
pub fn from_u16(i: u16) -... | true |
0feafd9f6d9c3cad0a2254ecfa847e5ee4146f30 | Rust | angelini/entity-query | /src/csv_parser.rs | UTF-8 | 5,337 | 2.6875 | 3 | [] | no_license | use csv;
use scoped_threadpool::Pool;
use std::collections::HashMap;
use ast::AstNode;
use cli::Join;
use data::{Datum, Db, Ref, Error};
use filter::Filter;
#[derive(Debug)]
pub struct CsvParser<'a> {
filename: &'a str,
entity: &'a str,
time: &'a str,
joins: &'a [Join],
}
impl<'a> CsvParser<'a> {
... | true |
032882d7e5d528a62e79500f5598b67488a2df6f | Rust | luqmana/cgmath-rs | /src/cgmath/vector.rs | UTF-8 | 11,652 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2013 The CGMath Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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 ... | true |
aa2133a0602ed220752e77bbc052bd17dd1913e8 | Rust | mac-l1/RemarkableFramebuffer | /rust-implementation/librustpad/src/ev.rs | UTF-8 | 1,309 | 2.578125 | 3 | [
"MIT"
] | permissive | use evdev;
use epoll;
use std;
pub trait EvdevHandler {
fn on_init(&mut self, name: String, device: &mut evdev::Device);
fn on_event(&mut self, device: &String, event: evdev::raw::input_event);
}
pub fn start_evdev<H: EvdevHandler>(path: String, handler: &mut H) {
let mut dev = evdev::Device::open(&path).... | true |
3bde34b786d73b595b467dc049cf9385c9d19032 | Rust | scottschroeder/storyestimate | /src/webapp/apikey.rs | UTF-8 | 2,398 | 3.25 | 3 | [] | no_license | use hyper::header::Basic;
use rocket::Outcome;
use rocket::http::Status;
use rocket::request::{self, FromRequest, Request};
use std::str::FromStr;
#[derive(Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct APIKey {
pub user_id: String,
pub user_key: Option<String>,
}
impl<'a, 'r> From... | true |
61759363a0b5888bd9ee9423e9cd5a7d9ebab4a3 | Rust | lutostag/pincers | /src/read.rs | UTF-8 | 1,110 | 2.859375 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use reqwest;
use std::collections::HashSet;
use std::fs::File;
use std::io::{self, Read};
lazy_static! {
static ref REMOTE_SCHEMES: HashSet<&'static str> = hashset! {
"https", "http", "ftps", "ftp"
};
}
pub fn is_remote(url: &str) -> bool {
if let Ok(url) = reqwest::Url::parse... | true |
d5ad882aa012e47f2a4a629d9c9b00c41c9215b8 | Rust | sdenel/tiny-static-web-server | /src/path_to_key.rs | UTF-8 | 1,707 | 3.40625 | 3 | [] | no_license | use std::collections::HashSet;
use std::sync::Mutex;
// TODO: this function should return the nearest existing index.html, not root
// TODO: Should the webapp behavior be activated with a flag? Currently, 404 requests are redirected to /index.html with no warning even for non webapps.
pub fn path_to_key(path: &str, kn... | true |
9bd150b9f60cc944de9853f6f305b8a9e3e2f106 | Rust | iamparnab/rusty-tree | /src/main.rs | UTF-8 | 1,261 | 3.375 | 3 | [] | no_license | fn main() {
for i in 1..4 {
draw_tree_segment(i);
}
draw_stem();
draw_base();
}
const HEIGHT: i32 = 12;
const WIDTH: i32 = 1 + (HEIGHT - 1) * 2; // AP
const STEM_WIDTH: i32 = HEIGHT / 3;
const STEM_HEIGHT: i32 = HEIGHT / 3;
const BASE_WIDTH: i32 = WIDTH * 2;
fn draw_tree_segment(level: i32) {
... | true |
1a7d103e7b9a678d8265489b1b92fb76d6a6420f | Rust | madskjeldgaard/nannou | /nannou_laser/src/ffi.rs | UTF-8 | 26,593 | 2.953125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Expose a C compatible interface.
use std::collections::HashMap;
use std::ffi::CString;
use std::fmt;
use std::io;
use std::os::raw;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
/// Allows for detecting and enumerating laser DACs on a network and establishing new streams of
/// communication wi... | true |
38620374925e4827eca77667c9eb13b68879f167 | Rust | colingluwa/Creditcoin-Consensus-Rust | /src/primitives/hash.rs | UTF-8 | 2,508 | 2.703125 | 3 | [] | no_license | macro_rules! impl_hash {
($name:ident, $size:expr) => {
#[derive(Clone, Copy)]
#[repr(transparent)]
pub struct $name {
inner: [u8; $size],
}
impl $name {
pub const SIZE: usize = $size;
pub const MIN: Self = Self {
inner: [u8::min_value(); $size],
};
pub con... | true |
1964af6946fc28cd363b40613e9e817d4617e63e | Rust | astral-sh/ruff | /crates/ruff_diagnostics/src/fix.rs | UTF-8 | 6,179 | 3.0625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | #[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use ruff_text_size::TextSize;
use crate::edit::Edit;
/// Indicates confidence in the correctness of a suggested fix.
#[derive(Default, Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize)... | true |
a1c5348ad2f062b5ba5bb6eace6e6851eaaa20eb | Rust | nbigaouette/advent_of_code_2018 | /day03/src/preparsed_ndarray.rs | UTF-8 | 4,454 | 2.9375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::cmp;
use std::collections::HashSet;
use crate::{parse_input, AoC, Day03SolutionPart1, Day03SolutionPart2, Input};
use ndarray::Array2;
type Grid = Array2<Vec<usize>>;
#[derive(Debug)]
pub struct Day03PreparsedNdarray {
input: Vec<Input>,
grid_size_width: usize,
grid_size_height: usize,
}
fn bu... | true |
2c09696fe56066e2f1721746d430a8ba43689692 | Rust | kinseywk/dicey | /src/lib.rs | UTF-8 | 3,685 | 3.6875 | 4 | [
"MIT"
] | permissive | #![allow(non_snake_case, non_upper_case_globals)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct DieRoll {
//Number of dice in the roll
pub quantity: usize,
//Number of die faces (6 = standard cubic die)
pub faces: usize,
//Net bonus and malus applied to the roll (e.g., 1d4+1 adds 1 to each roll)
pub ad... | true |
1cb91910631be47d9fbc78821be91beeb4cc5743 | Rust | Concordium/wasm-tools | /crates/wasm-encoder/src/code.rs | UTF-8 | 26,694 | 3.375 | 3 | [
"LLVM-exception",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
/// An encoder for the code section.
///
/// # Example
///
/// ```
/// use wasm_encoder::{
/// CodeSection, Function, FunctionSection, Instruction, Module,
/// TypeSection, ValType
/// };
///
/// let mut types = TypeSection::new();
/// types.function(vec![], vec![ValType::I32]);
///
/// let mut f... | true |
e590f9cc3bc61658b15ea7fcfedc93c7cce091ad | Rust | StackCrash/kryptos | /src/common/mod.rs | UTF-8 | 748 | 3.65625 | 4 | [
"MIT"
] | permissive | pub const ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
pub fn binary_to_char(bin: &str) -> Result<char, String> {
let binary = bin.as_bytes().iter().map(|b| b - 48).collect::<Vec<u8>>();
for bit in &binary {
if *bit > 1 {
return Err(String::from("Must be a valid binary number"));
... | true |
e95dd4fc71955bf79eb1ebf030173d27eb981356 | Rust | yuan-yuan-jia/Algorithms | /src/problems/backtracking/nqueens.rs | UTF-8 | 4,430 | 3.765625 | 4 | [
"MIT"
] | permissive | //! The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
//!
//! Given an integer n, return all distinct solutions to the n-queens puzzle.
//!
//! Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both ... | true |
efd3d047c44fa30c6f88b9de8f3cc4410a97acaf | Rust | arbanhossain/5dchess-tools | /lib/parse.rs | UTF-8 | 2,769 | 3.015625 | 3 | [
"MIT"
] | permissive | use super::game;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct GameRaw {
timelines: Vec<TimelineRaw>,
width: u8,
height: u8,
active_player: bool,
}
/// Represents an in-game timeline
#[derive(Debug, Deserialize)]
struct TimelineRaw {
index: f32,
states: Vec<Vec<usize>>,
widt... | true |
df05578e32242c25d9e7d2077794fc3a2da03bce | Rust | 0000marcell/LearnRust | /RH/aoc1/src/main.rs | UTF-8 | 1,188 | 3.90625 | 4 | [] | no_license | fn main() {
let instruction: Vec<String> = std::env::args().collect();
let instruction: &String = &instruction[1];
println!("{}", santa(instruction));
}
fn santa(instruction: &String) -> i32 {
// if '(' up else if ')' down
let mut floor: i32 = 0;
for paren in instruction.chars() {
prin... | true |
6a343d704b724f4e3b3d2632e8240d84080c4f8f | Rust | Godofh3ell/el_monitorro-1 | /src/db.rs | UTF-8 | 2,024 | 2.53125 | 3 | [
"MIT"
] | permissive | use chrono::prelude::*;
use chrono::{DateTime, Utc};
use diesel::pg::PgConnection;
use diesel::r2d2::{ConnectionManager, Pool, PooledConnection};
use dotenv::dotenv;
use once_cell::sync::OnceCell;
use std::env;
use tokio::sync::Semaphore;
use tokio::sync::SemaphorePermit;
pub mod feed_items;
pub mod feeds;
pub mod tel... | true |
916510d952a46ad8df39dc2a78aee51d1daedaac | Rust | potatosalad/leetcode | /src/n1122_relative_sort_array.rs | UTF-8 | 1,815 | 3.625 | 4 | [
"Apache-2.0"
] | permissive | /**
* [1122] Relative Sort Array
*
* Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.
* Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that don't appear in arr2 should be placed at the end of ... | true |
22e8a01c9a2474f92601c744aaa918083d913c1b | Rust | TerminalStudio/nativeshell | /nativeshell/src/shell/platform/win32/window_base.rs | UTF-8 | 18,540 | 2.53125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::{
cell::RefCell,
rc::{Rc, Weak},
};
use crate::{
shell::{
api_model::{
WindowFrame, WindowGeometry, WindowGeometryFlags, WindowGeometryRequest, WindowStyle,
},
IPoint, IRect, ISize, Point, Rect, Size,
},
util::OkLog,
};
use super::{
all_bindings::*,... | true |
8e91db882281095b6715f97f1a64202981b013ce | Rust | DrewKestell/ForayRust | /src/game_timer.rs | UTF-8 | 3,022 | 2.625 | 3 | [] | no_license | use winapi::um::profileapi::QueryPerformanceCounter;
use winapi::shared::ntdef::LARGE_INTEGER;
use std::mem::zeroed;
pub struct GameTimer {
seconds_per_count: f64,
delta_time: f64,
base_time: i64,
paused_time: i64,
stop_time: i64,
previous_time: i64,
current_time: i64,
stopped: bool
}
... | true |
c3337f1f1473accd16e0a194ec276ef69b78cc85 | Rust | gloriousfutureio/hermitdb | /src/memory_log.rs | UTF-8 | 2,578 | 2.796875 | 3 | [] | no_license | use std::collections::BTreeMap;
use std::fmt::Debug;
use crdts::{CmRDT, Actor};
use log::{TaggedOp, LogReplicable};
use error::Result;
#[derive(Debug, Clone)]
pub struct Log<A: Actor, C: Debug + CmRDT> {
actor: A,
logs: BTreeMap<A, (u64, Vec<C::Op>)>
}
#[derive(Debug, Clone)]
pub struct Op<A: Actor, C: Debug... | true |
3b6a8bd239de8e214574da7f3d0eb3faedfd1d68 | Rust | AlberErre/rust-experiments | /fizz-buzz/src/main.rs | UTF-8 | 573 | 4.15625 | 4 | [] | no_license | fn main() {
println!("Hello, Fizz Buzz!");
const NUMBER: i32 = 35;
let fizz_buzz_result = fizz_buzz(NUMBER);
println!("Fizz Buzz for number {} is: {:?}", NUMBER, fizz_buzz_result);
}
fn fizz_buzz(number: i32) -> Vec<String> {
//NOTE: we start at 1 to avoid handling another case with 0
let numbers = 1..=... | true |
00813770f2c8333ff4b3a5282971ad36f1644f50 | Rust | Dongitestil/PL_2_Rust | /server/src/main.rs | UTF-8 | 1,569 | 2.8125 | 3 | [] | no_license | use std::thread;
use std::net::{TcpListener, TcpStream, Shutdown};
use std::io::{Read, Write};
use std::str::from_utf8;
mod protector;
use protector::*;
fn handle_client(mut stream: TcpStream) {
let mut hash = [0 as u8; 5];
let mut key = [0 as u8; 10];
let mut mes = [0 as u8;50];
while match stream.re... | true |
ce1070567ee74acc90f0f31ff337228e172fe016 | Rust | evelynmitchell/stateright.github.io | /rs-src/getting-started/src/main.rs | UTF-8 | 3,202 | 2.53125 | 3 | [] | no_license | /* ANCHOR: all */
use stateright::actor::{*, register::*};
use std::borrow::Cow; // COW == clone-on-write
use std::net::{SocketAddrV4, Ipv4Addr};
// ANCHOR: actor
type RequestId = u64;
#[derive(Clone)]
struct ServerActor;
impl Actor for ServerActor {
type Msg = RegisterMsg<RequestId, char, ()>;
type State = ... | true |
539a574f3851eefc209d9506b0cbe9999a5ed8f8 | Rust | unpluggedcoder/memory-profiler | /integration-tests/test-programs/return-opt-u128.rs | UTF-8 | 401 | 2.640625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | const CONSTANT: u128 = 0xaaaaaaaaaaaaaaaa5555555555555555;
extern {
fn malloc( size: usize ) -> *const u8;
fn abort() -> !;
}
#[inline(never)]
#[no_mangle]
fn func_1() -> Option< u128 > {
unsafe { malloc( 123456 ); }
Some( CONSTANT )
}
#[inline(never)]
#[no_mangle]
fn func_2() {
if func_1() != So... | true |
d24d4db001063f5d1473e134935fe0021b6b5b70 | Rust | kavirajk/pgroup | /src/lib.rs | UTF-8 | 2,373 | 2.734375 | 3 | [] | no_license | use bincode;
use crossbeam_channel::Receiver;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::net::{SocketAddr, ToSocketAddrs, UdpSocket};
#[derive(Debug)]
struct Group {
me: Node,
peers: HashMap<String, Node>,
// ack for specific ping's seq_no.
ack_handlers: HashMap<u32, ... | true |
f9a2594077419e7a188555f362be2af0e36c6b1a | Rust | quinnnned/rust-mancala | /src/main.rs | UTF-8 | 9,671 | 3.09375 | 3 | [] | no_license | use std::fmt;
#[derive(Copy, Clone, PartialEq, Debug)]
struct Player {
pits: [i8; 6],
score: i8,
}
impl Player {
fn get_moves(&self) -> Vec<usize> {
(0..6)
.into_iter()
.filter(|&i| self.pits[i] != 0)
.collect::<Vec<_>>()
}
}
#[derive(Copy, Clone, PartialEq... | true |
ca8df953a610e9ef5696a063e7b52596cd83288f | Rust | blackjack/algorithms_pt1 | /rust/week01_quickmerge/src/percolation.rs | UTF-8 | 3,263 | 3.3125 | 3 | [] | no_license | use std::fmt::{Display, Formatter, Error};
use quickmerge::QuickMerge;
#[allow(dead_code)]
pub struct Percolation {
x: usize,
y: usize,
pub last: usize,
data: QuickMerge,
}
impl Percolation {
pub fn new(x: usize, y: usize) -> Percolation {
let mut p = Percolation {
x: x,
... | true |
fe45abe02d8c82057cab67c3d57a52c0db4ac9a4 | Rust | KaiseiYokoyama/iiif_awesome_sample_viewer | /src/iif_manifest.rs | UTF-8 | 1,711 | 2.75 | 3 | [] | no_license | #[derive(Deserialize, Debug, Serialize)]
pub struct Manifest {
#[serde(rename = "@context")]
context: String,
#[serde(rename = "@id")]
id: String,
#[serde(rename = "@type")]
type_: String,
license: String,
attribution: String,
description: String,
label: String,
sequences: Ve... | true |
157578cc19a1950de93f8033afdf0c4e222d9af6 | Rust | KallDrexx/r8 | /r8-core/src/execution.rs | UTF-8 | 51,703 | 2.90625 | 3 | [] | no_license | use custom_error::custom_error;
use crate::{Hardware, Instruction, Register};
use crate::hardware::{STACK_SIZE, MEMORY_SIZE, FRAMEBUFFER_HEIGHT, FRAMEBUFFER_WIDTH};
custom_error!{pub ExecutionError
InvalidRegisterForInstruction {instruction:Instruction} = "Invalid register was used for instruction: {instruction}",... | true |
b02f18df40f0853593c61d4e526fd341a4b168d3 | Rust | kalaninja/data-structures | /week2_priority_queues_and_disjoint_sets/2_job_queue/rust/src/main.rs | UTF-8 | 3,274 | 3.5 | 4 | [] | no_license | use std::io::stdin;
use std::fmt::{self, Display, Formatter};
type ThreadId = u32;
type ThreadTime = u64;
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
struct Thread {
time_idle: ThreadTime,
thread_id: ThreadId,
}
impl Thread {
fn new(thread_id: ThreadId, time_idle: ThreadTime) -> Self {
... | true |
ef1331be181b9020769930de3c4dcfc1ff3f1abd | Rust | MwlLj/rust-p2p | /exchange_service/src/enums/nat.rs | UTF-8 | 555 | 3.46875 | 3 | [] | no_license | use std::cmp::PartialEq;
#[derive(PartialEq, Debug, Clone)]
pub enum Nat {
Nat1 = 1,
Nat2 = 2,
Nat3 = 3,
Nat4 = 4,
NotNat4 = 5
}
impl std::convert::From<u8> for Nat {
fn from(item: u8) -> Self {
match item {
1 => Nat::Nat1,
2 => Nat::Nat2,
3 => Nat::... | true |
c18e0eec7aa060fe97fdb6dc292259a5da9e8088 | Rust | leon2k2k2k/xi_pl | /xi-backends/py_backend/py_prim.rs | UTF-8 | 4,355 | 2.515625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use std::collections::BTreeMap;
use xi_core::judgment::{Judgment, Primitive};
use xi_uuid::VarUuid;
use crate::py_backend::py_output::{
make_var_name, promise_resolve, to_py_ident, to_py_num, to_py_str, Expr,
};
use super::py_output::{to_py_app, to_py_ident1};
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum PyP... | true |
8be91f8a6314d1ee36682bf93fca8b5573a1dafd | Rust | SuperiorJT/mr-cd-projekt-red | /src/audio/receiver.rs | UTF-8 | 3,352 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::{
collections::HashMap,
sync::Arc,
sync::RwLock,
time::{Instant, SystemTime, UNIX_EPOCH},
};
use config::{Config, File};
use serde::Deserialize;
use serenity::model::id::UserId;
use serenity::voice::AudioReceiver;
use super::buffer::DiscordAudioBuffer;
use super::DiscordAudioPacket;
#[deriv... | true |
e1257f2999b0a1a7a626edd92e68b001cded0b65 | Rust | tonmanna/RustLearningFollowBookBeginer | /chapter2/src/tuples_sample3.rs | UTF-8 | 159 | 2.796875 | 3 | [] | no_license | #[derive(Debug)]
struct Matrix(f32, f32, f32, f32);
pub fn tuples_sample_struct() {
let matrix = Matrix(1.1,1.2,2.1,2.2);
println!("{:?}", matrix);
}
| true |
515021a225e189e61d7eab324be1137cab06e59b | Rust | shunty-gh/AdventOfCode2017 | /day12/aoc2017-day12.rs | UTF-8 | 2,689 | 3.203125 | 3 | [] | no_license | use std::io::prelude::*;
use std::fmt;
use std::io::BufReader;
use std::fs::File;
use std::path::Path;
use std::env;
/// Advent of Code 2017
/// Day 12
// compile with, for example:
// $> rustc -g --out-dir ./bin aoc2017-day12.rs
// or (providing the 'path' is set correctly in Cargo.toml):
// $> cargo build
... | true |
f5dff23875161835aebdb3f0e6a7dc725d3facee | Rust | KwinnerChen/rust_repo | /workspace_learning/complex/src/lib.rs | UTF-8 | 1,850 | 3.921875 | 4 | [] | no_license | #![allow(dead_code)]
use std::{fmt::{Display, Formatter, Result}, ops::Add, write};
/// 表示复数结构
#[derive(Debug, Default, PartialEq, Clone, Copy)]
struct Complex<T> {
re: T,
im: T,
}
impl<T: Add<Output=T>> Complex<T> {
/// 创建一个复数结构
/// # Example
/// ```
/// use complex::Complex;
/// let co... | true |
c2115a876151368aae7cb2232eb1b815a0990de5 | Rust | peterhj/libcpu_topo | /src/lib.rs | UTF-8 | 2,874 | 2.921875 | 3 | [] | no_license | extern crate libc;
use libc::*;
//use std::collections::{HashSet};
use std::fs::{File};
use std::io::{BufRead, BufReader};
use std::mem::{size_of_val, uninitialized};
use std::path::{PathBuf};
//use std::process::{Command};
/*pub enum CpuLevel {
Processor,
Core,
Thread,
}*/
#[cfg(target_os = "linux")]
pub fn s... | true |
fb51b6683054c4122e05bd60fe5ede509a3d103b | Rust | sbeckeriv/dex | /src/app/mod.rs | UTF-8 | 3,149 | 3.3125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod error;
mod pokemon;
mod style;
use error::Error;
use iced::{
button, Alignment, Application, Button, Column, Command, Container, Element, Length, Text,
};
use pokemon::Pokemon;
#[derive(Debug)]
pub enum Pokedex {
Loading,
Loaded {
pokemon: Pokemon,
search: button::State,
},
Err... | true |
4f2ae26f3aacf1d4e12313867cd19177ef29110b | Rust | pitcer/brucket | /c-generator/src/syntax/c_struct.rs | UTF-8 | 3,141 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::generator::{GeneratorError, GeneratorResult, GeneratorState, IndentedGenerator};
use crate::syntax::instruction::VariableDeclaration;
use derive_more::Constructor;
#[derive(Debug, PartialEq, Constructor)]
pub struct CStruct {
name: String,
fields: Fields,
}
impl IndentedGenerator for CStruct {
... | true |
3ccef59cbe0cd896e9356a4fcf1d782c11ab34c2 | Rust | naamancurtis/rust_data_structures_and_algorithms | /sorting/src/insertion_sort.rs | UTF-8 | 2,439 | 4.28125 | 4 | [
"MIT"
] | permissive | //! # Insertion Sort
//!
//! Is a simple sorting algorithm that builds the sorted array one element at a time by maintaining a sorted
//! sub-array into which elements are inserted.
//!
//! - Time Complexity: **O**(n<sup>2</sup>)
//! - Space Complexity: **O**( _log_(n) )
use std::cmp::Ordering;
/// Shorthand helper f... | true |
75e6ec41d57b2b916e9b24178f790cd732015af3 | Rust | Iwancof/SECR | /riscv-rust/src/terminal.rs | UTF-8 | 747 | 3.265625 | 3 | [
"MIT"
] | permissive | /// Emulates terminal. It holds input/output data in buffer
/// transferred to/from `Emulator`.
pub trait Terminal {
/// Puts an output ascii byte data to output buffer.
/// The data is expected to be read by user program via `get_output()`
/// and be displayed to user.
fn put_byte(&mut self, value: u8);
/// Gets... | true |
722a7a33904b12f0f16d1119e7b861b533edc412 | Rust | sirkibsirkib/middleman | /src/structs.rs | UTF-8 | 17,075 | 3.171875 | 3 | [
"MIT"
] | permissive | use super::*;
use mio::{
*,
event::Evented,
};
use ::std::{
io,
io::{
Read,
Write,
ErrorKind,
},
time,
};
#[derive(Debug)]
pub struct Middleman {
stream: mio::net::TcpStream,
buf: Vec<u8>,
buf_occupancy: usize,
payload_bytes: Option<u32>,
}
impl Middl... | true |
534738c930cb9798e38a845fb74c54ebbf1b5704 | Rust | gengteng/impl-leetcode-for-rust | /src/three_sum.rs | UTF-8 | 1,618 | 3.859375 | 4 | [
"MIT"
] | permissive | /// # 15. 3Sum
///
/// Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
///
/// # Note:
///
/// The solution set must not contain duplicate triplets.
///
/// # Example:
///
/// Given array nums = [-1, 0, 1, ... | true |
025a08ef28a850e3a7ede38d3f00a1b48980fc47 | Rust | rusty-ecma/resast | /src/pat.rs | UTF-8 | 2,954 | 3.265625 | 3 | [] | no_license | use crate::expr::{Expr, Prop};
use crate::{Ident, IntoAllocated};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// All of the different ways you can declare an identifier
/// and/or value
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
pub enum Pat<T... | true |
2eb8609523eddcfcf9aaec109460477cbf7759ea | Rust | dan-sf/advent_of_code | /2018/day2/solution2.rs | UTF-8 | 1,131 | 3.21875 | 3 | [] | no_license | use std::fs;
use std::io;
use std::io::BufRead;
fn get_common_chars(box_one: &String, box_two: &String) -> String {
box_one.chars()
.zip(box_two.chars())
.filter(|ch| ch.0 == ch.1)
.map(|ch| ch.0)
.collect()
}
fn find_common_id() -> Option<String> {
let input = fs::File::open("... | true |
e13c33e5a575f4ab435f01914a81c74b1033ae9a | Rust | xiaolang315/json-schema-to-c | /src/main.rs | UTF-8 | 1,037 | 2.90625 | 3 | [
"MIT"
] | permissive | // use std::process::Command;
use std::fs::read_to_string;
use std::fs::write;
use serde_json::from_str;
use serde_json::{Value};
fn make_str(body:String)->String {
let head = String::from(r#"
#ifdef __cplusplus
extern "C" {
#endif "#);
let tail = String::from(r#"
#ifdef __cplusplus
}
#endif
"#);
return ... | true |
27c9d7ded1cb3ebf884c97949751989c6f27c507 | Rust | rudib/axess | /axess_gui/src/windows/keyboard.rs | UTF-8 | 6,231 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::{borrow::Cow, fmt::Display};
use axess_core::payload::{DeviceState, UiPayload};
use packed_struct::PrimitiveEnum;
use crate::config::AxessConfiguration;
#[derive(Debug, Copy, Clone)]
pub enum UiEvent {
KeyDown(usize, u32),
KeyUp(usize, u32)
}
#[derive(Default, Debug)]
pub struct KeyboardState {
... | true |
d8f7063a021efc499a4e1676623450e539b4a860 | Rust | simon-whitehead/tetrs | /src/game/scoring/score.rs | UTF-8 | 1,983 | 2.859375 | 3 | [
"MIT"
] | permissive | use piston_window::{Graphics, Transformed};
use piston_window::character::CharacterCache;
use game::config::Config;
use game::render_options::RenderOptions;
pub struct Score {
score: u32,
location: (f64, f64),
color: [f32; 4],
font_size: u32,
}
impl Score {
pub fn new(config: &Config) -> Score {
... | true |
fe91a6ee5a258a2447a117eae677decb355d72c6 | Rust | enso-org/enso | /lib/rust/ensogl/component/text/src/buffer/rope/formatted.rs | UTF-8 | 2,010 | 3.375 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! A rope (efficient text representation) with formatting information.
use crate::prelude::*;
use crate::buffer::formatting::Formatting;
use crate::buffer::formatting::FormattingCell;
use enso_text::Rope;
use enso_text::RopeCell;
// =====================
// === FormattedRope ===
// =====================
/// A r... | true |
3df1d52edb3fc2c5ab768b76f40b288745bc7613 | Rust | rust-cc/rcmath | /src/utils.rs | UTF-8 | 576 | 3.265625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[derive(Debug)]
pub struct BitIterator<E> {
t: E,
n: usize,
}
impl<E: AsRef<[u64]>> BitIterator<E> {
pub fn new(t: E) -> Self {
let n = t.as_ref().len() * 64;
BitIterator { t, n }
}
}
impl<E: AsRef<[u64]>> Iterator for BitIterator<E> {
type Item = bool;
fn next(&mut self) ->... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.