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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
391ee6c2c3d2d9f5ea6d5fd6da6769b2d30115b3 | Rust | BadConfig/droux-rust | /src/crm.rs | UTF-8 | 7,427 | 2.6875 | 3 | [] | no_license | extern crate reqwest;
use serde_json::json;
use crate::Error;
use std::env;
use crate::routes::product::BuyForm;
use crate::routes::product::PrivForm;
use serde::{
Serialize,
Deserialize,
};
extern crate chrono;
use chrono::NaiveDateTime;
impl BuyForm {
pub fn send_new_order_to_crm(&self) -> Result<(Stri... | true |
dc68a26f49f44e64961075fcedd4b1fd39ef5380 | Rust | grogers0/advent_of_code | /2020/day23/src/main.rs | UTF-8 | 2,301 | 3.265625 | 3 | [
"MIT"
] | permissive | use std::io::{self, Read};
fn parse(puzzle_input: &str) -> (Vec<usize>, usize) {
let ord_cups: Vec<usize> = puzzle_input.trim_end().chars()
.map(|ch| ch.to_digit(10).unwrap() as usize - 1).collect();
for cup in 0..ord_cups.len() {
debug_assert!(ord_cups.contains(&cup));
}
let mut cups =... | true |
1aadf03494c8ef804767b586db13c73590d3a613 | Rust | ctm/runs | /src/parser/runsignup.rs | UTF-8 | 1,298 | 2.703125 | 3 | [] | no_license | use {
crate::prelude::*,
digital_duration_nom::duration::Duration,
serde::{Deserialize, Deserializer},
std::borrow::Cow,
};
#[allow(dead_code)]
#[derive(Deserialize, Debug)]
pub struct Placement {
place: String,
// bib: String,
name: String,
// city: String,
#[serde(deserialize_with... | true |
2a7676783c700d57a74ca8391689ec639c6294f9 | Rust | arbrk1/smart_access | /src/core_impls.rs | UTF-8 | 2,962 | 3.90625 | 4 | [
"MIT"
] | permissive | //! Implementation of [`At`](../trait.At.html) for core datatypes.
//!
//! The following traits are implemented:
//! * `At<usize, View=T> for [T]`: simple indexing
//! * `At<range, View=[T]> for [T]`: subslice (of fixed size)
//! * `At<(), View=T> for Option<T>`: the only meaningful sort of access
//! * `At<(), View=R>... | true |
bbe7e2c747ed3c4d5ed589af2d5dccffc6506115 | Rust | white-leaf-devs/recommendation-system | /engine/src/distances/users.rs | UTF-8 | 8,574 | 2.84375 | 3 | [
"MIT"
] | permissive | // Copyright (c) 2020 White Leaf
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#![allow(clippy::implicit_hasher)]
use crate::error::ErrorKind;
use crate::utils::common_keys_iter;
use controller::Ratings;
use num_traits::float::Float;
use std::{
collections::HashSet,... | true |
380973d1fbc50c58ec6b4e3dfa7b84c443fdd08c | Rust | system76/intel-spi | /src/mapper.rs | UTF-8 | 1,516 | 3.3125 | 3 | [
"MIT"
] | permissive | #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct PhysicalAddress(pub usize);
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct VirtualAddress(pub usize);
pub trait Mapper {
unsafe fn map_aligned(&mut self, address: PhysicalAddress, size: usize) -> Result<VirtualAddre... | true |
e34160a0dbbda4dc6c7bbfc0d702a280414551db | Rust | kchmck/p25.rs | /src/voice/descramble.rs | UTF-8 | 3,595 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Descramble/Deinterleave the dibits in a received voice frame.
use bits::Dibit;
use consts;
/// Descramble a portion of the given voice frame dibits into the PN-scrambled, coded
/// chunk `u_{idx}`.
pub fn descramble(dibits: &[Dibit; consts::FRAME_DIBITS], idx: usize) -> u32 {
DESCRAMBLERS[idx].descramble(dibi... | true |
b8a5e5bb30a59d8218781a418ad44dbdee0123d4 | Rust | solsensor/sol | /src/result.rs | UTF-8 | 2,738 | 2.734375 | 3 | [] | no_license | use crate::{api::result::Error as ApiError, web::result::Error as WebError};
use diesel::result::Error as DieselError;
use rocket::{
http::Status,
request::Request,
response::{Responder, Response},
};
use rusoto_core::RusotoError;
use rusoto_ses::SendEmailError;
use std::{convert::From, fmt};
pub type Resu... | true |
edadb1c5f23bf769417d8f5a2e15e0054186865e | Rust | fengkx/leetcode | /rust/group-anagrams/src/lib.rs | UTF-8 | 1,541 | 3.46875 | 3 | [
"Unlicense"
] | permissive | struct Solution;
impl Solution {
pub fn group_anagrams(strs: Vec<String>) -> Vec<Vec<String>> {
use std::collections::HashMap;
let mut map: HashMap<String, Vec<String>> = HashMap::new();
strs.into_iter().for_each(|s| {
let mut sortedStr = s.chars().collect::<Vec<char>>();
... | true |
e14dc8ddbc6d916ff08f2340c8d83eee5d2394cb | Rust | max-b/pingcap-rust | /src/bin/kvs-client.rs | UTF-8 | 3,906 | 2.96875 | 3 | [] | no_license | extern crate clap;
extern crate kvs;
use std::io;
use std::process;
use clap::{App, Arg, SubCommand};
use kvs::{Command, KvsClient};
fn main() -> io::Result<()> {
let addr_arg = Arg::with_name("addr")
.short("a")
.long("addr")
.help("address to connect to in IP:PORT format")
.tak... | true |
bbda91f9ded178988b69cea33c3787cfb999c6cc | Rust | discordance/schemafy | /schemafy_lib/src/lib.rs | UTF-8 | 29,639 | 2.625 | 3 | [
"MIT"
] | permissive | // This would be nice once it stabilizes:
// https://github.com/rust-lang/rust/issues/44732
// #![feature(external_doc)]
// #![doc(include = "../README.md")]
//! This is a Rust crate which can take a [json schema (draft
//! 4)](http://json-schema.org/) and generate Rust types which are
//! serializable with [serde](ht... | true |
6f52cf7fea274d1a4c5f5b67e0b3604a42fa35ac | Rust | murarth/option_vec | /src/lib.rs | UTF-8 | 21,013 | 4.03125 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! `OptionVec<T>`; an abstraction over `Vec<Option<T>>`
//!
//! An element in an `OptionVec<T>` can be accessed by index and maintains
//! its position when elements are removed from the container.
//!
//! An element inserted into an `OptionVec<T>` will occupy the first available
//! position in the container.
#![den... | true |
91d639a4bd1bcfc378a67c7695987064facf7993 | Rust | xoac/magnet | /magnet_derive/src/generics.rs | UTF-8 | 3,623 | 2.90625 | 3 | [
"MIT"
] | permissive | //! Parse and extend generic bounds.
use syn::{ Generics, GenericParam, WhereClause, WherePredicate, PredicateType };
use syn::{ TypeParamBound, TraitBound, TraitBoundModifier, TypePath };
use syn::{ Ident, Path, PathSegment };
use syn::punctuated::Punctuated;
use syn::token::{ Colon2, Add };
use proc_macro2::{ TokenS... | true |
805246bfe8512cb725986ab83852937a2f3a7362 | Rust | dtolnay/cargo-expand | /src/error.rs | UTF-8 | 839 | 2.90625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt::{self, Display};
use std::io;
pub enum Error {
Io(io::Error),
TomlSer(toml::ser::Error),
TomlDe(toml::de::Error),
}
pub type Result<T> = std::result::Result<T, Error>;
impl From<io::Error> for Error {
fn from(error: io::Error) -> Self {
Error::Io(error)
}
}
impl From<toml::... | true |
2ecf43f91770af4e8bff911b41ee86928109c355 | Rust | emeric-martineau/redis-concentrator | /src/lib/redis/stream/mod.rs | UTF-8 | 610 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | //! This module contain abstract type of stream.
//!
#[cfg(test)]
pub mod tests;
pub mod network;
/// Abstract stream for redis.
pub trait RedisStream {
/// Write data on lib.redis.stream.network.
fn write(&mut self, data: &[u8]) -> std::io::Result<()>;
/// Get byte from stream.
fn get(&mut self) -> ... | true |
0400a074eee2ec98bc5ccc0af52bbf24c08047dc | Rust | jonnycrunch/forest | /utils/bitfield/src/bitvec_serde.rs | UTF-8 | 2,518 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2020 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use super::{decode_and_apply_cache, rleplus::encode, BitField};
use bitvec::prelude::BitVec;
use serde::{ser, Deserialize, Deserializer, Serialize, Serializer};
impl Serialize for BitField {
fn serialize<S>(&self, serializer: S) -> Re... | true |
8d32bf1b412439d6011e41d72558953ad7da8572 | Rust | alexandrospanagiotidis/advent-of-code-2020-rust | /day10/src/main.rs | UTF-8 | 4,098 | 3.640625 | 4 | [] | no_license | use std::collections::HashMap;
use std::io::{BufRead, stdin};
type Joltage = u32;
fn main() {
let input: Vec<String> = stdin().lock().lines()
.map(|maybe_line| maybe_line.expect("Error while reading line"))
.collect();
// println!("input={0:?}", input);
let adapters: Vec<Joltage> = input... | true |
8713937caeb1fefc5677e7d7fd1309cf25a7916b | Rust | Yamboy1/rust-pong | /src/main.rs | UTF-8 | 1,542 | 2.953125 | 3 | [
"MIT"
] | permissive | use pancurses::{curs_set, initscr, noecho, endwin, Window, Input};
use std::thread::sleep;
use std::time::Duration;
use std::collections::VecDeque;
use rust_pong::{Paddle, Vector, ball_collision, move_paddle};
fn main() {
let window = initscr();
window.refresh();
window.keypad(true);
window.nodelay(true);
curs_se... | true |
84cd103bd01634a327d041a2bc09382465f7a868 | Rust | ricky26/advent-of-code-2020 | /src/bin/day9part1.rs | UTF-8 | 2,401 | 3.125 | 3 | [] | no_license | use std::io::Read;
use clap::{Arg, App};
use anyhow::anyhow;
fn find_sum(src: &[i64], target: i64) -> bool {
for (i, a) in src.iter().copied().enumerate() {
if a >= target {
continue
}
for b in src[i + 1..].iter().copied() {
if a + b == target {
retu... | true |
ba3365991c9fd8efc1d972a0ef56c883b042a853 | Rust | mstange/etw-profiler | /etw-reader/src/property.rs | UTF-8 | 1,582 | 3.375 | 3 | [] | no_license | //! ETW Event Property information
//!
//! The `property` module expose the basic structures that represent the Properties an Event contains
//! based on it's Schema. This Properties can then be used to parse accordingly their values.
use crate::FastHashMap;
use crate::tdh_types::Property;
use crate::schema::{Sch... | true |
47c5a0b7752eb882099b24ccd9b1affbeeac67dd | Rust | GothenburgBitFactory/taskwarrior | /taskchampion/taskchampion/src/utils.rs | UTF-8 | 1,328 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use uuid::Uuid;
/// A representation of a UUID as a key. This is just a newtype wrapping the 128-bit packed form
/// of a UUID.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) struct Key(uuid::Bytes);
impl From<&[u8]> for Key {
fn from(bytes: &[u8]) -> Key {
Key(byt... | true |
5624069f97c31594d82fba9055d196d46d7ead05 | Rust | oknozor/spark-atelier-cli | /src/dashboard.rs | UTF-8 | 1,691 | 2.78125 | 3 | [] | no_license | use crate::foreman_config::ForemanConfig;
use reqwest::Error;
const AUTH: &str = "xFeGdHjhqsixiZBUntXvSTGGMfsIzOcshZIVxWVoxnjWyzDXhTxHyiwbnoZnTVttFgJFCglnmHYyLhWSverHWCPMGSsumXPkyuWV";
#[derive(Serialize, Deserialize)]
struct NewTeam {
pub name: String,
}
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "c... | true |
430d3859d0d0ce72d936845cbbb5e7d66d554ab2 | Rust | keriwarr/cryptopals | /src/bin/4_detect_single_char_xor.rs | UTF-8 | 1,045 | 3.046875 | 3 | [] | no_license | //!
//! ## Executable for: Set 1 - Problem 4
//!
//! # Examples
//!
//! ```shell
//! ./detect_single_char_xor
//! ```
//!
use std::f64;
use std::fs::File;
use std::io::prelude::*;
extern crate cryptopals;
use cryptopals::byte_stream::ByteStream;
fn main() {
let mut f = File::open("./data/S1P4.txt").expect("file ... | true |
78b2e9d98dadbd50d47d2998d70f5e27bdd280c9 | Rust | lunatic-solutions/lunatic | /crates/lunatic-distributed/src/distributed/message.rs | UTF-8 | 2,060 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use bytes::Bytes;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum Request {
Spawn(Spawn),
Message {
environment_id: u64,
process_id: u64,
tag: Option<i64>,
data: Vec<u8>,
},
}
impl Request {
pub fn kind(&self) -> &'static st... | true |
b7e148f8624736880ed7f5e9636cb1dde0de0d85 | Rust | rbradford/cloud-hypervisor | /vmm/src/serial_buffer.rs | UTF-8 | 5,461 | 2.578125 | 3 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | // Copyright © 2021 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
use crate::serial_manager::EpollDispatch;
use std::io::Write;
use std::os::unix::io::RawFd;
// Circular buffer implementation for serial output.
// Read from head; push to tail
pub(crate) struct SerialBuffer {
buffer: Vec<u8>,
... | true |
cec74107399e9790db510234729069eab3c1bc31 | Rust | infinity0/rs-bwlim | /src/limit.rs | UTF-8 | 15,437 | 3.234375 | 3 | [] | no_license | //! Data structures to help perform rate limiting.
use std::collections::{HashMap, VecDeque};
use std::cmp;
use std::fmt::Debug;
use std::io::{self, Read, Write, ErrorKind};
use std::result::Result;
use bytes::{BytesMut, Buf, BufMut};
use crate::util::RorW;
use self::Status::*;
/// Generic buffer for rate-limiting,... | true |
eeb4df6af488ffe8590e72a23d8aa970edff5c44 | Rust | kizitorashiro/aquatyping | /src/effector.rs | UTF-8 | 16,558 | 3.140625 | 3 | [] | no_license | use rand::{thread_rng, Rng};
use image2ascii::{Char2DArray, CharPosition};
#[derive(Debug, PartialEq)]
pub enum EffectorType {
NO,
FADEIN(FadeDirection),
FADEOUT(FadeDirection),
}
#[derive(Debug, PartialEq)]
pub enum EffectorStatus {
DOING,
COMPLETED,
}
const TRANSPARENT_CHAR: char = ' ';
pub tr... | true |
75a3f7e3b3465c36e02a6253b66e7ac14414217c | Rust | theshortcut/advent-of-code | /2021/src/day4.rs | UTF-8 | 2,408 | 3 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
use std::collections::BTreeMap;
const ROW: u32 = 0b11111;
const COL: u32 = 0b100001000010000100001;
type BingoBoard = (BTreeMap<u8, usize>, u32);
#[aoc_generator(day4)]
fn parse_input_day4(input: &str) -> (Vec<u8>, Vec<BingoBoard>) {
let (draws_str, boards_str) = input.... | true |
d9b877b31a856fd937b527a08ff38ed89bc03549 | Rust | tikhono/CryptoHackPals | /hacks/diffie_hellman/diffie_hellman_starter_1/src/lib.rs | UTF-8 | 926 | 3.25 | 3 | [] | no_license | use num::Integer;
pub fn egcd<T: Clone + Integer>(a: &T, b: &T) -> (T, T, T) {
match *a == T::zero() {
true => (b.clone(), T::zero(), T::one()),
false => {
let (g, x, y) = egcd(&(b.clone() % a.clone()), a);
(g, y - (b.clone() / a.clone()) * x.clone(), x)
}
}
}
p... | true |
d4ca50c48bc951feabd34384952ff0cbfef52893 | Rust | jakmeier/paddlers-browser-game | /paddlers-game-master/src/setup/new_player.rs | UTF-8 | 2,914 | 2.6875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::db::DB;
use diesel::QueryResult;
use paddlers_shared_lib::prelude::*;
impl DB {
pub(super) fn new_player(&self, display_name: String, uuid: uuid::Uuid) -> QueryResult<Player> {
let player = NewPlayer {
display_name: display_name,
karma: 0,
uuid,
};
... | true |
fbad8243d3b5e2600638131c25a26ea25aed4f7b | Rust | osobo/appcryp-cryptopals | /src/code/mod.rs | UTF-8 | 5,254 | 2.75 | 3 | [] | no_license | use base64;
use hex;
use std::fs;
use std::time::SystemTime;
// == Private imports ==
mod aes_blackbox;
// == Re-exports ==
pub mod mt19937;
pub use mt19937::MT19937;
pub mod english2;
pub mod english4;
pub mod english5;
pub mod aes128;
// == Private help ==
fn purge_ws(s: &str) -> String {
s.chars().filter(|c|... | true |
637af3e7c1f49081717fd8fa61ef66b9af5fb85f | Rust | WooZoo86/ruffle | /core/src/avm1/activation.rs | UTF-8 | 8,268 | 3.140625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Activation records
use crate::avm1::object::Object;
use crate::avm1::scope::Scope;
use crate::avm1::Value;
use crate::tag_utils::SwfSlice;
use gc_arena::{GcCell, MutationContext};
use std::cell::{Ref, RefMut};
use std::sync::Arc;
/// Represents a single activation of a given AVM1 function or keyframe.
#[derive(Cl... | true |
5ab9dba82b1c919f7f70a7061afe845662445c97 | Rust | plaets/http-sysstat | /http_sysstat_pluginlib/src/interval_collector.rs | UTF-8 | 1,826 | 3.671875 | 4 | [] | no_license | use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
pub struct IntervalCollector<T,D> { //not sure about that name
pub interval: Duration,
pub last_result: Arc<Mutex<Option<T>>>,
pub data: Arc<Mutex<Option<D>>>,
pub collect: Option<Box<dyn FnMut(Arc<Mutex<Option<T>>>, Arc<Mutex<Optio... | true |
16441ca9ccd75ebe40e8737131adb52e83497d19 | Rust | hzkazmi/Batch6_34_Quarter1 | /June_16_2020/vector/src/main.rs | UTF-8 | 1,106 | 3.59375 | 4 | [] | no_license | use std::io;
fn main() {
let mut age: Vec<u8> = Vec::new();
loop {
println!("Enter Age");
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Error");
// match input.trim().parse() {
// Ok(temp) => {if temp==0 {
// brea... | true |
8be66d81bf610664f499e531e1d86b467239528e | Rust | IThawk/rust-project | /rust-master/src/test/ui/proc-macro/attribute.rs | UTF-8 | 2,457 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::*;
#[proc_macro_derive] //~ ERROR malformed `proc_macro_derive` attribute
pub fn foo1(input: TokenStream) -> TokenStream { input }
#[proc_macro_derive = ""] //~ ERROR malformed `proc_macro_derive` attribute
pub... | true |
d719b55d0a902902ab67954457aee363670b0dbf | Rust | JustusAdam/noria | /noria-server/dataflow/src/state/keyed_state.rs | UTF-8 | 10,259 | 2.75 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use fnv::FnvBuildHasher;
use rahashmap::HashMap as RaHashMap;
use std::rc::Rc;
use rand::prelude::{ThreadRng,Rng};
use super::mk_key::MakeKey;
use common::SizeOf;
use prelude::*;
type FnvHashMap<K, V> = RaHashMap<K, V, FnvBuildHasher>;
#[derive(Debug)]
#[allow(clippy::type_complexity)]
pub(super) enum KeyedState<T> ... | true |
15407b500fb99bf2a3ff45289de5667d942a2a25 | Rust | NJUPT-NYR/SOPT | /proxy/src/filter.rs | UTF-8 | 5,726 | 3.1875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use bloom::CountingBloomFilter;
use std::ops::DerefMut;
use std::sync::atomic::*;
use tokio::sync::RwLock;
enum Operation {
Set,
Delete,
}
/// A Filter built for solve both read and write in high concurrency
/// Updates will be operated in batch.
/// When a operation come, the update will be performed in 2 ph... | true |
41efbc217827caf3c33406058e829ced824b2d3e | Rust | Bonemind/dirnote | /src/main.rs | UTF-8 | 3,769 | 3.375 | 3 | [] | no_license | use clap::{ App};
use std::env;
use std::fs::{self, File};
use std::io::Write;
use std::io::Read;
use std::path::{PathBuf};
const DIRNOTE_FILE_NAME : &str = ".dirnote";
// Returns the path of the notes file relative to the current working directory
fn get_note_file_path() -> PathBuf {
let pwd = env::current_dir()... | true |
73dc29160fe3aa52ca63862f68d6e6e31b701968 | Rust | Sam-Belliveau/TheSamBoy | /src/gb/hardware/io/sound.rs | UTF-8 | 689 | 3 | 3 | [] | no_license |
#[derive(Clone)]
pub struct Sound {
}
impl Sound {
pub fn init() -> Self {
Self {
}
}
}
impl Sound {
pub fn step(&mut self, cycles: usize) {
// TODO: idk
}
}
impl Sound {
pub fn read_io_byte(&self, idx: u16) -> u8 {
match idx {
_ => ... | true |
7a464696812123cd5dc9741990e9f42a8da6e0a9 | Rust | kestred/web-analyzer-wip | /analysis/vue/src/debug.rs | UTF-8 | 3,597 | 2.625 | 3 | [] | no_license | use crate::VueDatabase;
use code_analysis::SourceId;
use code_grammar::{ast, AstNode};
use html_grammar::ast as html;
use html_grammar::syntax_kind as html_syntax;
use javascript_grammar::ast as js;
use javascript_grammar::syntax_kind as js_syntax;
use javascript_grammar::ast as ts;
use typescript_grammar::syntax_kind ... | true |
0d55fc5fb6a9d65b5e2404400c40df326aa54b73 | Rust | fbenkstein/advent-of-code | /dima/src/day22.rs | UTF-8 | 6,686 | 2.78125 | 3 | [] | no_license | use priority_queue::PriorityQueue;
use revord::RevOrd;
use std::collections::{btree_map, BTreeMap};
use std::usize;
use text_io::{scan, try_scan};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
struct Coord {
x: usize,
y: usize,
}
impl Coord {
fn new(x: usize, y: usize) -> Se... | true |
515496ae4d11af32beb4ad6a444896e8e2d25fd9 | Rust | dtolnay/colorous | /src/sequential.rs | UTF-8 | 986 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"BSD-3-Clause"
] | permissive | use crate::gradient::EvalGradient;
use crate::{interpolate, Color};
#[derive(Copy, Clone)]
pub(crate) struct Sequential {
pub name: &'static str,
pub three: [Color; 3],
pub four: [Color; 4],
pub five: [Color; 5],
pub six: [Color; 6],
pub seven: [Color; 7],
pub eight: [Color; 8],
pub nin... | true |
c7485363d345f6c4b8916ae02d2e9c9442730636 | Rust | uprtcl/hc-uprtcl | /code/src/versioned_tags.rs | UTF-8 | 2,390 | 2.78125 | 3 | [
"MIT"
] | permissive | use hdk::holochain_wasm_utils::api_serialization::get_links::LinksResult;
use hdk::prelude::*;
use std::convert::TryFrom;
pub fn link_with_content<T>(
base: &Address,
target: &Address,
link_type: String,
tag_content: T,
) -> ZomeApiResult<Address>
where
T: Into<String>,
{
let count = hdk::get_l... | true |
c3e15cbb1378f2a8a6a40bb6c1b1ae7c05b03a78 | Rust | rainDelay9/encrypted-box | /src/cli.rs | UTF-8 | 2,688 | 3.046875 | 3 | [] | no_license | use crate::encrypted_box_builder::EncryptedBoxBuilder;
use crate::encryption_scheme::EncryptionScheme;
use crate::openssl_aes::{defs as aes_defs, wrapper as aes};
use base64;
use exitfailure::ExitFailure;
use failure::ResultExt;
use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
pub fn cli() -> Result<(), ... | true |
6d5eb3f0549a9040d400d7dcb2cd89acdd3e78ab | Rust | agaviria/coyete | /backend/data/src/persistance/mod.rs | UTF-8 | 1,132 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use std::ops::Deref;
use diesel::pg::PgConnection;
use r2d2;
use r2d2_diesel::ConnectionManager;
use std::env;
pub type Pool = r2d2::Pool<ConnectionManager<PgConnection>>;
/// Generate a new r2d2 Pool for connection management in rocket sessions.
/// This object will be handed to the rocket `.manage()` managed state ... | true |
7bbb097ec8ae00e6f77d2ecd4960586e5000c60e | Rust | iCodeIN/imagine | /src/chunk.rs | UTF-8 | 1,847 | 2.75 | 3 | [
"Zlib"
] | permissive | use super::*;
#[derive(Debug, Copy, Clone)]
pub struct PngChunk<'b> {
pub(crate) length: u32,
pub(crate) chunk_type: ChunkType,
pub(crate) chunk_data: &'b [u8],
pub(crate) declared_crc: u32,
}
impl<'b> PngChunk<'b> {
pub fn get_actual_crc(&self) -> u32 {
const fn make_crc_table() -> [u32; 256] {
le... | true |
67540a50e8d35e03892707d5aae9dd1eb09cbddb | Rust | swidoff/ostep-projects | /initial-utilities/wzip/src/main.rs | UTF-8 | 1,888 | 3.15625 | 3 | [] | no_license | use std::env;
use itertools::Itertools;
use std::process::exit;
use std::fs::File;
use std::io::{Read, Write, stdout};
use std::io;
/// * Correct invocation should pass one or more files via the command line to the
/// program; if no files are specified, the program should exit with return code
/// 1 and print "wz... | true |
ab31ed1cff7e62a5d3d768ce8a6ceb8e4eea29e5 | Rust | zowens/rusty-scheme | /src/parser.rs | UTF-8 | 4,765 | 3.09375 | 3 | [] | no_license | use super::{Expr, BinOp, Atom};
use super::lex::Token::*;
use super::lex::*;
parser! {
fn parse_(Token, Span);
// combine two spans
(a, b) {
Span {
lo: a.lo,
hi: b.hi,
}
}
exp: Expr {
Ident(i) => Expr::Var(i),
sexp[x] => x,
atom[x] ... | true |
fd9d4d95ca18e874b84239ea73fec11750ca94b7 | Rust | sinclair20/cracking_the_coding_interview_6th_edition_rust | /src/c8_q7.rs | UTF-8 | 1,175 | 3.703125 | 4 | [
"Apache-2.0"
] | permissive | // Permutations without Dups: Write a method to compute all permutations of a string of unique
// characters
fn str_per(mut s: String) -> Vec<String> {
if s.is_empty() {
vec![String::from("")]
} else {
let c = s.pop().unwrap();
let subs = str_per(s);
subs.iter()
.ma... | true |
ab0ab83751efd83ae9e6cb55fbb4b0df13eeff68 | Rust | realitix/grind | /spirv-parser/src/entry_point.rs | UTF-8 | 2,925 | 2.546875 | 3 | [] | no_license | use std::collections::HashMap;
use enums;
use parse;
use format_from_id;
use is_builtin;
use location_decoration;
use name_from_id;
pub fn get_input_output(
doc: &parse::Spirv,
instruction: &parse::Instruction,
) -> (HashMap<String, u32>, HashMap<String, u32>) {
let (execution, id, ep_name, interface) = ... | true |
0d7d5bef281672ba36a67a9a23278d832d3ae292 | Rust | 0h-n0/rust-ising | /src/main.rs | UTF-8 | 4,454 | 2.796875 | 3 | [] | no_license | extern crate ndarray;
extern crate ndarray_parallel;
extern crate rand;
#[macro_use]
extern crate failure;
use ndarray_parallel::prelude::*;
use rand::{distributions::Uniform, seq::SliceRandom, thread_rng, Rng};
use std::convert::TryFrom;
use std::convert::TryInto;
#[derive(Debug, Fail)]
enum Ising2DError {
#[fa... | true |
90664fe923826368783cb37d40aab7e38d1aa415 | Rust | YushiOMOTE/toio-rs | /tests/proto.rs | UTF-8 | 1,810 | 2.75 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use toio::proto::*;
#[test]
fn test_id() {
let p: Vec<u8> = Id::Pos(IdPos::new(1, 2, 3, 4, 5, 6)).try_into().unwrap();
assert_eq!(
p,
vec![0x01, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00, 0x05, 0x00, 0x06, 0x00]
);
let p: Id = p.try_into().unwrap();
a... | true |
623c83107d218457438a2022254ad4cee4cc5e2a | Rust | yuemenglong/rust-sample | /src/rquery/context.rs | UTF-8 | 4,985 | 3.03125 | 3 | [] | no_license | use std::string::String;
use std::rc::Rc;
use std::fmt;
use rquery::selector::Selector;
use rquery::node::Node;
use rquery::node::NodeEnum;
impl fmt::Debug for SelectResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let mut ret = Ok(());
for (i, node) in self.res.iter().enumerate() ... | true |
6da1447a9a14d385d8ca5c3884c5783cc433ded5 | Rust | joshuarubin/keyjack | /src/jack_handlers/notification.rs | UTF-8 | 539 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
pub struct Handler {
sample_rate: Arc<AtomicUsize>,
}
impl Handler {
pub fn new(sample_rate: Arc<AtomicUsize>) -> Self {
Handler { sample_rate }
}
}
impl jack::NotificationHandler for Handler {
/// Called whenever the system sa... | true |
076d47cdc266bb77808c5ddb60d389b43beb69db | Rust | fracek/serde_with | /src/lib.rs | UTF-8 | 11,361 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![deny(
// missing_copy_implementations,
// missing_debug_implementations,
// missing_docs,
trivial_casts,
trivial_numeric_casts,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
variant_size_differences
)]
// #![warn(rust_2018_idioms)]
#![doc(test(attr(deny(
m... | true |
274b5b67f8cdec416def0342dd8355ee3bd829ed | Rust | andrew-d/rscrape | /src/lib.rs | UTF-8 | 1,724 | 2.984375 | 3 | [] | no_license | extern crate hyper;
extern crate kuchiki;
use std::error;
use std::io::Read;
use std::marker::PhantomData;
use hyper::method::Method;
use hyper::client::IntoUrl;
use kuchiki::Html;
pub mod fetchers;
/// The type parameter `P` is the type of a piece.
/// The type parameter `F` is the type of the fetcher.
pub struc... | true |
0d43d76e3c874a6b74f421415eabc3addf21d828 | Rust | TyrfingMjolnir/exa | /src/fs/feature/git.rs | UTF-8 | 3,236 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::path::{Path, PathBuf};
use git2;
use fs::fields as f;
/// Container of Git statuses for all the files in this folder's Git repository.
pub struct Git {
statuses: Vec<(PathBuf, git2::Status)>,
}
impl Git {
/// Discover a Git repository on or above this directory, scanning it for
/// the files'... | true |
d4c40be7f9ac4ee60d54d173a3ec35a6dc5df9c4 | Rust | forgerpl/hotmic | /src/data/histogram.rs | UTF-8 | 7,731 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::hash::Hash;
use fnv::FnvHashMap;
use hdrhistogram::Histogram as HdrHistogram;
use std::time::{Instant, Duration};
use super::Sample;
use helper::duration_as_nanos;
pub struct Histogram<T> {
window: Duration,
granularity: Duration,
data: FnvHashMap<T, WindowedHistogram>,
}
impl<T> Histogram<T>
... | true |
0c72f8eba5653b01e4d1a946c07cbbbfad2352e9 | Rust | untoldwind/t-rust-less | /cli/src/view/status_view.rs | UTF-8 | 1,594 | 3.09375 | 3 | [
"MIT"
] | permissive | use chrono::{DateTime, Utc};
use cursive::view::ViewWrapper;
use cursive::views::TextView;
use std::sync::Arc;
use t_rust_less_lib::api::Status;
use t_rust_less_lib::secrets_store::SecretsStore;
pub struct StatusView {
secrets_store: Arc<dyn SecretsStore>,
text_view: TextView,
last_update: Option<DateTime<Utc>>,... | true |
56d7f6f92db17443281e36dd58ff3f5f4fa3000c | Rust | yzhong52/AdventOfCode | /2019/src/y2019/day10.rs | UTF-8 | 4,755 | 3.046875 | 3 | [] | no_license | use super::super::helpers::parser::*;
use std::collections::{HashSet, BinaryHeap, HashMap};
use crate::helpers::models::SmallPoint;
use crate::helpers::puzzle::Puzzle;
fn count_visible(data: &Vec<Vec<char>>, x: usize, y: usize) -> usize {
let mut set: HashSet<(i32, bool)> = HashSet::new();
for (i, row) in data... | true |
895a8a2d35a85386ae9b9e09f1c6a2d5ebb2016f | Rust | 27factorial/pfecs | /src/resource.rs | UTF-8 | 4,769 | 3.109375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::storage::{ResourceStorage, ResourceStorageAllocator};
pub trait Resource: Send + Sync + 'static {}
impl<T: Send + Sync + 'static> Resource for T {}
pub trait ResourceTuple: self::sealed::ResourceTupleSealed + 'static {
fn store(self, allocator: &mut ResourceStorageAllocator);
}
pub trait IntoResource... | true |
88c7cbd5203e43038c3ceaf0945ad0217aa29cbc | Rust | mat-h7/mw-btc-swap | /src/enums.rs | UTF-8 | 733 | 2.96875 | 3 | [
"MIT"
] | permissive | use serde::{Serialize, Deserialize};
#[derive(PartialEq)]
pub enum HttpMethod {
GET,
POST
}
#[derive(PartialEq)]
pub enum Currency {
BTC,
GRIN
}
pub fn parse_currency_from_string(cur : String) -> Currency {
if cur.to_uppercase() == "BTC" || cur.to_uppercase() == "BITCOIN" {
... | true |
a0341f1e4f1bb78d535c6d13501b30f96adf68f5 | Rust | OsamaElHariri/HamsterWheel | /src/interpreter/interpreter.rs | UTF-8 | 13,512 | 3.03125 | 3 | [] | no_license | use crate::interpreter::importer::Importer;
use crate::interpreter::interpreter_result::InterpreterResult;
use crate::interpreter::loop_iterator::LoopIterator;
use crate::parser::parser::ParseError;
use crate::parser::parser::Parser;
use crate::parser::scope::Scope;
use crate::parser::var_type::Var;
use crate::parser::... | true |
8f08e5032c31b12b1de16c2b9cec44474954d79c | Rust | fortitudepub/rustdhipv2 | /src/utils/puzzles.rs | UTF-8 | 5,444 | 2.65625 | 3 | [
"MIT"
] | permissive | #![allow(warnings)]
use super::{constants, hit::DigestTypes};
use rand::{self, Rng};
use rand_chacha::rand_core::{CryptoRng, RngCore, SeedableRng};
use rand_chacha::ChaChaRng;
pub struct PuzzleSolver<'a, u8: 'a>(pub &'a mut [u8], pub &'a mut [u8]);
impl<'a> PuzzleSolver<'a, u8> {
pub fn ltrunc(&mut self, bytestr... | true |
6e8d5721ad4aab8a6dcc9b466df461f0f1f73efb | Rust | JulianSchmid/etherparse | /etherparse/src/transport/icmpv6_slice.rs | UTF-8 | 21,147 | 2.984375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::*;
/// A slice containing an ICMPv6 network package.
///
/// Struct allows the selective read of fields in the ICMPv6
/// packet.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Icmpv6Slice<'a> {
pub(crate) slice: &'a [u8],
}
impl<'a> Icmpv6Slice<'a> {
/// Creates a slice containing an ICMPv6 pac... | true |
5d2410349ae17c6fd3d25866ce30c695b6f97b89 | Rust | tylerXMD/advent_of_code_2019 | /day4/part1/src/main.rs | UTF-8 | 1,448 | 3.421875 | 3 | [] | no_license | use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
use std::error::Error;
fn check_has_double_digits(s: &str) -> bool {
let mut i = s.chars().skip(1);
let mut prev = s.chars().next().unwrap();
while let Some(current) = i.next() {
if prev == current {
return true;
... | true |
ee34d4e8907be3dc8d76120df48193e2b0dfc050 | Rust | imorph/vector | /lib/vrl/stdlib/src/parse_regex.rs | UTF-8 | 7,284 | 2.84375 | 3 | [
"MPL-2.0"
] | permissive | use regex::Regex;
use vrl::prelude::*;
use crate::util;
#[derive(Clone, Copy, Debug)]
pub struct ParseRegex;
impl Function for ParseRegex {
fn identifier(&self) -> &'static str {
"parse_regex"
}
fn parameters(&self) -> &'static [Parameter] {
&[
Parameter {
key... | true |
6eeea9a233e6db7c7fd5a79b21b53c346d0a1d51 | Rust | ericrobolson/RMercury | /src/rmercury_input.rs | UTF-8 | 1,595 | 3.203125 | 3 | [
"MIT"
] | permissive | /// Trait required to link up game input to a form that RMercury can utilize.
pub trait RMercuryInput {
/// Get the player id that the input maps to.
fn get_player_id(&self) -> usize;
/// Set the player id that the input will map to.
fn set_player_id(&mut self, player_id: usize);
/// Serialize the... | true |
59013008390acbaa02c529541306cee5cdb6bead | Rust | seija-engine/seija-old | /src/common/update.rs | UTF-8 | 2,709 | 3.046875 | 3 | [
"MIT"
] | permissive | use specs::{Component,VecStorage,World,WorldExt,Join};
use std::sync::{Arc,Mutex};
pub enum UpdateType {
Frame(u32),
Time(f32)
}
pub trait UpdateCallBack :Send + Sync {
fn run(&self);
}
#[derive(Default)]
pub struct Update {
updates:Vec<Arc<UpdateDesc>>
}
impl Update {
pub fn update(&self,dt:f32) ... | true |
b0fc744964eed7a6f4174d15df24517428a0a972 | Rust | wade-wu/mayastor | /mayastor/tests/memory_pool.rs | UTF-8 | 3,901 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use std::{collections::HashMap, ffi::CString, ptr::null_mut};
use once_cell::sync::OnceCell;
use common::compose::MayastorTest;
use mayastor::core::{mempool::MemoryPool, MayastorCliArgs};
pub mod common;
static MAYASTOR: OnceCell<MayastorTest> = OnceCell::new();
fn get_ms() -> &'static MayastorTest<'static> {
... | true |
64b9d6027ad528b4b0970fb4517106691de387ff | Rust | Cythan-Project/cythanc | /src/instructions/variables.rs | UTF-8 | 2,386 | 3.109375 | 3 | [] | no_license | use std::borrow::Cow;
use crate::{
instructions::DataRef,
template::{Instruction, Template},
utils::number_to_hex,
};
pub enum VariableDef<'a> {
NumberVariable(Cow<'a, str>, u8),
FunctionVariable(Cow<'a, str>, u8), /* FUNCTION_NAME, ARGUMENT_NUMBER */
}
impl Instruction for VariableDef<'_> {
... | true |
afa010c3700c62ef254e74afe4b4f2a1443a06de | Rust | lineCode/actix-web | /src/httpresponse.rs | UTF-8 | 12,310 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | //! Pieces pertaining to the HTTP message protocol.
use std::{io, mem, str};
use std::error::Error as Error;
use std::convert::Into;
use cookie::CookieJar;
use bytes::Bytes;
use http::{StatusCode, Version, HeaderMap, HttpTryFrom, Error as HttpError};
use http::header::{self, HeaderName, HeaderValue};
use Cookie;
//... | true |
27e612d843677e410e87d2779b6f315963346243 | Rust | crlf0710/metafont-rs | /src/section_0067_to_0070.rs | UTF-8 | 2,580 | 2.890625 | 3 | [] | no_license | //! @* \[6] Reporting errors.
//! When something anomalous is detected, \MF\ typically does something like this:
//! $$\vbox{\halign{#\hfil\cr
//! |print_err("Something anomalous has been detected");|\cr
//! |help3("This is the first line of my offer to help.")|\cr
//! |("This is the second line. I'm trying to")|\cr
//... | true |
18fb1d21a5623cef1a750469c7c79c88c6671f19 | Rust | Gozala/jerd | /src/exploration/old_types.rs | UTF-8 | 3,298 | 3.25 | 3 | [] | no_license |
// taking care of recursive definitions yep
struct Id {
hash: String,
size: usize,
pos: usize,
}
// All terms can have annotations (comments).
// ooooh also an annotation could be the macro that was invoked to produce this code 🤔
// so, what happens if you update a macro?
// you can choose to re-run the... | true |
daa6106fda82d2090016ab8d49f258b5af35d882 | Rust | stone-zeng/rustotf | /src/tables/ttf/prep.rs | UTF-8 | 1,067 | 3.125 | 3 | [
"MIT"
] | permissive | use std::mem::size_of;
use crate::font::Font;
use crate::types::Tag;
use crate::util::Buffer;
/// ## `prep` — Control Value Program
///
/// Specification: <https://docs.microsoft.com/en-us/typography/opentype/spec/prep>.
///
/// The Control Value Program consists of a set of TrueType instructions that will be e... | true |
4494c23a70f09f449fdc135ebdbeadc5f038e890 | Rust | 22116/paralel-clasifier | /src/lib.rs | UTF-8 | 1,763 | 3.109375 | 3 | [] | no_license | extern crate rand;
extern crate ndarray;
mod math;
use std::fmt;
use crate::math::weights::Weight;
pub type Data = [(Auto, Coefficient)];
#[derive(Clone)]
pub struct Robot<'a> {
data: &'a Data,
w0: Weight,
w: [Weight; 2],
}
#[derive(Debug)]
pub enum Class {
Light,
Heavy,
}
#[derive(Debug, Clo... | true |
b119b8f1c121aae1bdabd2d222a78e57e884e2f6 | Rust | danloh/rut-server-rust | /src/db/user.rs | UTF-8 | 4,918 | 2.59375 | 3 | [
"MIT"
] | permissive | // typed model and handle user message
use actix::Handler;
use bcrypt::{hash, verify, DEFAULT_COST};
use diesel::prelude::*;
use uuid::Uuid;
use crate::errors::ServiceError;
use crate::model::msg::{AuthMsg, Msg};
use crate::model::user::{AuthUser, ChangePsw, CheckUser, QueryUser, RegUser, UpdateUser, User};
use crate... | true |
6f6255b0980af833471b1cf650ab84d6e2403229 | Rust | ks3645/advent_of_code2017 | /src/day6.rs | UTF-8 | 1,317 | 3.453125 | 3 | [] | no_license | use utils;
use utils::Part;
use std::collections::HashMap;
pub fn solve(part: Part) -> u32 {
let mut banks = String::new();
utils::read_input_to_string(&mut banks, 6).unwrap();
count_cycles(banks, part)
}
fn count_cycles(banks:String, part:Part) -> u32 {
let mut banks: Vec<u32> = banks.split_whitesp... | true |
82707ba0e40fc2d4afbda8769fbd3abf38804e70 | Rust | oselgithub/rational | /rational/src/rational.rs | UTF-8 | 3,978 | 3.796875 | 4 | [] | no_license | use std::ops::Add;
use std::ops::Mul;
use std::ops::Neg;
use std::ops::Sub;
use std::string::ToString;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Rational {
n: i32,
d: i32,
}
impl Rational {
fn gcd(a: i32, b: i32) -> i32 {
if b == 0 {
a
}
else {
Rational::gcd(b, a % b)
}
}
... | true |
1939913a1e059e72801324ec3c096ae13c5384ea | Rust | Axect/Rust | /Library/cursive_tut/src/bin/on_select.rs | UTF-8 | 2,003 | 2.890625 | 3 | [] | no_license | extern crate cursive;
use cursive::traits::*;
use cursive::Cursive;
use cursive::views::{Dialog, SelectView, ListView, EditView, LinearLayout, TextView};
fn main() {
let mut s = Cursive::default();
let data: Vec<usize> = vec![1, 1];
s.set_user_data(data);
s.add_layer(
Dialog::new()
... | true |
99612872b9f18d356940801c76d0d5842ee852ee | Rust | globalic/Pizza | /src/main.rs | UTF-8 | 3,097 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | #![feature(plugin)]
#![plugin(rocket_codegen)]
extern crate rocket;
#[macro_use]
extern crate failure;
extern crate ctrlc;
use failure::Error;
use std::path::{Path, PathBuf};
use rocket::config::{Config, Environment};
use rocket::fairing;
use rocket::http::hyper::header::Pragma;
use rocket::request::Request;
use ro... | true |
8969d5c2051995ea5757d2ad9d98af90d95e24d5 | Rust | ZeroX-DG/vi-rs | /src/telex.rs | UTF-8 | 3,869 | 3.25 | 3 | [
"MIT"
] | permissive | //! The telex method transformation
use crate::processor::{
add_tone, modify_letter, remove_tone, reposition_tone_mark, Transformation,
};
use crate::util::{insert_ư_if_vowel_not_present, modify_letter_or_else, replace_last_char};
use crate::validation::is_valid_word;
use crate::TransformResult;
use super::process... | true |
48daa6041b3716baac902b00d273ca5adf4072f4 | Rust | jtavera235/Lisp-Inerpretor- | /src/main.rs | UTF-8 | 548 | 2.5625 | 3 | [] | no_license | mod parse;
mod env;
mod data;
use std::io::{self};
use data::RispErr;
fn main() {
let env = &mut env::default_env();
loop {
println!(">>");
let expr = slurp_expr();
match parse::parse_eval(expr, env) {
Ok(res) => println!("{}", res),
Err(e) => match e {
RispErr::R... | true |
c543778c55f0393d581c3c255109eebfb74b2297 | Rust | 0kalekale/leetcode | /two-sum/solution.rs | UTF-8 | 440 | 2.84375 | 3 | [] | no_license | impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut vect: Vec<i32> = vec![0; 2];
for i in 0..nums.len(){
for j in 0..nums.len(){
if (nums[j] == target - nums[i] && i != j){
vect[0] = i as i32;
... | true |
a6657f61378c489c0f4a6c4eb03286fcd297d30d | Rust | titouanfreville/rustGettingStarted | /guessing_game/src/main.rs | UTF-8 | 975 | 3.703125 | 4 | [] | no_license | extern crate rand;
use rand::Rng;
use std::cmp::Ordering;
use std::io;
fn check_guess(expected: u32) -> bool {
let mut guess = String::new();
println!("Please type your guess: ");
io::stdin()
.read_line(&mut guess)
.expect("Failed to read your guess :'(");
let guess_nb: u32 = match ... | true |
f739736e856e1fe1d58ce31ca61d93e59c23bf91 | Rust | Hizoul/tetris-link-research | /src/plot/mod.rs | UTF-8 | 5,071 | 2.703125 | 3 | [] | no_license | use plotters::prelude::*;
use plotters::style::{RGBAColor};
pub fn get_color(i: usize) -> RGBAColor {
let colors: Vec<Box<dyn Color>> = vec![
Box::new(RED), Box::new(GREEN), Box::new(BLUE), Box::new(CYAN), Box::new(BLACK), Box::new(YELLOW)
];
colors[i % colors.len()].to_rgba()
}
#[macro_export]
mac... | true |
a1354f99d8644e39b65446a93ea714decee96c38 | Rust | JoNil/aoc2020 | /src/bin/15_a.rs | UTF-8 | 1,772 | 3.234375 | 3 | [] | no_license | use std::collections::HashMap;
fn get_next_no(
last_no_was_first_time: bool,
last_no_was_last_on_round: i32,
index: i32,
input: &[i32],
) -> i32 {
if index - 1 < input.len() as i32 {
input[index as usize - 1]
} else if last_no_was_first_time {
0
} else {
... | true |
e9db026101aafe92f449a1bbec8d7580fe4176ac | Rust | nushell/nushell | /crates/nu-command/tests/format_conversions/nuon.rs | UTF-8 | 8,972 | 3.078125 | 3 | [
"MIT"
] | permissive | use nu_test_support::{nu, pipeline};
#[test]
fn to_nuon_correct_compaction() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
open appveyor.yml
| to nuon
| str length
| $in > 500
"#
));
assert_eq!(actual.out, "true"... | true |
ced423146b8f1d8cbfed0128a6eb2ff898f314a0 | Rust | Bugin10/rust_ray_tracer_book_2 | /.history/src/utility_20210104190609.rs | UTF-8 | 156 | 3.125 | 3 | [] | no_license | pub fn clamp(x: f32, min: f32, max: f32) -> f32 {
if x < min {
return min;
};
if x > max {
return max;
};
return max;
} | true |
102825a2d250612ba0cc8c5aecdf95822cfc2cc0 | Rust | maco/unused | /crates/read_ctags/src/parser.rs | UTF-8 | 8,267 | 2.578125 | 3 | [
"MIT"
] | permissive | mod internal;
use super::ctag_item::CtagItem;
use super::language::Language;
use super::tag_program::TagProgram;
use super::tags::Tags;
use super::token_kind::TokenKind;
use nom::{
branch::alt,
bytes::complete::{tag, take_until, take_while},
character::complete::{alphanumeric1, anychar},
combinator::{ma... | true |
f4f2e7700ef0ba8fba81e98fcf03e7ecd5064d8b | Rust | logansquirel/rust-programming-language | /chapter03/programs/ctof/src/main.rs | UTF-8 | 552 | 3.8125 | 4 | [
"MIT"
] | permissive | fn main() {
println!("Convert temperature from Celsius to Fahrenheit");
let cels: f64 = loop {
println!("Please input your temperature in Celsius");
let mut cels = String::new();
std::io::stdin()
.read_line(&mut cels)
.expect("failed to read line");
match ... | true |
a3f1ebf790ab918e5dc0d91684a85c1e77d014f1 | Rust | qianjunjushi/goose_packet | /src/basic_encoder.rs | UTF-8 | 5,496 | 3.453125 | 3 | [] | no_license | pub fn encode_boolean(tag:u8,value:bool,buffer: &mut[u8],pos:usize,fill:bool) ->usize{
if !fill
{
return 1;
}
let mut new_pos=pos;
buffer[new_pos]=tag;
new_pos+=1;
buffer[new_pos]=1;
new_pos+=1;
buffer[new_pos]= if value{0xff} else{0x00};
new_pos+=1;
new_pos
}
pub f... | true |
edee05b42524626db3e1f940b360fd6ada807028 | Rust | atroncy/rq | /src/value/mod.rs | UTF-8 | 7,965 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use error;
use ordered_float;
use serde;
use serde_json;
use std::collections;
use std::fmt;
use std::io;
pub mod avro;
pub mod cbor;
#[cfg(feature = "hjson_serde_0_9_support")]
pub mod hjson;
pub mod json;
pub mod messagepack;
pub mod protobuf;
pub mod toml;
pub mod yaml;
#[derive(Clone, Debug, Eq, Ord, PartialEq, ... | true |
7900d43009a5902241cc8eeba4ac40e3f435eb22 | Rust | truchi/timui | /exs/macros.rs | UTF-8 | 1,373 | 2.546875 | 3 | [] | no_license | use lib::{
component,
element,
element::Element,
layout::Layout,
render::render,
style::{Color, Style},
view,
};
use termion::terminal_size;
#[derive(Default, Debug)]
pub struct Root;
component!(
Root, (u16, u16); (),
fn view |_, _| view![
(Word, vec!['F', 'U', 'C', 'K'];
... | true |
487228ae4598a1e4618206a69571c12f5137dfbf | Rust | sueken5/resea | /servers/net/ip.rs | UTF-8 | 1,002 | 2.734375 | 3 | [
"MIT",
"CC0-1.0"
] | permissive | use crate::device::Device;
use crate::ipv4::{Ipv4Addr, Ipv4Network};
use resea::cell::RefCell;
use resea::fmt;
use resea::rc::Rc;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum NetworkProtocol {
Ipv4,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum IpAddr {
Ipv4(Ipv... | true |
7feec556c4aba7c138e36f899c79bd5c99ca68e6 | Rust | NeoLegends/minecraft-rs | /src/net/connection/login.rs | UTF-8 | 4,312 | 2.53125 | 3 | [] | no_license | use super::{play, ConnectionState};
use crate::net::{
crypto::{self, CryptStream},
packets::*,
util::Autoflush,
Client, ServerState,
};
use futures::{compat::Future01CompatExt, prelude::*};
use log::error;
use rand;
use reqwest::r#async::Client as HttpClient;
use serde::Deserialize;
use std::io::{self, ... | true |
59f05c4f47a0698714979c2aaaa22b732549d752 | Rust | Frezc/leetcode-solutions | /src/n0108_convert_sorted_array_to_binary_search_tree.rs | UTF-8 | 1,803 | 3.5625 | 4 | [] | no_license | /**
* [108] Convert Sorted Array to Binary Search Tree
*
* Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
*
* For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more tha... | true |
7542c535317bb7db40be273fbc1e4e8b35969832 | Rust | k-aziz/bardock | /src/bardock/util/config.rs | UTF-8 | 532 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::{env, path::{Path, PathBuf}};
use super::errors::BardockResult;
use anyhow::Context;
#[derive(Debug)]
pub struct Config {
cwd: PathBuf,
}
impl Config {
pub fn new(cwd: PathBuf) -> Config {
Config{
cwd
}
}
pub fn default() -> BardockResult<Config> {
let cwd... | true |
82c95c28be9d8eabf5ceef461b9e08f80d3187ed | Rust | luisgabrielroldan/advent-of-code-2020 | /src/solutions/day_02.rs | UTF-8 | 2,648 | 3.4375 | 3 | [] | no_license | use std::io::prelude::*;
use std::{fs::File, io::BufReader};
use crate::solver::Solver;
pub struct Solution;
type Policy = (usize, usize, char);
impl Solver for Solution {
type Input = Vec<String>;
type Output1 = u32;
type Output2 = u32;
fn parse_input(&self, file: File) -> Self::Input {
Bu... | true |
a0764b80fa2f2c50f889387a991f0bbaeaae2877 | Rust | briancabbott/GitHub-Repository-Downloader | /TypeScript/resources/code/ts_lib/Apollo-Latest/apollographql/apollo-rs/crates/apollo-parser/src/parser/grammar/description.rs | UTF-8 | 1,332 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{Parser, SyntaxKind};
/// See: https://spec.graphql.org/October2021/#Description
///
/// *Description*:
/// StringValue
pub(crate) fn description(p: &mut Parser) {
let _g = p.start_node(SyntaxKind::DESCRIPTION);
let _g_string = p.start_node(SyntaxKind::STRING_VALUE);
p.bump(SyntaxKind::STRIN... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.