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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e674efd52678d5abbd01cae6382e053121b41625 | Rust | xypage/Mancala | /src/objects.rs | UTF-8 | 4,053 | 3.28125 | 3 | [] | no_license | use std::fmt;
#[derive(Debug)]
pub struct Board {
holes: [Hole; 14],
current_player: Side,
other_player: Side
}
// Allows you to print a board without the debugging format, you still can but it looks better this way
impl fmt::Display for Board {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | true |
1967b342a88e4ceb62cd1b18818f35d1ab48c3d7 | Rust | dunnock/poloniex-api-rs | /src/data/book.rs | UTF-8 | 4,694 | 2.71875 | 3 | [
"MIT"
] | permissive | // TODO: Convert to serde deserialization!
use super::json::Expect;
use super::timeseries::{Timeseries, WithTime};
use crate::error::PoloError;
use json::JsonValue;
use serde::Serialize;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::fmt::Debug;
use time::Timespec;
use crate::get_time;
#[derive(Clo... | true |
9d2d5664e136c36be8a1f661adc3df8cab814d84 | Rust | dorucioclea/omics | /publishing/application/publication/create.rs | UTF-8 | 6,092 | 2.953125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use common::event::EventPublisher;
use common::result::Result;
use crate::domain::author::{AuthorId, AuthorRepository};
use crate::domain::category::{CategoryId, CategoryRepository};
use crate::domain::publication::{
Header, Image, Name, Publication, PublicationRepository, Syn... | true |
053fad45aacc610a2a7a86c00575948ebe2aed36 | Rust | userbaruu/aeromit | /src/app/errors.rs | UTF-8 | 5,125 | 2.9375 | 3 | [
"CC0-1.0"
] | permissive | //! # Module Errors
//!
//! Module ini digunakan untuk mengatasi `errors` yang mungkin terjadi
//!
//! <br />
//!
//! # Contoh
//!
//! ```rust
//! use crate::app::errors::{...}
//! ```
use std::{env, io};
use derive_more::{Display, Error};
use mongodb::bson;
use actix_web::{
error::ResponseError,
HttpResponse,
... | true |
b5c70ade3e1606919fd722bb41d707471825effe | Rust | acburigo/rust-bgapi | /src/le_gap/evt.rs | UTF-8 | 3,211 | 2.59375 | 3 | [
"MIT"
] | permissive | use bytes::{Buf, BufMut};
use le_gap::AddressType;
use num_traits::FromPrimitive;
use std::io::{Cursor, Read};
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct adv_timeout {
pub handle: u8,
}
impl From<&[u8]> for adv_timeout {
fn from(data: &[u8]) -> adv_timeout {
... | true |
b65d57e61ea3c9f3959956d5630002c80d3b07d4 | Rust | totechite/b_plus_tree | /src/insert.rs | UTF-8 | 8,571 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::bplus_tree::*;
use std::{convert::TryFrom, marker::PhantomData, mem::MaybeUninit, ptr::NonNull};
impl<K: Ord, V> BPlusTreeMap<K, V> {
pub fn insert(&mut self, key: K, value: V) -> Option<V> {
let ret = self.insert_aux(key, value);
if ret.is_none() {
self.length += 1;
... | true |
ca83f3ca8b1c33a618562ed237e9c10d529d434d | Rust | mrotaru/learning-rust | /recap/src/main.rs | UTF-8 | 1,589 | 4.0625 | 4 | [] | no_license | use std::rc::Rc;
use std::ops::Deref;
struct MyPointer<T> {
value: T,
}
impl<T> MyPointer<T> {
fn new(x: T) -> MyPointer<T> {
MyPointer {
value: x,
}
}
}
fn add(a: &i32, b: &i32) -> i32 {
a + b
}
fn main() {
// Box - "take value, package it in a box, send it to some s... | true |
18f2d8c04898fa8fa38c1c3e99bb3135cf247fc3 | Rust | YutaGoto/daily_atcoder | /2021-04/abc115_a.rs | UTF-8 | 306 | 2.8125 | 3 | [] | no_license | use whiteread::parse_line;
fn main() {
let d: usize = parse_line().unwrap();
match d {
25 => println!("Christmas"),
24 => println!("Christmas Eve"),
23 => println!("Christmas Eve Eve"),
22 => println!("Christmas Eve Eve Eve"),
_ => println!("Eve"),
}
}
| true |
43097a8901d135150c8e262355fda18af315ceb0 | Rust | DevNvll/fear | /src/tokens.rs | UTF-8 | 1,263 | 3.859375 | 4 | [] | no_license | #[derive(Debug, PartialEq)]
pub enum TokenType {
// Literals are stored as strings
Ident(String),
Global(String),
Integer(String),
StringLiteral(String),
// Operators
Assign,
Plus,
Minus,
Bang,
Asterisk,
Slash,
LowerThan,
GreaterThan,
Equal,
NotEqual,
Comma,
Se... | true |
5d5e031316f760a0b5da6e75f93d65d76c562e36 | Rust | fixrtm/diffy | /src/lib.rs | UTF-8 | 6,749 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Tools for finding and manipulating differences between files
//!
//! ## Overview
//!
//! This library is intended to be a collection of tools used to find and
//! manipulate differences between files inspired by [LibXDiff] and [GNU
//! Diffutils]. Version control systems like [Git] and [Mercurial] generally
//! com... | true |
514fe40bfb4c9e149b654869b143f981296b09b7 | Rust | ms705/timely-dataflow | /src/networking/networking.rs | UTF-8 | 15,224 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::io::{Read, Write, Result, BufRead, BufReader, BufWriter};
use std::fs::File;
use std::net::{TcpListener, TcpStream};
use std::mem::size_of;
use std::sync::Arc;
use std::sync::mpsc::{Sender, Receiver, channel};
use std::thread;
use std::thread::sleep_ms;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesEx... | true |
56345d2227cc9521ba4632c28789755963960617 | Rust | JennyBrennan/terminal-chess | /src/ai.rs | UTF-8 | 4,813 | 3.171875 | 3 | [] | no_license | use Side;
use game::{GameState};
use action::Action;
use piece::{Piece, Rank};
use engine;
pub fn make_move(state: &mut GameState) -> Option<Action> {
root_alpha_beta(state)
}
pub fn root_alpha_beta(state: &mut GameState) -> Option<Action> {
let side = state.next_to_move();
let action = possible_actions(... | true |
02e5f383b81089f97604d3c2c59d738c75a0ba7b | Rust | lemmi/aoc_2019 | /06/src/main.rs | UTF-8 | 1,916 | 3.203125 | 3 | [] | no_license | use aoc2019::lines;
use std::collections::HashMap;
use std::error::Error;
fn parse_edge(l: String) -> Result<(String, String), Box<dyn Error>> {
if let Some(p) = l.find(')') {
Ok((l[p + 1..].to_string(), l[..p].to_string()))
} else {
Err(Box::<dyn Error>::from(
"Invalid Edge descrip... | true |
707dba02f32a24feda96674e1cf08c5c74af80e2 | Rust | kogai/pfds | /src/heap/leftist.rs | UTF-8 | 8,104 | 3.40625 | 3 | [] | no_license | use std::fmt::Debug;
use heap::Heap;
#[derive(Debug, PartialEq, Clone)]
pub enum LeftistHeap<T: Clone + Ord + Debug> {
Leaf,
Node(i32, T, Box<LeftistHeap<T>>, Box<LeftistHeap<T>>),
}
use self::LeftistHeap::*;
impl<T: Clone + Ord + Debug> LeftistHeap<T> {
fn from_list_impl(xs: Vec<LeftistHeap<T>>) -> Self... | true |
89cc58038f578cb683f58a48a4790427147e9923 | Rust | selecao3/deeplearningforrust | /src/layers.rs | UTF-8 | 3,346 | 3.15625 | 3 | [] | no_license | use crate::matrix::MatrixTwo;
use crate::matrix::MatrixThree;
#[derive(Clone,Debug)]
pub struct Sigmoid {
params: Vec<MatrixTwo<f32>>
}
#[derive(Clone,Debug)]
pub struct Affine{
params: Vec<MatrixTwo<f32>>
}
#[derive(Clone,Debug)]
pub struct Embedding{
params: Vec<MatrixTwo<f32>>,
pub grads: Vec<Mat... | true |
aeffcaca77237b9e493edb44f67fa3fec06d39c3 | Rust | isgasho/fluvio | /cli/src/common/kf/query_api_versions.rs | UTF-8 | 928 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | //!
//! # Kafka -- Query Metadata
//!
//! Communicates with Kafka Controller to retrieve version information
//!
use kf_protocol::message::api_versions::KfApiVersionsRequest;
use kf_protocol::message::KfApiVersions;
use kf_protocol::api::AllKfApiKey;
use crate::error::CliError;
use crate::common::Connection;
/// Quer... | true |
3024e5a738e4a5331125f13e8f48584e90d93790 | Rust | wagao29/hack-assembler | /src/parser.rs | UTF-8 | 5,314 | 3.109375 | 3 | [] | no_license | use regex::Regex;
use std::io::prelude::*;
use std::io::BufReader;
const DEST_REGEX: &str = r"null=+|M=+|D=+|MD=+|A=+|AM=+|AD=+|AMD=+";
const COMP_REGEX: &str = r"=0$|=1$|=-1$|=D$|=A$|=!D$|=!A$|=-D$|=-A$|=D\+1$|=A\+1$|=D-1$|=A-1$|=D\+A$|=D-A$|=A-D$|=D&A$|=D\|A$|=M$|=!M$|=-M$|=M\+1$|=M-1$|=D\+M$|=D-M$|=M-D$|=D&M$|=D\|M... | true |
59b65885fba5afe9c94da925faff61f649eba9b4 | Rust | Jonesey13/generic_game | /src/geometry/bezier_2d.rs | UTF-8 | 1,061 | 3.09375 | 3 | [
"MIT"
] | permissive | use crate::geometry::*;
#[derive(Clone)]
pub struct BezierQuad {
c0: Point,
c1: Point,
c2: Point
}
impl BezierQuad {
pub fn new(c0: Point, c1: Point, c2: Point) -> BezierQuad {
BezierQuad {
c0: c0,
c1: c1,
c2: c2
}
}
pub fn from_line(line: L... | true |
3d4ac62afe0bbe3fc78cf11c87d7187f4e0a8298 | Rust | MDGSF/JustCoding | /rust-leetcode/leetcode_2373/src/main.rs | UTF-8 | 274 | 2.515625 | 3 | [
"MIT"
] | permissive | use leetcode_2373::solution1::Solution;
fn main() {
let grid = vec![
vec![9, 9, 8, 1],
vec![5, 6, 2, 6],
vec![8, 2, 6, 4],
vec![6, 2, 2, 2],
];
let result = Solution::largest_local(grid);
println!("result = {:?}", result);
}
| true |
79813652df21d008bede24c25c8a0268dcb27692 | Rust | fundon/Algorithms-and-Design-Pattern | /adventofcode/rust/src/4.rs | UTF-8 | 2,314 | 3.40625 | 3 | [] | no_license | use async_std::io;
struct Numbers(u32);
impl Iterator for Numbers {
type Item = u8;
fn next(&mut self) -> Option<Self::Item> {
match self.0 {
0 => None,
_ => {
let d = self.0 % 10;
self.0 /= 10;
Some(d as Self::Item)
... | true |
a4bc8239c54a5af8d13216e52c8a077ea0bc25f1 | Rust | kvakvs/ErlangRT | /lib-erlangrt/src/defs/sizes.rs | UTF-8 | 2,159 | 3.453125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::defs::{self, BitSize};
use core::fmt;
use std::ops::{Add, Sub};
/// Size of something in machine words (32 or 64 bit depending on platform)
#[derive(Copy, Clone)]
pub struct SizeWords {
pub words: usize,
}
#[allow(dead_code)]
impl SizeWords {
pub const fn one() -> Self {
Self { words: 1 }
}
pub... | true |
7905e8f3049a8b9f39d20bed38562b65995229d3 | Rust | nixpulvis/hell | /5/attack/evolution-wire/tests/src/either.rs | UTF-8 | 1,233 | 3.03125 | 3 | [] | no_license | use evolution_wire::{Nat, NatPlus, Either, SpeciesCard, Trait};
use serde_json as json;
#[test]
fn single_variant_match() {
let wire = r###"
[-2, "burrowing"]
"###;
let json = json::from_str(wire).unwrap();
let either = Either::<SpeciesCard, Nat>::from_value(json).unwrap();
assert!(eithe... | true |
c3a993f6f2fefe92f0b513573484fe3865c780bb | Rust | reproto/reproto | /lib/derive/format.rs | UTF-8 | 591 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::sir::Sir;
use reproto_core::errors::Result;
use std::fmt;
///
/// Decoder to use.
pub trait Format: fmt::Debug {
fn decode(&self, object: &reproto_core::Source) -> Result<Sir>;
}
/// Object accessor
pub trait Object {
type Value;
/// Get the value of the given key.
fn get(&self, key: &str)... | true |
dcbb9e978570848c2f243d2bf5fd51e94a8bf735 | Rust | AumyF/fers | /src/casl/ast.rs | UTF-8 | 578 | 2.84375 | 3 | [] | no_license | /// ソースコード
pub struct Source<'a>(Vec<Line<'a>>);
pub enum Line<'a> {
OperationLine(OperationLine<'a>),
CommentLine(CommentLine<'a>),
}
pub struct CommentLine<'a> {
comment: &'a str,
}
pub struct Label<'a>(&'a str);
pub enum Opecode {}
pub enum Operand {}
pub enum OperationLine<'a> {
OperandLine(Oper... | true |
b51f6ec053344c399a314a326d069e574db8b799 | Rust | battjt/space | /src/point.rs | UTF-8 | 1,176 | 3.609375 | 4 | [] | no_license | use rand::Rng;
pub type Float = f64;
#[derive(Debug, Copy, Clone)]
pub struct Point {
pub x: Float,
pub y: Float,
}
impl Point {
pub fn scale(self, s: Float) -> Point {
return Point {
x: self.x * s,
y: self.y * s,
};
}
pub fn add(self, that: Point) -> Point... | true |
8e32bd412724feca2a5b0b9ecf7e306ad2335636 | Rust | chesedo/cos-700 | /Code/Rust/macro-client/src/visitor_hand.highlighted.rs | UTF-8 | 2,172 | 3.046875 | 3 | [] | no_license | #[allow(unused_imports)]
use macro_patterns::visitor;
use std::fmt;
use crate::gui::elements::{Button, Child, Input, Window};
// Abstract visitor for `Button`, `Input` and `Window`
pub trait Visitor {
fn visit_button(&mut self, button: &dyn Button) {
visit_button(self, button)
}
fn visit_input(&mu... | true |
45f0c5dd2290adb3e586ed41b0b52ddf6b79dc23 | Rust | Lol3rrr/brainterpreter | /src/io/log_output.rs | UTF-8 | 237 | 2.53125 | 3 | [] | no_license | use crate::core::traits::Output;
pub struct LogOutput {}
impl LogOutput {
pub fn new() -> Self {
Self {}
}
}
impl Output for LogOutput {
fn output(&mut self, byte: u8) {
print!("{}", byte as char);
}
}
| true |
3470db36619ea73ab879b2dfdce0067fc5d4b52c | Rust | aspera-non-spernit/guru | /src/generators.rs | UTF-8 | 10,436 | 2.796875 | 3 | [] | no_license | use crate::{
features::{GameDayFeature, GoalDiffFeature, LeagueFeature, MedianScoreFeature, WDLFeature},
models::{Clubs, Match, Scoring},
utils::normalize,
Stats,
};
use std::collections::{HashMap};
/**
Example implementation
impl<'a> DefaultInputGenerator<'a> {
/***
Updates the St... | true |
549874da298535845cc04b236e42eb5fc631ae5d | Rust | hackadot/example-contracts | /swap/lib.rs | UTF-8 | 2,258 | 2.734375 | 3 | [] | no_license | #![cfg_attr(not(feature = "std"), no_std)]
use ink_lang as ink;
use ink_prelude::*;
#[ink::contract]
mod swap {
use ink_storage::Lazy;
use erc20::stub::Erc20;
use brush::traits::InkStorage;
#[ink(storage)]
#[derive(Default)]
pub struct Swap {
token_addr: AccountId,
exchange_... | true |
cf71bad625d3299a420fc854188f1d38027c9c92 | Rust | pka/Hecate | /src/meta/mod.rs | UTF-8 | 1,613 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::err::HecateError;
pub fn list(conn: &impl postgres::GenericConnection) -> Result<Vec<String>, HecateError> {
match conn.query("
SELECT key FROM meta ORDER BY key
", &[ ]) {
Ok(rows) => {
let mut names = Vec::<String>::new();
for row in rows.iter() {
... | true |
75659dbcbff128f2afc4f6a89edba70a2b0cff0a | Rust | TheNumerus/advent-of-code-2018 | /src/days/day_14.rs | UTF-8 | 2,107 | 2.765625 | 3 | [] | no_license | const INPUT: usize = 990941;
const INPUT_SLICED: [u8; 6] = [9, 9, 0, 9, 4, 1];
pub fn solve() {
let mut recipes = Vec::with_capacity(INPUT + 12);
recipes.extend_from_slice(&[3_u8, 7]);
let mut elves = (0, 1);
loop {
let score = recipes[elves.0] + recipes[elves.1];
if score >= 10 {
... | true |
d34d3880d09b7e9eb60b7906f6e66d6a20a8002c | Rust | attilahorvath/exercism-rust | /saddle-points/src/lib.rs | UTF-8 | 1,084 | 2.734375 | 3 | [
"MIT"
] | permissive | pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> {
let mut row_max = vec![None; input.len()];
let mut col_min = vec![(None, Vec::new()); input[0].len()];
for (row, values) in input.iter().enumerate() {
for (col, &value) in values.iter().enumerate() {
if row_max[row].... | true |
0d9db33b9d95f08b47fdaf3f22e0c64c14ef122a | Rust | PetterMansson/aws-iot-device-sdk-rust | /src/main_shadow.rs | UTF-8 | 2,570 | 2.796875 | 3 | [
"MIT"
] | permissive | mod client;
mod shadow;
use serde_json::json;
use serde_json::Value;
use std::{thread, time};
fn callback_get_accepted(payload: String) {
println!("Get Shadow Accepted: {}", payload);
}
fn callback_get_rejected(payload: String) {
println!("Get Shadow Rejected: {}", payload);
}
fn callback_update_accepted(pa... | true |
dc1c619bc178870761bb7202dcb61c05b3b8c73c | Rust | Mutestock/mini-project-loner-edition | /grpc/src/utils/config.rs | UTF-8 | 1,704 | 3.03125 | 3 | [] | no_license | use serde_derive::Deserialize;
use std::env;
use std::error::Error;
use std::fs;
lazy_static! {
static ref CONFIG_PATH: &'static str = "config.toml";
pub static ref CONFIG: Config =
read_config_file(&CONFIG_PATH).expect("Config file could not be read at lazy static");
}
#[derive(Deserialize)]
pub stru... | true |
1515bf36cc7b51cfa2c8259e28d72420609f666c | Rust | 0xfinch/popsicle | /gtk/src/app/state.rs | UTF-8 | 26,700 | 2.796875 | 3 | [
"MIT"
] | permissive | use super::super::BlockDevice;
use super::{App, OpenDialog};
use hash::HashState;
use image::{self, BufferingData};
use std::cell::{Cell, RefCell};
use std::mem;
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::Sender;
use std::sync::... | true |
3126cb09f8c47abc90cc562517a5762d10dc107f | Rust | dennisss/dacha | /pkg/net/src/dns/message_builder.rs | UTF-8 | 2,415 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use alloc::vec::Vec;
use common::errors::*;
use crate::dns::name::*;
use crate::dns::proto;
pub struct MessageBuilder {
data: Vec<u8>,
header: proto::Header,
name_encoder: NameEncoder,
}
impl MessageBuilder {
fn new(header: proto::Header) -> Self {
MessageBuilder {
data: vec![0; ... | true |
02bd38e441ac0e1e4d6c0fcb81d656177ab61282 | Rust | PabloMansanet/bevy_tween | /src/tween.rs | UTF-8 | 2,545 | 2.8125 | 3 | [] | no_license | use splines::{
interpolate::{cubic_bezier_def, quadratic_bezier_def, Interpolate, Linear},
Interpolation, Key, Spline,
};
use std::{
ops::{Add, Sub},
time::Duration,
};
use bevy::prelude::*;
#[derive(Copy, Clone)]
pub struct TweenValue<T: Copy>(pub T);
pub struct TweenComponent<T: Copy> {
spline: ... | true |
12475b8f616a79038c152d145b4a1f53ebb9d670 | Rust | baptistemanson/rust-pathfinder | /app/src/animation.rs | UTF-8 | 502 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::time::{Duration, Instant};
#[allow(dead_code)]
type UnitId = u16;
#[allow(dead_code)]
pub enum EaseFun {
Linear,
EaseIn,
EaseOut,
}
#[allow(dead_code)]
pub enum AnimationType {
Position { subject: UnitId, to: [f32; 2] },
InfoOverhead { subject: UnitId, text: String },
LogScroll { nb_o... | true |
79aed12a804bb76e7937c3c9fdff6296e26455bc | Rust | dprint/dprint | /crates/dprint/src/utils/cached_downloader.rs | UTF-8 | 2,316 | 3.09375 | 3 | [
"MIT"
] | permissive | use anyhow::anyhow;
use anyhow::Result;
use dprint_core::async_runtime::async_trait;
use std::cell::RefCell;
use std::collections::HashMap;
use crate::environment::UrlDownloader;
type CachedDownloadResult = Result<Option<Vec<u8>>, String>;
pub struct CachedDownloader<TInner: UrlDownloader> {
inner: TInner,
resul... | true |
66401b63d52f459704552306b0021bcdcbdd0142 | Rust | volks73/assert_cmd | /src/lib.rs | UTF-8 | 1,512 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! **Assert `process::Command`** - Easy command initialization and assertions.
//!
//! ```toml
//! [dependencies]
//! assert_cmd = "0.3"
//! ```
//!
//! ## Example
//!
//! Here's a trivial example:
//!
//! ```rust,ignore
//! extern crate assert_cmd;
//!
//! use std::process::Command;
//! use assert_cmd::prelude::*;
//... | true |
c7de7a5700b2074202452b5c03508f696d9c2287 | Rust | frgomes/rocket-recipes | /src/main.rs | UTF-8 | 1,675 | 2.640625 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate rocket_contrib;
use rocket::Data;
use rocket::request::{Form, LenientForm};
use rocket::response::{content, Stream};
use rocket_contrib::json::{Json, JsonValue};
use std::env... | true |
c5d46a59d921611f0a85c4342295b94186c30cde | Rust | happyborg/gitoxide | /git-transport/src/client/http/traits.rs | UTF-8 | 1,363 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use quick_error::quick_error;
use std::io;
quick_error! {
#[derive(Debug)]
pub enum Error {
Detail(description: String) {
display("{}", description)
}
PostBody(err: io::Error) {
display("An IO error occurred while uploading the body of a POST request")
... | true |
c67ba7a6114821e3cea1d41f8b5ec6843f85a106 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc270/src/bin/e.rs | UTF-8 | 898 | 2.5625 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
k: usize,
a: [usize; n],
};
let mut b = a.clone();
b.sort();
let mut sum = 0_usize;
let mut count_per_cycle = n;
let mut cycle_count = 0;
for b_i in b {
let d = (b_i - cycle_count) * count_per_cycle;
... | true |
f2a548f43b32ff2fb7bd39382475fd5aa7ac5722 | Rust | asyade/glola | /artnet/src/error.rs | UTF-8 | 1,572 | 3.328125 | 3 | [] | no_license | /// The result that this crate uses
pub type Result<T> = std::result::Result<T, Error>;
/// All the possible errors this crate can encounter
#[derive(Debug)]
pub enum Error {
/// Could not read or write to the inner curso
CursorEof(std::io::Error),
/// Could not serialize an artnet command
SerializeEr... | true |
24a42c44b6e6241640c24a43e953f0a9e974f3dd | Rust | kuroidoruido/AdventOfCode2020 | /day12/src/main.rs | UTF-8 | 8,150 | 3.6875 | 4 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
#[derive(Clone, Copy, Debug, PartialEq)]
enum Move {
North(i64),
South(i64),
East(i64),
West(i64),
Left(i64),
Right(i64),
Forward(i64),
}
#[derive(Clone, Copy, Debug, PartialEq)]
enum Direction {
North,
South,
East,
West,
}
fn mai... | true |
449b1610863fb61d4a0d789479178789e76ea04e | Rust | ncalibey/mini-projects | /rust/blog-actix/src/errors.rs | UTF-8 | 2,213 | 3.265625 | 3 | [] | no_license | use actix_web::error::BlockingError;
use actix_web::web::HttpResponse;
use diesel::result::DatabaseErrorKind::UniqueViolation;
use diesel::result::Error::{DatabaseError, NotFound};
use std::fmt;
#[derive(Debug)]
pub enum AppError {
RecordAlreadyExists,
RecordNotFound,
// Catch-all for other Diesel errors t... | true |
173e05e6beea3615ea7e4ae1c9beb12f4a487b10 | Rust | jacklund/cryptopals | /src/challenges/set_6/challenge_45.rs | UTF-8 | 1,506 | 3.140625 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use crate::digest::sha1::*;
use crate::dsa::*;
use num::{One, Zero};
use num_bigint::*;
#[test]
fn challenge_45() {
// Create DSA with default p and q, but g == 0
let mut dsa = DSA::new(&DEFAULT_P, &DEFAULT_Q, &BigUint::zero());
dsa.disable_r_che... | true |
3a5bd984d1551a85c1abddd56e101245eb9863f3 | Rust | pearzl/leetcode_rust | /src/answer/q0059_spiral_matrix_ii.rs | UTF-8 | 3,786 | 3.453125 | 3 | [] | no_license | // q0059_spiral_matrix_ii
struct Solution;
impl Solution {
pub fn generate_matrix(n: i32) -> Vec<Vec<i32>> {
if n == 0 {
return vec![];
}
let mut ret = Vec::with_capacity(n as usize);
for _ in 0..n {
// ret.push(Vec::with_capacity(n as usize)); // leetcode d... | true |
01f97a23a8f6f47c2b01e74ed565fdf728e89ced | Rust | sec-bit/zkp-toolkit | /src/gadget/mimc.rs | UTF-8 | 7,519 | 2.671875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use math::{Field, FromBytes, PairingEngine, ToBytes};
use scheme::r1cs::{ConstraintSynthesizer, ConstraintSystem, SynthesisError};
use crate::{Gadget, GadgetProof, Vec};
/// This is an implementation of MiMC, specifically a
/// variant named `LongsightF322p3` for BN-256.
/// See http://eprint.iacr.org/2016/492 for mo... | true |
c644d6e9d19daf6939d26b3d98ce21be8e80ebd8 | Rust | TyOverby/construct | /examples/demo.rs | UTF-8 | 399 | 3.265625 | 3 | [] | no_license | #[macro_use]
extern crate construct;
use std::collections::HashMap;
fn main() {
// Vector construction
let v = construct!(Vec<_>, 1,2,3,4);
assert_eq!(v, vec![1,2,3,4]);
// Hashmap construction
let m = construct!(HashMap<_,_>, (1, "hi"), (2, "bye"));
let mut manual = HashMap::new();
man... | true |
799c33248f41d194064e63e32dd5d4401173141e | Rust | adalbertoteixeira/data-utility-belt | /src/main.rs | UTF-8 | 9,749 | 3.015625 | 3 | [] | no_license | extern crate clap;
extern crate serde_json;
#[macro_use]
extern crate lazy_static;
extern crate regex;
use clap::{App, Arg, ArgMatches, SubCommand};
use regex::Regex;
use serde_json::{json, Map, Value};
use std::io::{self, Write};
mod is_different;
// use std::collections::HashMap;
pub fn main() {
let matches = Ap... | true |
12a637f3c6c4b91639fbabc07b15e25933a84814 | Rust | Sfera-IT/adventofcode2020 | /xanathar/day17b/src/main.rs | UTF-8 | 1,981 | 3.140625 | 3 | [] | no_license | use std::collections::{HashSet, HashMap};
use std::iter::Iterator;
fn parse_line(y: i64, line: &str, grid: &mut HashSet<(i64, i64, i64, i64)>) {
for (x, c) in line.chars().enumerate() {
if c == '#' {
grid.insert((x as i64, y, 0, 0));
}
}
}
fn evolve(grid: &mut HashSet<(i64, i64, i... | true |
33cd8538159a8e5281ef6d196f3dc5ae4e769c2b | Rust | jasilven/aoc-2019-rust | /src/bin/day18.rs | UTF-8 | 5,243 | 2.875 | 3 | [] | no_license | use anyhow::Result;
use std::collections::{HashMap, HashSet, VecDeque};
use std::io::{BufRead, BufReader};
mod util;
fn parse_input(path: &str) -> Result<HashMap<(isize, isize), char>> {
let mut result = HashMap::new();
let file = std::fs::File::open(path)?;
for (y, line) in BufReader::new(&file).lines().... | true |
bbeedd888ba67061d55c37a6e2c0630151e17080 | Rust | killercup/rng-cli | /src/main.rs | UTF-8 | 5,501 | 3.1875 | 3 | [] | no_license | use rand::{RngCore, SeedableRng};
use std::{
fmt,
io::{self, Write},
};
use structopt::StructOpt;
/// The number of bytes to handle in each generate-print iteration.
const BUFFER_SIZE: usize = 64 * 1024;
// We select PCG algorithm depending on platform. In order to get the best performance possible.
// This c... | true |
452c10a9b8aaea4767ccbe25c62dc8cb44653ed6 | Rust | lucifer1004/AtCoder | /arc116/src/bin/a.rs | UTF-8 | 420 | 2.6875 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
t: usize,
n: [usize; t],
};
println!(
"{}",
n.into_iter()
.map(|x| (if x % 2 == 1 {
"Odd"
} else if x % 4 != 0 {
"Same"
} else {
"Even"
... | true |
a9e831f24e5fe6fb59eb48f4b6d623c1f9a77a29 | Rust | 4lDO2/uninit-tools-rs | /src/wrappers.rs | UTF-8 | 10,855 | 3.21875 | 3 | [
"MIT"
] | permissive | use core::borrow::{Borrow, BorrowMut};
use core::mem::MaybeUninit;
use core::ops::{Deref, DerefMut};
use crate::traits::{Initialize, InitializeVectored, TrustedDeref};
/// A wrapper over `T` that assumes all of `T` to be initialized.
#[repr(transparent)]
#[derive(Clone, Copy, Default)]
pub struct AssertInit<T> {
... | true |
3840b7dac70e30625b7ad82c4ccf77ff7e4fafa5 | Rust | loiclec/fuzzcheck-rs | /fuzzcheck/tests/alternation_char_mutators.rs | UTF-8 | 1,294 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::ops::RangeInclusive;
use fuzzcheck::mutators::alternation::AlternationMutator;
use fuzzcheck::mutators::char::CharWithinRangeMutator;
use fuzzcheck::mutators::testing_utilities::test_mutator;
fn test_alternation_char_helper(ranges: impl IntoIterator<Item = RangeInclusive<char>> + Clone) {
let m = Alterna... | true |
ef85b820b4e895ed1e002c78c1c7219fc4651c08 | Rust | LucioFranco/tokio-compat-02 | /src/lib.rs | UTF-8 | 4,705 | 3.28125 | 3 | [
"MIT"
] | permissive | //! Tokio context aware futures utilities.
//!
//! This crate includes utilities around integrating Tokio with other runtimes
//! by allowing the context to be attached to futures. This allows spawning
//! futures on other executors while still using Tokio to drive them. This
//! can be useful if you need to use a Toki... | true |
65d5a7fc995e9d15cbee1ba73edeff8977604d91 | Rust | lsgng/ws-playback-sync-backend | /src/incoming_message.rs | UTF-8 | 1,084 | 2.703125 | 3 | [] | no_license | use crate::payload::{CrossFadePayload, FastForwardPayload, PlayPayload, StopPayload};
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
use std::error::Error;
use warp::ws::Message;
#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type", content = "payload", rename_all = "camelCase")]
p... | true |
cff9e5895a24f7fdb17e89c2a0a95ed71828e126 | Rust | owen8877/leetcode-rs | /src/problem_336.rs | UTF-8 | 1,935 | 3.40625 | 3 | [] | no_license | pub fn palindrome_pairs(words: Vec<String>) -> Vec<Vec<i32>> {
use std::collections::*;
let mut word_map = HashMap::new();
let mut blank_position = None;
for (i, word) in words.iter().enumerate() {
word_map.insert(word.as_str(), i);
if word.as_str() == "" {
blank_position =... | true |
5211fabbc4424d8c80b29d93e390fd4daeec9949 | Rust | cliff-db/cliffpack | /src/error.rs | UTF-8 | 2,580 | 2.984375 | 3 | [] | no_license | use std::fmt;
use std::io;
use std::string::FromUtf8Error;
/// This enum represents all possible errors when reading a plugin package.
#[derive(Debug)]
pub enum PluginReadError {
/// This error occurs if the magic number is incorrect. The magic number uniquely identifies the cliff plugin file type (.cpk).
Inva... | true |
686cbf0c7cb9e0144affee792d3b2ffd7551025c | Rust | scalexm/hashmap | /src/atomic_arc/mod.rs | UTF-8 | 7,789 | 3.15625 | 3 | [] | no_license | //! Differential reference counting adapted from [diff]. We use pointer
//! compression to store both a pointer and the outer count on one word, so
//! that we don't need double word atomics: see [wikipedia] on why we can use
//! the 16 highest bits of a pointer to store our outer count on x86_64,
//! and we can also u... | true |
8f3f3d7a84c618d37ab17fc0354ffa5d30e1dbeb | Rust | Azure/azure-sdk-for-rust | /sdk/storage_blobs/examples/container_01.rs | UTF-8 | 3,265 | 2.625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | use azure_core::{date, prelude::*};
use azure_storage::prelude::*;
use azure_storage_blobs::prelude::*;
use std::time::Duration;
use time::OffsetDateTime;
#[tokio::main]
async fn main() -> azure_core::Result<()> {
// First we retrieve the account name and access key from environment variables.
let account =
... | true |
0f85ad948a0e61f7b018a8b95e5cd2741e6e68c7 | Rust | Mohan-Cialfo/jaro | /src/main.rs | UTF-8 | 1,926 | 3.21875 | 3 | [] | no_license | use std::cmp;
pub fn main() {
println!("{}", jaro_wrinker_distance("abc", "acd"));
}
pub fn jaro_wrinker_distance(s1: &str, s2: &str) -> f32 {
let mut m: f32 = 0.0;
let s1_length = s1.len();
let s2_length = s2.len();
if s1_length == 0 && s2_length == 0 {
return 0.0;
}
if s1 == s2 ... | true |
8ca9df8af77a7678ac78dc2c69e34e43aab165f0 | Rust | ngi-nix/reowolf | /src/runtime/mod.rs | UTF-8 | 34,780 | 2.765625 | 3 | [
"MIT"
] | permissive | /// cbindgen:ignore
mod communication;
/// cbindgen:ignore
mod endpoints;
pub mod error;
/// cbindgen:ignore
mod logging;
/// cbindgen:ignore
mod setup;
#[cfg(test)]
mod tests;
use crate::common::*;
use error::*;
use mio::net::UdpSocket;
/// The interface between the user's application and a communication session,
/... | true |
58534a0bc679c622ae2b8d0941497c67e7fdd01a | Rust | jakubfijalkowski/aoc_2020 | /src/bin/day22.rs | UTF-8 | 2,940 | 3.4375 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
struct Game {
player1: Vec<u8>,
player2: Vec<u8>,
}
impl Game {
fn parse(s: &str) -> Game {
let mut p = s.split("\n\n");
Game {
player1: Self::parse_deck(p.next().unwrap()),
player2: Self::p... | true |
7bd18f7e7279a11595c563df2ab3764ac4bf5c1b | Rust | thequux/smalltalk.rs | /src/objectmemory/dist_format.rs | UTF-8 | 3,588 | 2.796875 | 3 | [] | no_license | use crate::interpreter::InstanceSpecification;
use crate::objectmemory::{ObjectLayout, ObjectMemory, OOP};
use byteorder::{BigEndian, ByteOrder as _, ReadBytesExt};
use std::fs::File;
use std::io::{self, prelude::*, SeekFrom};
use std::path::Path;
pub enum DistFormat {}
struct ObjTblEntry {
flags: u16,
locati... | true |
2676842ce6e22cc5652f6cb02733d30a9d2914b8 | Rust | sile/stun_codec | /src/convert.rs | UTF-8 | 302 | 3.5625 | 4 | [
"MIT"
] | permissive | //! Conversion traits.
/// This trait allows for attempting to a cheap reference-to-reference conversion.
pub trait TryAsRef<T> {
/// Attempts to convert `self` to a reference to `T`.
///
/// If it is not possible, this method will return `None`.
fn try_as_ref(&self) -> Option<&T>;
}
| true |
5fe6291a74f51450ab236ccc479de5ec00693415 | Rust | AndreiKazakov/first-person-terminal-engine | /src/player.rs | UTF-8 | 483 | 3.359375 | 3 | [
"MIT"
] | permissive | pub struct Player {
pub x: f64,
pub y: f64,
pub angle: f64,
}
impl Player {
pub fn turn_left(&mut self) {
self.angle -= 0.1
}
pub fn turn_right(&mut self) {
self.angle += 0.1
}
pub fn move_forward(&mut self) {
self.x += self.angle.sin() * 0.5;
self.y +=... | true |
bcc1a9aeea98da5d62618c0b5dede1bf7cd5153d | Rust | mfelsche/http-types | /src/content/encoding_proposal.rs | UTF-8 | 4,222 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::content::Encoding;
use crate::ensure;
use crate::headers::HeaderValue;
use crate::utils::parse_weight;
use std::cmp::{Ordering, PartialEq};
use std::ops::{Deref, DerefMut};
/// A proposed `Encoding` in `AcceptEncoding`.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct EncodingProposal {
/// The prop... | true |
e55ba32bcace28e397f2eccfc0f2dfd041fadde5 | Rust | uesud/rust-challenge | /examples/ex011.rs | UTF-8 | 230 | 3.046875 | 3 | [
"MIT"
] | permissive | //! 与えられた整数をローマ数字に変換するサンプル
use rust_challenge::math::num_to_roman;
mod common;
use common::read_u32;
pub fn main() {
let n = read_u32("n");
println!("{}", num_to_roman(n));
} | true |
100c41553e463e6d49a2a4cfb07ef4d0984e4cfe | Rust | andymac-2/code-snippets | /rust/10print.rs | UTF-8 | 154 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | fn dummy () {}
fn functional (a: u32) -> impl Fn (u32) -> u32 {
|b| a + b;
}
let copy = dummy;
let add_three = functional(3);
fn main () {
()
} | true |
d2a37260361643f90bc28bbf8c51a8afb95f53cb | Rust | dlinyang/solas | /examples/sphere/main.rs | UTF-8 | 4,241 | 2.53125 | 3 | [] | no_license | use solas::format::{image_file::ImageFile};
use solas::object::sphere::Sphere;
use solas::scene::{Scene,Canvas};
use solas::base::camera::Camera;
use solas::material::bsdf::*;
use solas::renderer::*;
use rmu::vector::Vector3;
use std::sync::Arc;
use solas::base::random::RNG;
fn main() {
println!("This is a Ray ... | true |
6262981318eb751c3e46a678e446055e622c72ea | Rust | PacktPublishing/Rust-Programming-Recipies | /Section 3/src/v5_pool.rs | UTF-8 | 1,577 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
pub struct ThreadPool {
ch_s: Option<mpsc::Sender<Box<Fn() + Send>>>,
n: u32,
ch_done: mpsc::Receiver<()>,
}
impl ThreadPool {
pub fn new(n: u32) -> Self {
let (ch_s, ch_r) = mpsc::channel();
let a = Arc::new(Mutex::new(ch_r))... | true |
b12bc8647362b9f3baa363fecb570577cda709fa | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/futures/tests/recurse.rs | UTF-8 | 476 | 2.796875 | 3 | [
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | extern crate futures;
use std::sync::mpsc::channel;
use futures::future::ok;
use futures::prelude::*;
#[test]
fn lots() {
fn doit(n: usize) -> Box<Future<Item=(), Error=()> + Send> {
if n == 0 {
Box::new(ok(()))
} else {
Box::new(ok(n - 1).and_then(doit))
}
}
... | true |
9c4d9e2d30f24e75d96f9a0c030029355e58d8e5 | Rust | cgaebel/bench-psl | /src/main.rs | UTF-8 | 3,654 | 2.84375 | 3 | [] | no_license | #![allow(unstable)]
use std::collections::{hash_map, HashMap, HashSet};
use std::default::Default;
use std::iter::range;
use std::num::Int;
use std::sync::Future;
fn real_cap_of(load_factor: f64, base_cap: usize) -> usize {
let hm: HashMap<usize, ()> =
HashMap::with_capacity_hash_state_and_load_factor(
... | true |
194df0addce0a36c331673a76399e87803cb5c50 | Rust | tangentstorm/bex | /src/base.rs | UTF-8 | 3,833 | 3.046875 | 3 | [
"MIT"
] | permissive | #![macro_use]
///! bex: a boolean expression library for rust
///! outside the base, you deal only with opaque references.
///! inside, it could be stored any way we like.
use nid::{NID,VID};
pub trait Base {
fn new(n:usize)->Self where Self:Sized; // Sized so we can use trait objects.
fn num_vars(&self)->usize;
... | true |
fd481e92761c269c3c27d6ece0dfef6c4cba85c9 | Rust | kyunghoon/rusoto | /rusoto/credential/src/instance_metadata.rs | UTF-8 | 3,109 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! The Credentials Provider for an AWS Resource's IAM Role.
use reqwest;
use std::io::Read;
use {AwsCredentials, CredentialsError, ProvideAwsCredentials, parse_credentials_from_aws_service};
const AWS_CREDENTIALS_PROVIDER_IP: &'static str = "169.254.169.254";
const AWS_CREDENTIALS_PROVIDER_PATH: &'static str = "lat... | true |
ab68cce2423f3b70ea4b7fca42181509ebdbc311 | Rust | cole-miller/stdsimd | /crates/core_simd/src/array.rs | UTF-8 | 8,821 | 3.21875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::intrinsics;
use crate::masks::*;
use crate::vector::ptr::{SimdConstPtr, SimdMutPtr};
use crate::vector::*;
/// A representation of a vector as an "array" with indices, implementing
/// operations applicable to any vector type based solely on "having lanes",
/// and describing relationships between vector an... | true |
5ad9bd7fe602357352f10d6b4e9311ac5b162b1f | Rust | tonyo/semaphore | /aorta/src/projectstate.rs | UTF-8 | 15,271 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fmt;
use std::mem;
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Instant;
use chrono::{DateTime, Utc};
use parking_lot::RwLock;
use serde::de::DeserializeOwned;
use url::Url;
use uuid::Uuid;
use config::AortaConfig;
use event::StoreChangeset;... | true |
ddc4664d0a446216c58360a5af5d71416ff0d522 | Rust | nmatsui/robot_simulator_rust | /src/models/robot.rs | UTF-8 | 2,019 | 3.0625 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | //! The `robot` module provides an state equation of a simulated robot and the jacobian of the state equation
extern crate nalgebra as na;
use crate::utils;
/// The default value of maximum linear acceleration
pub const MAX_LIN_ACC: f64 = 2.5;
/// The default value of maximum angular acceleration
pub const MAX_ANG_A... | true |
2e708c7beea4d5aeed4130497f2fff7d7ca0aad8 | Rust | dtn7/bp7-rs | /src/dtntime.rs | UTF-8 | 2,759 | 3.03125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use core::fmt;
use core::sync::atomic::{AtomicUsize, Ordering};
use core::time::Duration;
use humantime::format_rfc3339;
use serde::{Deserialize, Serialize};
use std::time::UNIX_EPOCH;
/// Time since the year 2k in milliseconds
pub type DtnTime = u64;
pub const SECONDS1970_TO2K: u64 = 946_684_800;
const MS1970_TO2K: ... | true |
3133600fcb30845c9233664e639de54345d8a58d | Rust | oscoin/osrank-rs | /bin/source_contributions.rs | UTF-8 | 14,899 | 2.75 | 3 | [] | no_license | extern crate clap;
extern crate csv;
extern crate reqwest;
extern crate serde;
extern crate failure;
#[macro_use]
extern crate failure_derive;
use clap::{App, Arg};
use csv::StringRecord;
use reqwest::{Client, Url};
use serde::de::DeserializeOwned;
use serde::Deserialize;
use std::{thread, time};
use std::collection... | true |
b123cffd35b637675578cae806fa4213faf3c8ef | Rust | bheisler/criterion.rs | /src/stats/bivariate/mod.rs | UTF-8 | 3,996 | 3.03125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Bivariate analysis
mod bootstrap;
pub mod regression;
mod resamples;
use crate::stats::bivariate::resamples::Resamples;
use crate::stats::float::Float;
use crate::stats::tuple::{Tuple, TupledDistributionsBuilder};
use crate::stats::univariate::Sample;
#[cfg(feature = "rayon")]
use rayon::iter::{IntoParallelIterat... | true |
3e0f0cb0bc790a48b78315dc29ebce07631f3067 | Rust | takatori/todo-rs | /src/main.rs | UTF-8 | 1,791 | 2.515625 | 3 | [] | no_license | #![feature(plugin, custom_derive, custom_attribute)]
// use compiler plugin
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate rocket_contrib;
extern crate serde_json;
extern crate r2d2;
extern crate r2d2_diesel;
extern crate dotenv;
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_codegen... | true |
fa1250cbb48af2f999502d04460596b045caffe9 | Rust | mr-rodgers/asgi_server | /src/asgi_driver/asgi_send.rs | UTF-8 | 1,208 | 2.78125 | 3 | [
"Unlicense"
] | permissive | use futures::{channel::mpsc::Sender, SinkExt};
use pyo3::{exceptions::*, prelude::*, types::*};
/// A python callable that wraps a Rust asynchronous sink. It's meant to
/// be passed as `send` into an ASGI 3.0 context
///
/// `AsgiSend` wraps a Rust mpsc::Sender<Py<PyDict>> in a python callable
/// that accepts an asg... | true |
2036dfff87e4f6714bd1999649f319e27781b2ad | Rust | antewu/seeker | /ssclient/src/connection_pool.rs | UTF-8 | 5,611 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::VecDeque;
use std::io::Result;
use std::sync::Arc;
use std::time::{Duration, Instant};
use async_std::future;
use async_std::io;
use async_std::sync::{channel, Mutex, Receiver, Sender};
use tracing::{error, trace};
use crate::encrypted_stream::EncryptedTcpStream;
use crate::BoxFuture;
pub(crate... | true |
cdc0c68e1e56bd837444d80c7da893138b7351ed | Rust | acidburn0zzz/ruffle | /core/src/avm1/object/value_object.rs | UTF-8 | 4,340 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Object impl for boxed values
use crate::avm1::activation::Activation;
use crate::avm1::error::Error;
use crate::avm1::object::TObject;
use crate::avm1::{Object, ScriptObject, Value};
use crate::impl_custom_object;
use gc_arena::{Collect, GcCell, MutationContext};
use std::fmt;
/// An Object that serves as a box f... | true |
1cfb83676d502d08a7df8c0eb5a1d01a23c27862 | Rust | lights0123/ndless-rs | /ndless/src/bindings/out.rs | UTF-8 | 322 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! # Serial output
//! This module contains tools to output to the serial port. Also, take a look at
//! [io::stdout](crate::io::stdout).
use core::fmt::Arguments;
use crate::io;
use crate::io::Write;
pub fn print_fmt(fmt: Arguments) -> core::fmt::Result {
io::stdout().write_fmt(fmt).map_err(|_| core::fmt::Error)
... | true |
94dbc58c14029a8edd14bc443abfec89a3beb350 | Rust | juanjo/geotron | /src/main.rs | UTF-8 | 4,114 | 2.578125 | 3 | [] | no_license | use std::net::IpAddr;
use std::env;
extern crate pretty_env_logger;
#[macro_use] extern crate log;
use maxminddb;
use maxminddb::geoip2;
extern crate serde_json;
use serde::{Serialize};
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Method, Request, Response, Server, StatusCode};
const GEOIP_... | true |
34d2f35e42c26bf76da0545bb9286d620344cbdf | Rust | ingSlonik/wuake | /src/key_events.rs | UTF-8 | 1,600 | 3.09375 | 3 | [
"MIT"
] | permissive | extern crate user32;
use std::sync::mpsc::Sender;
use std::{thread, time};
pub struct KeyEvent {
key: i32,
pressed: bool,
}
impl KeyEvent {
pub fn new(key: i32) -> KeyEvent {
unsafe {
KeyEvent {
key: key,
pressed: user32::GetAsyncKeyState(key) != 0,
... | true |
2f18cd1478a9adb9fabb7398e28e9cc0af9785b5 | Rust | lassade/toctoc | /src/json/object.rs | UTF-8 | 2,091 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::collections::BTreeMap;
use std::iter::FromIterator;
use std::mem::{self, ManuallyDrop};
use std::ops::{Deref, DerefMut};
use std::ptr;
use crate::json::{drop, Value};
/// A `BTreeMap<String, Value>` with a non-recursive drop impl.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Object<'de> {
inner... | true |
97d571cd1fc2af92b63eceaa1fafd600ceff09a6 | Rust | rust-bio/rust-bio | /src/data_structures/interval_tree/avl_interval_tree.rs | UTF-8 | 22,129 | 3.703125 | 4 | [
"MIT"
] | permissive | //! Interval tree, a data structure for efficiently storing and searching intervals.
//!
//! This data structure uses an `Interval` type to define the intervals. It is implemented by
//! wrapping the `std::ops::Range` in a newtype. An interval must have a positive with and the interval bounds
//! may be specified by an... | true |
28488873e95e2d82b1836156c69c76e6affbc00c | Rust | umatbro/p-tutorials | /rust/rust-book/server_project/src/main.rs | UTF-8 | 1,641 | 2.828125 | 3 | [] | no_license | use server_project::ThreadPool;
use std::{
fs,
io::{prelude::*, BufReader},
net::{TcpListener, TcpStream},
process, thread,
time::Duration,
};
const CRLF: &str = "\r\n";
fn main() {
let listener = TcpListener::bind("0.0.0.0:7878").unwrap();
let pool = match ThreadPool::build(4) {
O... | true |
9d0f5e1f0165bdaf345d20a6f0e3ebdb591a41ca | Rust | bytecodealliance/wasmtime | /crates/environ/src/builtin.rs | UTF-8 | 6,375 | 2.5625 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | /// Helper macro to iterate over all builtin functions and their signatures.
#[macro_export]
macro_rules! foreach_builtin_function {
($mac:ident) => {
$mac! {
/// Returns an index for wasm's `memory.grow` builtin function.
memory32_grow(vmctx: vmctx, delta: i64, index: i32) -> pointe... | true |
948da2226599df3e9114e6d9d27a7a97d4e18041 | Rust | erikbergsten/faulty | /registry/src/main.rs | UTF-8 | 1,211 | 2.859375 | 3 | [] | no_license | use std::result;
use std::error::Error;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};
mod net;
use net::{Message};
mod service;
public interface Service {
fn id(&self) -> u16;
fn handle_message(&mut self, message: &mut Message) -> bool;
}
HashMap<u16, Service>
//use std::sync::mpsc::{channel, Receiver, Sende... | true |
0ad952441ae7a40e24157e9063f5d5417ffe0817 | Rust | ncatelli/slab | /examples/basic.rs | UTF-8 | 342 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use slab::*;
const CHUNKS: usize = usize::BITS as usize;
fn main() {
let mut slab = SlabAllocator::<u32, CHUNKS>::new();
let boxed_values: Vec<_> = (0..(usize::BITS * 32) as u32)
.into_iter()
.map(|x| slab.boxed(x).unwrap())
.collect();
for x in boxed_values.iter() {
print... | true |
3723737911fea89e473c92e467e3ff8cfdebad58 | Rust | jonahwilliams/learn-rust | /iterating/src/main.rs | UTF-8 | 609 | 3.75 | 4 | [] | no_license | fn main() {
let mut range = 0..10;
loop {
match range.next() {
Some(x) => {
println!("{}", x);
},
None => { break }
}
}
let nums = vec![1, 2, 3];
for num in &nums {
println!("{}", num);
}
let one_to_one_hundred ... | true |
6834b1bbbb0762c3d0f8e86101bf7acd8b2fc796 | Rust | dwrensha/zillions | /impls/std-mpsc/server.rs | UTF-8 | 3,793 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | use std::net::{SocketAddr, TcpListener, TcpStream};
use std::sync::mpsc;
enum InternalMessage {
NewClient(SocketAddr, mpsc::SyncSender<Vec<u8>>),
ClientDisconnected(SocketAddr),
NewMessage(Vec<u8>),
}
struct DisconnectNotifier {
peer_addr: SocketAddr,
tx: mpsc::Sender<InternalMessage>,
}
impl Dro... | true |
7de5f00b3e4036e528f57f183140776bdc344590 | Rust | johnmcl001/TheRustProgrammingLanguage | /RustCookBook/3_compression/decompress_a_tarball/src/main.rs | UTF-8 | 528 | 2.609375 | 3 | [] | no_license | use std::fs::File;
use flate2::Compression;
use flate2::write::{GzDecoder, GzEncoder};
use tar::Archive;
fn main() -> Result<(), std::io::Error> {
let tar_gz = File::create("test.tar.gz")?;
let enc = GzEncoder::new(tar_gz, Compression::default());
let mut tar = tar::Builder::new(enc);
tar.append_dir_al... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.