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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
0a58111b64d1b40c776966b432847bbdc3f4d806 | Rust | UTMIST/oneshot-rs | /src/sample/two.rs | UTF-8 | 2,485 | 2.828125 | 3 | [
"MIT"
] | permissive | use rand::seq::SliceRandom;
use std::path::PathBuf;
use std::vec::Vec;
use std::{ffi, fs, io};
macro_rules! choose {
($dir:expr, $func:expr) => {
fs::read_dir($dir)?
.map($func)
.collect::<Result<Vec<_>, io::Error>>()?
.choose(&mut rand::thread_rng())
};
($dir:ex... | true |
5a047eb4d1dc12525e0082643dc9e02325be38b4 | Rust | sirixdb/sirix-rust-client | /src/info.rs | UTF-8 | 3,750 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | //! This module contains types for holding token information and the various node types
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use std::{fmt, io, str::FromStr};
/// A specific connection token
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(test, derive(Serialize, std::cmp::PartialEq))]
pub st... | true |
5b904d1c14f26807271080792e4f52ada61db853 | Rust | Hydrant777/aoc10 | /src/main.rs | UTF-8 | 1,649 | 3.15625 | 3 | [] | no_license | use std::time::Instant;
fn main() {
let start = Instant::now();
let mut data: Vec<u32> = include_str!("test3.txt").lines().map(|c| c.parse::<u32>().unwrap()).collect();
data.sort();
//data.push(data[data.len()-1]+3);
println!("{:?}", data);
// let mut last_adapter: u32 = 0;
// let mut jolts: Vec<u32> =... | true |
09997543ed3b1bee45acc2ed5a83a8a3ff5000c5 | Rust | jacokoo/fff-rs | /fff-macros/src/draw_to.rs | UTF-8 | 2,684 | 2.703125 | 3 | [] | no_license | use proc_macro::TokenStream;
use quote::quote;
use syn::parse_macro_input;
use syn::*;
pub fn do_draw_to(attr: TokenStream, item: TokenStream) -> TokenStream {
let target = parse_macro_input!(attr as Ident);
let body = parse_macro_input!(item as Item);
if let Item::Impl(mut im) = body {
let used: ... | true |
2bf8db93e6a3b1589fb6ff333a694385eacf80cc | Rust | actix/actix-net | /actix-service/src/pipeline.rs | UTF-8 | 9,092 | 2.921875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // TODO: see if pipeline is necessary
#![allow(dead_code)]
use core::{
marker::PhantomData,
task::{Context, Poll},
};
use crate::{
and_then::{AndThenService, AndThenServiceFactory},
map::{Map, MapServiceFactory},
map_err::{MapErr, MapErrServiceFactory},
map_init_err::MapInitErr,
then::{The... | true |
ed00565517566ae986fd9e60e605e15c7d893478 | Rust | jonduvnjak/cc_gui | /src/main.rs | UTF-8 | 5,627 | 2.9375 | 3 | [] | no_license | #![deny(warnings)]
#![warn(clippy::all)]
const AE: [u32; 4] = [3, 4, 3, 7];
const MC: [u32; 10] = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5];
const VISA: [u32; 1] = [4];
// use std::panic;
use egui::*;
use egui_glium::storage::FileStorage;
#[derive(serde::Deserialize, serde::Serialize)]
struct MyApp {
cc: String,
}
impl D... | true |
a071712e96f2f4eb43c916b3d155c29326689cd3 | Rust | oberien/das-protokoll | /v1/csync/src/server/sender.rs | UTF-8 | 2,450 | 2.578125 | 3 | [] | no_license | use std::io;
use std::sync::{Arc, Mutex};
use std::path::PathBuf;
use std::fs;
use futures::{Sink, Async, AsyncSink, Poll, StartSend};
use tokio::net::UdpSocket;
use memmap::MmapMut;
use bitte_ein_bit::BitMap;
use codec::{self, MTU};
use server::ChannelMessage;
pub struct Sender {
socket: UdpSocket,
vec: Vec... | true |
3fdb4255fb158fc2a6de9dd257548d49d115aa27 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/wast/src/core/func.rs | UTF-8 | 2,530 | 2.84375 | 3 | [
"LLVM-exception",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::core::*;
use crate::kw;
use crate::parser::{Parse, Parser, Result};
use crate::token::{Id, NameAnnotation, Span};
#[derive(Debug)]
pub struct Func<'a> {
pub span: Span,
pub id: Option<Id<'a>>,
pub name: Option<NameAnnotation<'a>>,
pub exports: InlineExport<'a... | true |
7e9028a9e6bcf147fdfcf889ab507fa6c0bb8b68 | Rust | sria91-rlox/yaliir | /interpreter/src/astprinter.rs | UTF-8 | 3,176 | 3.4375 | 3 | [
"MIT"
] | permissive | use crate::expression::{Expr, Visitor};
use crate::object::Object;
use crate::token::Token;
pub struct AstPrinter {}
impl AstPrinter {
#[allow(dead_code)]
pub fn print(&mut self, expr: Expr) -> String {
expr.accept(self)
}
fn parenthesize(&mut self, name: &str, exprs: &[&Expr]) -> String {
... | true |
c6ba9f9f35dcf04db178a558b28e8122f89560a6 | Rust | DoumanAsh/os-sync | /src/sem/mod.rs | UTF-8 | 2,482 | 3.765625 | 4 | [
"BSL-1.0"
] | permissive | //!Semaphore primitive
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
mod posix;
#[cfg(all(unix, not(any(target_os = "macos", target_os = "ios"))))]
pub use posix::Sem;
#[cfg(windows)]
mod win32;
#[cfg(windows)]
pub use win32::Sem;
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod mac;
#[c... | true |
9283432ac8862f8bc5889c97e44c80fdb82d0e2d | Rust | garrison/cargo | /src/cargo/sources/path.rs | UTF-8 | 4,374 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::cmp;
use std::fmt::{Show, Formatter};
use std::fmt;
use std::io::fs;
use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry};
use ops;
use util::{CargoResult, internal, internal_error};
pub struct PathSource {
id: SourceId,
path: Path,
updated: bool,
packages: Vec<Pack... | true |
5b6d3f4508d5719e5cd5a78231def5d4d2191b54 | Rust | wwhitesell1995/cryptopals | /Rust/set_1_c4/src/main.rs | UTF-8 | 813 | 2.953125 | 3 | [] | no_license | mod crypto_functions;
use std::str;
fn main() {
output_decrypted_string();
}
fn output_decrypted_string() {
let filename = "set_1_c4_input.txt";
let filehexlines = crypto_functions::read_file_to_string_vec(filename);
let mut max_score_bytes = Vec::new();
for hex_input in filehexlines {
m... | true |
eb1c88d1a09f67f05e9239aadb2c12b862783c5e | Rust | takubokudori/winwrap | /src/um/processenv.rs | UTF-8 | 1,236 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright takubokudori.
// This source code is licensed under the MIT or Apache-2.0 license.
use crate::{raw::um::processenv::*, string::*, *};
use winwrap_derive::*;
/// Gets an environment variable string.
///
/// # Example
///
/// ```rust
/// use winwrap::{
/// string::AString, um::processenv::get_environmen... | true |
b3fb27de469a1c3fe5f19cb21a8401d67a06c65b | Rust | paritytech/jsonrpc | /derive/tests/pubsub-macros.rs | UTF-8 | 4,099 | 2.71875 | 3 | [
"MIT"
] | permissive | use jsonrpc_core;
use jsonrpc_pubsub;
use serde_json;
#[macro_use]
extern crate jsonrpc_derive;
use jsonrpc_core::futures::channel::mpsc;
use jsonrpc_pubsub::typed::Subscriber;
use jsonrpc_pubsub::{PubSubHandler, PubSubMetadata, Session, SubscriptionId};
use std::sync::Arc;
pub enum MyError {}
impl From<MyError> for ... | true |
51a8a8d1798b0accea0b32172b52b82a2e4fdc9f | Rust | minhkhiemm/rust | /error/src/main.rs | UTF-8 | 1,368 | 3.265625 | 3 | [] | no_license | use std::fs;
use std::io;
use std::io::Read;
fn main() {
// let f = open_or_panic("hello");
// println!("{:?}", f);
let _ = match read_file("hello.go") {
Err(e) => panic!("{:?}", e),
Ok(c) => println!("{}", c),
};
// let _ = match fs::File::open("./hello.go") {
// Ok(file) =... | true |
1630d097ce1be81659201b5cd564dba5926d1d22 | Rust | IThawk/rust-project | /rust-master/src/test/ui/abi/struct-enums/struct-return.rs | UTF-8 | 1,617 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![allow(dead_code)]
// ignore-wasm32-bare no libc to test ffi with
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Quad { a: u64, b: u64, c: u64, d: u64 }
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Floats { a: f64, b: u8, c: f64 }
mod rustrt {
use super::{Floats, Quad};
#[link(name = "rust_test_... | true |
07302b3797b4d82f5e8410b486125fe21bcfc1f3 | Rust | SimonCadge/sound-effights-godot | /src/lib.rs | UTF-8 | 10,739 | 2.609375 | 3 | [] | no_license | #[macro_use]
extern crate gdnative;
use pitch_detection::{McLeodDetector, PitchDetector, Pitch};
#[derive(gdnative::NativeClass)]
#[inherit(gdnative::Reference)]
struct AudioAnalyser;
#[derive(ToVariant)]
struct Analysis {
sample: gdnative::AudioStreamSample,
duration: f32,
volume: f32,
frequency: Op... | true |
0c363073abc82dcd90e2cdf226939b4e2ba5fc9f | Rust | kaj/rsass | /rsass/src/css/string.rs | UTF-8 | 6,599 | 3.484375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::value::Quotes;
use std::fmt::{self, Write};
/// A string in css. May be quoted.
#[derive(Clone, Debug, Eq, PartialOrd)]
pub struct CssString {
value: String,
quotes: Quotes,
}
impl CssString {
/// Create a new `CssString`.
pub fn new(value: String, quotes: Quotes) -> Self {
CssStri... | true |
7a4ceefa12de7855875d549032ce5dcf7d3be4f6 | Rust | laerling/rust-kernel | /src/memory.rs | UTF-8 | 821 | 2.75 | 3 | [] | no_license | use x86_64::structures::paging::PageTable;
/// Returns a mutable reference to the active level 4 table.
///
/// This function is unsafe because the caller must guarantee that the
/// complete physical memory is mapped to virtual memory at the passed
/// `physical_memory_offset`. Also, this function must be only called... | true |
1a5c2a2b8def45d6cead5f558c92aad02568e762 | Rust | altdesktop/colornamer-rs | /src/color.rs | UTF-8 | 2,972 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[derive(Copy, Clone, Debug)]
pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub name: &'static str
}
lazy_static! {
static ref HEX_ALPHABETS: HashMap<char, u32> = {
let mut m = HashMap::new();
m.insert('0', 0);
m.insert('1', 1);
... | true |
6462b36164ed4c36c2e2e7eff6cba6fc783ae487 | Rust | antonisdimopoulos/rust-x509-example | /src/main.rs | UTF-8 | 3,073 | 3.046875 | 3 | [] | no_license | use std::env;
use std::collections::HashMap;
use x509_parser::prelude::{parse_x509_certificate, parse_x509_pem};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 3 {
println!("Usage: {} [encode | decode] filename", &args[0]);
std::process::exit(1);
}
let que... | true |
4ffa11f1afd218a46e64587aab8e577c9b4de796 | Rust | Matthias-Fauconneau/iced | /native/src/widget/text_input/cursor.rs | UTF-8 | 5,471 | 3.9375 | 4 | [
"MIT"
] | permissive | //! Track the cursor of a text input.
use crate::widget::text_input::Value;
/// The cursor of a text input.
#[derive(Debug, Copy, Clone)]
pub struct Cursor {
state: State,
}
/// The state of a [`Cursor`].
///
/// [`Cursor`]: struct.Cursor.html
#[derive(Debug, Copy, Clone)]
pub enum State {
/// Cursor without ... | true |
e37947cb6202bdd45a378401d49046aa8f765500 | Rust | jlingohr/ray_trace | /src/aarect.rs | UTF-8 | 3,196 | 2.984375 | 3 | [] | no_license | use super::aabb::AABB;
use super::hittable::{HitRecord, Hittable};
use super::material::Material;
use super::point::Point;
use super::ray::Ray;
use super::vector::Vec3;
use rand::Rng;
pub enum Plane {
XY,
XZ,
YZ,
}
impl Plane {
pub fn get_axes(&self) -> (usize, usize, usize) {
match *self {
... | true |
a7125e70c600b1aea55afd9eab2fb39ee5e9fc10 | Rust | anuj-modi/adventofcode2020 | /src/one/mod.rs | UTF-8 | 593 | 3.125 | 3 | [] | no_license | use std::fs;
pub fn solve() {
let contents =
fs::read_to_string("input/one.txt").expect("Something went wrong reading the file");
let mut nums = vec![];
for line in contents.split("\n") {
if let Ok(n) = line.parse::<u32>() {
nums.push(n);
}
}
for x in &nums {
... | true |
56e357cc5f0c8478099f82464e00c8238aa3cdbc | Rust | dmexe/tc-cache | /src/snapshot/reading.rs | UTF-8 | 4,460 | 2.5625 | 3 | [] | no_license | use std::io::ErrorKind::UnexpectedEof;
use std::io::{Cursor, Error as IoError, Read, Write};
use std::path::Path;
use crate::bytes::FromLeBytes;
use crate::errors::ResultExt;
use crate::mmap::Mmap;
use crate::snapshot::{Entry, BUFFER_SIZE, VERSION, VERSION_LEN};
use crate::{mmap, Error, Stats};
#[derive(Debug)]
pub s... | true |
f348ebd6e7bd47b0b3ab982d7d0bcc1376366913 | Rust | ltriess/advent-of-code-2020 | /src/bin/11_seating-system_part1.rs | UTF-8 | 3,526 | 3.609375 | 4 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{self, BufRead, BufReader};
struct WaitingArea {
width: u32,
height: u32,
seats: Vec<Vec<char>>,
}
impl WaitingArea {
fn new(seats: Vec<Vec<char>>) -> WaitingArea {
WaitingArea {
width: seats[0].len() as u32,
height: seats.len() as u32,
... | true |
bb4d79d133c2b1fa90c4eb4cb1b4750d548d534e | Rust | enetsee/advent_of_code_2020 | /day5/src/main.rs | UTF-8 | 1,627 | 3.4375 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, BufRead, BufReader, Error, ErrorKind};
fn main() {
let mut f = File::open("input.txt")
.and_then(|f| {
BufReader::new(f)
.lines()
.map(|res| res.map(|str| unique_id(decode(&str))))
.collect::<io::Result<Vec<u... | true |
76af8506e18a585a6bf6fbd3ef4f00cf63e5d514 | Rust | felixzhuologist/rusty-pi-os | /2-fs/fat32/src/mbr.rs | UTF-8 | 3,366 | 3.078125 | 3 | [] | no_license | use std::{fmt, io};
use util;
use traits::BlockDevice;
const TABLE_OFFSET: usize = 446;
const ENTRY_SIZE: usize = 16;
#[repr(C, packed)]
#[derive(Copy, Clone)]
pub struct CHS {
// FIXME: Fill me in.
}
#[repr(C, packed)]
#[derive(Debug, Clone)]
pub struct PartitionEntry {
bootable: bool,
partition_type: ... | true |
f09507c4382204ed7f9f27b884e55d329c5f6546 | Rust | Caleb-o/100-days-of-code | /rust/src/bytecode/chunk.rs | UTF-8 | 1,743 | 3.5 | 4 | [] | no_license | use super::value::{Value, ValueArray};
#[derive(Debug)]
pub enum OpCode
{
Constant,
Negate,
Add,
Subtract,
Multiply,
Divide,
Return,
Unknown,
}
impl From<u8> for OpCode
{
fn from(orig: u8) -> Self
{
match orig
{
0 => Self::Constant,
1 =>... | true |
749d50928e890d89a1596c53a34dc9a22accc1c3 | Rust | jiangzhe/jqdata | /jqdata-blocking/src/error.rs | UTF-8 | 2,472 | 3.171875 | 3 | [
"MIT"
] | permissive | use serde::de;
use std::fmt;
#[derive(Debug)]
pub enum Error {
Reqwest(reqwest::Error),
Server(String),
Client(String),
Serde(String),
Csv(csv::Error),
Json(serde_json::Error),
Io(std::io::Error),
Utf8(std::str::Utf8Error),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt:... | true |
6d80cefd27b66497bdb7425c743e22226659a973 | Rust | zyhong/tickrs | /src/common.rs | UTF-8 | 8,311 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::hash::{Hash, Hasher};
use std::str::FromStr;
use std::time::Duration;
use chrono::{Local, TimeZone, Utc};
use itertools::izip;
use serde::Deserialize;
use tickrs_api::Interval;
use crate::api::model::ChartData;
use crate::api::Range;
#[derive(PartialEq, Clone, Copy, Debug, Hash, Deserialize)]
pub enum Chart... | true |
87e2ff049356e403409571b4b2e020610d43343c | Rust | BookOwl/neko-rs | /src/lib.rs | UTF-8 | 716 | 2.703125 | 3 | [
"Unlicense"
] | permissive | //! A module for working with the [neko vm](http://nekovm.org/).
//!
//! This module contains two main parts.
//!
//! 1. The raw FFI bindings in the [raw submodule](raw/).
//! 2. A safe, rusty wrapper in the top level.
//!
//! Unless you have a specific reason otherwise you should always use the safe wrapper instead of... | true |
2954cb338d8c1bb713f542a473bb374235e2814b | Rust | noodle-2d/rust-start-project | /src/task/guessing_game.rs | UTF-8 | 795 | 3.578125 | 4 | [] | no_license | use std::cmp::Ordering;
use crate::util::input;
pub fn run_task() {
println!("Guess the number!");
let secret_number = input::get_random_number();
loop {
println!("Please input your guess.");
let guess = match input::get_number_from_stdin() {
Ok(number) => number,
E... | true |
346d7a15ace35a1c1b7175e729d4f9049300bf39 | Rust | IThawk/rust-project | /rust-master/src/test/ui/try-operator-on-main.rs | UTF-8 | 591 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // ignore-cloudabi no std::fs support
#![feature(try_trait)]
use std::ops::Try;
fn main() {
// error for a `Try` type on a non-`Try` fn
std::fs::File::open("foo")?; //~ ERROR the `?` operator can only
// a non-`Try` type on a non-`Try` fn
()?; //~ ERROR the `?` operator can only
// an unrelated... | true |
5a4c9b623f4b78f6db43551099b7f88c89ce0b56 | Rust | deinstapel/cursive-multiplex | /src/error.rs | UTF-8 | 927 | 2.953125 | 3 | [
"BSD-3-Clause"
] | permissive | use crate::Id;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum AddViewError {
#[error("some error occured")]
GenericError {},
}
#[derive(Debug, Error)]
pub enum RemoveViewError {
#[error("invalid id given, cannot be removed: {}", id)]
InvalidId { id: Id },
#[error("id has no parent, cannot... | true |
cfb14b7417399bf50223cf8f70fb5a8037761509 | Rust | canhmai/BLAKE3f | /b3sum/src/gpu.rs | UTF-8 | 11,335 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"CC0-1.0"
] | permissive | use anyhow::Result;
use blake3::gpu::GpuHasher;
use blake3::join::RayonJoin;
use blake3::{OutputReader, CHUNK_LEN};
use std::collections::VecDeque;
use std::fs::File;
use super::vulkan::{GpuInstance, GpuTask};
const BUFFER_SIZE: usize = 32 * 1024 * 1024;
const TASKS: usize = 3;
pub struct Gpu {
disabled: bool,
... | true |
b995d56ee99128e06e2cf6bc4e9fcd3e7b84ab5b | Rust | johnshaw/aoc-2019 | /day07/src/main.rs | UTF-8 | 2,088 | 2.65625 | 3 | [] | no_license | use std::io::{self, BufRead};
use common::*;
use itertools::Itertools;
use std::pin::Pin;
use std::future::Future;
use std::rc::Rc;
async fn part_2(line: String) {
let line = Rc::new(line);
let mut results = Vec::new();
for perm in (5..10).permutations(5) {
// Create connections
let (mut s1... | true |
75b4e56002f693899e9965852d350d19c451fc04 | Rust | tonngw/leetcode | /rust/1984-minimum-difference-between-highest-and-lowest-of-k-scores.rs | UTF-8 | 675 | 3.296875 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn minimum_difference(nums: Vec<i32>, k: i32) -> i32 {
let mut nums = nums;
let (mut left, mut right) = (0, (k - 1) as usize);
let mut res = i32::MAX;
nums.sort();
while right < nums.len() {
res = res.min(nums[right] - nums[left]);
... | true |
34cdcf1bf5d5cbe048f5c90ae4ea6bc98bc4b256 | Rust | FireFlyForLife/RustSoftwareRaytracer | /src/ray.rs | UTF-8 | 466 | 3.21875 | 3 | [
"MIT"
] | permissive | use crate::math_extensions::*;
#[derive(Debug)]
pub struct Ray {
pub origin: Vec3,
pub direction: Vec3,
}
impl Ray {
pub fn new(origin: Vec3, direction: Vec3) -> Ray {
Ray{ origin, direction}
}
pub fn point_at_parameter(&self, t: f32) -> Vec3 {
self.origin + t * self.direction
... | true |
cf5104456d9f9c52d1803d6465f5b1fdfa4f4b62 | Rust | cedretaber/codes_for_atcoder | /abc/081/b.rs | UTF-8 | 1,161 | 2.671875 | 3 | [] | no_license | macro_rules! get {
($t:ty) => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().parse::<$t>().unwrap()
}
};
($($t:ty),*) => {
{
let mut line: String = String::new();
std::i... | true |
95dde14212f450dab838e6b9fd9e6f0e9ad1b93c | Rust | ZcashFoundation/zebra | /zebra-chain/src/primitives/proofs/halo2.rs | UTF-8 | 1,465 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use std::{fmt, io};
use crate::serialization::{
zcash_serialize_bytes, SerializationError, ZcashDeserialize, ZcashSerialize,
};
/// An encoding of a Halo2 proof, as used in [Zcash][halo2].
///
/// Halo2 proofs in Zcash Orchard do not have a fixed size, hence the newtype
/// ar... | true |
a5215a35194a4dc0e8a3a987e99e93fa899705e9 | Rust | syohex/exercism | /rust/perfect-numbers/src/lib.rs | UTF-8 | 503 | 3.28125 | 3 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq, Eq)]
pub enum Classification {
Abundant,
Perfect,
Deficient,
}
pub fn classify(num: u64) -> Option<Classification> {
if num == 0 {
return None;
}
let n = if num == 1 {
0
} else {
(1..=(num / 2)).filter(|&n| num % n == 0).sum::<u64>()
}... | true |
aa6ae5321a8896adae26782708d838b69baf4512 | Rust | canguruhh/hyperspace | /primitives/src/lib.rs | UTF-8 | 2,571 | 2.59375 | 3 | [] | no_license | #![cfg_attr(not(feature = "std"), no_std)]
#[macro_use]
extern crate num_derive;
use codec::{Decode, Encode};
#[cfg(feature = "std")]
use serde::{Deserialize, Serialize};
use sp_runtime::{
FixedU128,
generic,
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiSignature, RuntimeDebug
};
/// An index to a b... | true |
48879733d0d3d70e7e354ededf546c1e71a8ce8a | Rust | InterstellerM0nkey/skyline-rs | /src/text_iter.rs | UTF-8 | 7,650 | 2.890625 | 3 | [] | no_license | use crate::hooks::{getRegionAddress, Region};
use std::{iter::StepBy, ops::Range};
pub struct TextIter<InnerIter: Iterator<Item = usize> + Sized> {
inner: InnerIter,
}
impl TextIter<StepBy<Range<usize>>> {
pub fn new() -> Self {
unsafe {
let text = getRegionAddress(Region::Text) as usize;
... | true |
1ebb70cd54c340ea082c31c4ce782babe6ba5566 | Rust | teloxide/teloxide | /crates/teloxide-core/src/types/user.rs | UTF-8 | 6,285 | 3.4375 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::types::UserId;
/// This object represents a Telegram user or bot.
///
/// [The official docs](https://core.telegram.org/bots/api#user).
#[serde_with_macros::skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct User {
... | true |
1f0ce7558a93ae3c19f0d417c4ecf9ef0902e32e | Rust | Herlitzd/fsix | /src/main.rs | UTF-8 | 2,208 | 2.96875 | 3 | [] | no_license | //! The simplest possible example that does something.
extern crate ggez;
use ggez::conf;
use ggez::event::{self, EventHandler, Keycode, Mod};
use ggez::graphics::{self, DrawMode, Point2, Vector2};
use ggez::nalgebra as na;
use ggez::{Context, GameResult};
const g: f32 = 1.0;
struct MainState {
actors: Vec<Actor>... | true |
667d31ae2a5d38c0f608e90d71f6ccc3e7ee8000 | Rust | kabergstrom/atelier-assets | /loader/src/handle.rs | UTF-8 | 21,710 | 3.0625 | 3 | [] | no_license | use crate::{AssetRef, AssetUuid, LoadHandle, LoadStatus, Loader, LoaderInfoProvider, TypeUuid};
use crossbeam_channel::{unbounded, Receiver, Sender};
use derivative::Derivative;
use serde::{
de::{self, Deserialize, Visitor},
ser::{self, Serialize, Serializer},
};
use std::{
cell::RefCell,
collections::{... | true |
71827f2bf8c9ec6f3af1a56a5babfbf590f074fc | Rust | allchain/BlockChainRust | /blockchain8/core/src/miner.rs | UTF-8 | 1,453 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use crate::block::Block;
use crate::pow::ProofOfWork;
use crate::transaction::Transaction;
const MINER_NAME: &str = "anonymous";
#[derive(Debug, Clone)]
pub struct Miner {
name: String,
pub balance: u64,
address: String,
}
impl Miner {
pub fn new(address: String) -> Self {
Miner {
... | true |
0318f8ff0761689b093f4295f2a455f59c87c4f6 | Rust | rheehot/FFXIVTools | /libs/sqpack_reader/src/reference.rs | UTF-8 | 1,537 | 2.890625 | 3 | [
"MIT"
] | permissive | #[cfg(debug_assertions)]
use alloc::string::String;
use super::archive_id::SqPackArchiveId;
#[derive(Copy, Clone, Hash, Eq, PartialEq)]
pub struct SqPackFileHash {
pub path: u32,
pub folder: u32,
pub file: u32,
}
impl SqPackFileHash {
pub fn new(path_str: &str) -> Self {
let folder_separator ... | true |
91e214476192ba8ec4fe5689e7cadf22b9c86b3b | Rust | johnchandlerburnham/johnchandlerburnham.github.io | /projects/trpl/04/ownership/src/main.rs | UTF-8 | 2,459 | 3.84375 | 4 | [] | no_license | fn main() {
{ let s = "hello";
println!("s in scope: {}", s);
}
// println!{"s not in scope: {}", s);
{ let mut s = String::from("hello");
s.push_str(", world!");
println!("{}", s);
}
{ let s1 = String::from("hello");
// let s2 = s1;
println!("{}, world", s1);
}
{ let s = String:... | true |
c0793ed10a7a4f957be2d36803a402510772f65a | Rust | yijie37/DaQiao | /bridge/parity-ethereum/ethcore/sync/src/chain/mod.rs | UTF-8 | 60,289 | 2.84375 | 3 | [
"Unlicense"
] | permissive | // Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at yo... | true |
e2c13adae74c37a1278a8b97e8ca0c663a8784b4 | Rust | EFanZh/LeetCode | /src/problem_0239_sliding_window_maximum/deque_2.rs | UTF-8 | 2,192 | 3.421875 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::collections::VecDeque;
struct Queue {
front: i32,
rest: VecDeque<i32>,
}
impl Queue {
fn with_capacity(capacity: usize) -> Self {
Self {
... | true |
359e5ebd68c6ef8b41c031b2c4000fcabe67ecfa | Rust | danieldk/tch-rs | /src/nn/init.rs | UTF-8 | 2,831 | 3.3125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Variable initialization.
use crate::{Device, Kind, TchError, Tensor};
/// Variable initializations.
#[derive(Debug, Copy, Clone)]
pub enum Init {
/// Constant value.
Const(f64),
/// Random normal with some mean and standard deviation.
Randn { mean: f64, stdev: f64 },
/// Uniform initializatio... | true |
b0a15995ff56229c83641c29b456ae56ea06462c | Rust | ikornaselur/rusty-invaders | /src/cpu/instructions/daa.rs | UTF-8 | 456 | 3.03125 | 3 | [] | no_license | use cpu::CPU;
/// Perform decimal adjustment, ignoring the Auxiliary Carry
///
/// Sets conditions flags
///
/// # Cycles
///
/// 4
///
/// # Arguments
///
/// * `cpu` - The cpu to perform the DDA in
///
pub fn daa(cpu: &mut CPU) -> u8 {
if cpu.a & 0x0f > 9 {
cpu.a += 6;
}
if cpu.a & 0xf0 > 0x90 {
... | true |
6d745e71c97cc3a531d18510e73c9f59f6399193 | Rust | galenelias/AdventOfCode_2016 | /src/Day1/mod.rs | UTF-8 | 1,347 | 3.28125 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::collections::HashSet;
#[derive(PartialEq, Copy, Clone)]
enum Dir {
North,
East,
South,
West,
}
pub fn solve() {
let stdin = io::stdin();
let input : Vec<_> = stdin.lock().lines().next().unwrap().unwrap()
.split(", ").map(String::from).collect();
let dirs = vec!(Dir::No... | true |
06aeefac324b2d29942bb299afeb3b585919e5d7 | Rust | jeamland/aoc2020 | /day15/src/main.rs | UTF-8 | 1,485 | 3.171875 | 3 | [] | no_license | use std::collections::HashMap;
use std::str::FromStr;
use clap::{App, Arg};
fn main() {
let matches = App::new("AOC2020 Day 15")
.arg(
Arg::with_name("start")
.help("Starting numbers")
.required(true)
.index(1),
)
.get_matches();
... | true |
71b03f4db6d14568f8fd843f5ed9b12fc6e1e58d | Rust | ThePrimeagen/vim-royale | /vim_royale_view/src/message.rs | UTF-8 | 1,046 | 2.875 | 3 | [] | no_license | use encoding::server::{ServerMessage, self};
#[derive(Debug, Clone)]
pub enum Msg {
Closed,
Connecting,
Connected,
Error(String),
Message(ServerMessage),
KeyStroke(String),
}
impl Msg {
pub fn key_from_msg(msg: &Msg) -> &'static str {
return match msg {
Msg::Closed => "... | true |
d6bbd5546c390e6138d341dc565da900c6aadd78 | Rust | quebin31/word-count | /src/main.rs | UTF-8 | 2,416 | 2.890625 | 3 | [] | no_license | use std::fs::File;
use anyhow::Error;
use clap::{App, Arg};
use serde_json as json;
const VERSION: &str = env!("CARGO_PKG_VERSION");
const AUTHORS: &str = env!("CARGO_PKG_AUTHORS");
const ABOUT: &str = env!("CARGO_PKG_DESCRIPTION");
fn main() -> Result<(), Error> {
let matches = App::new("word-count")
.a... | true |
ecf38a0742c4cdb1ca31b83387a1f6efb1f1c96c | Rust | slinkydeveloper/json-fuse-fs | /src/fs.rs | UTF-8 | 7,006 | 2.625 | 3 | [] | no_license | use fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyDirectory};
use super::*;
use std::time::{Duration, SystemTime};
use libc::ENOENT;
use std::collections::HashMap;
use std::convert::TryInto;
use std::rc::{Rc, Weak};
use std::borrow::Borrow;
use json_fuse_fs::Flatten;
const TTL:... | true |
77bd9b295609eb6684678af178e893f30de57af7 | Rust | aylei/leetcode-rust | /src/solution/s0309_best_time_to_buy_and_sell_stock_with_cooldown.rs | UTF-8 | 2,365 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | /**
* [309] Best Time to Buy and Sell Stock with Cooldown
*
* Say you have an array for which the i^th element is the price of a given stock on day i.
*
* Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times) w... | true |
23771e153b2a397610bb0ddfb00ebffbd13b3273 | Rust | rust-embedded/msp430 | /src/interrupt.rs | UTF-8 | 2,912 | 3.15625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Interrupts
use crate::asm;
pub use critical_section::{CriticalSection, Mutex};
/// Disables all interrupts
#[inline(always)]
pub fn disable() {
match () {
#[cfg(target_arch = "msp430")]
() => unsafe {
// Do not use `nomem` and `readonly` because prevent subsequent memory accesses ... | true |
4aa3d8c45b495c3373021c67fb8af5230ca83447 | Rust | padenot/mafmds | /src/main.rs | UTF-8 | 9,215 | 2.8125 | 3 | [] | no_license | use cubeb::StereoFrame;
use std::f32::consts::PI;
use std::sync::Arc;
use audio_clock::audio_clock;
use monome::{Monome, MonomeEvent};
use std::{thread, time};
use crossbeam::queue::ArrayQueue;
const SAMPLE_FREQUENCY: u32 = 48_000;
const STREAM_FORMAT: cubeb::SampleFormat = cubeb::SampleFormat::Float32NE;
type Frame... | true |
05d885ae0365b70f84464d9980de3f20df0acd7b | Rust | DrSh4dow/printpdf | /src/types/plugins/xmp/xmp_metadata.rs | UTF-8 | 3,289 | 2.953125 | 3 | [
"MIT"
] | permissive | //! Stub plugin for XMP Metadata streams, to be expanded later
use time::OffsetDateTime;
use lopdf;
use PdfConformance;
use utils::random_character_string_32;
/// Initial struct for Xmp metatdata. This should be expanded later for XML handling, etc.
/// Right now it just fills out the necessary fields
#[derive(Debug... | true |
8c77a950168b047d65bf084e6c9bf16ec5119e5b | Rust | sueken5/resea | /servers/pcat/keyboard.rs | UTF-8 | 2,390 | 2.6875 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | use crate::keymap::*;
use resea::collections::VecDeque;
use resea::idl::kernel::{call_listen_irq, call_read_ioport};
use resea::prelude::*;
const KEYBOARD_IRQ: u8 = 1;
const IOPORT_DATA: u64 = 0x60;
const IOPORT_STATUS: u64 = 0x64;
const STATUS_OUTBUF_FULL: u8 = 1 << 0;
pub struct Keyboard {
kernel_server: &'stat... | true |
df7af0d1070fc9c876912fd3756e0de42c257e18 | Rust | popovegor/codeforces | /830A/rust/src/main.rs | UTF-8 | 2,768 | 2.734375 | 3 | [] | no_license | fn main() {
use std::io::stdin;
use std::io::prelude::*;
use std::collections::{HashMap, HashSet};
use std::i32;
let stdin = stdin();
let mut lc = 0;
let mut men : HashSet<i32> = HashSet::new();
let mut keys : HashSet<i32> = HashSet::new();
let mut office : i32 = 0;
while let S... | true |
a3bd259b322df1a9b1fe3b8de63c9c285a3aecdd | Rust | edg-l/teestatus | /src/common.rs | UTF-8 | 170 | 2.546875 | 3 | [
"MIT"
] | permissive | /// Player info.
#[derive(Debug)]
pub struct Player {
pub name: String,
pub clan: String,
pub country: i32,
pub score: i32,
pub is_spectator: bool,
}
| true |
b0e3231e5e353a6561cfcff5ef76374aeefe866a | Rust | zhengminlai/Rust | /linked_list/src/main2.rs | UTF-8 | 1,461 | 3.515625 | 4 | [] | no_license | // This linked list implementation is credited to Jonathon Reem: github.com/reem
use std::sync::Arc;
// A functional, shareable, persistent singly linked list
// This implementation is threadsafe that could have cycles
pub enum List<T> {
// A list with a head and a tail
Cons(T, Arc<List<T>>),
// The empty list
... | true |
d146023b5b6683ab98bed539c0a7df2de80979eb | Rust | passcod/blograph | /native/list/src/test_contains.rs | UTF-8 | 499 | 2.875 | 3 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
#[test]
fn there() {
let list = test_util::make_list();
let item = list.find_by_slug("2015/jan/25/300-shorts").unwrap();
assert_eq!(list.contains(&item), true);
}
#[test]
fn not_there() {
let all = test_util::make_list();
let item = all.find_by_slug("2015/jan/25/300-shorts").unwrap(... | true |
a19351e377e9a7d11335c31868886fd5cd9e7ed2 | Rust | baitcenter/actix-raft | /src/memory_storage/mod.rs | UTF-8 | 6,530 | 2.734375 | 3 | [] | no_license | use std::collections::BTreeMap;
use actix::prelude::*;
use log::{error};
use serde::{Serialize, Deserialize};
use crate::{
AppError, NodeId,
messages,
storage::{
AppendLogEntries,
ApplyEntriesToStateMachine,
CreateSnapshot,
CurrentSnapshotData,
GetCurrentSnapshot,
... | true |
a973b8893d881125605835b1690331697df7f084 | Rust | bradparks/metaswitch-server | /src/service.rs | UTF-8 | 3,402 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::net::{IpAddr,SocketAddr};
use std::collections::HashMap;
use futures::{Future,future};
use futures;
use futures::*;
use hyper::{self, Method, StatusCode, Body, Request, Response};
use hyper::service::{Service, NewService};
use hyper::server::conn::Http;
use serde_json;
use tokio;
use tokio::net::TcpListener;
... | true |
ee115c3fc94d338fb0444c3c560ad3a0b884903a | Rust | TheYkk/rs-whois | /src/main.rs | UTF-8 | 672 | 3.0625 | 3 | [] | no_license | use std::io::{
Read,
Write,
};
use std::net::TcpStream;
use std::str::from_utf8;
fn main() -> Result<(), std::io::Error> {
// Open new tcp connection to whois server
let mut con = TcpStream::connect("whois.nic.uno:43")?;
// Send domain name with new line
con.write_all("kaan.uno \r\n".as_bytes(... | true |
ad31ddb831e1bd5bf315b63577400871dd995e64 | Rust | calebhiebert/aoc2020 | /src/day13.rs | UTF-8 | 3,906 | 3.265625 | 3 | [] | no_license | use prettytable::{Table, Row, Cell};
const TEST_DATA: &str = "1001798
7,13,x,x,59,x,31,19";
#[derive(Debug)]
struct SchedTimes {
times: Vec<i32>
}
impl SchedTimes {
fn closest_to(&self, n: i32) -> (i32, i32) {
self
.times
.iter()
.map(|bid| {
let mu... | true |
5e308c26118dfe6d090631d58241b67f8859ea17 | Rust | joshradin/apfmalloc | /tests/multi_threads.rs | UTF-8 | 2,363 | 2.5625 | 3 | [
"MIT"
] | permissive | extern crate apfmalloc_lib;
use core::sync::atomic::Ordering;
use apfmalloc_lib::ptr::auto_ptr::AutoPtr;
use apfmalloc_lib::{do_aligned_alloc, do_free, IN_BOOTSTRAP, IN_CACHE};
use std::alloc::{GlobalAlloc, Layout};
use std::sync::{Arc, Mutex};
use std::thread;
struct Dummy;
#[global_allocator]
static ALLOCATOR: Dumm... | true |
6017205ac01d404e4b0cf8a92ce6ff56c5bd532e | Rust | sssilver/tetrust | /src/curses_renderer.rs | UTF-8 | 2,559 | 3.046875 | 3 | [] | no_license | use error::Result;
use game::board::Board;
use pancurses;
use renderer::{Point, Renderer};
use std::collections::BinaryHeap;
use subsystem::Subsystem;
pub struct CursesRenderer<'a> {
window: &'a pancurses::Window,
texts: BinaryHeap<(Point, String)>,
blocks: BinaryHeap<(Point, bool)>
}
impl<'a> CursesRe... | true |
da6c6d1eb43593385eddae47692bec57aeec7ef8 | Rust | Lutetium-Vanadium/anilang | /crates/vm/src/value/serialize.rs | UTF-8 | 8,562 | 2.875 | 3 | [
"MIT"
] | permissive | use super::Value;
use crate::function::Function;
use crate::types::Type;
use crate::DeserializationContext;
use serialize::{Deserialize, DeserializeCtx, Serialize};
use std::cell::RefCell;
use std::io::{self, prelude::*};
use std::rc::Rc;
impl Serialize for Value {
fn serialize<W: Write>(&self, buf: &mut W) -> io:... | true |
9c96999d697c00997710aa79763d3ad2f80e3bbc | Rust | SlimTim10/embedded-rust-examples | /src/led-pattern/f3/src/examples/_00_hello.rs | UTF-8 | 880 | 2.796875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Prints "Hello, world" on the OpenOCD console
//!
//! ```
//! #![deny(unsafe_code)]
//! #![deny(warnings)]
//! #![no_main]
//! #![no_std]
//!
//! #[macro_use(entry, exception)]
//! extern crate cortex_m_rt as rt;
//! extern crate cortex_m_semihosting as semihosting;
//! extern crate f3;
//! extern crate panic_semih... | true |
db03cc15df71c5e23e64b2d536c4ab4442ea971d | Rust | secmlberry/solang | /src/resolver/cfg.rs | UTF-8 | 86,435 | 2.859375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use num_bigint::BigInt;
use num_bigint::Sign;
use num_traits::One;
use num_traits::FromPrimitive;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::LinkedList;
use unescape::unescape;
use parser::ast;
use hex;
use output;
use output::Output;
use resolver;
#[derive(Parti... | true |
8d1680c17208c07a8e9f3533ab583d4793917be3 | Rust | fabianboesiger/idle-game | /src/routes/account.rs | UTF-8 | 3,956 | 2.65625 | 3 | [] | no_license | use crate::{
combine,
model::{
session::{update_session, with_session, Flashes, Layout, Session},
user::{
extract_confirm_password, extract_password, extract_username, User,
},
},
Error,
};
use askama::Template;
use std::collections::HashMap;
use warp::{filters::Boxed... | true |
03f15e4df37b777257c01c30f25c3fccd421d9de | Rust | wotsushi/competitive-programming | /arc/094/d.rs | UTF-8 | 1,590 | 3.171875 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
#![allow(unused_variables)]
fn bis<P>(ok: i64, ng: i64, p: P) -> i64
where P: Fn(i64) -> bool {
let mid = (ok + ng) / 2;
if (ok - ng).abs() == 1 {
ok
} else if p(mid) {
bis(mid, ng, p)
} else {
bis(ok, mid, p)
}
}
fn main() {
let Q: usize =... | true |
5d72553271bf34e8cfb8339e494a83ad58bf10e6 | Rust | bradfordcp/adventofcode | /2020/handy-haversnacks/src/lib.rs | UTF-8 | 3,555 | 3.234375 | 3 | [] | no_license | use std::{collections::{HashMap, HashSet}, fs, io};
#[macro_use]
extern crate lazy_static;
extern crate regex;
use regex::Regex;
lazy_static! {
// light red bags contain 1 bright white bag, 2 muted yellow bags.
static ref RULE_REGEX: Regex = Regex::new(r"(.*) contain (.+)\.").unwrap();
static ref BAG_REGE... | true |
d4ac69144bd31729c0bc8a1fd141a59759224363 | Rust | Nakamurus/rust_markdown_graph | /src/input_handler.rs | UTF-8 | 1,357 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use clap::{App, Arg, Error};
pub fn input_handler<'a>() -> Result<(String, String, String), Error> {
let matches = App::new("markdown_outliner")
.version("0.1")
.author("Nakamura")
.about("parse markdown file to create file outline")
.arg(
Arg::with_name("INPUT")
... | true |
247a9b11d7797efef8c7d3e2c66d95b5040dceae | Rust | peterjgilbert/etcommon-rs | /block-core/src/transaction.rs | UTF-8 | 1,430 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use rlp::{UntrustedRlp, DecoderError, RlpStream, Encodable, Decodable};
use bigint::{Address, U256, M256};
use sha3::{Digest, Keccak256};
// Use transaction action so we can keep most of the common fields
// without creating a large enum.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TransactionAction {
Ca... | true |
d45490dbf8157b943b1152d2abef9cc56416a334 | Rust | lbrande/rust-deep-learning | /lib/src/utils/vector.rs | UTF-8 | 6,128 | 3.109375 | 3 | [] | no_license | use rand::prelude::*;
use rand::seq::SliceRandom;
use std::isize;
use std::iter::*;
use std::ops::*;
use std::slice::Iter;
use std::slice::IterMut;
use std::vec::IntoIter;
pub trait VectorUtils<'a, T: 'a> {
fn data(&'a self) -> &'a [T];
fn len(&'a self) -> isize {
self.data().len() as isize
}
... | true |
8895ee27b3e17205047ff7f47f78fe49a7b3a155 | Rust | saschazar21/cloudflare-workers | /packages/crypto/tests/web.rs | UTF-8 | 1,232 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen_test;
use wasm_bindgen_test::*;
use crypto::*;
// wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
pub fn test_private_key_has_length() {
let bitsize = BIT_SIZE[0];
let key = Crypt... | true |
25af3ed4034ad828078d2bdbb6f9094d4577b86f | Rust | LukasKalbertodt/jswag | /src/check/mod.rs | UTF-8 | 3,166 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::io::{self, Read};
use job::Job;
use std::fs::File;
use base::{code, diag};
use syntax;
use std;
use args::Encoding;
use std::path::Path;
#[derive(Debug)]
pub enum Error {
Io(io::Error),
Utf8(std::str::Utf8Error),
// CriticalReport(diag::Report),
Unknown,
}
impl From<io::Error> for Error {
... | true |
6302f862a9807c6179e6fd5b11de8543a3e014a1 | Rust | TyPott/aoc2018 | /day3/src/main.rs | UTF-8 | 1,967 | 3.21875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use std::str::FromStr;
static INPUT: &str = include_str!("input");
fn main() {
println!("Day 3, Part 1: {}", part1(INPUT));
println!("Day 3, Part 2: {}", part2(INPUT));
}
fn part1(input: &str) -> usize {
let mut pairs = HashMap::new();
for claim in input.line... | true |
149828be12aa55072d806b8384f57586b6773049 | Rust | little-dude/xain-fl | /rust/xaynet-server/src/storage/impls.rs | UTF-8 | 7,689 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | use crate::state_machine::coordinator::CoordinatorState;
use derive_more::{From, Into};
use paste::paste;
use redis::{ErrorKind, FromRedisValue, RedisError, RedisResult, RedisWrite, ToRedisArgs, Value};
use xaynet_core::{
crypto::{ByteObject, PublicEncryptKey, PublicSigningKey},
mask::{EncryptedMaskSeed, MaskOb... | true |
ad6e9c13e823960d92cffeb42468c4061dfc7747 | Rust | tntmeijs/webby | /webby/src/request/http_method.rs | UTF-8 | 656 | 3.046875 | 3 | [
"MIT"
] | permissive | #[derive(PartialEq, Eq)]
pub enum HttpMethod {
INVALID,
GET,
HEAD,
POST,
PUT,
DELETE,
CONNECT,
OPTIONS,
TRACE,
PATCH,
}
impl From<&str> for HttpMethod {
fn from(str: &str) -> Self {
match str.trim() {
"GET" => Self::GET,
"HEA... | true |
041895f516f1d6dbf28291792d79f9c73401d470 | Rust | mikemoraned/qrmethis | /src/main.rs | UTF-8 | 1,713 | 2.703125 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
use std::io::Cursor;
use image::Luma;
use image::{png, ColorType};
use qrcode::QrCode;
use rocket::http::ContentType;
use rocket::http::RawStr;
use rocket::http::Status;
use rocket::request::FromParam;
use rocket::Response;
use std::io::... | true |
39c3034d6396a1b1cc3628051f850deb4327cd1e | Rust | PsichiX/Oxygengine | /engine/overworld/src/resources/quests.rs | UTF-8 | 6,578 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::resources::market::{Currency, MarketItemId};
use oxygengine_core::id::ID;
use std::collections::{HashMap, HashSet};
pub type ObjectiveId = ID<Objective<()>>;
pub type QuestId = ID<Quest<(), ()>>;
#[derive(Debug, Clone)]
pub struct Objective<T>
where
T: std::fmt::Debug + Clone + Send + Sync,
{
pub d... | true |
d709eb7dcc2a8b95d0cd6b55dfd4e05b0e38d3ba | Rust | Chainflow/secret-secret | /src/msg.rs | UTF-8 | 2,324 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use schemars::JsonSchema;
use serde::{Deserialize, Serialize, Serializer};
use cosmwasm_std::{HumanAddr, Uint128};
use crate::viewing_key::ViewingKey;
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct InitialBalance {
pub address: HumanAddr,
pub amount: Uint128,
}
#[derive(Serialize,... | true |
d4d3c4bd5ca34ba8f9c5c35a02054230e4ecb23e | Rust | isgasho/sarek | /src/nn/weight_init.rs | UTF-8 | 13,659 | 2.65625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use {
log::{
debug,
info,
log_enabled
},
rand::{
prelude::{
*
}
},
std::{
collections::{
HashSet
},
error::{
Error
}
},
crate::{
backend::{
Context,
Mod... | true |
8e2f5df7a12938e69eb4c45748306d6835c27972 | Rust | BigTij/rust_programming | /employee_management/src/main.rs | UTF-8 | 2,138 | 3.796875 | 4 | [] | no_license | use std::collections::HashMap;
use std::io;
fn choose_department() -> String {
println!("Please choose a department:");
let mut department = String::new();
io::stdin()
.read_line(&mut department)
.expect("failed to read line.");
department.trim().to_string()
}
fn list_department_names(... | true |
164f9fc8bac4ae01339723bd1a88f148d888817c | Rust | nikolads/simple-towers | /src/components/movement.rs | UTF-8 | 1,243 | 2.875 | 3 | [] | no_license | use amethyst::core::nalgebra::Vector2;
use amethyst::ecs::prelude::*;
use derive_deref::{Deref, DerefMut};
/// Position component.
#[derive(Clone, Debug, Deref, DerefMut)]
pub struct Pos(pub Vector2<f32>);
impl Component for Pos {
type Storage = VecStorage<Self>;
}
/// Velocity component.
#[derive(Clone, Debug, ... | true |
3a288874561da8c803e63273adb015c5d79c8d61 | Rust | getreu/stringsext | /src/mission.rs | UTF-8 | 29,982 | 2.6875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Parse and convert command-line-arguments into static `MISSION` structures,
//! that are mainly used to initialize `ScannerState`-objects.
#![allow(clippy::too_many_arguments)]
#![allow(clippy::type_complexity)]
extern crate anyhow;
extern crate encoding_rs;
use crate::input::ByteCounter;
use crate::options::ARGS;... | true |
fdb415750f45e6b147d2f357fe2173a0b147cf37 | Rust | jtdowney/advent-2019 | /day2/src/main.rs | UTF-8 | 1,724 | 3.40625 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::str;
const PART2_RESULT: usize = 19_690_720;
fn execute_intcode(noun: usize, verb: usize, memory: &[usize]) -> usize {
let mut memory = memory.to_vec();
memory[1] = noun;
memory[2] = verb;
let mut ip = 0;
loop {
match memory[ip] {
1 => {... | true |
812fa84fd61803a7167c0594c65aaafbd97b101a | Rust | 95th/deno | /std/wasi/testdata/std_fs_file_read.rs | UTF-8 | 384 | 2.609375 | 3 | [
"MIT"
] | permissive | // { "preopens": { "/fixture": "fixture" } }
use std::io::Read;
fn main() {
let mut file = std::fs::File::open("/fixture/file").unwrap();
let mut buffer = [0; 2];
assert_eq!(file.read(&mut buffer).unwrap(), 2);
assert_eq!(&buffer, b"fi");
assert_eq!(file.read(&mut buffer).unwrap(), 2);
assert_eq!(&buffe... | true |
db074e68bd2fa39fd47b86daf232cf8ead442508 | Rust | newAM/r3 | /src/r3/src/utils/binary_search.rs | UTF-8 | 3,051 | 3.640625 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! Given an abstract random-accessible sequence, returns an index pointing to
//! the first element that is not less than (greater than or equal to) some
//! value (which is implicit to this macro). The provided predicate is used to
//! compare the element at a given index to that value.
//!
//! Returns a `usize` in r... | true |
2df8ec89c46fce731c4d855b6b3cbfc242730e1d | Rust | david-pe/advent-of-code | /5782/src/main/day09/tests.rs | UTF-8 | 938 | 2.6875 | 3 | [] | no_license | use super::*;
use crate::assets::Asset;
use crate::input_as_str_iter;
fn example_data() -> String {
String::from(
"2199943210
3987894921
9856789892
8767896789
9899965678",
)
}
#[test]
fn example_1() {
let example = example_data();
let lines = inp... | true |
cb5be98ca74216bbfa02a859cac6271a0ff4effc | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/futures-util/src/abortable.rs | UTF-8 | 3,530 | 2.875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::task::AtomicWaker;
use alloc::sync::Arc;
use core::fmt;
use core::pin::Pin;
use core::sync::atomic::{AtomicBool, Ordering};
use futures_core::future::Future;
use futures_core::task::{Context, Poll};
use futures_core::Stream;
use pin_project_lite::pin_project;
pin_project! {
/// A future/stream which can... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.