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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f8e0ff2e35c17c117eee7bdafd8745142247d6bd | Rust | jgust/advent-of-code-2018 | /day2/src/bin/d2p2.rs | UTF-8 | 1,267 | 3.5 | 4 | [
"MIT"
] | permissive | use day2::{hamming_distance, INPUT};
use std::collections::HashSet;
fn main() {
let words: Vec<&str> = INPUT.lines().map(|line| line.trim()).collect();
let mut candidates = HashSet::new();
for w1 in &words {
let found: HashSet<&str> = words
.iter()
.filter(|w2| hamming_dist... | true |
e1ea72419d1c006a54ce2ed17707e35cc2ec3f75 | Rust | tokio-rs/tokio | /tokio/src/runtime/runtime.rs | UTF-8 | 17,214 | 3.296875 | 3 | [
"MIT"
] | permissive | use crate::runtime::blocking::BlockingPool;
use crate::runtime::scheduler::CurrentThread;
use crate::runtime::{context, EnterGuard, Handle};
use crate::task::JoinHandle;
use std::future::Future;
use std::time::Duration;
cfg_rt_multi_thread! {
use crate::runtime::Builder;
use crate::runtime::scheduler::MultiTh... | true |
400263a4c9dfeb4178156627b713a2a9054baff4 | Rust | iCodeIN/colo | /src/color/parse.rs | UTF-8 | 9,676 | 3.046875 | 3 | [
"MIT"
] | permissive | use anyhow::anyhow;
use std::{cmp::Ordering, num::ParseFloatError};
use thiserror::Error;
use super::{hex, html, Color, ColorFormat, ColorSpace};
use crate::{
terminal::{stdin, ColorPicker},
State,
};
use ParseError::*;
/// Error caused by parsing a number in a certain color space.
///
/// This error can occ... | true |
d4f5d03312f890fb54c9090f1c93b331cb91d2b5 | Rust | clucompany/cluConcatBytes | /examples/raw.rs | UTF-8 | 713 | 3 | 3 | [
"Apache-2.0"
] | permissive |
#![feature(plugin)]
#![plugin(cluConcatBytes)]
fn main() {
let c_str = concat_bytes!(@"cluWorld");
//[u8; 8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
assert_eq!(&c_str, b"cluWorld");
let c_str2 = concat_bytes!(@"cluWorld");
//[u8; 8]
//array: [99, 108, 117, 87, 111, 114, 108, 100], len: 8
a... | true |
f7f4df005c6eb469faffb9787cd652b98067e0c9 | Rust | snow2flying/drogue-tls | /src/tls_connection.rs | UTF-8 | 7,882 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::alert::*;
use crate::connection::*;
use crate::handshake::ServerHandshake;
use crate::key_schedule::KeySchedule;
use crate::record::{ClientRecord, ServerRecord};
use crate::{
traits::{AsyncRead, AsyncWrite},
TlsError,
};
use rand_core::{CryptoRng, RngCore};
use crate::application_data::ApplicationDa... | true |
6d17d6e6786d96e1081ce2bce52e254c1907c14b | Rust | herou/Rust-Crash-Course | /src/var.rs | UTF-8 | 415 | 3.859375 | 4 | [
"Apache-2.0"
] | permissive | pub fn run(){
let name = "Elio";
let mut age = 37;
println!("My name is {} and I am {}", name, age);
age = 38;
println!("My name is {} and I am {}", name, age);
// Define constant
const ID: i32 = 1;
println!("ID: {}", ID);
// Assign multiple vars
let (name, last_name, age) = ("... | true |
cb87e2f8261315c38964d8822acc8a4fab3d6c93 | Rust | clap-rs/clap | /tests/derive_ui/clap_empty_attr.rs | UTF-8 | 214 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use clap::Parser;
#[derive(Parser, Debug)]
#[command]
struct Opt {}
#[derive(Parser, Debug)]
struct Opt1 {
#[arg = "short"]
foo: u32,
}
fn main() {
let opt = Opt::parse();
println!("{opt:?}");
}
| true |
7e28dfa405282f839c5f183f2b24e51d9d482dea | Rust | wbprice/perfect-good-bad-guessing-game | /src/main.rs | UTF-8 | 4,788 | 3.40625 | 3 | [
"MIT"
] | permissive | use structopt::StructOpt;
use read_input::prelude::*;
use rand::Rng;
#[derive(Debug, StructOpt)]
struct Cli {
#[structopt(short = "d", long = "digit", default_value="3")]
/// Sets the number of digits used for the secret number
digit: i8,
#[structopt(long = "debug")]
/// Turns on debug logging
... | true |
a4baab0aaec63b9cdccdee2386b41f82036206cd | Rust | slelaron/rtiow | /src/image.rs | UTF-8 | 1,962 | 3.203125 | 3 | [] | no_license | use rayon::prelude::*;
use std::io::{Result, Write};
use std::marker::{Send, Sync};
use std::ops::{Index, IndexMut};
#[derive(Clone, Copy)]
pub struct Color {
pub red: u8,
pub green: u8,
pub blue: u8,
}
pub struct Image {
pixels: Vec<Color>,
width: u32,
height: u32,
}
impl Image {
pub fn ... | true |
506e149be3c3c30781d4165869627a80222dced0 | Rust | DoumanAsh/actix-http | /src/ws/client/mod.rs | UTF-8 | 1,019 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod connect;
mod error;
mod service;
pub use self::connect::Connect;
pub use self::error::ClientError;
pub use self::service::{Client, DefaultClient};
#[derive(PartialEq, Hash, Debug, Clone, Copy)]
pub(crate) enum Protocol {
Http,
Https,
Ws,
Wss,
}
impl Protocol {
fn from(s: &str) -> Option<Proto... | true |
0362b7a7da4709e0f704b7bbb354e2de04b19d38 | Rust | anhdungle93/rust_tutorial | /functions/src/main.rs | UTF-8 | 235 | 3.296875 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
another_function();
another_function_2(3);
}
fn another_function() {
println!("Another function.");
}
fn another_function_2(x: i32) {
println!("The value of x is: {}", x)
} | true |
3ce12cd5adf6ce4ed72a7a1452d92ddcb6d742da | Rust | jutuon/pc-ps2-controller | /src/device/command_queue.rs | UTF-8 | 13,242 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::io::SendToDevice;
use super::keyboard::driver::{
DelayMilliseconds, KeyboardScancodeSetting, RateValue, SetAllKeys, SetKeyType,
};
use super::keyboard::raw::{CommandReturnData, FromKeyboard};
use arraydeque::{Array, ArrayDeque, CapacityError, Saturating};
#[derive(Debug)]
pub struct CommandQueue<T: Arr... | true |
041a232c7987dc01689318760129fc1f5a2d9020 | Rust | quebin31/transactions | /src/error.rs | UTF-8 | 541 | 2.984375 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
use std::fmt::{
Display,
Formatter
};
#[derive(Debug)]
pub struct ConcurrencyError {
message: String
}
impl ConcurrencyError {
pub fn new(msg: &str) -> Self {
ConcurrencyError { message: String::from(msg) }
}
}
impl Error for ConcurrencyError {
fn description(&se... | true |
08410cb452664dfbebabe89592ad0ca3676bf978 | Rust | Hilldrupca/LeetCode | /rust/Problems/Easy/two_sum/src/main.rs | UTF-8 | 1,393 | 3.859375 | 4 | [] | no_license | use std::collections::HashMap;
struct Solution {}
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
// Returns the indices of the two numbers that sum to the target value.
// Assumed that each input has exactly one solution.
//
// Constraints:
// ... | true |
d9e26164f7b3bf29d6ec18895ac6b47623986d1b | Rust | GaloisInc/crucible | /crux-mir/test/conc_eval/ops/deref3.rs | UTF-8 | 694 | 3.0625 | 3 | [
"BSD-3-Clause"
] | permissive | #![cfg_attr(not(with_main), no_std)]
// Method call via `DerefMut::deref_mut`
extern crate core;
use core::ops::{Deref, DerefMut};
struct MyPtr<T>(T);
impl<T> Deref for MyPtr<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
impl<T> DerefMut for MyPtr<T> {
fn deref_mut(&mut self) -> &... | true |
c21f4fed216e0ae6a25a79aa87efeebe6c9e3b6f | Rust | gbip/stm32f429x | /src/otg_fs_global/fs_gnptxsts/mod.rs | UTF-8 | 2,042 | 2.640625 | 3 | [
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::FsGnptxsts {
#[doc = r" Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct Nptxf... | true |
91e67c68541cc92f009f42d745009eef4398bfa4 | Rust | Axect/Peroxide | /src/numerical/spline.rs | UTF-8 | 24,178 | 3.453125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Spline interpolations
//!
//! # Available splines
//!
//! * Cubic spline
//! * Cubic Hermite spline
//!
//! # `Spline` trait
//!
//! ## Methods
//!
//! Let `T: Into<f64> + Copy`
//! * `fn eval<T>(&self, x: T) -> f64` : Evaluate the spline at x
//! * `fn eval_vec<T>(&self, v: &[T]) -> Vec<f64>` : Evaluate splin... | true |
88b50d7ae5b05b2af3965e5aae974183f58f864b | Rust | makepad/makepad | /draw/vector/bender/tessellator/src/monotone_tessellator.rs | UTF-8 | 3,987 | 3.046875 | 3 | [
"MIT"
] | permissive | use bender_arena::Arena;
use bender_geometry::mesh::Callbacks;
use bender_geometry::{LineSegment, Point};
use std::cmp::Ordering;
#[derive(Clone, Debug, Default)]
pub struct MonotoneTessellator {
monotone_polygon_pool: Vec<MonotonePolygon>,
monotone_polygon_arena: Arena<MonotonePolygon>,
}
impl MonotoneTessel... | true |
b57ac65245e5eb1712edc5d7a4f65b57fb1e3153 | Rust | keithnoguchi/rustos | /examples/post11.rs | UTF-8 | 1,710 | 2.75 | 3 | [] | no_license | //! Writing an [OS] in Rust
//!
//! [os]: https://os.phil-opp.com
#![no_std]
#![no_main]
#![feature(custom_test_frameworks)]
#![test_runner(rustos::test_runner)]
#![reexport_test_harness_main = "test_main"]
extern crate alloc;
extern crate bootloader;
extern crate rustos;
extern crate x86_64;
use alloc::{boxed::Box, rc... | true |
54362a56bf19f6f34f28e86e604b821c095a9863 | Rust | qfizik/quizx | /quizx/src/vec_graph.rs | UTF-8 | 12,555 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | // QuiZX - Rust library for quantum circuit rewriting and optimisation
// using the ZX-calculus
// Copyright (C) 2021 - Aleks Kissinger
//
// 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 Licens... | true |
6d61fed75c4bf4b591f8de9d5646e3712e39d51e | Rust | TovarishFin/eth-fabulous | /src/main.rs | UTF-8 | 2,254 | 3.1875 | 3 | [] | no_license | use clap::{App, Arg};
use num_cpus;
use regex::Regex;
fn validate_hexadecimal(arg: String) -> Result<(), String> {
let rgx = Regex::new("^[0-9a-fA-F]+$").unwrap();
if rgx.is_match(&arg) {
Ok(())
} else {
Err(String::from("search param must be hexadecimal"))
}
}
fn validate_processors(... | true |
2fd28ca43a9d33c419b29615df4fcbb91f44cb7d | Rust | ptgamr/learn-rust | /ownership.rs | UTF-8 | 701 | 3.96875 | 4 | [] | no_license | fn main() {
let s = String::from("hello"); // s comes into scope
takes_ownership(s); // s's value moves into the function
// ... and no longer valid here
let x = 5; // x comes into scope
makes_copy(x); // x would m... | true |
bee8ec417127ed3cad3ba724add83b3ef34902b3 | Rust | kamalmarhubi/futures-rs | /src/util.rs | UTF-8 | 515 | 2.515625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::panic::{self, AssertUnwindSafe};
use {PollResult, PollError};
// TODO: reexport this?
struct ReuseFuture;
pub fn recover<F, R, E>(f: F) -> PollResult<R, E>
where F: FnOnce() -> R + Send + 'static
{
panic::catch_unwind(AssertUnwindSafe(f)).map_err(PollError::Panicked)
}
pub fn reused<E>() -> PollErr... | true |
71a7e149fdded647b9d7781dcb36050879183985 | Rust | thecristidima/AdventOfRust | /2020/src/day-13/main.rs | UTF-8 | 2,592 | 3.328125 | 3 | [
"MIT"
] | permissive | use modinverse::modinverse;
use utils::files::read_lines_iter;
fn part_one(timestamp: u64, buses: &Vec<String>) -> u64 {
let part_one_buses = buses
.iter()
.filter(|s| **s != "x")
.map(|s| s.parse::<u64>().unwrap())
.collect::<Vec<_>>();
let mut time_to_wait = u64::MAX;
le... | true |
caeb29e35ba3f5aadffd68214b981073e13b8e1d | Rust | SanderHageman/advent_of_code_2020 | /src/day07.rs | UTF-8 | 3,102 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
type TParsed = HashMap<String, TParsedSub>;
type TParsedSub = Rule;
pub fn day(input: String) -> (usize, usize) {
let parsed_input = parse(&input);
(part_1(&parsed_input), part_2(&parsed_input))
}
fn part_1(input: &TParsed) -> usize {
fn has_shiny<'a>((name, rule): &'a (&St... | true |
f3932ed2e0ef498ec712ae07633c94ba2424d7aa | Rust | Tsuguri/PSW | /keiro/src/Paths/mod.rs | UTF-8 | 34,099 | 2.75 | 3 | [] | no_license | use Data;
use Math::Vector::Vector2;
use Math::Vector::Vector3;
fn move_tool(
result: &mut Vec<Vector3<f32>>,
j: i32,
previous: i32,
y: &mut i32,
h: f32,
g: &Fn(i32, i32) -> f32,
floorOffset: f32,
up: &mut bool,
yToWorld: &Fn(i32) -> f32,
xToWorld: &Fn(i32) -> f32,
height: i... | true |
bce98dae7b781a8d88ebd050cd9270ebe8bc39a3 | Rust | Keksoj/suivre_le_rust_book | /04_Ownership/borrowing/src/main.rs | UTF-8 | 1,387 | 3.625 | 4 | [] | no_license | // 2019-01-01
// On veut à nouveau calculer la longueur d'une chaine de caractères.
// Seulement, on va chercher à ne pas prendre l'ownership de la variable.
// Pour agrémenter le game, j'ai rajouté une invite à l'utilisateur.
// importer la bibliothèque entrée/sortie
use std::io;
fn main() {
println!("Tap... | true |
4d59e4d0100ea64b93af5fba5c9c6d9a6905e0e0 | Rust | emanon-was/wip-rust | /src/pound/cfg/service/session.rs | UTF-8 | 1,102 | 3.109375 | 3 | [] | no_license | use pound::cfg::Block;
use pound::fmt::Decode;
use pound::fmt::Indent;
#[allow(dead_code)]
pub enum Session {
Kind(SessionKind),
ID(String),
TTL(i32),
}
#[allow(dead_code)]
pub enum SessionKind {
IP,
Basic,
URL,
Params,
Cookie,
Header,
}
impl Decode for SessionKind {
fn decode... | true |
fcc7176e8e8fe9af1b803dca76a80da5a30db0d3 | Rust | plzhang4321/os_summer | /LearningRust/src/sword_09.rs | UTF-8 | 909 | 3.25 | 3 | [] | no_license | #[derive(Default)]
struct CQueue {
q: Vec<i32>,
k: Vec<i32>,
}
impl CQueue {
fn new() -> Self {
Default::default()
}
fn append_tail(&mut self, value: i32) {
self.q.push(value);
}
fn delete_head(&mut self) -> i32 {
match self.k.pop() {
Some(n) => n,
... | true |
d089f84a6aa5c4e91575207133bf29c1bae267d4 | Rust | truelossless/crocolang | /src/crocoi/node/multiplicate_node.rs | UTF-8 | 771 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::{
ast::node::MultiplicateNode,
crocoi::{utils::get_value, CrocoiNode, ICodegen, INodeResult, ISymbol},
};
use crate::error::CrocoError;
use crate::token::LiteralEnum::*;
impl CrocoiNode for MultiplicateNode {
#[cfg(feature = "crocoi")]
fn crocoi(&mut self, codegen: &mut ICodegen) -> Result<... | true |
35256163290e982f40a284fe6adc0cc8de111645 | Rust | nficca/tubes | /tests/lib.rs | UTF-8 | 1,591 | 2.96875 | 3 | [] | no_license | extern crate tubes;
use std::thread;
use tubes::{Payload, Tubes};
#[test]
fn it_works() {
let mut tubes = Tubes::new().add_tube("foo").add_tube("bar");
let foo_receiver = tubes.subscribe("foo").unwrap();
let foo_receiver2 = tubes.subscribe("foo").unwrap();
let bar_receiver = tubes.subscribe("bar").un... | true |
334cf5381d59328f8de0ef9da2e3017e0ad59614 | Rust | ivfranco/notes | /Dragon_Book/chapter_9/data_flow/src/utils.rs | UTF-8 | 491 | 3.109375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use std::hash::Hash;
pub fn sorted<'a, I, T: 'a>(set: I) -> Vec<T>
where
I: IntoIterator<Item = T>,
T: Ord + Hash + Clone,
{
let mut sorted: Vec<_> = set.into_iter().collect();
sorted.sort();
sorted
}
pub fn filter_indices<'a, I: 'a, T, F: 'a>(iter: I, p: F) -> impl Iterator<Item = usize> + 'a
whe... | true |
fa7cf0ffa11f74235b6d556a5e11ddd0911577d5 | Rust | desto-git/rust-test | /src/entity.rs | UTF-8 | 522 | 3.3125 | 3 | [
"Unlicense"
] | permissive | use types::Coordinate;
use traits::Drawable;
pub struct Entity {
position: Coordinate<u8>,
sprite: Coordinate<u8>,
}
impl Entity {
pub fn new( position: Coordinate<u8>, sprite: Coordinate<u8> ) -> Entity {
Entity {
position: position,
sprite: sprite,
}
}
pub fn set_position( &mut self, position: Coord... | true |
e935376a810900dade48477fef3b403c9598ab28 | Rust | eupn/axp173-rs | /src/irq.rs | UTF-8 | 4,416 | 2.96875 | 3 | [
"MIT"
] | permissive | //! Interrupts (IRQs).
use bit_field::BitField;
use embedded_hal::blocking::i2c::{Write, WriteRead};
use crate::{Axp173, Axp173Result, Error, OperationResult};
/// An AXP173 interrupt.
#[derive(Debug, Copy, Clone)]
#[allow(missing_docs)] // TODO: document IRQs
pub enum Irq {
AcinOvervoltage,
AcinPluggedIn,
... | true |
c96f3e3792a7a40f8db8a67bd9eda2b43077663b | Rust | jmulcahy/advent-of-code-2017 | /day1/src/bin/main.rs | UTF-8 | 546 | 2.703125 | 3 | [] | no_license | extern crate day2;
extern crate day1;
use std::error::Error;
fn main() {
let filename = "input.txt";
let input = match day2::read_file(filename) {
Err(why) => panic!("couldn't open {}: {}", filename, why.description()),
Ok(input) => input
};
let data = match day1::parse_input(&input) {... | true |
9f15e75e26d84aa607e322654077448004e4c792 | Rust | algebraicdb/algebraicdb | /algebraicdb/src/table/pattern_iter.rs | UTF-8 | 2,294 | 2.84375 | 3 | [] | no_license | use super::{Cell, Table};
use crate::pattern::CompiledPattern;
use crate::types::TypeMap;
#[derive(Clone, Copy)]
pub struct RowPatternIter<'p, 'ts, 'tb> {
pattern: &'p CompiledPattern,
types: &'ts TypeMap,
table: &'tb Table,
row: usize,
}
#[derive(Clone, Copy)]
pub struct CellPatternIter<'p, 'ts, 'tb>... | true |
9b506ae204c16212f6adae58b0c5869fac66fd1c | Rust | srijs/rust-cfn | /src/aws/dlm.rs | UTF-8 | 74,085 | 2.59375 | 3 | [
"MIT"
] | permissive | //! Types for the `DLM` service.
/// The [`AWS::DLM::LifecyclePolicy`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dlm-lifecyclepolicy.html) resource type.
#[derive(Debug, Default)]
pub struct LifecyclePolicy {
properties: LifecyclePolicyProperties
}
/// Properties for the `Lifecycl... | true |
cdcdb82cf4114cdc554b1ac63a2a40393c8dd0d7 | Rust | chengyi818/kata | /Language/rust/grammer/trait_demo/static_dispatch_trait_demo_01/src/main.rs | UTF-8 | 572 | 3.328125 | 3 | [] | no_license | #[allow(dead_code)]
struct Cat {
name: String,
age: i32,
}
impl Cat {
fn new(name: String, age: i32) -> Self {
Self { name, age }
}
}
trait Animal {
fn name(&self) -> &'static str;
// fn by_ref(&self) -> &Self;
}
impl Animal for Cat {
fn name(&self) -> &'static str {
"Cat"
... | true |
7174777629d69b4a2afaf113cb472eb075734122 | Rust | hawkw/mycelium | /util/src/macros.rs | UTF-8 | 3,501 | 2.640625 | 3 | [
"MIT"
] | permissive | macro_rules! loom_const_fn {
(
$(#[$meta:meta])*
$vis:vis fn $name:ident($($arg:ident: $T:ty),*) -> $Ret:ty $body:block
) => {
$(#[$meta])*
#[cfg(not(loom))]
$vis const fn $name($($arg: $T),*) -> $Ret $body
$(#[$meta])*
#[cfg(loom)]
$vis fn $name(... | true |
a526dd222d9fb221344c84df28521a1a98c20095 | Rust | arbimo/postnu | /src/labels.rs | UTF-8 | 12,201 | 3.046875 | 3 | [] | no_license | use crate::algebra::*;
use std::fmt::{Display, Error, Formatter};
#[derive(Clone, Copy, Debug)]
pub struct Wait<N, W> {
pub node: N,
pub delay: W,
}
#[derive(Clone, Debug)]
pub struct Lab<N, W> {
pub root: Option<N>,
pub scalar: W,
pub waits: Vec<Wait<N, W>>,
}
impl<N, W> Lab<N, W>
where
N: Ord... | true |
cb2da0608ff701ea5cfafe7f91d2b83313cbac99 | Rust | Ogeon/rust-wiringpi | /src/lib.rs | UTF-8 | 20,365 | 2.78125 | 3 | [
"MIT"
] | permissive | #![doc(html_root_url = "http://ogeon.github.io/docs/rust-wiringpi/master/")]
#![cfg_attr(feature = "strict", deny(warnings))]
extern crate libc;
use std::marker::PhantomData;
use pin::{Pin, Pwm, GpioClock, RequiresRoot};
macro_rules! impl_pins {
($($name:ident),+) => (
$(
#[derive(Clone, Co... | true |
3b7acb8df1c4ece5c45dc7d519409e9da5f9a85a | Rust | julienduchesne/challenges | /backend/src/groups/advent_of_code_2020/day20.rs | UTF-8 | 14,797 | 2.96875 | 3 | [] | no_license | use std::collections::HashSet;
use anyhow::Result;
use ndarray::{Array, Array2, Axis};
use num_integer::Roots;
use rand::seq::SliceRandom;
use crate::groups::challenge_config::ChallengeConfig;
pub struct Day20 {}
trait FlipRotate {
fn rotate(&mut self);
fn flip_horizontal(&mut self);
fn flip_vertical(&mu... | true |
42f1f24e02eea09f23a0cdd23b76a51bb37b399f | Rust | ThePants999/advent-of-code-2020 | /src/day6.rs | UTF-8 | 1,034 | 3.015625 | 3 | [
"CC0-1.0"
] | permissive | use std::collections::HashSet;
use crate::utils;
pub fn day6(input_lines: &[String]) -> (u64, u64) {
let groups = utils::group_lines_split_by_empty_line(input_lines);
let (unions, intersections): (Vec<HashSet<char>>, Vec<HashSet<char>>) = groups.iter().map(|group| group_responses(group)).unzip();
let part1... | true |
730174af1856580c07279b70f078e0f6506c478c | Rust | regendo/advent-of-code-2019 | /day13/src/main.rs | UTF-8 | 8,207 | 3.1875 | 3 | [] | no_license | use day09;
use std::{collections::HashMap, fmt::Display, io};
use std::{convert::TryFrom, error::Error};
trait Decider: io::BufRead {
fn decide_on_move(&mut self, player_position: (i32, i32), ball_position: (i32, i32));
}
impl Decider for io::BufReader<io::Stdin> {
fn decide_on_move(&mut self, player_position: (i32... | true |
48f4ef8c3a3a51584b80100b4ecafe683664ef89 | Rust | akiles/embassy | /embassy-stm32/src/subghz/tx_params.rs | UTF-8 | 6,000 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /// Power amplifier ramp time for FSK, MSK, and LoRa modulation.
///
/// Argument of [`set_ramp_time`][`super::TxParams::set_ramp_time`].
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[repr(u8)]
pub enum RampTime {
/// 10µs
Micros10 = 0x00,
/// 20µs
... | true |
92a105b843ce43e793cd9d5c46e1443c881e5dea | Rust | cjab/uoc | /src/uoc.rs | UTF-8 | 4,844 | 2.546875 | 3 | [] | no_license | extern crate byteorder;
extern crate argparse;
extern crate sdl2;
mod tile_data;
mod index;
mod art;
mod anim;
mod texture;
mod color;
use tile_data::TileData;
use texture::TextureData;
use art::ArtData;
use anim::AnimationFile;
use argparse::{ArgumentParser, Store};
use sdl2::event::Event;
use sdl2::surface::Surf... | true |
e11af4d382e6f0f6f6b07ec93b30bb8d4e952265 | Rust | oliverlee/dominion | /dominion/src/dominion/arena/effect/moneylender.rs | UTF-8 | 3,038 | 3.203125 | 3 | [] | no_license | use super::prelude::*;
pub(super) const EFFECT: &Effect = &Effect::Conditional(
func,
"You may trash a Copper from your hand. If you do, +$3.",
);
fn func(arena: &mut Arena, player_id: usize, cards: &[CardKind]) -> Result<Outcome> {
let error = Err(Error::UnresolvedActionEffect(&EFFECT.description()));
... | true |
c48d18ed9c76b385801d4070713143faa2362c46 | Rust | skyser2003/ditto_bot_rust | /src/slack/test.rs | UTF-8 | 1,974 | 2.90625 | 3 | [] | no_license | use super::*;
#[test]
pub fn test_deserialize_basic_message() {
serde_json::from_str::<Message>(
r#"{
"type": "message",
"channel": "C2147483705",
"user": "U2147483697",
"text": "Hello world",
"ts": "1355517523.000005"
}"#,
)
.unwrap();
}
#[test]
pub fn ... | true |
fb23d61ea78e4a7762269aa89ec333350b4ab48c | Rust | xrelkd/caracal | /tests/common/mod.rs | UTF-8 | 3,763 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::time::{Duration, Instant};
use caracal::{
ClipboardLoad, ClipboardLoadExt, ClipboardStore, ClipboardStoreExt, ClipboardSubscribe,
ClipboardWait, Error,
};
pub trait ClipboardTester {
type Clipboard: 'static
+ Clone
+ Sync
+ Send
+ ClipboardSubscribe
+ Clipb... | true |
9f5805ff0f94d028a8c67a58d49a7c6fd702ed33 | Rust | arcnmx/memento | /src/arm/eabi.rs | UTF-8 | 2,964 | 2.578125 | 3 | [] | no_license | use core::ptr;
#[no_mangle] #[inline]
pub unsafe extern fn __aeabi_memset(dst: *mut u8, len: usize, v: u32) {
let v = v as u8;
for off in 0..len {
ptr::write(dst.offset(off as isize), v);
}
}
#[no_mangle] #[inline]
pub unsafe extern fn __aeabi_memset4(dst: *mut u32, len: usize, v: u32) {
let v = v & 0xff;
let ... | true |
1ad82f182590dbfdd7c82df2577fd974c95bb795 | Rust | brady131313/rustta | /rustta_bindgen/src/meta/group_table.rs | UTF-8 | 1,271 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::ffi::CStr;
use crate::ffi::*;
use crate::types::TaResult;
pub struct GroupTable(*mut TA_StringTable);
impl GroupTable {
pub fn new() -> TaResult<Self> {
let mut table = std::ptr::null_mut();
let ret_code = unsafe { TA_GroupTableAlloc(&mut table) };
if ret_code != TA_RetCode::TA_... | true |
55b20d16931c843fa61a3f9b868085ace4ea4790 | Rust | youngbloood/actix3 | /common/src/msg.rs | UTF-8 | 1,543 | 3.140625 | 3 | [
"MIT"
] | permissive | // 请求msg和响应msg
use serde::{Deserialize,Serialize};
use actix_web::HttpResponse;
use actix_web::error;
use failure::Fail;
#[derive(Fail, Debug)]
pub enum BusinessError {
#[fail(display = "Validation error on field: {}", field)]
ValidationError { field: String },
#[fail(display = "An internal error occurr... | true |
ef20c5159ed95d2e091c1e003b3ccb6c9721305f | Rust | Weasy666/egui | /crates/ecolor/src/hsva_gamma.rs | UTF-8 | 1,447 | 3.15625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{gamma_from_linear, linear_from_gamma, Color32, Hsva, Rgba};
/// Like Hsva but with the `v` value (brightness) being gamma corrected
/// so that it is somewhat perceptually even.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct HsvaGamma {
/// hue 0-1
pub h: f32,
/// saturation 0-1
... | true |
85103cdde29bf769a6110c41870de48cf72ad4b9 | Rust | wannabit-jayb/kms | /src/types/vote.rs | UTF-8 | 8,581 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use super::{BlockID, TendermintSign, Time};
use chrono::{DateTime, Utc};
use std::time::{SystemTime, UNIX_EPOCH};
use subtle_encoding::hex::encode_upper;
// TODO(ismail): we might not want to use this error type here
// see below: those aren't prost errors
use prost::error::DecodeError;
enum VoteType {
PreVote,
... | true |
139d6ce2d0f01621ff69bacff1754ce1170a9b60 | Rust | fotcorn/x86emu | /src/instruction_set.rs | UTF-8 | 13,009 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::fmt;
#[derive(Clone, Copy, Debug)]
pub enum RegisterSize {
Bit8,
Bit16,
Bit32,
Bit64,
Segment,
}
#[derive(Debug, Copy, Clone)]
pub enum Register {
// 64 Bit
RAX,
RBX,
RCX,
RDX,
RSP,
RBP,
RSI,
RDI,
R8,
R9,
R10,
R11,
R12,
R13,
... | true |
b51a2a6c640682ca752dcbbfb527879e97672746 | Rust | kpozin/icu4x | /components/pluralrules/tests/rules.rs | UTF-8 | 2,690 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unicode",
"ICU",
"Apache-2.0"
] | permissive | mod fixtures;
mod helpers;
use icu_pluralrules::rules::{parse, parse_condition, test_condition, Lexer};
use icu_pluralrules::PluralOperands;
#[test]
fn test_parsing_operands() {
let path = "./tests/fixtures/rules.json";
let test_set: fixtures::RuleTestSet =
helpers::read_fixture(path).expect("Failed t... | true |
bcb986143363fccb9e43c50f715c586c25256ccb | Rust | mhetrerajat/ds-challenge | /exercism/rust/proverb/src/lib.rs | UTF-8 | 522 | 2.75 | 3 | [
"MIT"
] | permissive | pub fn build_proverb(list: &[&str]) -> String {
let mut result = String::new();
let length = if list.len() != 0 { list.len() - 1 } else { 0 };
for idx in 0..length {
result.push_str(
format!(
"For want of a {} the {} was lost.\n",
list[idx],
... | true |
a08cdafd012cc0d0158bc528463d6e61030aea8b | Rust | jafow/pals | /src/xor.rs | UTF-8 | 4,768 | 3.296875 | 3 | [] | no_license | extern crate hex;
use table;
use std::collections::HashMap;
use FreqScore;
struct Freq {
raw: u8,
pct: f32
}
/// xor_fixed
/// take 2 equal length buffers and return the fixed
/// xor of them
pub fn xor_fixed(buf1: &[u8], buf2: &[u8]) -> Result<Vec<u8>, hex::FromHexError> {
// assert_eq!(buf1.len(), buf... | true |
927f51de741103d2ab6c5c893263321dbe70d5d3 | Rust | nikomatsakis/rust | /src/libstd/smallintmap.rs | UTF-8 | 3,288 | 3.078125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"bzip2-1.0.6",
"BSD-1-Clause"
] | permissive | /*
Module: smallintmap
A simple map based on a vector for small integer keys. Space requirements
are O(highest integer key).
*/
import core::option;
import core::option::{some, none};
// FIXME: Should not be @; there's a bug somewhere in rustc that requires this
// to be.
/*
Type: smallintmap
*/
type smallintmap<T> =... | true |
07658967a551590c5fe42efaff36344f1762e8ce | Rust | jatinchowdhury18/distortion-rs | /distortionlib/src/waveshape.rs | UTF-8 | 1,398 | 3.078125 | 3 | [] | no_license | use super::utils;
pub struct WaveShape {
amount: f32,
skew: f32,
}
impl WaveShape {
const MIN_EXP: f32 = 0.4;
const MAX_EXP: f32 = 5.0;
pub fn new() -> Self {
WaveShape {
amount: 2.5,
skew: utils::get_skew_for_centre(WaveShape::MIN_EXP, WaveShape::MAX_EXP, 2.5),
... | true |
c27fc4c8e7ca8746a16fe6e2948e8fc07bc3f93c | Rust | DoYouEvenCpp/aoc2015 | /day15/src/main.rs | UTF-8 | 3,530 | 3.421875 | 3 | [] | no_license | use std::cmp;
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
struct Ingredient {
capacity: i32,
durability: i32,
flavor: i32,
texture: i32,
calories: i32,
}
type DataType = Vec<Ingredient>;
fn get_input() -> DataType {
let mut m = DataType::new();
m.push(Ingredient {
capacity: 2,
... | true |
004768ec9d4670945a03b9ce56d775b608cef19b | Rust | ryanpbrewster/wasm-fzf | /src/main.rs | UTF-8 | 1,723 | 2.703125 | 3 | [] | no_license | use fst::IntoStreamer;
use fst::{automaton::Subsequence, Streamer};
use std::{
io::{stdin, stdout, Write},
time::Instant,
};
use termion::event::{Event, Key};
use termion::input::{MouseTerminal, TermRead};
use termion::{cursor::Goto, raw::IntoRawMode};
const WORDS: &str = include_str!("../data/words_alpha.txt"... | true |
ba473d4915b52e0b1e851c7d1e8aaae17aceeb6e | Rust | INDAPlus21/murnion-task-2 | /avstand_till_kanten/src/main.rs | UTF-8 | 1,318 | 4 | 4 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::cmp;
/// Takes an input file with two numbers R and C, in a format of a single line "r c"
/// Then converts it into an output string displaying a rectangle R wide and C long
fn main() {
// Get the input
let input = io::stdin();
let mut s = &input.lock().lines... | true |
fc76a97e2957b54b4f0c4caaab70437ae225f104 | Rust | mfred488/ferris-is-you | /ferris-base/tests/hot_melt.rs | UTF-8 | 1,418 | 2.90625 | 3 | [
"MIT"
] | permissive | use ferris_base;
mod utils;
#[test]
fn hot_destroys_melt() {
let start = vec![
"............",
"..🦀🔥......",
"Fe==Me......",
"Fe==U La==Ho",
];
let inputs = vec![
ferris_base::core::direction::Direction::RIGHT,
ferris_base::core::direction::Direction::RIGH... | true |
cd7efc14caa523ac72047a9382dbd3e9c52e550a | Rust | rust-lang/rust | /tests/ui/traits/new-solver/cycles/coinduction/incompleteness-unstable-result.rs | UTF-8 | 2,324 | 2.90625 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // compile-flags: -Ztrait-solver=next
#![feature(rustc_attrs)]
// This test is incredibly subtle. At its core the goal is to get a coinductive cycle,
// which, depending on its root goal, either holds or errors. We achieve this by getting
// incomplete inference via a `ParamEnv` candidate in the `A<T>` impl and requir... | true |
6db6f91fe96edc9ff65b5c0de06d5076b5eacf4f | Rust | siddharthparmarr/rustcode | /rustcode/easyrust/othercollections/hashmap2.rs | UTF-8 | 554 | 3.296875 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let canadian_cities = vec!["calgary", "vancouver", "gimli"];
let german_cities = vec!["karlsruhe", "bad doberan", "bielefeld"];
let mut city_hashmap = HashMap::new();
for city in canadian_cities {
city_hashmap.insert(city, "canada");
}
for ci... | true |
f79833ec4b633a3dbf4ee98b9015b908c094e58b | Rust | rthinman/sts3x | /src/lib.rs | UTF-8 | 13,943 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! This is a platform-agnostic Rust driver for the Sensirion STS30, STS31, and STS35
//! high-accuracy, low-power, I2C digital temperature sensors, based on the
//! [`embedded-hal`] traits.
//!
//! [`embedded-hal`]: https://github.com/rust-embedded/embedded-hal
//!
//! TODO: More information here.
//!
//! The driv... | true |
c2cdc62cec14af76951b975bcf6a03f34a1687ff | Rust | 3akur6/checksec | /src/main.rs | UTF-8 | 1,259 | 2.6875 | 3 | [] | no_license | mod checksec;
mod elf;
use crate::checksec::checksec;
use clap::{App, Arg};
use std::path::Path;
use std::process::exit;
fn main() {
let matches = App::new("CheckSec")
.author("3akur6 <github.com/3akur6>")
.arg(
Arg::with_name("files")
.help("Files to check")
... | true |
bea1fb04fea63b6f251e4aa1a2d2e4a663b0be4d | Rust | oxidecomputer/cli | /src/config_from_env.rs | UTF-8 | 3,281 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::env;
use anyhow::Result;
use thiserror::Error;
use crate::cmd_auth::parse_host;
use crate::config_file::get_env_var;
const OXIDE_HOST: &str = "OXIDE_HOST";
const OXIDE_TOKEN: &str = "OXIDE_TOKEN";
pub struct EnvConfig<'a> {
pub config: &'a mut (dyn crate::config::Config + 'a),
}
impl EnvConfig<'_> {
... | true |
86a27c7e5c9a95a94e2f8fc83f3f7a11da6ab2b7 | Rust | jsperafico/learn-rust | /11.3_unit-integration-test/tests/integration_test.rs | UTF-8 | 263 | 2.953125 | 3 | [
"MIT"
] | permissive | use unit_integration_test::Point;
mod common;
#[test]
fn must_create_new_point() {
common::setup();
Point::new(1,1,1);
}
#[test]
fn must_draw_a_point() {
common::setup();
let p = Point::new(1,1,1);
assert_eq!(p.draw(), "(1, 1, 1)");
}
| true |
45602ed700a2ff136cf2fe9719f075e9290af097 | Rust | swilcox3/flexi-cad | /operations/src/entity_ops/tests.rs | UTF-8 | 15,781 | 2.578125 | 3 | [] | no_license | use super::*;
use crate::prelude::*;
use crate::tests::*;
use crossbeam_channel::Receiver;
fn test_setup(desc: &str, callback: impl Fn(PathBuf, UserID, Receiver<UpdateMsg>)) {
let file = PathBuf::from(desc);
let (s, r) = crossbeam_channel::unbounded();
let user = UserID::new_v4();
app_state::init_file(... | true |
4ff2ea6485dd295a2d8a861f64ac143c7bb2b40d | Rust | KotoDevelopers/koto | /src/rust/src/metrics_ffi.rs | UTF-8 | 7,523 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT",
"AGPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use libc::{c_char, c_double};
use metrics::{try_recorder, GaugeValue, Key, Label};
use metrics_exporter_prometheus::PrometheusBuilder;
use std::ffi::CStr;
use std::net::{IpAddr, SocketAddr};
use std::ptr;
use std::slice;
use tracing::error;
#[no_mangle]
pub extern "C" fn metrics_run(
bind_address: *const c_char,
... | true |
794a9c5d00621f26d34a2fe2bc7344959d7eef70 | Rust | travismiller/not80 | /src/main.rs | UTF-8 | 2,441 | 2.734375 | 3 | [] | no_license | extern crate dotenv;
#[macro_use]
extern crate error_chain;
extern crate futures;
extern crate hyper;
use dotenv::dotenv;
use futures::future::Future;
use hyper::{StatusCode};
use hyper::header::{ContentLength, ContentType, Host, Location};
use hyper::server::{Http, Request, Response, Service};
use std::env;
use std::... | true |
37c87f5486b320e748d30b230ecb83552e74fe4a | Rust | jujinesy/storycraft_loco-protocol-rs | /src/network.rs | UTF-8 | 5,585 | 2.828125 | 3 | [
"MIT"
] | permissive | /*
* Created on Sat Nov 28 2020
*
* Copyright (c) storycraft. Licensed under the MIT Licence.
*/
use std::{collections::HashMap, io::{self, Read, Write}, sync::mpsc::Receiver, sync::mpsc::SendError, sync::mpsc::{Sender, channel}};
use crate::command::{self, Command, processor::CommandProcessor};
#[derive(Debug)]... | true |
fa01d1970e05a34f85faa2d0016c4fc2d78ed3e9 | Rust | abonander/rust-image | /src/gif/mod.rs | UTF-8 | 789 | 2.703125 | 3 | [
"MIT"
] | permissive | //! Decoding of GIF Images
//!
//! GIF (Graphics Interchange Format) is an image format that supports lossless compression.
//!
//! # Related Links
//! * http://www.w3.org/Graphics/GIF/spec-gif89a.txt - The GIF Specification
//!
pub use self::decoder::GIFDecoder;
pub use self::encoder::Encoder as GIFEncoder;
pub u... | true |
7d4a4f7ba79407d188298a7c9fac90237ee29650 | Rust | dai1975/fiatproof | /src/bitcoin/protocol/message/ping_message.rs | UTF-8 | 1,621 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | #[derive(Debug,Default,Clone)]
pub struct PingMessage
{
pub nonce: u64,
}
use super::message::{ Message, COMMAND_LENGTH };
impl Message for PingMessage {
const COMMAND:[u8; COMMAND_LENGTH] = [0x70, 0x69, 0x6e, 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
}
impl std::fmt::Display for PingMessage {
f... | true |
0f263d5d139f06762bf5e85e34bf6991fc75604b | Rust | johnz133/hyper | /src/http2/notes.rs | UTF-8 | 1,664 | 2.796875 | 3 | [
"MIT"
] | permissive | pub enum HttpFrame { //3 frames
pub struct HttpConnection<S> where S: TransportStream {
pub fn with_stream(stream: S) -> HttpConnection<S> {
pub fn send_frame<F: Frame>(&mut self, frame: F) -> HttpResult<()> {
pub fn recv_frame(&mut self) -> HttpResult<HttpFrame> {
pub struct ClientConnection<... | true |
83bb7eb12fa99672ef3877a5e6846038ab95af57 | Rust | Xiantas/Render | /src/camera.rs | UTF-8 | 482 | 2.96875 | 3 | [] | no_license | /*
Définition de la caméra
'fov' paramètre l'angle de la vision de la caméra
*/
#![allow(non_snake_case)]
use crate::rotation::{Rotation, Coords};
pub struct Camera {
pub pos: Coords,
pub rot: Rotation,
fov: f64
}
impl Camera {
pub fn new(pos: Coords, rot: Rotation, fov: f64) -> Camera {
Camera {
pos,
... | true |
79203d8a848fbaf0bac709d6500b572b6aaac235 | Rust | gf712/advent-of-code-2019 | /day2/rust/day2/src/lib.rs | UTF-8 | 1,675 | 3.484375 | 3 | [] | no_license | fn process_operations(vec: &mut Vec<usize>) {
let mut i: usize = 0;
while i < vec.len() {
let value = match vec[i] {
1 => vec[vec[i + 1]] + vec[vec[i + 2]],
2 => vec[vec[i + 1]] * vec[vec[i + 2]],
_ => return,
};
let pos = vec[i + 3];
vec[pos]... | true |
8ab4a91af684fcc4f65de7f447dae539fb2a73a9 | Rust | noobLue/tmc-langs-rust | /tmc-langs-framework/src/command.rs | UTF-8 | 8,162 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Custom wrapper for Command that supports timeouts and contains custom error handling.
use crate::{error::CommandError, TmcError};
use std::io::Read;
use std::time::Duration;
use std::{ffi::OsStr, thread::JoinHandle};
use std::{fs::File, io::Write};
pub use subprocess::ExitStatus;
use subprocess::{Exec, PopenError,... | true |
e79dc2cd6c0b6f1458a54d6da9d711de62aae0c9 | Rust | yzhs/sokoban | /src/save/collection_state.rs | UTF-8 | 5,446 | 2.84375 | 3 | [] | no_license | use std::fs::File;
use std::path::Path;
use crate::util::DATA_DIR;
use super::level_state::*;
use super::{SaveError, UpdateResponse};
#[derive(Debug, Serialize, Deserialize)]
pub struct CollectionState {
pub name: String,
pub collection_solved: bool,
#[serde(default)]
pub levels_solved: u32,
p... | true |
57455f64a992a0af36b45f41ea4e0984fb53a121 | Rust | Embracethevoid/evjson | /src/evjson.rs | UTF-8 | 17,094 | 3.546875 | 4 | [] | no_license | use std::collections::HashMap;
// use std::ops::{Index, IndexMut};
#[derive(Debug, PartialEq)]
pub enum Number {
Integer(i64),
Float(f64),
}
#[derive(Debug, PartialEq)]
pub enum EVValue {
Object(EVObject),
Array(Vec<EVValue>),
Str(String),
Number(Number),
Boolean(bool),
Null,
}
// pub s... | true |
874c2afccf42a00760a3f626da83394df1111edd | Rust | k0nserv/advent-of-rust-2018 | /src/day01.rs | UTF-8 | 1,396 | 3.59375 | 4 | [
"MIT"
] | permissive | use std::collections::HashSet;
fn parse<'a>(input: &'a str) -> impl Iterator<Item = i64> + 'a {
input
.split(|c: char| c == ',' || c.is_whitespace())
.map(|n| n.trim())
.filter(|n| n.len() > 1)
.map(|number| number.parse::<i64>().expect("Expected only valid numbers"))
}
pub fn star... | true |
49b203ce7d103f53b65496576f086a17b66dbbb1 | Rust | adrianchitescu/aoc20-rs | /utils/src/lib.rs | UTF-8 | 368 | 2.75 | 3 | [] | no_license | pub mod utils {
use std::{env, fs};
use std::io::{Error, ErrorKind, Result};
pub fn get_file_input(arg_position : usize) -> Result<String> {
if let Some(file_name) = env::args().nth(arg_position) {
fs::read_to_string(file_name)
} else {
Err(Error::new(ErrorKind::Inval... | true |
18005279a9b5e1438a4d1cbcf1409dc65f3198e5 | Rust | vincenthz/tesserae | /examples/tesseraed/editor/swatch.rs | UTF-8 | 1,966 | 3.28125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::fs::File;
use std::path::Path;
use std::ops::{Index, IndexMut};
use std::io;
use std::io::{Read,Cursor};
use sdl2::pixels::Color;
use byteorder::{ReadBytesExt,WriteBytesExt};
const SWATCH_SIZE: usize = 256;
pub struct Swatch {
data: Vec<Color>,
}
impl Index<usize> for Swatch {
type Output = Color;
... | true |
1a0c9933321d3e625890861f4ce009193a0d4d21 | Rust | r2gnl/xaynet | /rust/xaynet-analytics/src/sender.rs | UTF-8 | 904 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | //! In this file `Sender` is just stubbed and will need to be implemented.
use anyhow::{Error, Result};
use crate::data_combination::data_points::data_point::DataPoint;
/// `Sender` receives a `Vec<DataPoint>` from the `DataCombiner`.
///
/// It will need to call the exposed `calculate()` method on each `DataPoint` ... | true |
02bf5781b978df01dbaa7af77f375c0db2c4ef99 | Rust | GGist/bip-rs | /bip_handshake/src/message/complete.rs | UTF-8 | 1,599 | 3.046875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::net::SocketAddr;
use message::protocol::Protocol;
use message::extensions::{Extensions};
use bip_util::bt::{InfoHash, PeerId};
/// Message containing completed handshaking information.
pub struct CompleteMessage<S> {
prot: Protocol,
ext: Extensions,
hash: InfoHash,
pid: PeerId,
addr: S... | true |
05121797d3653bd4779d1553d457f338843fae00 | Rust | alistair23/opentitan | /sw/host/rom_ext_image_tools/signer/image/src/image.rs | UTF-8 | 3,197 | 2.875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#![deny(warnings)]
#![deny(unused)]
#![deny(unsafe_code)]
use crate::manifest;
use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
pub enum ImageError {
#[err... | true |
16d16926164cfa954b7422b1fc4cd71837c17bbd | Rust | peppizza/songbird-yt-dlp | /src/driver/connection/error.rs | UTF-8 | 4,659 | 2.5625 | 3 | [
"ISC"
] | permissive | //! Connection errors and convenience types.
use crate::{
driver::tasks::{error::Recipient, message::*},
ws::Error as WsError,
};
use flume::SendError;
use serde_json::Error as JsonError;
use std::{error::Error as StdError, fmt, io::Error as IoError};
#[cfg(not(feature = "tokio-02-marker"))]
use tokio::time::e... | true |
ca6ff933975412289f199226ae4df42d0f7f3d88 | Rust | cibingeorge/rquickjs | /core/src/value/function/types.rs | UTF-8 | 9,333 | 3.359375 | 3 | [
"MIT"
] | permissive | use crate::{AsFunction, Ctx, Function, IntoJs, ParallelSend, Result, Value};
use std::{
cell::RefCell,
marker::PhantomData,
ops::{Deref, DerefMut},
};
/// The wrapper for method functions
///
/// The method-like functions is functions which get `this` as the first argument. This wrapper allows receive `thi... | true |
a4c5be0552a64492437b0269ddc93fd192c06358 | Rust | funn1est/leetcode-rust | /src/solutions/n2_add_two_numbers/mod.rs | UTF-8 | 1,998 | 3.296875 | 3 | [] | no_license | #[allow(unused_imports)]
use super::libs::linked_list::{vec_to_list_node, ListNode};
/// https://leetcode.com/problems/add-two-numbers/
///
/// https://leetcode-cn.com/problems/add-two-numbers/
pub struct Solution {}
impl Solution {
pub fn add_two_numbers(
l1: Option<Box<ListNode>>,
l2: Option<Box... | true |
daa43c27a0ea3f633b95116d15f0ed7b527b7602 | Rust | MaulingMonkey/rust-reviews | /src/bin/diff.rs | UTF-8 | 1,906 | 2.765625 | 3 | [] | no_license | use std::process::{Command, exit};
use std::path::PathBuf;
fn main() {
let mut args = std::env::args();
let _exe = args.next();
let krate = args.next().unwrap_or_else(|| { eprintln!("Usage: cargo diff [crate] [version]"); exit(1); });
let vers = args.next().unwrap_or_else(|| { eprintln!("Usage: cargo ... | true |
2c986073907bc61e9bc90de3dbdd11816601b3f6 | Rust | allchain/s3-server | /src/ops/delete_object.rs | UTF-8 | 2,110 | 2.625 | 3 | [
"MIT"
] | permissive | //! [`DeleteObject`](https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html)
use crate::error::S3Result;
use crate::output::{wrap_output, S3Output};
use crate::utils::{RequestExt, ResponseExt};
use crate::{BoxStdError, Request, Response};
use hyper::StatusCode;
use serde::Deserialize;
use crate::dto::... | true |
a6cb1333bf7bfb00e97e0634d5fbcc3a6481a408 | Rust | gobanos/cargo-aoc | /cargo-aoc/src/app.rs | UTF-8 | 17,563 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use aoc_runner_internal::Day;
use aoc_runner_internal::Part;
use clap::ArgMatches;
use credentials::CredentialsManager;
use date::AOCDate;
use project::ProjectManager;
use reqwest::header::{COOKIE, USER_AGENT};
use reqwest::blocking::Client;
use reqwest::StatusCode;
use std::error;
use std::fs;
use std::fs::File;
use s... | true |
b943b29a09475e8399b64acfbc8b95c553b70ad5 | Rust | ericrallen/advent-of-code | /2022/advent/src/days/day_three.rs | UTF-8 | 2,864 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::PART_TWO_INDICATOR;
static EMPTY_STR: &str = "";
static CHARACTERS: &'static str = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
static ELVES_IN_GROUP: usize = 3;
fn check_duplicates<'a>(item: char, pocket: &str) -> Vec<&str> {
let test: Vec<&str> = pocket.matches(item).collect();
return te... | true |
1e560f504d20acba15e953d1074b486a91c24820 | Rust | dylatos9230/WaGraphic | /src/programs/color_2d_gradient.rs | UTF-8 | 4,434 | 2.515625 | 3 | [
"MIT"
] | permissive | use super::super::tools;
use js_sys::WebAssembly;
use wasm_bindgen::JsCast;
use web_sys::WebGlRenderingContext as GL;
use web_sys::*;
pub struct Color2DGradient {
program: WebGlProgram,
index_count: i32,
color_buffer: WebGlBuffer,
rect_vertice_buffer: WebGlBuffer,
u_opacity: WebGlUniformLocation,
... | true |
6845cc76ff9b5958a07a05ca72b0cc8d95da8342 | Rust | lawrencecrane/adventofcode2020 | /day10/src/lib.rs | UTF-8 | 2,923 | 3.328125 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::HashMap;
impl Adapters {
// Adds the charging outlet and device's built-in adapter to data and sorts it
pub fn new(mut data: Vec<usize>) -> Self {
data.push(0);
data.push(*data.iter().max().unwrap() + 3);
data.sort();
Self { data ... | true |
2107cb1386cd62871a42e9e38fe95d5c414136d3 | Rust | narcisobenigno/sars-plot | /src/row.rs | UTF-8 | 1,784 | 3.015625 | 3 | [] | no_license | use serde::Deserialize;
#[derive(Debug, Deserialize, Eq, PartialEq)]
pub struct Row {
#[serde(rename = "data de publicação")]
pub data_de_publicacao: String,
#[serde(rename = "UF")]
pub uf: String,
#[serde(rename = "Unidade da Federação")]
pub unidade_da_federacao: String,
#[serde(rename = ... | true |
ea9f16f547ffc01f0f6d36360bafaa744c83b45e | Rust | mgottschlag/rp2040-pac | /src/resets.rs | UTF-8 | 1,499 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Reset control. If a bit is set it means the peripheral is in reset. 0 means the peripheral's reset is deasserted."]
pub reset: crate::Reg<reset::RESET_SPEC>,
#[doc = "0x04 - Watchdog select. If a bit is set then the watchdog wi... | true |
950df6696d8eec30477f0ebea31b9a5461ddec89 | Rust | hisland/my-learn | /rust-programming-2/00-common-programming-concepts/04-const-can-not-use-runtime-value.rs | UTF-8 | 146 | 2.90625 | 3 | [] | no_license | fn two() -> u32 {
3 + 2
}
fn main() {
const FOO: u32 = two(); // 不能使用运行时值作为 const 的值
print!("{:?}", FOO);
}
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.