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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9b67760c5b9134bf8545db55a85abee16655fae9 | Rust | jvff/ioc-test | /src/scpi/subsystems/source/voltage/mod.rs | UTF-8 | 524 | 2.796875 | 3 | [] | no_license | mod offset;
use super::SourceCommand;
use super::super::super::str_extensions::StrExtensions;
pub fn decode(string: &str) -> Option<SourceCommand> {
let command = string.skip_expected_chars("VOLTage");
if command.starts_with("?") {
return Some(SourceCommand::VoltageGet);
} else if command.starts_... | true |
4d412122068597c1a77682d96b21dd5b2fcacb76 | Rust | yitapi/analyze_amplicons | /src/main.rs | UTF-8 | 11,425 | 2.71875 | 3 | [] | no_license | //
extern crate bio;
extern crate itertools;
use std::collections::HashMap;
use std::cmp;
use std::env;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use bio::io::fastq;
use bio::alignment::pairwise::*;
use bio::alignment::AlignmentOperation;
// fn check(rec: &fastq::Record, read: &str) -> (u16, V... | true |
cc2b676f06e2045ce12759a3b37a94d94e11c057 | Rust | jinjim/cage | /src/pod_config.in.rs | UTF-8 | 4,396 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // This is not a standalone Rust module. It gets processed by serde to
// generate serialization code and included directly into another module.
/// Indicates whether a pod is a regular service or a one-shot task.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum PodType {... | true |
b087fc774ff0f07727cd41b0f28e3dda89c8bb81 | Rust | lovesegfault/cracking-the-coding-interview | /01-arrays-and-strings/03-urlify/src/main.rs | UTF-8 | 2,177 | 3.546875 | 4 | [] | no_license | const URL_WHITESPACE: &str = "%20";
fn urlify(s: &str) -> String {
s.trim().replace(char::is_whitespace, URL_WHITESPACE)
}
fn urlify_in_place(v: &mut Vec<char>) {
// first we must resize the vec to make sure we can fit the replacements
let trailing_whitespace_count = v.iter().rev().take_while(|c| c.is_whi... | true |
65cdff15f683c65848589b695939bf3250eddee8 | Rust | XOSplicer/color-mix | /src/main.rs | UTF-8 | 7,869 | 2.796875 | 3 | [] | no_license | use css_colors::{Angle, Color, Ratio, HSL, RGB};
use std::fs::{self, File};
use std::io::Write;
use std::iter;
use std::panic;
use std::path::Path;
#[derive(Debug)]
enum ComputeError {
EmptyInput,
AverageOutOfRange,
AngleOutOfRange,
PercentageOutOfRange,
Panic,
}
#[derive(Debug)]
struct Record {
... | true |
8b07c24861399e81e182936bd05ef63cba924c89 | Rust | elusivejoe/huffman-coding | /src/huffman.rs | UTF-8 | 4,013 | 3.65625 | 4 | [] | no_license | use std::cmp::Ordering;
#[derive(Eq, Debug)]
pub struct Node {
pub frequency: u64,
pub byte: Option<u8>,
pub left: Option<Box<Node>>,
pub right: Option<Box<Node>>,
}
#[derive(Copy, Clone)]
pub struct HuffmanCode {
bin_repres: u8,
bin_length: u8,
}
impl HuffmanCode {
pub fn new() -> Huffma... | true |
d73c18c9e00c248d5672198c22a8c864e0255e00 | Rust | quinn-rs/quinn | /quinn/src/recv_stream.rs | UTF-8 | 20,514 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
future::Future,
io,
pin::Pin,
task::{Context, Poll},
};
use bytes::Bytes;
use proto::{Chunk, Chunks, ConnectionError, ReadableError, StreamId};
use thiserror::Error;
use tokio::io::ReadBuf;
use crate::{
connection::{ConnectionRef, UnknownStream},
VarInt,
};
/// A stream that can on... | true |
d5425c87bfcd4f39f9f6a413ca066214d2b4f550 | Rust | patractlabs/ink | /crates/env/src/engine/off_chain/hashing.rs | UTF-8 | 2,243 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018-2020 Parity Technologies (UK) Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicab... | true |
8ddd0b0108a10760cb4a68a7020ba54e0948c1ff | Rust | fits/try_samples | /rust/arrow-rs/parquet/tempo_sample/src/main.rs | UTF-8 | 2,900 | 2.5625 | 3 | [] | no_license | use parquet::arrow::arrow_reader::ParquetRecordBatchReaderBuilder;
use arrow::array::StructArray;
use std::{env, fs::File, path::Path};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn print_attrs(s: &StructArray, prefix: &str) {
if let Some(at) = s.column_by_name("Attrs") {
let ns... | true |
ada5f81b50c78cf13aa4098f26ff0760c9695402 | Rust | Istar-Eldritch/sexe | /sexe-parser/src/lib.rs | UTF-8 | 13,194 | 2.8125 | 3 | [
"Unlicense"
] | permissive | #[macro_use]
extern crate nom;
extern crate sexe_expression;
pub use nom::types::CompleteStr;
use sexe_expression::*;
use std::f64::consts::{E, PI};
// This is a custom implementation of nom::recognize_float that does not parse
// the optional sign before the number, so that expressions like `x+3` parse
// correctly ... | true |
d6cc8bf4fc5acd9e2f97a7d13066ca41a4185641 | Rust | ndesmic/rustrott | /part1/src/main.rs | UTF-8 | 2,854 | 2.890625 | 3 | [
"MIT"
] | permissive | extern crate clap;
extern crate regex;
mod bytes;
mod lump_info;
use clap::{App, Arg, SubCommand};
use regex::{Regex};
use std::fs;
use std::vec::Vec;
use std::path::{Path};
use crate::lump_info::{LumpInfo};
fn main() {
let matches = App::new("WAD Reader Util")
.subcommand(SubCommand::with_na... | true |
53f66626e6d422a653ca2f0bbb6653c556946ef3 | Rust | zaeleus/noodles | /noodles-refget/src/sequence/metadata.rs | UTF-8 | 757 | 2.6875 | 3 | [
"MIT"
] | permissive | mod alias;
pub(crate) mod builder;
pub use self::alias::Alias;
pub(crate) use self::builder::Builder;
use serde::Deserialize;
/// Sequence metadata.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
pub struct Metadata {
md5: String,
ga4gh: Option<String>,
length: u32,
aliases: Vec<Alias>,
}
impl ... | true |
ceeae8b6a3c1b87c6922bfa6dc126f155a0583af | Rust | ifzz/bot4 | /backtester/src/backtest/mod.rs | UTF-8 | 3,118 | 3.1875 | 3 | [
"MIT"
] | permissive | //! Defines a backtest, which determines what data is sent and the
//! conditions that trigger it to be sent.
use std::thread;
use std::time::Duration;
use std::sync::mpsc;
use uuid::Uuid;
use algobot_util::trading::tick::*;
use {BacktestType, DataSource, DataDest};
use sim_broker::SimBrokerSettings;
/// Commands f... | true |
6811a2a1103c9e48a5894ddde198761c8b44c376 | Rust | only-cliches/Reach-Web-Service-Engine | /src/database.rs | UTF-8 | 12,837 | 2.640625 | 3 | [] | no_license | use std::char::from_u32;
use std::fmt::Debug;
use std::path::PathBuf;
use std::str::from_utf8;
use std::sync::Arc;
use rocksdb::{IteratorMode, ReadOptions, DB};
use serde_json;
use unicode_normalization::UnicodeNormalization;
use warp::{http::StatusCode, hyper::body::Bytes, Filter, Rejection, Reply};
use self::DBErro... | true |
60f3b4a9e028b1f8d68d3465c27a8499e18479bd | Rust | khonsulabs/muse | /muse/src/sampler/oscillator/square.rs | UTF-8 | 269 | 2.875 | 3 | [
"MIT"
] | permissive | use super::OscillatorFunction;
use std::f32::consts::PI;
#[derive(Debug)]
pub struct Square {}
impl OscillatorFunction for Square {
fn compute_sample(value: f32) -> f32 {
if value < PI {
1.0
} else {
-1.0
}
}
}
| true |
3eea2555c830a2126f0233ae659f76c6a268ab09 | Rust | derrickturk/tapl | /ch04/untyped_bigstep.rs | UTF-8 | 2,024 | 3.59375 | 4 | [] | no_license | use std::rc::Rc;
#[derive(Clone, Debug)]
enum Term {
T,
F,
IfThenElse(Rc<Term>, Rc<Term>, Rc<Term>),
Z,
Succ(Rc<Term>),
Pred(Rc<Term>),
IsZero(Rc<Term>),
}
impl Term {
fn is_value(&self) -> bool {
match *self {
Term::T | Term::F | Term::Z => true,
Term::... | true |
82785fdb56bb71eda213f118a1ff51d6cf364860 | Rust | JudgeGlass/subsurface | /src/world/registry.rs | UTF-8 | 1,910 | 2.875 | 3 | [] | no_license | use prelude::*;
use std::collections::hash_map::HashMap;
use world::block::{BlockID, Face};
pub struct Registry {
ids_by_name: HashMap<String, BlockID>,
uvs_by_id: HashMap<BlockID, BlockUV>,
}
#[derive(Clone, Copy)]
pub struct BlockUV {
uvs: [Point2<u8>; 6],
}
impl BlockUV {
pub fn one_face(uv_origi... | true |
f199370391261fdf3c282ef93fe984c2e420ca73 | Rust | mfaghihi/prime64 | /src/main.rs | UTF-8 | 2,502 | 3.03125 | 3 | [] | no_license | use primegen::mathfuncs::*;
fn main() {
// Doing some tests
//let a :u64 =3;
//let b :u64 =6;
//let prime :u64 =5;
// let base: u64 = 2;
// let twop: u64 = base.pow(31);
// let twop2: u64 = base.pow(31)+1;
// let mayprime :u64 = base.pow(31)+32;
//println!("a+b = {:?}",field_... | true |
e4859166cfe019002dcbe32c28c5c5e5629f432d | Rust | lars-frogner/Whirl-Rust | /src/eos/adiabatic_ideal_gas.rs | UTF-8 | 4,605 | 3.234375 | 3 | [] | no_license | //! Ideal gas equation of state
use super::EquationOfState;
use crate::{
error::{WhirlError, WhirlResult},
geometry::dim::*,
num::fvar,
units::Units,
};
/// Equation of state for a particular ideal adiabatic gas.
#[derive(Debug, Clone)]
pub struct AdiabaticIdealGasEOS {
adiabatic_index: fvar,
... | true |
194bfa18bb372e3051b458a95a7c6d8d96e6a680 | Rust | Noah2610/LD45-WorkingTitle | /src/components/player.rs | UTF-8 | 1,101 | 2.71875 | 3 | [
"MIT"
] | permissive | use super::component_prelude::*;
pub struct Player {
pub settings: PlayerSettings,
pub acceleration: Vector,
pub max_velocity: (Option<f32>, Option<f32>),
pub jump_data: Option<PlayerJumpSettings>,
pub used_dash: bool,
}
impl Player {
pub fn set_normal_speed(&mut self) {
self... | true |
33c4dcd58cb77f3c9bdefa2505d297c3c9e1c599 | Rust | SarthakDandotiya/rust-ing | /008b/src/main.rs | UTF-8 | 1,263 | 3.84375 | 4 | [] | no_license | // Derive annotation
// Allows us to print out an instantiation on A with a debug flag so that we can see it in the console
// We also have the copy and clone traits
// Clone is interesting as it gives a little bit of control over how our variables work in our ownership system
// If we want to make it so that we dont h... | true |
887b0d500853faca634e7920c8ceb95071bac106 | Rust | inversion-engine/inversion-api-rust | /crates/broker/src/inv_share.rs | UTF-8 | 6,314 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | //! Synchronized droppable share-lock around internal state data.
use crate::inv_error::*;
use parking_lot::{Mutex, RwLock};
use std::sync::atomic;
use std::sync::Arc;
/// Callback for delayed initialization of InvShare
pub type InvShareInitCb<T> = Box<dyn FnOnce(T) + 'static + Send>;
/// Synchronized droppable shar... | true |
751d7c2de2f04534c73f16a77274966897efa71e | Rust | luhuimao/morgan | /interface/bpf/rust-utils/src/log.rs | UTF-8 | 5,609 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | //! @brief Morgan Rust-based BPF program logging
use crate::entrypoint::{SolKeyedAccount, SolPubkey};
/// Prints a string to stdout
#[inline(never)] // stack intensive, prevent inline so everyone does not incur cost
pub fn sol_log(message: &str) {
// TODO This is extremely slow, do something better
let mut bu... | true |
812c9f68d034e8d94c3f0e83b3392dd26be89b7e | Rust | marciok/speedtest_watchdog | /src/g_drive/file.rs | UTF-8 | 3,321 | 2.75 | 3 | [] | no_license | extern crate hyper;
extern crate yup_oauth2 as oauth2;
extern crate google_drive3 as drive3;
use self::oauth2::{Authenticator, DefaultAuthenticatorDelegate, ApplicationSecret, DiskTokenStorage};
use self::drive3::Drive;
use std::fs::File;
const JSON_SECRET: &'static str = "authfile";
const MIME_TYPE: &'static str = "... | true |
22067cabeae0489d3946af982d408587b81069d5 | Rust | isgasho/commonplace | /libcommonplace/src/lib.rs | UTF-8 | 6,574 | 2.59375 | 3 | [] | no_license | use std::collections::HashMap;
use std::path::PathBuf;
use std::fs;
use std::fs::File;
use std::io::Write;
use rusqlite::params;
use uuid::Uuid;
pub use libcommonplace_types::{TagRow, TagTree, Note};
pub use rusqlite::Connection;
#[derive(Debug)]
pub enum CommonplaceError {
Sqlite(rusqlite::Error),
Io(std::io... | true |
dff72df30373dcc23b8a01c2cfff25012c324f56 | Rust | mendess/rust-pacman | /src/controler.rs | UTF-8 | 2,440 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::pacman::{ghost::Ghost, ghost::GhostMode, map::Map, Direction, Pacman, Stats};
use piston::input::Button;
use piston::input::Event;
use piston::input::{PressEvent, UpdateEvent};
pub struct Controler {
game: Pacman,
delta: f64,
paused: bool,
}
impl Controler {
pub fn new(game: Pacman) -> Self... | true |
9004a441a5f8f585f2987ef5dec64852db7681ac | Rust | Johan-Mi/persimmon | /ui/src/widgets/toggle.rs | UTF-8 | 999 | 2.890625 | 3 | [
"Unlicense"
] | permissive | use crate::core::{UiResponse, Widget};
use constants::keybinds::CONFIRM;
pub struct Toggle {
pub is_on: bool,
pub on: Box<dyn Widget>,
pub off: Box<dyn Widget>,
}
impl Widget for Toggle {
fn handle_event(
&mut self,
event: &sdl2::event::Event,
) -> Option<crate::core::UiResponse> {... | true |
812b6247a76c107a6392ab6aead1f1ed64dc614c | Rust | 3007-Ani-Sha/rustlings | /exercises/enums/enums1.rs | UTF-8 | 460 | 3.203125 | 3 | [
"MIT"
] | permissive | // enums1.rs
// Make me compile! Execute `rustlings hint enums1` for hints!
#[derive(Debug)]
enum Message {
Quit(String),
Echo(String),
Move(String),
ChangeColor(String), // TODO: define a few types of messages as used below
}
fn main() {
let home = Message::Quit(String::from("EOC"));
println!("{:?... | true |
7c62bc0fde84fa2b64d657e7428de20838ffc3cd | Rust | sivizius/rusm | /src/lib.rs | UTF-8 | 29,793 | 2.703125 | 3 | [] | no_license | //#![allow(warnings)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![feature(try_trait)]
#![feature(type_alias_enum_variants)]
macro_rules! assemblyZeroOperand
{
(
$theName:ident,
$theArchitecture:ident::$theInstruction:ident,
)
=> {
pub fn $theName
(
self,
... | true |
961bf2e5bc1fe99ee772dd07153ae8390e4f064a | Rust | malcolmrebughini/rusty-kmeans | /src/lib.rs | UTF-8 | 5,063 | 3.296875 | 3 | [] | no_license | use rand;
use std::collections::HashMap;
type Point = (f64, f64);
type Centers = Vec<Point>;
type Labels = Vec<usize>;
// Can be moved to its own module
fn calculate_euclidian_distance(p: Point, q: Point) -> f64 {
let (x1, y1) = p;
let (x2, y2) = q;
let x = x1 - x2;
let y = y1 - y2;
return (x * ... | true |
ba5f100674475a2887f60daef48698951ea0d73b | Rust | ziwon/learning-rust | /rust-lang-book/error/src/main.rs | UTF-8 | 1,736 | 3.375 | 3 | [] | no_license | use std::io;
use std::io::Read;
use std::io::ErrorKind;
use std::fs::File;
fn main() {
//panic!("crash and burn");] let v = vec![1, 2, 3];
//v[99];
//
let f = File::open("hello.txt");
//let f = match f {
//Ok(file) => file,
//Err(error) => {
//panic!("There was a probl... | true |
8d0a3d1b8f7a9bb77bce670df20f48920a1c977a | Rust | scifi6546/art_of_computer_programming_practice | /src/buddy.rs | UTF-8 | 5,125 | 3.25 | 3 | [] | no_license | enum BinaryTree {
Data(Free),
Root(Box<[BinaryTree; 2]>),
}
impl BinaryTree {
/// Gets first element with free root and sets it to used
pub fn get_first_free(&mut self, traverse_levels: usize) -> Option<usize> {
match self {
Self::Data(free) => {
if traverse_levels ==... | true |
d30cff781afd8b8da714924a4e35f961ee8e529d | Rust | CmdrMoozy/bdrck | /bdrck/src/cli.rs | UTF-8 | 22,308 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2015 Axel Rasmussen
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in w... | true |
7fffe2364d6c1785550dd30b68ce568159b0de1a | Rust | qwelyt/advent-of-code | /2021/rust/src/day3/mod.rs | UTF-8 | 5,296 | 3.40625 | 3 | [] | no_license | use crate::util::{char_to_i32, lines_from_file, vec_to_string};
pub fn day3() {
println!("== Day 3 ==");
let input = lines_from_file("src/day3/input.txt");
let a = part_a(&input);
println!("Part A: {}", a);
let b = part_b(&input);
println!("Part B: {}", b);
}
fn part_a(input: &Vec<String>) -> ... | true |
56dcb7af15e086dc91f6e1a66bd2fb0cb707ac6d | Rust | AlexNav73/Rust | /net/client/src/main.rs | UTF-8 | 313 | 3.1875 | 3 | [] | no_license |
use std::net::UdpSocket;
use std::thread;
fn main() {
let mut socket = UdpSocket::bind("127.0.0.1:4243").unwrap();
let buf = [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 2, 3];
loop {
println!("{:?}", socket.send_to(&buf, "127.0.0.1:4242").unwrap());
thread::sleep_ms(100);
}
}
| true |
023a601289f42ea2119d09a8c0c69d1537019e24 | Rust | Despire/rust-structures | /sort/quick/src/lib.rs | UTF-8 | 2,267 | 4.03125 | 4 | [
"MIT"
] | permissive | //! # Quick
//!
//! `quick` provides sort capabilities using quick sort
//! using O(n log(n)) on average and O(n^2) at worst time complexity
//! and O(h) space complexity.
/// Sorts the slice within the specified intervar [b, e)
/// using recursive quick sort.
fn internal_quicksort<T>(b: usize, e: usize, slice: &mut [... | true |
53ffd47978a7960b641001755a59b86c38fa921d | Rust | agmcleod/adventofcode-2018 | /21/src/coded_version.rs | UTF-8 | 1,335 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::cmp::Ordering;
fn main() {
let mut register_four_values = HashMap::new();
let r0: usize = 0;
let mut r1: usize = 0;
let mut r2: usize = 0;
let mut r3: usize = 0;
let mut r4: usize = 0;
let mut count = 6;
loop {
r3 = r4 | 65536;
... | true |
d62f8183b7961fea4e52ab1ff6463841c096ffbd | Rust | cstyles/advent-of-code-2020 | /day-04/src/main.rs | UTF-8 | 5,007 | 3.171875 | 3 | [] | no_license | use regex::Regex;
use std::convert::{TryFrom, TryInto};
use std::iter::{FromIterator, IntoIterator};
static INPUT: &str = include_str!("../input.txt");
#[derive(Debug, Default)]
struct Passport<'a> {
byr: Option<&'a str>,
iyr: Option<&'a str>,
eyr: Option<&'a str>,
hgt: Option<&'a str>,
hcl: Optio... | true |
2a17d25b7bffa5bb0ced0ed9c432d45c6b0b4a77 | Rust | vorner/rats | /src/draw.rs | UTF-8 | 3,955 | 2.546875 | 3 | [] | no_license | use std::ops::DerefMut;
use amethyst::assets::{AssetStorage, Handle, Loader, ProgressCounter};
use amethyst::core::Transform;
use amethyst::core::math::Vector3;
use amethyst::ecs::{Read, ReadExpect, System, SystemData, World};
use amethyst::ecs::prelude::*;
use amethyst::prelude::*;
use amethyst::renderer::{Camera, Im... | true |
96e18998b4946d16026186206759f0fb88e69457 | Rust | sile/dlfs | /src/functions/mod.rs | UTF-8 | 775 | 3.171875 | 3 | [] | no_license | pub mod activation;
pub mod loss;
pub fn argmax(xs: &[f64]) -> usize {
assert_ne!(xs.len(), 0);
let mut max_value = xs[0];
let mut max_index = 0;
for i in 1..xs.len() {
if max_value < xs[i] {
max_value = xs[i];
max_index = i;
}
}
max_index
}
pub fn numer... | true |
357b2335356f670aee51031b480a7fa6bbb2e822 | Rust | RZaga09/small_rust_projs | /rock_paper_scissors/src/main.rs | UTF-8 | 970 | 3.4375 | 3 | [] | no_license | //Rock, Paper, Scissors in Rust
extern crate rand;
use std::io;
use rand::Rng;
fn main() {
loop {
println!("0 = Rock");
println!("1 = Paper");
println!("2 = Scissors");
let comp_num = rand::thread_rng().gen_range(0, 3);
let mut pl_num = String::new();
io::stdin().read_line(&mut pl_num)
.expect("F... | true |
7d552a4e6109ee14d7c727ab51a209f69cba7797 | Rust | celaus/rust-bme680 | /src/sensors.rs | UTF-8 | 1,415 | 3.09375 | 3 | [] | no_license | use std::error::Error;
// Copy of the traits that used to come with the i2cdev library but are now gone ...
/// Trait for sensors that provide access to temperature readings
pub trait Thermometer {
type Error: Error;
/// Get a temperature from the sensor in degrees celsius
///
/// Returns `Ok... | true |
21cc2378eeda7ea2bac13bded8b911e39ce6f12e | Rust | cormac-obrien/dissent | /src/lib.rs | UTF-8 | 2,703 | 3.359375 | 3 | [
"MIT"
] | permissive | #![warn(missing_docs)]
//! A flexible, zero-copy recursive descent parsing toolkit.
//!
//! This library provides a set of traits and types useful for constructing
//! lexers and recursive-descent parsers which consume lexer output. Tokens
//! (lexemes) are defined by the `TokenType` trait, while syntax rules are
//!... | true |
75450cdd181d071c90bd243af9d050a49a20d9c6 | Rust | giodamelio/little_boxes | /vendor/winnow/examples/custom_error.rs | UTF-8 | 902 | 2.953125 | 3 | [
"MIT"
] | permissive | use winnow::error::ErrMode;
use winnow::error::ErrorKind;
use winnow::error::ParserError;
use winnow::prelude::*;
#[derive(Debug, PartialEq, Eq)]
pub enum CustomError<I> {
MyError,
Nom(I, ErrorKind),
}
impl<I: Clone> ParserError<I> for CustomError<I> {
fn from_error_kind(input: &I, kind: ErrorKind) -> Sel... | true |
414bf83398d4bc11158646040280a5dc8ca3a1d0 | Rust | Rowmance/Gladius | /src/rules/move_application.rs | UTF-8 | 19,521 | 3.65625 | 4 | [
"MIT"
] | permissive | //! A movement of a piece
use board::file::File;
use board::piece::Piece;
use board::player::Player;
use board::rank::Rank;
use board::square::Square;
use rules::castle_rights::CastleRights;
use rules::game_state::GameState;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::result::Result;
/// Represe... | true |
891b1c85c055266a488315c2826b730d6643778b | Rust | mlemesle/word_tree | /src/tree/tree.rs | UTF-8 | 2,330 | 3.671875 | 4 | [] | no_license | use std::collections::HashMap;
#[derive(Debug)]
struct Node {
c: char,
is_word: bool,
childs: HashMap<char, Node>,
}
impl Node {
// Creates a new Node, with the given character
fn new(c: char) -> Node {
Node {
c: c,
is_word: false,
childs: HashMap::new()... | true |
5db89d1ac734dd67d669bee78c39168ab0cab645 | Rust | Sammons/sammons-vst | /src/my_reverb.rs | UTF-8 | 2,866 | 3.1875 | 3 | [] | no_license |
use crate::Arc;
pub struct MyReverbParams {
// sample_rate: i32,
decay: f32
}
pub struct RingBuffer {
buffer: Vec<f32>,
read_position: i32,
write_position: i32,
}
impl RingBuffer {
fn new(vec: Vec<f32>) -> RingBuffer {
return RingBuffer {
buffer: vec,
read_p... | true |
2fde3ad56af6eb9800e7866fbba60745913dd623 | Rust | mareek/BrainRust | /src/utils.rs | UTF-8 | 448 | 3 | 3 | [
"WTFPL"
] | permissive | use std::fs::File;
use std::io::Read;
use std::path::Path;
pub fn read_file(file_path : &Path) -> String {
let mut buffer = String::new();
match File::open(file_path) {
Ok(mut file) => match file.read_to_string(&mut buffer) {
Ok(_) => buffer,
Err(e) => panic!("realy invalid file... | true |
e6685f61a7403d37bf65e41c5e8651a433f755c4 | Rust | DaTa-/advent-of-code-2020 | /src/bin/day9_part1.rs | UTF-8 | 740 | 2.640625 | 3 | [
"MIT"
] | permissive | fn main() {
let preamble_len = 25;
let mut input = String::from_utf8(std::fs::read("input/day9").unwrap())
.unwrap()
.split_terminator("\n")
.map(|n| n.parse().unwrap())
.collect::<Vec<u64>>();
let (buf, input) = input.split_at_mut(preamble_len);
let answer = input
... | true |
7893c84b5545f93963cf707b7e74fc607835a9da | Rust | ihrwein/backoff | /tests/retry.rs | UTF-8 | 1,024 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | extern crate backoff;
use backoff::Error;
use backoff::ExponentialBackoff;
use std::io;
#[test]
fn retry() {
let mut i = 0;
let success_on = 3;
{
let f = || -> Result<(), Error<io::Error>> {
i += 1;
if i == success_on {
return Ok(());
}
... | true |
3f810b28006ec354995df8e3e77c3902e7caa4cf | Rust | brunobell/rust | /src/test/run-make-fulldeps/coverage/lib/used_crate.rs | UTF-8 | 4,624 | 3.109375 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | #![allow(unused_assignments, unused_variables)]
use std::fmt::Debug;
pub fn used_function() {
// Initialize test constants in a way that cannot be determined at compile time, to ensure
// rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
// dependent conditions.
let ... | true |
dc6ab40bcc28f09e466c6f8fc31d65e4b406e500 | Rust | FyroxEngine/Fyrox | /examples/3rd_person.rs | UTF-8 | 12,203 | 2.765625 | 3 | [
"MIT"
] | permissive | //! Example 03. 3rd person walk simulator.
//!
//! Difficulty: Advanced.
//!
//! This example based on async example, because it requires to load decent amount of
//! resources which might be slow on some machines.
//!
//! In this example we'll create simple 3rd person game with character that can idle,
//! walk, or ju... | true |
9b38c2067dbb34cc8c6131d91c4bf7a7565135e5 | Rust | Masterchef365/GameKernel | /host/src/matchmaker.rs | UTF-8 | 4,849 | 3.015625 | 3 | [] | no_license | use futures::channel::mpsc::{channel, Receiver, SendError, Sender};
use futures::sink::SinkExt;
use futures::stream::{Stream, StreamExt};
use loopback::Loopback;
use protocols::*;
use std::collections::HashMap;
pub type MatchMakerConnection = Sender<Request>;
pub type ConnSender = Sender<Loopback>;
/// Connect to a m... | true |
c484361e2b5e4da251415a26c382e0c2fe3a6e27 | Rust | orndorffgrant/boa | /boa/src/builtins/array_buffer/mod.rs | UTF-8 | 30,460 | 2.78125 | 3 | [
"MIT",
"Unlicense"
] | permissive | use crate::{
builtins::{typed_array::TypedArrayName, BuiltIn, JsArgs},
context::StandardObjects,
gc::{Finalize, Trace},
object::{
internal_methods::get_prototype_from_constructor, ConstructorBuilder, FunctionBuilder,
JsObject, ObjectData,
},
profiler::BoaProfiler,
property::A... | true |
3bb814b97c5c75e0a66242bcec8dd71e6d8488c7 | Rust | minghu6/rust-minghu6 | /coll_st/benches/dict_common.rs | UTF-8 | 620 | 2.515625 | 3 | [] | no_license |
#[macro_export]
macro_rules! gen_data {
($get_one: ident, $group: expr, $num: expr) => {{
let group = $group;
let num = $num;
let mut keys = std::collections::HashSet::new();
let mut elems = vec![];
for _ in 0..num {
let mut k = $get_one();
let mut ... | true |
30465412f64d1dc70d5736c2eee6f61f39bc54ea | Rust | hyperium/headers | /src/common/content_length.rs | UTF-8 | 3,025 | 3.265625 | 3 | [
"MIT"
] | permissive | use {Header, HeaderValue};
/// `Content-Length` header, defined in
/// [RFC7230](http://tools.ietf.org/html/rfc7230#section-3.3.2)
///
/// When a message does not have a `Transfer-Encoding` header field, a
/// Content-Length header field can provide the anticipated size, as a
/// decimal number of octets, for a potent... | true |
99313e8fca9e6a42d2e2f471b5e55bb704b80259 | Rust | JohnTitor/classifui | /src/main.rs | UTF-8 | 14,473 | 2.640625 | 3 | [] | no_license | #![feature(array_windows)]
#![feature(format_args_capture)]
#![feature(total_cmp)]
use clap::App;
use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};
use liblinear::util::TrainingInput;
use liblinear::{Builder as LiblinearBuilder, LibLinearModel as _, SolverType};
use regex::Regex;
use serde::{Deserialize, Seria... | true |
bc385ff769de4ae5ed2b9c0106548bc92e4086b5 | Rust | eriknelson/rustbook_notes | /c4_ownership/src/main.rs | UTF-8 | 21,687 | 3.9375 | 4 | [] | no_license | fn main() {
//scope()
//moves_and_mem();
//refs()
slices()
}
////////////////////////////////////////////////////////////////////////////////
// What is Ownership?
////////////////////////////////////////////////////////////////////////////////
// Ownership is Rust's central feature.
// All programs have to ma... | true |
6760f4add7681909c008b71878d5a2841c674688 | Rust | jbelke/wasm_website_frontend | /src/components/input.rs | UTF-8 | 524 | 2.734375 | 3 | [] | no_license | use jsx_macro::*;
use jsx_types::*;
#[derive(Clone)]
pub struct Input {}
pub struct InputProps<'a> {
pub value: String,
pub on_input: Box<events::InputEventHandler<'a>>,
pub on_keydown: Box<events::KeyboardEventHandler<'a>>,
}
impl<'a> StatelessComponent<'a, InputProps<'a>> for Input {
fn render(props: Input... | true |
d8c6944d55ba493a61c77be7fb1dba9829ea602d | Rust | nevesnunes/env | /common/code/snippets/rust/select_multiple_queues.rs | UTF-8 | 791 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use tokio::{sync::mpsc, time::sleep};
#[tokio::main]
async fn main() {
let (tx1, mut rx1) = mpsc::channel::<u64>(128);
let (tx2, mut rx2) = mpsc::channel::<u64>(128);
let work = move |tx: mpsc::Sender<u64>, val: u64| {
tokio::spawn(async move {
for _ in 0..3 {... | true |
32401c81f8c3b9827132626512a672c63d7d0e08 | Rust | jc00ke/hatty | /src/main.rs | UTF-8 | 3,778 | 2.921875 | 3 | [
"MIT"
] | permissive | #![deny(unsafe_code)]
use macaddr::MacAddr6;
use std::fmt::Debug;
use std::io;
use std::iter;
use std::net::{Ipv4Addr, SocketAddr, UdpSocket};
use structopt::StructOpt;
const MAC_SIZE: usize = 6;
const MAC_PER_MAGIC: usize = 16;
const HEADER: [u8; 6] = [0xFF; 6];
const PACKET_SIZE: usize = HEADER.len() + MAC_PER_MAGIC... | true |
36fea410f50823c4ea0b8983df446e62a75927e0 | Rust | getsentry/symbolicator | /crates/symbolicator/src/server.rs | UTF-8 | 3,650 | 2.578125 | 3 | [
"MIT"
] | permissive | use axum_server::Handle;
#[cfg(feature = "https")]
use std::fs::read;
use std::net::SocketAddr;
#[cfg(feature = "https")]
use std::path::PathBuf;
use anyhow::{Context, Result};
#[cfg(feature = "https")]
use axum_server::tls_rustls::RustlsConfig;
use futures::future::try_join_all;
use futures::future::BoxFuture;
use ... | true |
3ed5a199cffbab7f5964461bf72f2e3d9aaf0ef3 | Rust | RSSchermer/ARWA | /arwa/src/message/message_sender.rs | UTF-8 | 2,592 | 3.109375 | 3 | [
"MIT"
] | permissive | pub(crate) mod message_sender_seal {
pub trait Seal {}
}
pub trait MessageSender: message_sender_seal::Seal {
// TODO: add `post_message` method. Figure out how to define the message type. This can be
// simply `JsValue`, however, this can trigger errors when parts of that `JsValue` do not
// support "... | true |
00dd1ec165250bdece82d350ffc5d6662406b38b | Rust | primenumber/poyot | /src/main.rs | UTF-8 | 1,042 | 2.65625 | 3 | [] | no_license | pub mod tokenize;
pub mod parse;
pub mod generate;
pub mod trans;
use std::io;
use std::io::Read;
use std::fs::File;
use std::env;
use std::io::BufWriter;
fn main() -> io::Result<()> {
let mut args = env::args();
let _program = args.next().unwrap();
let in_filename = args.next().expect("Please specify inp... | true |
b836a83afcccca50560e0b17240dae88301b3851 | Rust | jtescher/ruma | /ruma-client-api/src/r0/thirdparty.rs | UTF-8 | 2,940 | 2.71875 | 3 | [
"MIT"
] | permissive | //! Endpoints for third party lookups
pub mod get_location_for_protocol;
pub mod get_location_for_room_alias;
pub mod get_protocol;
pub mod get_protocols;
pub mod get_user_for_protocol;
pub mod get_user_for_user_id;
use std::collections::BTreeMap;
use ruma_identifiers::{RoomAliasId, UserId};
use serde::{Deserialize... | true |
b37713cbdc17d839608f1bc7c66c2a96b3766ca0 | Rust | prz23/zinc | /zinc-compiler/src/semantic/analyzer/expression/tests.rs | UTF-8 | 10,524 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The expression tests.
//!
use zinc_lexical::Location;
use crate::error::Error;
use crate::semantic::element::r#type::Type;
use crate::semantic::error::Error as SemanticError;
use crate::semantic::scope::item::variable::Variable as ScopeVariableItem;
use crate::semantic::scope::item::Item as ScopeItem;
#[test... | true |
de8550c85cfc4d18465b58abd4ae37d5720cd2a5 | Rust | m-mueller678/block-game | /src/world/chunk_map/atomic_light.rs | UTF-8 | 798 | 3.1875 | 3 | [] | no_license | use geometry::Direction;
use std::sync::atomic::{Ordering, AtomicU8};
#[derive(Default)]
pub struct LightState {
level: AtomicU8,
direction: AtomicU8,
}
const NO_DIRECTION: u8 = 6;
impl LightState {
pub fn level(&self) -> u8 {
self.level.load(Ordering::Relaxed)
}
pub fn direction(&self) -... | true |
84a10b71c5cb2426a02e3d63018ca6b0267a2fb0 | Rust | dkatz23238/actix-mongo-jwt-api | /src/controller/users.rs | UTF-8 | 4,343 | 2.5625 | 3 | [] | no_license | use crate::models::users::{AuthenticateUser, AuthorizedUser, Info, UpdateUser, User};
use crate::AppState;
use actix_web::error::BlockingError;
use actix_web::{web, HttpResponse, Responder};
use actix_web_validator::ValidatedJson;
pub async fn signup_user(
app_data: web::Data<AppState>,
user: ValidatedJson<Use... | true |
6b546105d18307634f31101a9fb062752a51e28c | Rust | ms140569/prompter | /src/segments/username.rs | UTF-8 | 568 | 2.53125 | 3 | [] | no_license | use serde_json::{Value, Map};
use Segment;
use ResultSet;
use themes::*;
use prompt::Prompt;
#[derive(Debug)]
pub struct UsernameSegment {
pub options: Option<Map<String, Value>>
}
impl Segment for UsernameSegment {
fn compute(&self, prompt: &Prompt) -> ResultSet {
let mut bgcolor = prompt.theme[USE... | true |
34f17f4836e2e0e8aa604a5e52f9c83bffa6ee60 | Rust | Serdnad/lyrical_syllables | /src/lib.rs | UTF-8 | 3,982 | 3.328125 | 3 | [] | no_license | mod tests;
use regex::Regex;
// POTENTIAL IMPOVEMENTS:
// - CODE:
// --- TODO: Cleanup unused code and old comments
// - FUNCTIONALITY:
// --- MOAR TESTS
// TODO: cmd option -o <filename> that writes output to file
pub fn syllables_in_word(s: &str) -> usize {
assert!(
!s.contains(' '),
"One word ... | true |
ce722abe8a81a195149ff28f928c783c441b5cfc | Rust | shamansir/rust-playground | /17_2.rs | UTF-8 | 1,341 | 3.734375 | 4 | [] | no_license | fn main() {
{
trait Printable {
fn print(&self);
}
impl Printable for int {
fn print(&self) { println!("{:?}", *self) }
}
impl Printable for ~str {
fn print(&self) { println!("{}", *self) }
}
5.print();
(~"foo").... | true |
cfbb386b789a25b7eaab603af2cf2caef30013a3 | Rust | simon-frankau/advent_of_code_2018 | /day11b/src/main.rs | UTF-8 | 2,270 | 3.34375 | 3 | [
"MIT"
] | permissive | const GRID_SERIAL: i32 = 5719;
fn get_power(x: usize, y: usize) -> i32 {
let (x, y) = ((x as i32) + 1, (y as i32) + 1);
let rack_id = x + 10;
let power_level = rack_id * y;
let power_level = power_level + GRID_SERIAL;
let power_level = power_level * rack_id;
let power_level = (power_level / 10... | true |
3ef720c2eac93ed400249dc6d33fbcd6c50fc296 | Rust | pnkfelix/pnkfx-blog | /hacks/rust-hacks/count-cards.rs | UTF-8 | 5,228 | 3.1875 | 3 | [
"MIT"
] | permissive | //extern mod cards (vers = "0.2");
//use cards::*;
pub enum card_tag { facedown, faceup }
pub enum card_suit { clubs, diamonds, hearts, spades }
pub struct card {
tag: card_tag,
suit: card_suit,
rank: u8, // 1..13
next: Option<@card>
}
// version 0:
fn count_cards(pile... | true |
ee7e3cb64463a6fca45bb127d6811bb8e3eae1e6 | Rust | mayone-du/rust-wasm-practice | /src/lib.rs | UTF-8 | 217 | 2.890625 | 3 | [] | no_license | use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn add_one(num: i32) -> i32 {
num + 1
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_add_one() {
assert_eq!(add_one(3), 4);
}
}
| true |
4e70ea73298a3ce82c210276bbe24a9687ec4a05 | Rust | Mr4k/thread_benchmark | /locking_counter/src/locking_counter.rs | UTF-8 | 341 | 3 | 3 | [] | no_license | use std::sync::{Mutex};
pub struct LockingCounter {
pub count: Mutex<u64>,
}
impl LockingCounter {
pub fn increment(&self) {
let mut mut_count = self.count.lock().unwrap();
*mut_count += 1;
}
pub fn fetch(&self) -> u64 {
let mut_count = self.count.lock().unwrap();
retur... | true |
22a43a05c8ebc17a1b0dcaab8e2abbc92e2c03d2 | Rust | microsoft/winmd-rs | /src/parsed/element_type.rs | UTF-8 | 2,178 | 3.125 | 3 | [
"MIT"
] | permissive | use super::*;
use crate::traits::Decode;
#[derive(Debug)]
pub enum ElementType {
Void,
Bool,
Char,
I8,
U8,
I16,
U16,
I32,
U32,
I64,
U64,
F32,
F64,
ISize,
USize,
String,
Struct(TypeDefOrRef),
Class(TypeDefOrRef),
}
impl ElementType {
pub fn fr... | true |
7e1f890334c50690dd37341aca8a0b6186d10691 | Rust | waonder-rs/magma | /src/pipeline/vertex_input.rs | UTF-8 | 3,053 | 2.765625 | 3 | [] | no_license | use ash::vk;
use crate::Format;
use super::{
input_assembly,
InputAssembly
};
#[derive(Clone, Copy, Debug)]
#[repr(i32)]
pub enum Rate {
/// Specifies that vertex attribute addressing is a function of the vertex index.
Vertex = vk::VertexInputRate::VERTEX.as_raw(),
/// Specifies that vertex attribute addressing ... | true |
557da6d812dc9b28d46449d79b32bd4c7360d7ef | Rust | eric-wood/wm8731 | /src/lib.rs | UTF-8 | 4,184 | 3.03125 | 3 | [
"MIT"
] | permissive | //! A simple HAL for the Cirrus Logic/Wolfson WM8731 audio codec
//!
//! This crate provides simple abstractions for the various control registers on the WM8731.
//!
//! Each function returns a [`Register`] struct, representing the address and value for the register.
//! With the exception of `active` and `reset`, regi... | true |
95c08b9215a5467cb249e96649c1d35b3bea67c8 | Rust | YCP-Swarm-Robotics-Capstone-2020-2021/swarm-website-visualization | /src/math/transform.rs | UTF-8 | 12,957 | 3.109375 | 3 | [] | no_license | use cgmath::
{
prelude::*,
vec3,
Vector3,
Quaternion,
Rad,
Matrix4,
};
/// Holds a scale, orientation, and position for a transformation
#[derive(Clone, Copy, Debug)]
pub struct SubTransformation
{
scale: Vector3<f32>,
orientation: Quaternion<f32>,
translation: Vector3<f32>,
has... | true |
eb6f9f9d57a67fffd139309694cb78141ff3f944 | Rust | spaceships/combustion | /src/position.rs | UTF-8 | 2,614 | 3.0625 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | use crate::util::{from_algebra, to_algebra, ChessError};
use std::fmt;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub struct Pos(usize);
impl Pos {
pub fn new(rank: usize, file: usize) -> Pos {
Pos(rank * 8 + file)
}
pub fn zero() -> Pos {
Pos(0)
}
pub fn from_index(ix: ... | true |
96cd6307f6604a1ba1c923b553023d6e96afc82b | Rust | sunli829/yql | /libs/core/src/expr/func.rs | UTF-8 | 2,547 | 2.96875 | 3 | [] | no_license | use anyhow::Result;
use serde::de::DeserializeOwned;
use serde::Serialize;
use crate::array::{ArrayRef, DataType};
use crate::expr::signature::Signature;
pub trait GenericStatefulFunction: dyn_clone::DynClone + Sync + Send + 'static {
fn call(&mut self, args: &[ArrayRef]) -> Result<ArrayRef>;
fn save_state(&... | true |
2446ccfe19a8ae1b979253cd9dd3f00eb0d817c9 | Rust | BeatButton/hashbrown | /src/raw/alloc.rs | UTF-8 | 1,444 | 2.734375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | pub use self::inner::*;
#[cfg(feature = "nightly")]
mod inner {
use crate::alloc::alloc::Layout;
pub use crate::alloc::alloc::{Allocator, Global};
use core::ptr::NonNull;
#[allow(clippy::map_err_ignore)]
pub fn do_alloc<A: Allocator>(alloc: &A, layout: Layout) -> Result<NonNull<u8>, ()> {
... | true |
64068e4c28ca200ad4ee402f7a82da5efea68d84 | Rust | kb10uy/mpywd | /src/endpoint.rs | UTF-8 | 4,741 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | //! Contains endpoint handlers.
use crate::{
schema::{
ErrorResponse, FancyApiQuery, FancyApiResponse, FancyApiResponseFrame, SimpleApiQuery,
SimpleApiResponse,
},
State,
};
use async_std::sync::Arc;
use log::info;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};
use rand::p... | true |
002a7a84bae0071f85d806f5fb51e598680247f4 | Rust | skreimeyer/rustbuddy | /examples/mkerr_results/blockcomment.rs | UTF-8 | 721 | 3.328125 | 3 | [
"Unlicense"
] | permissive | /*
Welcome to the wild world of block comments
on several lines
This file only has a main function
*/
use std::error::Error;
use std::fmt;
#[derive(Debug)]
struct MyCustomErrorName {
message: String
}
impl MyCustomErrorName {
fn new(message: &str) -> MyCustomErrorName {
MyCustomErrorName{message: me... | true |
81e0229af7dedb06795ce0bc2cbd4de5dcbc095a | Rust | fabianboesiger/neural-network | /src/feed_forward.rs | UTF-8 | 3,990 | 2.765625 | 3 | [] | no_license | use crate::{Matrix, Network, Number, Vector};
use ndarray::{arr1, s, stack, Axis};
use rand::distributions::{Distribution, Standard};
use rayon::prelude::*;
const LEARNING_RATE: f32 = 0.001;
/// A feedforward neural network using backpropagation as a learning strategy.
#[derive(Debug)]
pub struct FeedForward<N>
where... | true |
c66b23d57df1c37174ca6cdd0cdf1c2328ff8437 | Rust | drahnr/ockam | /implementations/rust/ockam/ockam_vault/src/secret_impl.rs | UTF-8 | 2,956 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::error::Error;
use crate::software_vault_impl::{SoftwareVaultImpl, VaultEntry};
use arrayref::array_ref;
use ockam_vault_core::secret::Secret;
use ockam_vault_core::secret_vault::SecretVault;
use ockam_vault_core::types::{
PublicKey, SecretAttributes, SecretKey, SecretType, CURVE25519_SECRET_LENGTH,
};
us... | true |
f2a5d043c285816127189b612928e28fb5d7de5a | Rust | adamgreig/stm32ral | /src/stm32f7/peripherals/rcc_v1.rs | UTF-8 | 133,040 | 2.53125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #![allow(non_snake_case, non_upper_case_globals)]
#![allow(non_camel_case_types)]
//! Reset and clock control
//!
//! Used by: stm32f730, stm32f7x2, stm32f7x3
use crate::RWRegister;
#[cfg(not(feature = "nosync"))]
use core::marker::PhantomData;
/// clock control register
pub mod CR {
/// PLLI2S clock ready flag
... | true |
83c6bd93b5994b47359a8c9475cacce401dce3f7 | Rust | EvanJP/icu4x | /components/cldr-json-data-provider/src/support.rs | UTF-8 | 2,574 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unicode",
"ICU",
"Apache-2.0"
] | permissive | use crate::CldrPaths;
use icu_data_provider::iter::DataEntryCollection;
use icu_data_provider::prelude::*;
use std::convert::TryFrom;
use std::sync::RwLock;
pub(crate) trait DataKeySupport {
fn supports_key(data_key: &DataKey) -> Result<(), DataError>;
}
pub(crate) struct LazyCldrProvider<T> {
src: RwLock<Opt... | true |
c9b7f061b9f83070bf4faa73d24817ab9ae86dbd | Rust | Melephas/task_manager_redux | /src/task/file_task_provider.rs | UTF-8 | 522 | 2.96875 | 3 | [] | no_license | use std::{
fs::File,
path::Path,
};
#[derive(Default)]
pub struct FileTaskProvider {
file: Option<File>,
}
impl FileTaskProvider {
pub fn new() -> FileTaskProvider {
Default::default()
}
pub fn new_from_file(file: File) -> FileTaskProvider {
FileTaskProvider {
file... | true |
8d200751d90db6f2f35b73f850e76650d1b73669 | Rust | 5l1v3r1/crush | /src/lib/stream/reverse.rs | UTF-8 | 735 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::lang::errors::{error, CrushResult};
use crate::lang::execution_context::CommandContext;
use crate::lang::stream::{CrushStream, ValueSender};
use crate::lang::table::Row;
pub fn run(input: &mut dyn CrushStream, sender: ValueSender) -> CrushResult<()> {
let output = sender.initialize(input.types().to_vec(... | true |
90cbfa21001e12dee953190e01d69de658e9ee35 | Rust | jayong93/alt_invalid_win_chars | /src/lib.rs | UTF-8 | 489 | 2.765625 | 3 | [] | no_license | use std::borrow::Cow;
const INVALID_CHARS: [char; 9] = ['<', '>', ':', '"', '/', '\\', '|', '?', '*'];
pub fn alter_invalid_win_chars(name: Cow<str>) -> Option<String> {
if let Some(idx) = name.find(INVALID_CHARS.as_ref()) {
let mut new_name;
let (valid_part, invalid_part) = name.split_at(idx);
... | true |
54f18ad24ca66992b5c4784a2e82ca2dc2927ca2 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/wasmparser/src/readers/core/exports.rs | UTF-8 | 979 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LLVM-exception",
"Apache-2.0"
] | permissive |
use crate::{BinaryReader, FromReader, Result, SectionLimited};
pub type ExportSectionReader<'a> = SectionLimited<'a, Export<'a>>;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ExternalKind {
Func,
Table,
Memory,
Global,
Tag,
}
#[derive(Debug, C... | true |
25861c728e26cebe7354743e2b30d9f021ba899a | Rust | yusdacra/ruma | /ruma-common/src/push.rs | UTF-8 | 8,638 | 3.03125 | 3 | [
"MIT"
] | permissive | //! Common types for the [push notifications module][push]
//!
//! [push]: https://matrix.org/docs/spec/client_server/r0.6.1#id89
use ruma_common::StringEnum;
use serde::{Deserialize, Serialize};
mod action;
mod any_push_rule;
mod condition;
mod predefined;
pub use self::{
action::{Action, Tweak},
any_push_r... | true |
7b8aade117db4ee7e8a49d222e52047129953670 | Rust | alvaro-cuesta/rustopals | /tests/set4/mod.rs | UTF-8 | 2,756 | 2.90625 | 3 | [] | no_license | /// Break "random access read/write" AES CTR - https://cryptopals.com/sets/4/challenges/25
mod challenge25_break_random_access_aes_ctr {
use rustopals::block::{BlockCipher, AES128};
use rustopals::stream::{SeekableStreamCipher, StreamCipher, CTR};
const PLAINTEXT: &str = include_str!("25.txt");
fn edi... | true |
a1d9246eb86a04d646416da59e5a5135c1ba4326 | Rust | laturner42/PegGame | /src/main.rs | UTF-8 | 3,139 | 3.25 | 3 | [] | no_license | fn main() {
let init_state = State{board: make_board(), prev: ((0,0), (0,0))};
recurse(&init_state);
init_state.print();
}
fn recurse(state: &State) -> bool{
let succ = get_successors(&state.board);
for s in range(0,succ.len()) {
if is_winner(&succ[s].board) { succ[s].print(); return true; ... | true |
2e13edb6e9e9b963541efb7cacd1834fb5470f2e | Rust | yiv/tantivy | /src/fastfield/readers.rs | UTF-8 | 13,610 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::common::CompositeFile;
use crate::fastfield::MultiValueIntFastFieldReader;
use crate::fastfield::{BytesFastFieldReader, FastValue};
use crate::fastfield::{FastFieldNotAvailableError, FastFieldReader};
use crate::schema::{Cardinality, Field, FieldType, Schema};
use crate::space_usage::PerFieldSpaceUsage;
use ... | true |
b3c15c9eb2efb738c3825c78f4d0c4789a0d3b2b | Rust | btg99/datachest | /minecraft/src/lower.rs | UTF-8 | 23,475 | 3.015625 | 3 | [] | no_license | use crate::*;
pub fn lower(command: Command) -> String {
match command {
Command::Scoreboard(s) => scoreboard(s),
Command::Function(f) => function(f),
Command::Execute(e) => execute(e),
Command::Tellraw(t) => tellraw(t),
}
}
fn scoreboard(scoreboard: Scoreboard) -> String {
... | true |
d076d28e098bc0151283e58f61d5d5c25f2d8f62 | Rust | flmng0/soy | /src/lib.rs | UTF-8 | 1,798 | 4 | 4 | [] | no_license | //! # Soy
//! Rust interpolation library.
//!
//! # Usage
//! The main trait used for interpolation is [`soy::Lerper`]. It requires a
//! single method, `calculate`, which calculates interpolation progression at a
//! given time.
//!
//! Example implementing linear interpolation, taken directly from `soy`'s
//! impleme... | true |
7a0f0a56851f32e726cec783baf007e6d9ffc566 | Rust | bojand/infer | /examples/file.rs | UTF-8 | 917 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::env::args;
use std::process::exit;
fn main() {
let mut args = args();
let path = match args.nth(1) {
Some(path) => path,
None => {
eprintln!("Please specify the file path");
exit(1);
}
};
match infer::get_from_path(path) {
Ok(Some(info))... | true |
977f5974dfbd3c33a2fecd1711dbee11ce145369 | Rust | siler/sled | /crates/model/tests/model.rs | UTF-8 | 2,515 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use model::{linearizable, model};
#[test]
fn test_model() {
use std::sync::atomic::{AtomicUsize, Ordering};
model! {
Model => let m = AtomicUsize::new(0),
Implementation => let mut i: usize = 0,
Add(usize)(v in 0usize..4) => {
let expected = m.fetch_add(v, Ordering::SeqCst)... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.