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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9939da177aa64ae6c38e81042c981be3fd8410ff | Rust | nakakura/study | /frp/carboxyl/sec2/merge/src/main.rs | UTF-8 | 2,218 | 2.9375 | 3 | [] | no_license | extern crate console;
extern crate carboxyl;
use console::Term;
use std::io;
use std::io::prelude::*;
use std::net::TcpListener;
use std::thread;
fn clear(lines: usize) -> io::Result<()> {
let term = Term::stdout();
term.clear_last_lines(lines)?;
Ok(())
}
fn display(stream: carboxyl::Stream<String>) {
... | true |
54477d719740eb3160053e0fe0e52832b8576b2f | Rust | JohnGinger/aoc | /2017/rust/src/day12.rs | UTF-8 | 1,691 | 2.875 | 3 | [
"MIT"
] | permissive | use crate::aoc_util;
use std::collections::HashMap;
use std::collections::HashSet;
pub fn run() {
let mut groups = HashMap::new();
let mut location_counter: usize = 0;
for line in aoc_util::iterate_input_lines(12) {
groups.insert(location_counter, get_connected(&line));
location_counter += ... | true |
2cf94ceba9115ca48048124235809ffedea06297 | Rust | isgasho/heph | /src/actor_ref/rpc.rs | UTF-8 | 10,660 | 3.84375 | 4 | [
"MIT"
] | permissive | //! Types related the `ActorRef` Remote Procedure Call (RPC) mechanism.
//!
//! RPC is implemented by sending a [`RpcMessage`] to the actor, which contains
//! the request message and a [`RpcResponse`]. The `RpcResponse` allows the
//! receiving actor to send back a response to the sending actor.
//!
//! To support RPC... | true |
6aa7d727f3b04ffb726ba86a695ef955c5396bdd | Rust | Mubelotix/terrarust | /src/loader.rs | UTF-8 | 2,481 | 2.875 | 3 | [] | no_license | use crate::progress_bar::ProgressBar;
use futures::{
channel::{oneshot, oneshot::Receiver},
future::join_all,
join,
};
use std::time::Duration;
use wasm_bindgen::JsValue;
use wasm_game_lib::{
graphics::{canvas::*, color::*, font::*, image::*, text::*},
log,
system::sleep,
};
pub async fn load_i... | true |
3cb90fec90e5e4d02767b70938418a49feffa3a8 | Rust | marty777/adventofcode2019 | /src/day18.rs | UTF-8 | 12,279 | 2.734375 | 3 | [
"MIT"
] | permissive | // day 18
use std::collections::HashMap;
struct MazeNode {
obstacle: bool,
key_index: i64,
door_index: i64,
}
struct Key {
x: usize,
y: usize,
symbol: char,
}
struct Door {
_x: usize,
_y: usize,
symbol: char,
key_index: usize,
}
struct Maze {
grid: Vec<Vec<MazeNode>>,
keys: Vec<Key>,
doors: Vec<Door>,
... | true |
6698b1099745a08478c3894962178b194d748716 | Rust | Jake-Moss/cayley-table-gen | /src/main.rs | UTF-8 | 2,427 | 3.375 | 3 | [] | no_license | use std::io;
use std::io::Write;
fn main() {
let mut input = String::new();
print!("Modulo: ");
io::stdout().flush().unwrap();
io::stdin().read_line(&mut input).expect("error: unable to read user input");
let n = input.trim().parse::<u16>().unwrap();
println!("");
let mut input = Strin... | true |
9f4e29692972bcf298ee3ecaedf90942bc3d6d93 | Rust | silky/jagger | /src/collections/vecset.rs | UTF-8 | 15,913 | 3.78125 | 4 | [
"MIT"
] | permissive | /**
* A set implemented as a binary vector.
*/
use std::cmp::Ordering;
use std::iter::{FromIterator, IntoIterator, range_step};
use std::default::Default;
use std::slice;
use std::fmt;
use test::Bencher;
/**
* A set implemented using a sorted vector. Due to memory locality and
* caching, this set implementation w... | true |
4e0f0edf821efd1f7dc3835960c72fbd1cc70546 | Rust | silvia-odwyer/photon | /crate/src/iter.rs | UTF-8 | 2,323 | 3.828125 | 4 | [
"Apache-2.0"
] | permissive | pub struct ImageIterator {
width: u32,
height: u32,
item: u32,
}
impl ImageIterator {
pub fn new(width: u32, height: u32) -> Self {
Self {
width,
height,
item: 0_u32,
}
}
pub fn with_dimension(dimension: &(u32, u32)) -> Self {
Self {
... | true |
0715ec0002a78f0ead7e40d21f57fe421aae478a | Rust | shikharvashistha/wallet-e | /src/wallet_lib.rs | UTF-8 | 1,076 | 2.59375 | 3 | [
"MIT"
] | permissive | use secp256k1::{PublicKey, SecretKey};
use anyhow::{Result};
use secp256k1::rand::{rngs, SeedableRng};
use web3::Web3;
use web3::transports::Http;
use web3::types::{TransactionParameters, U256, H256, H160};
pub fn create_keypair() -> Result<(SecretKey, PublicKey)>{
let secp = secp256k1::Secp256k1::new();
let m... | true |
8636c0dbfb858033e47e3e8dc838b71a25bc9958 | Rust | kohbis/leetcode | /algorithms/1668.maximum-repeating-substring/solution.rs | UTF-8 | 244 | 2.5625 | 3 | [] | no_license | impl Solution {
pub fn max_repeating(sequence: String, word: String) -> i32 {
let mut k = &sequence.len() / &word.len();
while sequence.find(&word.repeat(k)).is_none() {
k -= 1;
}
k as _
}
}
| true |
18af8c1cffe43b6c8800315e73fa3c91b676d23d | Rust | pkafma-aon/LeetCode-Rust | /src/two_sum_ii_input_array_is_sorted.rs | UTF-8 | 658 | 3.375 | 3 | [
"WTFPL"
] | permissive | impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let (mut left, mut right) = (0, nums.len() - 1);
while left < right {
let sum = nums[left] + nums[right];
if sum == target {
return vec![left as i32 + 1, right as i32 + 1];
}... | true |
39388f94e8d56f409c0dfaa27e665c096e02706a | Rust | forkkit/kas | /crates/kas-widgets/src/view/filter_list.rs | UTF-8 | 14,543 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! Filter-list view widget
use super::{driver, Driver, Li... | true |
0ce29f99826d58d64e494ce565be1fc841faf90a | Rust | iqlusioninc/yubihsm.rs | /src/object/label.rs | UTF-8 | 2,779 | 3.28125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Object labels: descriptions of objects
use super::{Error, ErrorKind};
use std::{
fmt::{self, Debug, Display},
ops::{Deref, DerefMut},
str::{self, FromStr},
};
/// Number of bytes in a label on an object (fixed-size)
pub const LABEL_SIZE: usize = 40;
/// Placeholder text in event labels contain invali... | true |
b1aca1853b0f814580b788ddb3904ad2b9fa8a00 | Rust | saskenuba/SteamHelper-rs | /crates/steam-client/src/connection/mod.rs | UTF-8 | 11,141 | 2.78125 | 3 | [
"MIT"
] | permissive | //! This module handles connections to Content Manager Server
//! First you connect into the ip using a tcp socket
//! Then reads/writes into it
//!
//! Packets are sent at the following format: packet_len + packet_magic + data
//! packet length: u32
//! packet magic: VT01
//!
//! Apparently, bytes received are in litt... | true |
11146115e3e7a5ee79c7623d118492a3b26ad6f7 | Rust | mzr/slow | /src/main.rs | UTF-8 | 1,159 | 2.65625 | 3 | [] | no_license | use std::io;
use argparse::{ArgumentParser, Store};
fn main() {
let mut ns_delay = 0;
let mut s_delay = 0;
{
let mut parser = ArgumentParser::new();
parser.refer(&mut ns_delay)
.add_option(&["-n", "--nanoseconds"], Store,
"Delay between printed lines in nanosec... | true |
c70c1f84d48094e813ca9f7b407c87ee58e0e58e | Rust | image-rs/canvas | /texel/src/texel.rs | UTF-8 | 20,251 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | // Distributed under The MIT License (MIT)
//
// Copyright (c) 2019, 2020 The `image-rs` developers
#![allow(unsafe_code)]
use core::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use core::marker::PhantomData;
use core::{fmt, hash, mem, num, ptr, slice};
use crate::buf::buf;
/// Marker struct to denote a texel ty... | true |
63318945cd7f539d31d4cbebfc7e39950a4914bd | Rust | srijs/rust-cfn | /src/aws/ec2.rs | UTF-8 | 1,003,706 | 2.5625 | 3 | [
"MIT"
] | permissive | //! Types for the `EC2` service.
/// The [`AWS::EC2::CapacityReservation`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-capacityreservation.html) resource type.
#[derive(Debug, Default)]
pub struct CapacityReservation {
properties: CapacityReservationProperties
}
/// Properties f... | true |
d6fd3ff9ff41b9a27fd2b6bb2ccd57a240bb4dc4 | Rust | Fusselwurm/arma3-reflection | /extension/src/args_parser.rs | UTF-8 | 2,182 | 3.53125 | 4 | [] | no_license | use core::option::Option::Some;
use std::collections::HashMap;
pub struct ArgsParser {
args: Vec<String>,
}
impl ArgsParser {
pub fn new(args: Vec<String>) -> ArgsParser {
ArgsParser { args: ArgsParser::split_at_newline(args.clone()) }
}
/*
for some reason, on Windows at least, A3S pa... | true |
59cede11466df7735f824a90f325df82b80ebcea | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/generics/generic-unique.rs | UTF-8 | 278 | 3.140625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![allow(dead_code)]
#![feature(box_syntax)]
struct Triple<T> { x: T, y: T, z: T }
fn box_it<T>(x: Triple<T>) -> Box<Triple<T>> { return box x; }
pub fn main() {
let x: Box<Triple<isize>> = box_it::<isize>(Triple{x: 1, y: 2, z: 3});
assert_eq!(x.y, 2);
}
| true |
91feaa790349ca68dc2dbb62e1d66dac20f77941 | Rust | playXE/pgc | /src/lib.rs | UTF-8 | 37,279 | 2.71875 | 3 | [
"MIT"
] | permissive | //! Simple mark&sweep garbage collector that can work in multiple threads (multithreaded collection support is still W.I.P).
//!
//! Internally this GC implementation uses mimalloc as fast memory allocator.
//! Marking is done in sync or in parallel.
//! Parallel marking is usually slower,but the idea is that the longe... | true |
42204010f3dcbd08ee60676bb6b272a9848b5140 | Rust | arshiahf/user_input | /src/requests/mod.rs | UTF-8 | 3,680 | 3.328125 | 3 | [] | no_license | // Collection of functions that allow the programmer to request user input
use interpret::{parse_string_to_vec};
use std::str::FromStr;
use std::io::{stdin, stdout};
use std::io::{BufWriter, Write};
use std::string::String;
use std::process::{exit};
use std::fs::{File, DirBuilder};
// Places a desired message into th... | true |
b9f0816170586e914f274bfbc4272bb93179e220 | Rust | Bhu1-V/mini-grep | /src/lib.rs | UTF-8 | 5,103 | 3.65625 | 4 | [] | no_license | use std::fs;
use std::error::Error;
use std::env;
pub struct Config {
expression : String,
file_name : String,
env_var: u8,
}
impl Config {
pub fn new(mut args: env::Args) -> Result<Config, &'static str>{
if args.len() < 3 {
return Err("Not Enough Arguments. ");
}
a... | true |
cb49e1fe81f1ad79b95c586fbc392d67b5073166 | Rust | cheunghoward/sqlite-gui | /src/cext.rs | UTF-8 | 1,234 | 3.03125 | 3 | [] | no_license | /// Helpers for converting data representations Rust <---> C
extern crate libc;
use cext::libc::{c_char, c_int};
use std::ffi::{CString, c_str_to_bytes};
use std::mem;
use std::raw::Slice;
use std::str;
/// C Constants
pub static TRUE : c_int = 1;
pub static FALSE : c_int = 0;
/// Converts a rust string to a c stri... | true |
a95863894c28ec9ae9f0e38088e80b9b9a219643 | Rust | jfoucher/rust-6502 | /src/computer.rs | UTF-8 | 66,820 | 2.875 | 3 | [] | no_license | use std::sync::mpsc;
use std::time;
use std::thread;
mod decode;
#[derive(Clone, Debug)]
pub struct Info {
pub msg: String,
pub qty: u64,
}
const LOG_LEVEL:i16 = 0;
const OUTPUT_BTM:u16 = 0xf000;
const OUTPUT_TOP:u16 = 0xf100;
#[derive(Eq, Hash, PartialEq, Clone, Copy, Debug)]
pub enum ADRESSING_MODE {
... | true |
df139797078e7e6f8aba1d389834ef0e76f9245d | Rust | kissmikijr/caolo-backend | /sim/simulation/src/tables/page_table/pt_iter.rs | UTF-8 | 619 | 3.234375 | 3 | [
"MIT"
] | permissive | pub struct PTIter<It: Iterator> {
inner: It,
i: usize,
cap: usize,
}
impl<It: Iterator> PTIter<It> {
pub fn new(inner: It, cap: usize) -> Self {
Self { inner, cap, i: 0 }
}
}
impl<It: Iterator> Iterator for PTIter<It> {
type Item = It::Item;
fn size_hint(&self) -> (usize, Option<u... | true |
82bfc6668b8a16a69e7040f670aaebdecc71a719 | Rust | Syntaf/bignum | /src/error.rs | UTF-8 | 808 | 3.703125 | 4 | [] | no_license | use std::fmt::{Debug, Formatter};
use std::fmt::Error as fmt_Error;
/// Enum type to specify *what* error happened, is used as a
/// member type in `Error`
#[derive(Debug)]
pub enum ErrorType {
Empty,
NonNumeric,
UnsignedOverflow
}
/// The Struct returned in `Result` when an Error is encountered,
/// lik... | true |
098167b3854a0ebf8368fc3d5ddd258a3c4204d2 | Rust | ishankhare07/exploring-rust | /syntax and semantics/function_pointer/src/main.rs | UTF-8 | 103 | 2.828125 | 3 | [] | no_license | fn foo(x: i32) -> i32 { x }
fn main() {
let x: fn(i32) -> i32 = foo;
println!("{}", x(10));
}
| true |
67daf344b683d433a1f716cbd602b8d84d87f0fa | Rust | venkatarun95/rust_transform_struct | /tests/test.rs | UTF-8 | 1,797 | 3.28125 | 3 | [
"MIT"
] | permissive | use transform_struct::transform_struct;
fn round_float(f: f64) -> u64 {
f.round() as u64
}
fn round_float_pair(f: (f64, f64)) -> (u64, u64) {
(f.0 as u64, f.1 as u64)
}
transform_struct!(
/// Foo
#[derive(Clone,PartialEq)]
/// Bar
pub struct TestStruct1
/// Bar2
pub struct TestNewStru... | true |
5ace0e6fbe92843fd490da93bdd5280b3080c2c4 | Rust | chamoctopi/rust-bitbankcc | /src/model/response/transactions_data.rs | UTF-8 | 1,500 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::model::response::Response;
use crate::model::{Transactions, TransactionsValue};
use crate::{BitbankError, Error, OrderSide};
use serde::Deserialize;
use std::convert::TryFrom;
use std::str::FromStr;
#[derive(Deserialize)]
pub struct TransactionsData {
transactions: Vec<TransactionsInnerData>,
}
#[deriv... | true |
237ef53dc71db2de81eaed4f6c6d71763f6556d0 | Rust | stavenko/gerber-ruster | /src/plotter/path.rs | UTF-8 | 3,019 | 3.296875 | 3 | [] | no_license | extern crate nalgebra as na;
use super::StrokePathElement;
use super::intersector::{ IntersectorEnum, Ray };
use std::cmp::Ordering;
use na::Vector2;
use std::f32::EPSILON;
type Vec2 = Vector2<f32>;
#[derive(Clone, Debug, PartialEq)]
pub enum PathType {
Rect(f32, f32),
Circle(f32),
Stroke
}
#[derive(Debug)]
pu... | true |
ca790135f9d8caaf8625eb84ba691f07a7f2adb0 | Rust | KillingSpark/rustbus | /rustbus/src/wire/unmarshal/traits.rs | UTF-8 | 18,073 | 3.421875 | 3 | [
"MIT"
] | permissive | //! Provides the Unmarshal trait and the implementations for the base types
use crate::wire::marshal::traits::Signature;
use crate::wire::unmarshal;
use crate::wire::unmarshal::UnmarshalContext;
// these contain the implementations
mod base;
mod container;
pub use base::*;
pub use container::*;
/// This trait has to... | true |
966ed86ff3ae4eda9b669f99c6d08a6ee03875a6 | Rust | andyspicer/cartunes | /src/setup.rs | UTF-8 | 38,128 | 3.640625 | 4 | [
"MIT"
] | permissive | //! Parsers and internal representations for iRacing setup exports.
use crate::config::Config;
use crate::gui::ShowWarning;
use crate::str_ext::Capitalize;
use kuchiki::traits::TendrilSink;
use ordered_multimap::ListOrderedMultimap;
use std::collections::{HashMap, VecDeque};
use std::fs;
use std::path::{Path, PathBuf}... | true |
3ecb9cebba6bb9b5ef7fbbef9b59bc70279da218 | Rust | DataDog/glommio | /glommio/src/io/dma_file_stream.rs | UTF-8 | 72,043 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Unless explicitly stated otherwise all files in this repository are licensed
// under the MIT/Apache-2.0 License, at your convenience
//
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2020 Datadog, Inc.
//
use crate::{
io::{dma_file::align_down, read_result::ReadRe... | true |
ceac362ead7f72664b39cebf10e03f7cbcef8ec5 | Rust | erikjohnston/rust-almonds | /src/verifier.rs | UTF-8 | 6,809 | 3.6875 | 4 | [
"MIT"
] | permissive | use Almond;
struct DeconstructedCaveatEntry<'a> {
pub key: &'a [u8],
pub value: Option<&'a [u8]>,
pub accepted: Option<bool>,
}
/// The verifier takes an almond and checks if it satisfies a list of
/// predicates.
///
/// An almond will be accepted if:
///
/// - All caveats match and pass at least one p... | true |
3259a69719dfa6807a24e15f37d0955bcf3f6c6d | Rust | klaatu01/maze-rs | /src/alg/sidewinder.rs | UTF-8 | 1,158 | 2.640625 | 3 | [] | no_license | use super::super::Chunk;
use super::super::Grid;
use super::bta::Rand;
use std::time::{SystemTime, UNIX_EPOCH};
pub fn sidewinder(grid: &Grid<Chunk>) -> () {
let mut rng = Rand::new(0);
match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(t) => rng = Rand::new(t.as_millis() as u32),
_ => (),... | true |
46a82e5e75a8c98cd588244f4e1edbe3ed306b38 | Rust | tearitco/FactorishWasm | /src/structure.rs | UTF-8 | 12,419 | 2.625 | 3 | [
"MIT"
] | permissive | mod iter;
use super::{
drop_items::DropItem,
dyn_iter::{DynIter, DynIterMut},
items::ItemType,
underground_belt::UnderDirection,
water_well::FluidBox,
FactorishState, Inventory, InventoryTrait, Recipe,
};
use rotate_enum::RotateEnum;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
us... | true |
5002ac63042a3d8a60b298db05c295becabf6e18 | Rust | biaoma-ty/arrow-datafusion | /datafusion-examples/examples/deserialize_to_struct.rs | UTF-8 | 2,602 | 2.734375 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
a1028b58713d53b7ef8a74242dd2ecd6873efb32 | Rust | yonkeltron/tapper | /src/main.rs | UTF-8 | 4,364 | 2.8125 | 3 | [] | no_license | use clap::{App, Arg, SubCommand};
use testanything::tap_writer::TapWriter;
fn main() {
let matches = App::new("tapper")
.about(env!("CARGO_PKG_DESCRIPTION"))
.author(env!("CARGO_PKG_AUTHORS"))
.version(env!("CARGO_PKG_VERSION"))
.subcommand(
SubCommand::with_name("plan")... | true |
7912d8acc50d6034cbcf5faa8abe94fee83b5836 | Rust | asvedr/oolang | /src/syn/_mod.rs | UTF-8 | 8,368 | 2.671875 | 3 | [] | no_license | //use syn_expr::*;
//use syn_act::*;
use syn::utils::*;
//use type_sys::*;
use syn::reserr::*;
use syn::_fn::*;
use syn::class::*;
use syn::ext_c::*;
use syn::compile_flags::*;
use syn::except::*;
use std::fmt;
pub struct Import {
pub path : Vec<String>,
pub alias : Option<String>
/* if None then 'use m... | true |
fa2716b64ecb7dc03f4e7a7093385451e36c3a90 | Rust | andywarduk/aoc2016 | /day24/src/map.rs | UTF-8 | 2,894 | 3.359375 | 3 | [] | no_license | use std::collections::{BTreeMap, HashMap};
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct Coord {
x: usize,
y: usize
}
impl Coord {
pub fn new(x: usize, y: usize) -> Coord {
Coord {x, y }
}
pub fn new_relative(&self, xadd: isize, yadd: isize) -> Coord {
Coord {
... | true |
346e489eb3ae441ae0bb8dee44e8ed2f225336a3 | Rust | kobigurk/plumo-prover | /src/types.rs | UTF-8 | 2,308 | 2.53125 | 3 | [] | no_license | use algebra_core::CanonicalDeserialize;
use bls_crypto::{PublicKey as BlsPubkey, Signature};
use ethers_core::{
types::*,
utils::rlp::{self, Decodable, DecoderError, Rlp},
};
pub const VANITY: usize = 32;
#[derive(Clone, Debug)]
pub struct AggregatedSeal {
pub bitmap: Vec<bool>,
pub round: u64,
pu... | true |
f4d4f749acba7ed5b429781ab913baefde8384fd | Rust | manpat/web-common-rs | /src/rendering/types.rs | UTF-8 | 931 | 3.078125 | 3 | [] | no_license | #![allow(dead_code)]
use math::*;
#[derive(Copy, Clone, Debug)]
pub struct Viewport {
pub size: Vec2i,
}
impl Viewport {
pub fn new() -> Viewport {
Viewport{ size: Vec2i::zero() }
}
pub fn get_aspect(&self) -> f32 {
let (sw, sh) = self.size.to_tuple();
sw as f32 / sh as f32
}
pub fn client_to_gl_coords... | true |
57d7146fca12986146543de7a8d8f5b0ba320cff | Rust | eirproject/eir | /libeir_syntax_erl/src/parser/ast/mod.rs | UTF-8 | 3,042 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | mod attributes;
mod expr;
mod functions;
mod module;
mod types;
use libeir_diagnostics::{SourceIndex, SourceSpan};
pub use self::attributes::*;
pub use self::expr::*;
pub use self::functions::*;
pub use self::module::*;
pub use self::types::*;
pub use super::{ParseError, ParserError};
pub use crate::lexer::{Ident, Sy... | true |
d9556668fa37f945f1693d366eb30292dc410df2 | Rust | niuez/cp-rust-library | /src/tovec.rs | UTF-8 | 261 | 2.984375 | 3 | [] | no_license | pub trait ToVec {
type Item;
fn tovec(self) -> Vec<Self::Item>;
}
impl<I: std::iter::Iterator> ToVec for I {
type Item = <Self as std::iter::Iterator>::Item;
fn tovec(self) -> Vec<Self::Item> {
self.collect::<Vec<Self::Item>>()
}
}
| true |
459c84a591f051dea8f221dae3597e26390e5c2d | Rust | dragonrider7225/advent_of_code_rust | /aoc_2022/src/day_12/mod.rs | UTF-8 | 7,323 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::{
cmp::Reverse,
collections::HashSet,
fs::File,
io::{self, BufRead, BufReader},
ops::Index,
};
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
struct Pos {
x: usize,
y: usize,
}
impl Pos {
fn neighbors(&self) -> impl Iterator<Item = Self> + '_ {
(0..4).filter_map(|i... | true |
8ac4445ad6641d6d98e6f10cf0a94775f919e9e8 | Rust | mstarzinger/monster | /src/path_exploration/control_flow_graph.rs | UTF-8 | 7,568 | 3.296875 | 3 | [
"MIT"
] | permissive | //! # Handle control flow graphs
//!
//! This module defines and handles control flow graphs.
//!
//! There are three different kind of edges:
//! - trivial edges (`pc = pc + 4;`)
//! - any non control flow instruction
//! - `beq`: false edge
//! - pure edges
//! - `beq`: true edge
//! - `jal`: when link not us... | true |
c80ab208375bb163db2d76bd1b91a06bbd08e5dd | Rust | dtantsur/rust-osauth | /src/loading/env.rs | UTF-8 | 5,284 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018-2020 Dmitry Tantsur <dtantsur@protonmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required ... | true |
c8e47c5aa5f085685fab69e770b7e8bc11a7bd3f | Rust | po-gl/Raytracer | /src/pattern/checker_pattern.rs | UTF-8 | 2,725 | 3.703125 | 4 | [
"MIT"
] | permissive | /// # Checker Patterns
/// `checker_pattern` is a module to represent a checker board pattern
use crate::color::Color;
use crate::tuple::Tuple;
use crate::float::Float;
use crate::matrix::Matrix4;
use crate::pattern::Pattern;
use std::fmt::{Formatter, Error};
use std::any::Any;
#[derive(Debug, PartialEq, Copy, Clone)... | true |
296dc7b7a233cb8b4cf263c4d80122475751bf22 | Rust | meugur/algorithms | /src/interval_scheduling.rs | UTF-8 | 1,563 | 3.65625 | 4 | [] | no_license | //!
//! Given the start and finish times of n times,
//! determines the maximum number of intervals that can be scheduled
//!
fn interval_scheduling(intervals: &mut Vec<(usize, usize)>) -> usize {
if intervals.is_empty() {
return 0
}
if intervals.len() == 1 {
return 1
}
intervals.s... | true |
55f2001b2844daccbad1edcf03d2adc48919c0ba | Rust | jamesgraves/auto-clippy | /src/repos.rs | UTF-8 | 4,294 | 2.765625 | 3 | [
"MIT"
] | permissive | use super::database;
use anyhow::{Result, anyhow};
use std::string::String;
use git2::Repository;
static USER_ADDED_REFCOUNT: isize = 1000000;
static REPOS_DIR: &str = "repos";
/*
static COMMON_HOSTING_SITES: [&str; 6] = [
"beanstalkapp.com",
"bitbucket.org",
"github.com",
"gitlab.com",
"launchpad... | true |
c46d88d9b3bd944a8063e0bef4f7fafe34472420 | Rust | shiki-tak/ddd-at-rust | /chapter03_entity/src/s2.rs | UTF-8 | 1,265 | 3.53125 | 4 | [] | no_license | #![allow(dead_code)]
use derive_getters::Getters;
use anyhow::Result;
use common::MyError;
#[derive(Clone, Debug, Getters)]
pub struct User {
name: Name,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Name(String);
impl User {
pub fn new(name: Name) -> Self {
Self { name }
}
pub fn ch... | true |
d020e81ce3cc979ead7190940689d041e7c6bcea | Rust | magneticleaves/Gestalt | /gestalt/src/client/tileart.rs | UTF-8 | 566 | 3.328125 | 3 | [] | no_license | use ustr::*;
pub trait TileArt {
/// Which render pass should handle this tile?
fn get_render_type(&self) -> u32; /*In the files specifying renderers for individual TileArts, this will be
a string which we'll then run through a hashmap to get this u32.*/
}
#[derive(Clone, Debug)]
pub struct TileArtSimple... | true |
6ff75938b015ffd2dedcd39296b68f28c4d262b4 | Rust | LPGhatguy/all-term | /src/backend/ansi/ansi_terminal.rs | UTF-8 | 3,758 | 2.96875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::{
io::{self, Write},
sync::mpsc,
collections::VecDeque,
};
use crate::{
os::current::{enable_raw_mode, disable_raw_mode, get_terminal_size},
key::Key,
style::Style,
terminal_backend::TerminalBackend,
};
use super::input::{start_input_thread, read_key};
pub struct AnsiTerminal {
... | true |
4153d10fdcaf4742f7843848e75d545488f23a51 | Rust | davidszotten/advent-of-code-2019 | /src/bin/day01.rs | UTF-8 | 1,218 | 3.1875 | 3 | [] | no_license | use aoc2019::{dispatch, Result};
fn main() -> Result<()> {
dispatch(&part1, &part2)
}
fn part1(input: &str) -> Result<i32> {
Ok(input
.split('\n')
.filter_map(|x| x.parse::<i32>().ok())
.map(|x| x / 3 - 2)
.sum())
}
fn recurse_fuel(mass: i32) -> i32 {
let mut sum = 0;
... | true |
4d1a9572015dd9effebf372dccfa67428d021a81 | Rust | hsabouri/42_npuzzle | /src/parser.rs | UTF-8 | 3,545 | 2.96875 | 3 | [] | no_license | use super::Point;
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
fn file_to_str_array(filename: &str) -> Result <Vec<Vec<String>>, String> {
let file = match File::open(filename) {
Ok(n) => n,
Err(e) => return Err(format!("Could not open file '{}':\n{}", filename, e)),
};
... | true |
2c898e7e8109ca61268d440839702d4ff8552a3c | Rust | mosuka/tantivy | /columnar/src/column_values/u64_based/bitpacked.rs | UTF-8 | 3,619 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::io::{self, Write};
use common::{BinarySerializable, OwnedBytes};
use fastdivide::DividerU64;
use tantivy_bitpacker::{compute_num_bits, BitPacker, BitUnpacker};
use crate::column_values::u64_based::{ColumnCodec, ColumnCodecEstimator, ColumnStats};
use crate::{ColumnValues, RowId};
/// Depending on the field ... | true |
c7849a73e756944c9039531e47d9a79d15d9a851 | Rust | Thumbnailer/thumbnailer_cli | /src/commands/resize.rs | UTF-8 | 2,013 | 3.5 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | use thumbnailer::{GenericThumbnail, Resize};
use crate::commands::Command;
/// Representation of the resize-command as a struct
pub struct CmdResize {
/// Contains the `index` as u32 of arguments list
index: u32,
/// Contains the `Resize` enum as option
size: Resize,
}
impl CmdResize {
/// Return... | true |
716227c910ba9ae3f316347be6f9d378c5f84204 | Rust | AliasT/craftinginterpreters | /src/lang/token.rs | UTF-8 | 3,406 | 3.09375 | 3 | [] | no_license | use super::ast::Statement;
use std::{
fmt::{Debug, Display},
rc::Rc,
};
use phf::phf_map;
#[allow(non_camel_case_types)]
#[allow(unused)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum TokenType {
// Single-character tokens.
LEFT_PAREN,
RIGHT_PAREN,
LEFT_BRACE,
RIGHT_BRACE,
COMMA,
... | true |
5ad0a3b59c62e13ce54b5fc8ba9b217ae26ef9a4 | Rust | stewart/advent-2017 | /day11/src/main.rs | UTF-8 | 1,421 | 3.65625 | 4 | [] | no_license | use std::ops::Add;
#[derive(Debug)]
struct Point(isize, isize);
impl Point {
fn distance(&self) -> isize {
(self.0.abs() + self.1.abs() + (self.0 + self.1).abs()) / 2
}
}
impl Add for Point {
type Output = Self;
fn add(self, other: Point) -> Point {
Point(self.0 + other.0, self.1 + o... | true |
1e217f465d8716e6ffebc590c5bd94905d57617f | Rust | zk-ml/ZEN | /zk-ml-private-model/src/relu_circuit.rs | UTF-8 | 1,813 | 2.546875 | 3 | [] | no_license | use crate::*;
use algebra::ed_on_bls12_381::*;
use r1cs_core::*;
use r1cs_std::alloc::AllocVar;
use r1cs_std::boolean::Boolean;
use r1cs_std::ed_on_bls12_381::FqVar;
use r1cs_std::eq::EqGadget;
// statement:
// if y_in[i] < 0, y_out[i] = 0;
// else y_out[i] = y_in[i]
#[derive(Debug, Clone)]
pub(crate) struct ReLUCir... | true |
bbce0f46b41bbde2e56df69ee64d4dca99a0e71d | Rust | lnicola/serde_fix | /serde_fix/tests/test_deserialize.rs | UTF-8 | 2,002 | 3.15625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::Deserialize;
#[derive(Deserialize, Debug, PartialEq)]
struct NewType<T>(T);
#[test]
fn deserialize_newtype_i32() {
let result = vec![("field".to_owned(), NewType(11))];
assert_eq!(serde_fix::from_str("field=11\u{1}"), Ok(result));
}
#[test]
fn deserialize_bytes() {
let result = vec![("first".... | true |
0705ca66ca8380293c1132296778ca0d0dc84f16 | Rust | hansihe/beam_code | /src/graph/dominance.rs | UTF-8 | 2,739 | 2.53125 | 3 | [] | no_license | use ::itertools::Itertools;
use ::std::collections::{ HashMap, HashSet };
use ::std::hash::Hash;
use super::{ GraphDfs, GraphPredecessors };
pub fn immediate_dominators<NodeId>(start: NodeId,
index_to_node_id: &GraphDfs<NodeId>,
predecessors: &Gr... | true |
2c51556f246da53ecc4e8db9d1780f103c9e0b59 | Rust | threnody96/rgengine | /src/node/label/one_line_label_option.rs | UTF-8 | 1,827 | 2.734375 | 3 | [] | no_license | use ::node::label::{ LabelOption };
use ::util::{ NoOption };
use ::util::parameter::{ FontStyle, Color };
#[derive(Clone)]
pub struct OneLineLabelOption {
pub path: String,
pub point: u16,
pub color: Color,
pub style: FontStyle,
}
impl Default for OneLineLabelOption {
fn default() -> Self {
... | true |
90aaeea9139baf0d6c760fae4bbf93250ff39fdb | Rust | tearne/library | /rust/10_cli_pass/src/main.rs | UTF-8 | 1,557 | 2.796875 | 3 | [] | no_license | // https://stackoverflow.com/questions/34611742/how-do-i-read-the-output-of-a-child-process-without-blocking-in-rust
// [dependencies]
// futures = "0.3.15"
// tokio = { version = "1", features = ["full"] }
use futures::stream::StreamExt; // <-- claimed to be unused
use futures::prelude::*;
use std::process::Stdio;
... | true |
8b3ba02477dfbaada70c87006d5f1dfd8daafe07 | Rust | javiteri95/hackerRank | /BigSum/bigSum.rs | UTF-8 | 256 | 3.796875 | 4 | [] | no_license |
fn a_very_big_sum(ar: &[i32]) -> i32{
let mut sum = 0;
for element in ar.iter() {
sum += element;
}
sum
}
fn main() {
let array = [1,2,34];
let sum = a_very_big_sum(&array);
println!("The value of sum is: {}", sum);
} | true |
d206fc599d3f1505871c289dfc72e165096cd715 | Rust | channgo2203/rosrust | /rosrust/src/tcpros/subscriber.rs | UTF-8 | 15,411 | 2.609375 | 3 | [
"MIT"
] | permissive | use super::error::{ErrorKind, Result, ResultExt};
use super::header::{decode, encode, match_field};
use super::{Message, Topic};
use crate::rosmsg::RosMsg;
use crate::util::lossy_channel::{lossy_channel, LossyReceiver, LossySender};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use crossbeam::channel::{bo... | true |
c715387cefb72073e11f4e943702007e9cd3093f | Rust | 22116/paralel-clasifier | /src/math/mod.rs | UTF-8 | 818 | 2.765625 | 3 | [] | no_license | use crate::{Data, Auto, Coefficient};
use std::cmp;
pub mod weights;
/// Normalize Auto dataset
pub fn norm(data: &Data) -> Vec<(Auto, Coefficient)> {
let mut data = data.to_vec();
let max = max(&data);
for (a, _c) in data.iter_mut() {
(*a).cargo /= max.0 as f32;
(*a).seats /= max.1 as f3... | true |
a4ab373b11041f6be0004c5ca9f37d9e827f0849 | Rust | jonhoo/loom | /tests/atomic.rs | UTF-8 | 1,150 | 2.625 | 3 | [
"MIT"
] | permissive | #![deny(warnings, rust_2018_idioms)]
use loom::sync::atomic::AtomicUsize;
use loom::thread;
use std::sync::atomic::Ordering::{AcqRel, Acquire, Relaxed, Release};
use std::sync::Arc;
#[test]
#[should_panic]
fn invalid_unsync_load_relaxed() {
loom::model(|| {
let a = Arc::new(AtomicUsize::new(0));
... | true |
8be3fe94a45c91f00440812eba98b03b57d5f8f9 | Rust | jmpargana/exercism | /rust/binary-search/src/lib.rs | UTF-8 | 559 | 3.265625 | 3 | [] | no_license | use std::cmp::Ordering;
pub fn find(array: &[i32], key: i32) -> Option<usize> {
let (mut start, mut end) = (0, array.len());
while start <= end {
let middle = (end + start) / 2;
if array.len() <= middle { return None }
match key.cmp(array.get(middle)?) {
Ordering::Equal =... | true |
5ea49e128403a52b8169016940d39fbcd16ef498 | Rust | eeeeeta/f24-telemetry-server | /src/pool.rs | UTF-8 | 1,570 | 2.890625 | 3 | [] | no_license | //! Managing the database pool.
//!
//! Code here abridged from https://rocket.rs/guide/state/#databases.
use r2d2_diesel::ConnectionManager;
use r2d2;
use rocket::Rocket;
use std::ops::Deref;
use rocket::http::Status;
use diesel::pg::PgConnection;
use rocket::request::{self, FromRequest};
use rocket::{Request, State,... | true |
b38e80c870481bed1c7d2dd3716fadcd90761550 | Rust | JRAndreassen/graph-rs | /examples/error_handling.rs | UTF-8 | 2,126 | 3.28125 | 3 | [
"MIT"
] | permissive | use graph_error::GraphFailure;
use graph_rs::prelude::*;
/*
This example shows how you can handle errors returned from Microsoft Graph.
The GraphError struct represents a Microsoft Graph Error that resembles the type of errors
described in the docs: https://docs.microsoft.com/en-us/graph/errors
When an error is retu... | true |
d72478cfedd2df652f73df76d942c882abea6d78 | Rust | jacokoo/fff-rs | /src/ui/layout/sized.rs | UTF-8 | 2,110 | 2.9375 | 3 | [] | no_license | use crate::ui::base::draw::{Draw, Drawable};
use crate::ui::base::shape::{Point, Size};
use crate::ui::Mrc;
use std::cmp;
pub struct SizedBox {
inner: Size,
drawable: Drawable,
have_width: bool,
have_height: bool,
}
impl SizedBox {
pub fn new(child: Mrc<dyn Draw>) -> Self {
SizedBox {
... | true |
f8db50a237251e8dd4747cf8dcbeb70adb1353c3 | Rust | wiltonlazary/nebulet | /src/abi/ipc.rs | UTF-8 | 913 | 2.59375 | 3 | [
"MIT"
] | permissive | use object::{ProcessRef, MonoCopyRef, HandleRights};
use nil::Ref;
use nabi::{Result, Error};
use nebulet_derive::nebulet_abi;
/// Creates a mono copy ipc handle.
/// Another process can write to this buffer,
/// assuming they have the handle.
#[nebulet_abi]
pub fn ipc_monocopy_create(buffer_offset: u32, buffer_size: ... | true |
07828af8a83fe56ecb18871ddacc735e8682c634 | Rust | JulianSchmid/etherparse | /etherparse/src/transport/icmpv6_header.rs | UTF-8 | 19,727 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{err::ValueTooBigError, *};
use arrayvec::ArrayVec;
/// The statically sized data at the start of an ICMPv6 packet (at least the first 8 bytes of an ICMPv6 packet).
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Icmpv6Header {
/// Type & type specific values & code.
pub icmp_type: Icmpv6Type,
... | true |
809e2128896d26246b119b712cea54408fbed881 | Rust | sphela/docstorage | /src/configure.rs | UTF-8 | 1,659 | 2.96875 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
#[derive(Serialize, Deserialize, Debug)]
struct RawConfig {
server: Option<RawServerConfig>,
}
#[derive(Serialize, Deserialize, Debug)]
struct RawServerConfig {
port: Option<u16>,
ipv_4_addr: Option<String>,
doc_root: Option<String>,
}
pub struct Config {
... | true |
d09ddf4c7f169984db9eab0f30efa4dbb877b1d4 | Rust | anon-real/sigma-rust | /ergotree-ir/src/types/stuple.rs | UTF-8 | 2,793 | 3 | 3 | [
"CC0-1.0"
] | permissive | use std::collections::HashMap;
use std::convert::TryFrom;
use std::convert::TryInto;
use std::slice::Iter;
use crate::mir::select_field::TupleFieldIndex;
use super::stype::SType;
use super::stype_param::STypeVar;
/// Tuple items with bounds check (2..=255)
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct TupleItems... | true |
8a877605d23025d733e4a456928ff37606bc3029 | Rust | ThinkChaos/freader | /src/reader/mod.rs | UTF-8 | 2,098 | 2.546875 | 3 | [] | no_license | use actix_web::{dev::HttpServiceFactory, web, HttpResponse};
use std::convert::TryFrom;
use crate::prelude::*;
use stream::{ItemId, StreamId};
mod stream;
mod subscription;
mod user_info;
mod utils;
pub fn service() -> impl HttpServiceFactory {
web::scope("/reader/api/0")
.wrap(utils::RequireAuth)
... | true |
a80f1159a02bb7eba01b6ba47c1e9e9ea92f6027 | Rust | darksv/AdventOfCode2017 | /22/src/main.rs | UTF-8 | 3,351 | 3.421875 | 3 | [] | no_license | fn main() {
println!("1: {}", do_first());
println!("2: {}", do_second());
}
fn do_first() -> usize {
let mut infected: std::collections::HashSet<(isize, isize)> = read_infected().into_iter().collect();
let mut cleaned = std::collections::HashSet::new();
let mut infections = 0;
let mut x = 0;
... | true |
2df4b2035c4491f6abb10693a11576cf19bfca09 | Rust | vinberm/substrate_lesson | /lesson_four/task_1/src/main.rs | UTF-8 | 627 | 3.28125 | 3 | [] | no_license | fn main() {
let red_light = TrafficLight::Red;
println!("red light is: {}", red_light.time());
let green_light = TrafficLight::Green;
println!("green light is: {}", green_light.time());
let yellow_light = TrafficLight::Yellow;
println!("yellow light is: {}", yellow_light.time());
}
enum Traffic... | true |
1787787fb8287f789aab9c63221fa792b933ece0 | Rust | peterpaul/sudoku-solver-rust | /src/coord.rs | UTF-8 | 219 | 2.9375 | 3 | [] | no_license | #[derive(Clone, PartialEq, Eq, Debug)]
pub struct Coord {
pub x: usize,
pub y: usize,
}
impl Coord {
pub fn new(x: usize, y: usize) -> Self {
Coord {
x,
y,
}
}
}
| true |
bff9360f1bb1dff2137f9e21c74bb3880eb60f7d | Rust | enso-org/enso | /lib/rust/reflect/tests/test.rs | UTF-8 | 559 | 2.640625 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | // The type definitions in this crate exercise `#[derive(Reflect)]`.
// === Non-Standard Linter Configuration ===
#![allow(dead_code)]
use enso_reflect as reflect;
use enso_reflect_macros::Reflect;
#[derive(Reflect)]
struct Foo;
#[derive(Reflect)]
struct Bar {
bar: Foo,
}
#[derive(Reflect)]
enum Baz {
Ba... | true |
8c56fe54590e400c7116a893748521cbc11cb89d | Rust | wezm/dslite2svd | /crates/tm4c123x/src/pwm0/faultval/mod.rs | UTF-8 | 13,303 | 2.8125 | 3 | [
"0BSD",
"BSD-3-Clause"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::FAULTVAL {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | true |
ce6d3819caed05d181cb8b95296be6941c158e4b | Rust | tianyu94/talent-plan | /courses/rust/projects/my-project-1/kvs/src/kv.rs | UTF-8 | 1,543 | 3.78125 | 4 | [
"MIT",
"CC-BY-4.0"
] | permissive | use std::collections::HashMap;
/// Key Value Store
///
/// # Examples
///
/// ```
/// let mut store = kvs::KvStore::new();
/// ```
#[derive(Default)]
pub struct KvStore {
map: HashMap<String, String>,
}
impl KvStore {
/// New Key Value Store
///
/// # Examples
///
/// ```
/// let mut store... | true |
4e56da431b05e4d53693a18017712347b63ce557 | Rust | macdonaldo/monkey | /src/evaluator.rs | UTF-8 | 11,385 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::ast::*;
use crate::object::*;
pub trait Evaluation {
fn evaluate(self, env: &mut Environment) -> Result<Object, String>;
}
impl Evaluation for Program {
fn evaluate(self, env: &mut Environment) -> Result<Object, String> {
match self {
Program {
... | true |
60576f452def449d0fb3a96d52c2ba9528f85c30 | Rust | pombredanne/cauchy | /cauchy-core/src/tests/primitives/transaction_tests.rs | UTF-8 | 1,005 | 2.8125 | 3 | [
"MIT"
] | permissive | mod serialisation {
use std::convert::TryFrom;
use bytes::Bytes;
use crate::{primitives::transaction::*, utils::serialisation::*};
#[test]
fn test_serialise() {
let raw = &b"\x01\x03aux\x06binary"[..];
let aux = Bytes::from(&b"aux"[..]);
let binary = Bytes::from(&b"binary"... | true |
18ae9377d8d91dade562f3d5fbc40c5962332ef5 | Rust | http-rs/surf | /src/middleware/logger/mod.rs | UTF-8 | 671 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Logging middleware.
//!
//! This middleware is used by default unless the `"middleware-logger"` feature is disabled.
//!
//! # Examples
//!
//! ```no_run
//! # #[async_std::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
//! let req = surf::get("https://httpbin.org/ge... | true |
a86daaf409f4c99e40c195d6f99f58e2a870b067 | Rust | Aloento/RustySpine | /src/attachments/path_attachment.rs | UTF-8 | 618 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use crate::attachments::vertex_attachment::VertexAttachment;
use crate::utils::color::Color;
pub struct PathAttachment<'a> {
Vertex: VertexAttachment<'a>,
color: Color,
lengths: Vec<f32>,
closed: bool,
constantSpeed: bool,
}
impl PathAttachment {
pub fn new(name: String) -> Self {
Self... | true |
eabcd098f66bbe6f40fc7e045e948cdd7ee01e73 | Rust | jiegec/online_tac_vm | /src/lib.rs | UTF-8 | 3,888 | 2.59375 | 3 | [] | no_license | #![recursion_limit = "256"]
mod common;
pub mod runner;
use common::{Msg, Request};
use stdweb::{js, web::window};
use yew::agent::{Bridge, Bridged};
use yew::services::ConsoleService;
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
const LIMIT: u32 = 1000;
pub struct Model {
console:... | true |
c7905a172ad2d10fac45b89c223e9852430ec635 | Rust | QuestofIranon/rusty-celery | /src/app/mod.rs | UTF-8 | 12,015 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use futures::{select, StreamExt};
use log::{debug, error, info, warn};
use std::collections::HashMap;
use std::sync::RwLock;
use tokio::signal::unix::{signal, SignalKind};
use tokio::sync::mpsc::{self, UnboundedSender};
mod trace;
use crate::protocol::{Message, MessageBody, TryIntoMessage};
use crate::{Broker, Error,... | true |
63377dddd91f630f50b4a4f76cc497736634c8e9 | Rust | curtisxk38/rcheer | /src/codegen.rs | UTF-8 | 5,368 | 2.75 | 3 | [] | no_license | use crate::ast::{Binary, BinaryOp, Expr, If, Literal, Unary, UnaryOp};
pub struct CodeGenerator {
bb_label_counter: i32
}
impl CodeGenerator {
pub fn new() -> CodeGenerator {
CodeGenerator {bb_label_counter: 0}
}
pub fn gen_code(&mut self, ast: Expr) -> String {
let mut program = Stri... | true |
c9350b98d1da005e1aab876bd95e0db86284e52c | Rust | serbanrobu/natte | /src/bin/natte-agent.rs | UTF-8 | 3,459 | 2.65625 | 3 | [] | no_license | use async_std::{fs, stream};
use futures::StreamExt;
use serde::Deserialize;
use std::net::{IpAddr, SocketAddr};
use std::path::PathBuf;
use std::process::Stdio;
use std::sync::Arc;
use std::time::Duration;
use structopt::StructOpt;
use tide::utils::async_trait;
use tide::{log, sse, Middleware, Next, Request, Response,... | true |
dd038b0fd497ba9da91bba8f77ab408789dee4f3 | Rust | Glinkis/rust-test | /src/point.rs | UTF-8 | 2,032 | 3.84375 | 4 | [] | no_license | use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
use std::string::ToString;
pub struct Point<T> {
pub x: T,
pub y: T,
pub z: T,
}
impl<T: Add<Output = T>> Add for Point<T> {
type Output = Self;
fn add(self, other: Self) -> Self::Output {
Self {
x... | true |
15f2e845f0b589ac52fd0e1d946f5a5127f5f08b | Rust | rustwasm/wasm-bindgen | /crates/js-sys/tests/wasm/WebAssembly.rs | UTF-8 | 5,899 | 2.59375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use js_sys::*;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::JsFuture;
use wasm_bindgen_test::*;
#[wasm_bindgen(module = "tests/wasm/WebAssembly.js")]
extern "C" {
#[wasm_bindgen(js_name = getWasmArray)]
fn get_wasm_array() -> Uint8Array;
#[wasm_bindgen(js_name = getTableObject)]
fn get_tabl... | true |
7b371e75fb35b6983221e3452c7e4f4b685a0804 | Rust | ssnover/acpi_client | /src/cooling.rs | UTF-8 | 2,151 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::fs::read_dir;
use std::path;
use crate::utils::*;
/// State information on a cooling device's activity.
#[derive(Clone, Copy)]
pub struct CoolingStatus {
/// The current level of the cooling device relative to the max_state
pub current_state: i32,
/// The maximum level of activity of the cooling ... | true |
838dd6db238ca1140864fed8db63e18f65c71ec3 | Rust | kornholi/hyper | /src/http/buffer.rs | UTF-8 | 2,913 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::io::{self, Write};
use std::ptr;
const INIT_BUFFER_SIZE: usize = 4096;
pub const MAX_BUFFER_SIZE: usize = 8192 + 4096 * 100;
#[derive(Debug, Default)]
pub struct Buffer {
vec: Vec<u8>,
tail: usize,
head: usize,
}
impl Buffer {
pub fn new() -> Buffer {
Buffer::default()... | true |
c15f174e5a50792528110f87ccb27835d40b3e43 | Rust | mosin-men/mosinOS | /src/libs/syscalls.rs | UTF-8 | 1,037 | 2.5625 | 3 | [] | no_license |
use crate::syscalls::{*};
pub fn exit() { unsafe { syscall(EXIT, 0, 0, 0, 0, 0, 0); } }
pub fn alloc(size: u32) -> *mut u32 { unsafe {
return syscall(ALLOC, size, 0, 0, 0, 0, 0) as *mut u32;
}
}
pub fn free<T>(addr: *mut T) { unsafe {
syscall(FREE, addr as u32, 0, 0, 0, 0, 0);
}
}
pub fn spawn(stack_size :... | true |
b33fb7d5222600e464c6eee7d1e7bc18e027dacb | Rust | mardiros/gandi-rs | /src/api/organization_list.rs | UTF-8 | 4,328 | 2.765625 | 3 | [
"BSD-2-Clause"
] | permissive | //! [organizations list](https://api.gandi.net/docs/organization/#get-v5-organization-organizations) route binding
use std::vec::Vec;
use clap::{App, ArgMatches, SubCommand};
use reqwest::RequestBuilder;
use serde::{Deserialize, Serialize};
use super::super::args::pagination::{
add_subcommand_options as add_pagin... | true |
088e8fe2f55a1caa556e541639851924b8850523 | Rust | burdettadam/indy-vdr | /libindy_vdr/src/ledger/requests/schema.rs | UTF-8 | 7,722 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use super::constants::{GET_SCHEMA, SCHEMA};
use super::{get_sp_key_marker, ProtocolVersion, RequestType};
use crate::common::did::{DidValue, ShortDidValue};
use crate::common::error::prelude::*;
use crate::utils::qualifier;
use crate::utils::validation::Validatable;
use std::collections::HashSet;
pub const MAX_ATTRIB... | true |
35ad59088afa70b04c255a0eecd94e340f48f663 | Rust | sabtorres/gltf-viewer-rs | /src/renderer/fullscreen.rs | UTF-8 | 1,791 | 2.734375 | 3 | [] | no_license | use std::mem::size_of;
use std::sync::Arc;
use vulkan::{ash::vk, create_device_local_buffer_with_data, Buffer, Context, Vertex};
#[derive(Clone, Copy)]
#[allow(dead_code)]
pub struct QuadVertex {
position: [f32; 2],
coords: [f32; 2],
}
impl Vertex for QuadVertex {
fn get_bindings_descriptions() -> Vec<vk:... | true |
839ff1d69171307f3facc32dfdd701a81b1d8478 | Rust | nlevitt/monie | /examples/add-via.rs | UTF-8 | 2,184 | 2.71875 | 3 | [
"MIT"
] | permissive | //! A mitm proxy example using monie. Adds via header to each request and
//! response.
#![deny(warnings)]
use futures::future::Future;
use http::header::{HeaderMap, HeaderValue};
use http::uri::Uri;
use hyper::{Body, Chunk, Request, Response, Server};
use monie::{Mitm, MitmProxyService};
#[derive(Debug)]
struct Ad... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.