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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
dc098bcfb84728da205f41fa65737f437e9c6cc2 | Rust | QuilonQuest/ProximaNet | /ext-eth-bridge-apps/aurora-engine/src/admin_controlled.rs | UTF-8 | 1,011 | 2.828125 | 3 | [
"CC0-1.0"
] | permissive | use crate::sdk;
pub type PausedMask = u8;
pub(crate) const ERR_PAUSED: &str = "ERR_PAUSED";
pub trait AdminControlled {
/// Returns true if the current account is owner
fn is_owner(&self) -> bool {
sdk::current_account_id() == sdk::predecessor_account_id()
}
/// Return the current mask repre... | true |
ee1e5e54e6bac08901190f5211c6b6741c8069d3 | Rust | shieldo/unveil-rs | /src/server/watcher.rs | UTF-8 | 2,416 | 2.96875 | 3 | [
"MIT"
] | permissive | use notify::Watcher;
use std::{path::PathBuf, sync::mpsc::channel, thread::sleep, time::Duration};
pub fn trigger_on_change<F>(closure: F)
where
F: Fn(Vec<PathBuf>),
{
use notify::{DebouncedEvent::*, RecursiveMode::*};
// Create a channel to receive the events.
let (tx, rx) = channel();
let mut w... | true |
eb9d249192ef30b0a231d3a1435672095ebad8f1 | Rust | destroycomputers/indexing-service | /indexing/src/live_indexer.rs | UTF-8 | 7,324 | 3.109375 | 3 | [] | no_license | use std::{
collections::HashSet,
path::{Path, PathBuf},
sync::{mpsc, Arc, Mutex},
thread,
time::Duration,
};
use notify::{self, DebouncedEvent, RecommendedWatcher, RecursiveMode, Watcher};
use tracing::{error, info, instrument, trace, warn};
use walkdir::WalkDir;
use crate::{Indexer, Result};
///... | true |
e96c9b8ae7dd8fefd5a75096e011b0eb50863c27 | Rust | 0e4ef622/aoc | /2022/day21/src/solution.rs | UTF-8 | 5,199 | 3.078125 | 3 | [] | no_license | use std::{collections::*, str::FromStr, fmt::{Display, Write}};
use rand::random;
use itertools::{iproduct, Itertools};
use util::*;
#[derive(Copy, Clone, Debug)]
enum Op {
Add,
Sub,
Mul,
Div,
}
impl Display for Op {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
matc... | true |
ea2ea35ad855ccfa5b02c949d4a0bf9d84100055 | Rust | etclabscore/jade-signer-rpc | /src/util/crypto.rs | UTF-8 | 1,150 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | //! # Crypto util functions
use sha3::Digest;
use sha3::Keccak256;
/// Keccak-256 crypto hash length in bytes
pub const KECCAK256_BYTES: usize = 32;
/// Calculate Keccak-256 crypto hash
pub fn keccak256(data: &[u8]) -> [u8; KECCAK256_BYTES] {
let mut keccak = Keccak256::default();
keccak.input(data);
let ... | true |
88e2271577ac21f9af74a1ac15e74b27327638cd | Rust | mcountryman/chal | /src/lex/error.rs | UTF-8 | 1,464 | 3.171875 | 3 | [] | no_license | use crate::types::Span;
use std::{error::Error, fmt::Display, num::ParseFloatError};
pub type LexResult<'buf, T> = Result<T, LexError<'buf>>;
/// An error which can be returned when tokenizing a str.
#[derive(Debug, Clone)]
pub enum LexError<'buf> {
BadIdent(String, Span<'buf>),
BadString(String, Span<'buf>),
B... | true |
aed4ea974c7320490882421d409cdf0d08e3dc33 | Rust | NeoLegends/runtext | /src/driver.rs | UTF-8 | 3,086 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::io;
use futures::future;
use futures::prelude::*;
use futures_stream_select_all::select_all;
use serde_yaml::Value;
use tokio_core::reactor::Handle;
use actions::Action;
use actions::command::{ACTION_NAME as COMMAND_ACTION_NAME, CommandAction};
use context::{Context, TriggerBehavior};
use triggers::{Activity... | true |
d1000a1190b2eb16247ba147c6e442ad3446b3b7 | Rust | pcein/trust-rust | /code/fearless-concurrency/closures/a4.rs | UTF-8 | 126 | 2.84375 | 3 | [] | no_license |
fn main() {
let mut v = vec![1, 2, 3, 4];
let mut f = |x| { v[0] += 1; x + v[0] };
println!("{}", f(10));
}
| true |
6bc4f291b0f5758612a22f5c4eea6250b0b876db | Rust | Tenjin0/rust-leetcode | /search_insert/benches/benchmark.rs | UTF-8 | 640 | 2.59375 | 3 | [] | no_license | #![feature(test)]
extern crate test;
use test::{Bencher};
use search_insert::{search_linear, search_quick};
#[bench]
fn bench_search_linear(b: &mut Bencher) {
b.iter(|| {
// Inner closure, the actual test
for _i in 1..100 {
let a = vec![1, 2, 3, 4, 5];
let target = 3;
... | true |
8675c4c05e102e72295b17d9bd9b4c51e0f7cf72 | Rust | Jarusk/spork | /tests/lib.rs | UTF-8 | 536 | 2.75 | 3 | [
"MIT"
] | permissive | extern crate spork;
use spork::Spork;
#[test]
fn it_works() {
assert!(1 > 0);
}
#[test]
fn test_hash_map() {
let mut map = Spork::new();
map.insert("Daniel", "798-1364");
map.insert("Daniel", "164-6743");
assert_eq!(map.get("Daniel").unwrap(),"164-6743");
}
#[test]
#[should_panic(expected = "as... | true |
b451d1f3182f556c9441e8bc5c1e790846006cb9 | Rust | willdoescode/hera | /src/eval/env.rs | UTF-8 | 1,057 | 3.28125 | 3 | [
"MIT"
] | permissive | use super::object::Object;
use std::{cell::RefCell, collections::HashMap, rc::Rc};
#[derive(PartialEq, Clone, Debug)]
pub struct Env {
store: HashMap<String, Object>,
outer: Option<Rc<RefCell<Env>>>,
}
impl Env {
pub fn new() -> Self {
Self {
store: HashMap::new(),
outer: N... | true |
4c05f8d9001c8f723dc48f61602ebf2392ae21d8 | Rust | AgustinCB/study | /compilers/craftinginterpreters/rloxi/src/function.rs | UTF-8 | 2,423 | 2.953125 | 3 | [] | no_license | use std::fmt::{Debug, Formatter, Error};
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
use crate::value::Value;
use crate::types::{SourceCodeLocation, Statement, ProgramError};
use crate::state::State;
use crate::interpreter::Evaluable;
use crate::class::LoxObject;
#[derive(Clone, PartialEq)]... | true |
744c94ef79afd7e2c7249ee308b98774608acce9 | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/object/src/write/util.rs | UTF-8 | 4,480 | 2.65625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use
alloc
:
:
vec
:
:
Vec
;
#
[
cfg
(
feature
=
"
std
"
)
]
use
std
:
:
{
io
mem
}
;
use
crate
:
:
pod
:
:
{
bytes_of
bytes_of_slice
Pod
}
;
#
[
allow
(
clippy
:
:
len_without_is_empty
)
]
pub
trait
WritableBuffer
{
fn
len
(
&
self
)
-
>
usize
;
fn
reserve
(
&
mut
self
size
:
usize
)
-
>
Result
<
(
)
(
)
>
;
fn
resize
... | true |
eb2ed1ce07dcd1d4f5ad7838f02ff6044f74abc4 | Rust | allenap/firstaide | /src/config.rs | UTF-8 | 7,722 | 2.640625 | 3 | [] | no_license | use std::env;
use std::ffi::OsStr;
use std::fmt;
use std::fs;
use std::io;
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::process::Command;
use path_absolutize::Absolutize;
use serde::Deserialize;
use toml;
use crate::sums;
type Result = std::result::Result<Config, Error>;
pub enum Error... | true |
bbed839b35a66bf9d669e944cd8f02e22d3748c1 | Rust | diesel-rs/diesel | /diesel_compile_tests/tests/fail/select_requires_valid_grouping.rs | UTF-8 | 3,374 | 2.953125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate diesel;
use diesel::prelude::*;
table! {
users {
id -> Integer,
name -> Text,
hair_color -> Nullable<Text>,
}
}
table! {
posts {
id -> Integer,
title -> Text,
user_id -> Integer,
}
}
table! {
comments {
id -> Integer,
t... | true |
8012e8f4355308f389cff4b909e1d920b7306c17 | Rust | awons/rs-chip8 | /console/src/implementation/display.rs | UTF-8 | 1,332 | 2.921875 | 3 | [] | no_license | use chip8::display::*;
use std::io::{stdout, Stdout, Write};
use std::ops;
use termion::raw::{IntoRawMode, RawTerminal};
pub struct ConsoleDisplay {
terminal: RawTerminal<Stdout>,
}
impl ConsoleDisplay {
pub fn new() -> Self {
let mut terminal = stdout().into_raw_mode().unwrap();
write!(termin... | true |
8e0ec6c9e6fa928392a6743e847171c10d78bb5f | Rust | viichi/vnlib | /vnbase/src/run_loop/mod.rs | UTF-8 | 7,991 | 3.0625 | 3 | [
"MIT"
] | permissive |
//! 消息循环,包含:函数投递,定时器,周期历程,循环内对象
//!
//! # Examples
//!
//! ```
//! use std::thread;
//! use std::io;
//! use vnbase::run_loop;
//!
//! // 获得当前线程的循环句柄
//! let handle = run_loop::clone_handle();
//!
//! let th = thread::spawn(move || {
//! let mut sth = String::new();
//! println!("Input something:");
//! ... | true |
d135d4e0cf9800a4b4206d91e37739c0f559b2fe | Rust | LycrusHamster/muta | /core/api/src/schema/mod.rs | UTF-8 | 3,430 | 2.734375 | 3 | [
"MIT"
] | permissive | mod block;
mod receipt;
mod transaction;
use std::convert::From;
use derive_more::{Display, From};
use std::num::ParseIntError;
use protocol::{ProtocolError, ProtocolErrorKind, ProtocolResult};
pub use block::{Block, BlockHeader};
pub use receipt::{Event, Receipt, ReceiptResponse};
pub use transaction::{
to_sig... | true |
66438db32148a08d2f1ff9b1c5ccbaac2c63aa97 | Rust | thedanieljun/2dgames-in-rust | /2dgames-jorge-danny-cynthia/src/objects.rs | UTF-8 | 1,198 | 2.984375 | 3 | [] | no_license | #![allow(dead_code)]
const DEPTH: usize = 4;
const WIDTH: usize = 240;
const HEIGHT: usize = 360;
pub type Color = [u8; DEPTH];
#[derive(Copy, Clone, PartialEq)]
pub struct Vec2 {
pub x: f32,
pub y: f32,
}
impl Vec2 {
pub fn new(x: f32, y: f32) -> Self {
Self { x, y }
}
}
#[derive(Copy, Clon... | true |
b94751ad717efaa0c7e60510a53c2d47efd7fe38 | Rust | hmcfletch/project-euler | /rust/001/src/main.rs | UTF-8 | 181 | 2.96875 | 3 | [] | no_license | fn main() {
let mut total = 0;
for x in 0..1000 {
if x % 3 == 0 || x % 5 == 0 {
total = total + x;
}
}
println!("total: {}", total);
}
| true |
49716a4c0a022c7bd1cba0a415bd36d9f80f8fd9 | Rust | DRvader/AOC2020 | /src/bin/3/2.rs | UTF-8 | 871 | 3.234375 | 3 | [] | no_license | use std::error::Error;
fn traverse(mountain: &Vec<Vec<char>>, x_change: usize, y_change: usize) -> usize {
let mut x_pos = x_change;
let mut y_pos = y_change;
let mut tree_count = 0;
while y_pos < mountain.len() {
let y = &mountain[y_pos];
if y[x_pos % y.len()] == '#' {
tree_count += 1;
... | true |
b04c9a7fc652adfb0e6cab53eaaa63eeaa4c9deb | Rust | dunnock/tonic-bench | /src/bin/client.rs | UTF-8 | 4,185 | 2.890625 | 3 | [
"MIT"
] | permissive | use hello_bench::greeter_client::GreeterClient;
use hello_bench::{Empty, Something};
use futures::future::{select_all, try_join_all, FutureExt};
use tonic::Request;
use structopt::StructOpt;
pub mod hello_bench {
tonic::include_proto!("hellobench");
}
#[derive(StructOpt)]
struct Opt {
/// Number of parallel c... | true |
6cacb0e643ff323837efdf213f30456376dbe067 | Rust | himikof/coreutils | /test/tsort.rs | UTF-8 | 677 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::process::Command;
static PROGNAME: &'static str = "./tsort";
fn get_file_contents(name: &str) -> Vec<u8> {
let mut f = File::open(Path::new(name)).unwrap();
let mut contents: Vec<u8> = vec!();
let _ = f.read_to_end(&mut contents);
con... | true |
b7ef77d497ced8d590f92d5c019baa86d2fae8c3 | Rust | carllerche/minidb | /src/server.rs | UTF-8 | 11,489 | 3.109375 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Processes requests from clients & peer nodes
//!
//! # Overview
//!
//! The MinDB server is a peer in the MiniDB cluster. It is initialized with a
//! port to bind to and a list of peers to replicate to. The server then
//! processes requests send from both clients and peers.
//!
//! # Peers
//!
//! On process star... | true |
6da737c93c579c9d353480dcd184740c87f0e7f7 | Rust | theduke/slog-loggly-rs | /src/lib.rs | UTF-8 | 3,571 | 2.734375 | 3 | [] | no_license | extern crate slog;
extern crate slog_async;
extern crate reqwest;
extern crate serde;
#[macro_use]
extern crate serde_json;
use std::{
time::Duration,
cell::RefCell,
};
use slog::{
Drain,
Record,
OwnedKVList,
};
use slog_async::{Async};
use serde_json::{
Map,
Value,
};
struct InnerLogglyD... | true |
d2322e3431dc78380e12217cc462d04c1e5e7394 | Rust | Pauan/SaltyBetBot | /bin/process-records/src/main.rs | UTF-8 | 892 | 2.78125 | 3 | [] | no_license | use std::fs::File;
use std::io::{Read, Write};
use std::io::{Result, BufReader, BufWriter};
use algorithm::record::{deserialize_records, serialize_records};
fn read(path: &str) -> Result<String> {
let mut reader = BufReader::new(File::open(path)?);
let mut contents = String::new();
reader.read_to_string(&... | true |
5d9d6ae6f7d305fc8b59f4975843ad56ba034826 | Rust | pygaur/Rust-Training | /examples/04-ownership/dangling_pointer.rs | UTF-8 | 166 | 3.375 | 3 | [] | no_license | fn get_greeting() -> &String {
let s = String::from("hello");
return &s
}
fn main() {
let s = get_greeting();
println!("The value of s: {}", s);
}
| true |
f870aca6d127a6e51ac50602762955b7c26752c9 | Rust | jonathansharman/gynjo | /src/values/list.rs | UTF-8 | 9,149 | 3.0625 | 3 | [
"MIT"
] | permissive | // Functional list implementation based on https://rust-unofficial.github.io/too-many-lists/third-final.html.
use super::Quant;
use super::Val;
use crate::env::SharedEnv;
use crate::errors::RtErr;
use crate::format_with_env::FormatWithEnv;
use crate::primitives::Num;
use itertools::Itertools;
use num::integer::div_c... | true |
a80c94b98cbcfca9860dbd4f1500ea9ac95879b1 | Rust | stokekld/rust-learning | /errors/src/main.rs | UTF-8 | 2,798 | 3.921875 | 4 | [] | no_license | struct Person {
first: String,
middle: Option<String>,
last: String,
}
fn build_full_name(person: &Person) -> String {
let mut full_name = String::new();
full_name.push_str(&person.first);
full_name.push_str(" ");
if let Some(middle) = &person.middle {
full_name.push_str(&middle);
... | true |
d532eb7e945a23ba07b044cf540cfe515524985b | Rust | hyperium/headers | /src/common/connection.rs | UTF-8 | 3,410 | 3.328125 | 3 | [
"MIT"
] | permissive | use std::iter::FromIterator;
use self::sealed::AsConnectionOption;
use util::FlatCsv;
use {HeaderName, HeaderValue};
/// `Connection` header, defined in
/// [RFC7230](http://tools.ietf.org/html/rfc7230#section-6.1)
///
/// The `Connection` header field allows the sender to indicate desired
/// control options for the... | true |
4ba1ec9ac96beb5d7d46bb42f98af6b2abc5d3e9 | Rust | ccqpein/Arithmetic-Exercises | /Asteroid-Collision/AC.rs | UTF-8 | 1,261 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | pub fn asteroid_collision(asteroids: Vec<i32>) -> Vec<i32> {
let mut asteroid_inner = asteroids.iter();
let mut stack: Vec<i32> = vec![*asteroid_inner.next().unwrap()];
while let Some(v) = asteroid_inner.next() {
loop {
if stack.last().is_none() {
stack.push(*v);
... | true |
14d0eb331d9957f4aebdf93228bca1775509074f | Rust | Lachei/vulkano-raytracing | /src/control/event_manager.rs | UTF-8 | 1,981 | 2.671875 | 3 | [
"MIT"
] | permissive | extern crate winit;
use super::keyboard::Keyboard;
use super::mouse::Mouse;
use std::mem;
pub struct EventManager {
pub keyboard: Keyboard,
pub mouse: Mouse,
done: bool,
recreate_swapchain: bool,
}
impl EventManager {
pub fn new() -> EventManager {
EventManager {
keyboard: Ke... | true |
7994b6fb9913241cd04d3d610ee23c132b4908c3 | Rust | errantsky/adventofcode-2017-rust | /src/spinlock_17.rs | UTF-8 | 2,739 | 3.3125 | 3 | [] | no_license | fn spinlock_tick(current_pos: usize, step: usize, buffer: &mut Vec<usize>) -> usize {
let next_val = buffer[current_pos] + 1;
let next_pos = (current_pos + step).rem_euclid(buffer.len()) + 1;
buffer.insert(next_pos, next_val);
return next_pos;
}
#[cfg(test)]
mod tests {
use super::*;
use std::c... | true |
a4acc7ab929c7c52ec10f788552b26f9e649bde2 | Rust | knokko/knukki-rs | /examples/color-clicking/menu.rs | UTF-8 | 915 | 2.59375 | 3 | [] | no_license | use knukki::*;
pub const EXAMPLE_NAME: &'static str = "color-clicking";
pub fn create_app() -> Application {
let component = TestComponent {
red: 100,
green: 200,
};
Application::new(Box::new(component))
}
struct TestComponent {
red: u8,
green: u8,
}
impl Component for TestCompo... | true |
7eacb5e4840654b52e71a8110dc3c5fb3f9b0620 | Rust | mozilla/dump_syms | /src/common.rs | UTF-8 | 2,953 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
use once_cell::sync::Lazy... | true |
ca7644c16fed5261236ff4318471e9c5b401f595 | Rust | faradayio/bigml-rs | /bigml/src/resource/execution/mod.rs | UTF-8 | 6,647 | 2.859375 | 3 | [] | no_license | //! An execution of a WhizzML script.
use serde::de;
use serde::de::DeserializeOwned;
use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use url::Url;
use super::id::*;
use super::status::*;
use super::{Library, Script};
use super::{Resource, ResourceCommon};
us... | true |
08cde6c46f9c6e7be38bdacc0bac5c27a1307af7 | Rust | ftilde/ugdb | /src/gdbmi/output.rs | UTF-8 | 11,275 | 2.703125 | 3 | [
"MIT"
] | permissive | use super::Token;
pub use json::object::Object;
pub use json::JsonValue;
use nom::{
alt, call, do_parse, error_position, is_not, many0, map, named, opt, separated_list, tag, value,
};
use log::{error, info};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ResultClass {
Done,
Running,
Connected,
... | true |
6614ab8e5f09d52c04904f3db6e074d13223d1c2 | Rust | ray-kast/Ingot | /src/oneshot_pool.rs | UTF-8 | 1,831 | 3 | 3 | [] | no_license | use std::{
collections::VecDeque,
sync::{Arc, Barrier, Mutex},
thread::{self, JoinHandle},
};
struct Worker {
handle: JoinHandle<()>,
}
pub struct OneshotPool<T>
where
T: Send + 'static,
{
q: Arc<Mutex<VecDeque<T>>>,
workers: Vec<Worker>,
}
impl<T> OneshotPool<T>
where
T: Send + 'static,
{
pub fn n... | true |
d1ab7b0539c4c35ab8f97494808a3a9e4c3a9677 | Rust | jmacmahon/advent-of-code-2016 | /src/day04/mod.rs | UTF-8 | 2,359 | 3.421875 | 3 | [] | no_license | use std::error::Error;
#[derive(Debug)]
pub struct Room<'a> {
name: &'a str,
sector: u32,
checksum: &'a str,
}
pub fn parse_line(line: &str) -> Result<Room, Box<Error>> {
let mut bracket_split = line.split('[');
let first_part = bracket_split.next().ok_or("Bad parse")?;
let checksum = bracket_... | true |
d65b77e1c3aed99ee11827504c9e748bca3ce62c | Rust | unixpickle/brute-tree | /src/server/main.rs | UTF-8 | 4,310 | 2.546875 | 3 | [] | no_license | extern crate brute_tree;
extern crate clap;
extern crate futures;
extern crate hyper;
extern crate serde_json;
extern crate tokio_core;
use std::fs::File;
use std::io::{Read, Write};
use std::net::{SocketAddr, SocketAddrV4, Ipv4Addr};
use std::sync::mpsc::{Sender, channel};
use std::thread;
use clap::{Arg, App};
use ... | true |
e9bbecda96a0baaee31cb10ecf42699cd56f8e75 | Rust | msuesskraut/calc-engine | /src/cells.rs | UTF-8 | 691 | 3.46875 | 3 | [
"MIT"
] | permissive | #[derive(PartialEq, Debug, Clone, Copy)]
pub enum Value {
Double(f64),
}
impl Default for Value {
fn default() -> Self {
Self::Double(0.0f64)
}
}
#[derive(Debug, Default)]
pub struct Cell {
value: Value,
}
impl Cell {
pub fn get_value(&self) -> Value {
self.value
}
}
#[derive... | true |
d88a4727246d64741bbf1dfc254cae1f1589db45 | Rust | kosslab-kr/rust | /src/librustc/dep_graph/dep_node.rs | UTF-8 | 9,260 | 2.546875 | 3 | [
"MIT",
"Apache-2.0",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"BSD-2-Clause",
"Unlicense",
"LicenseRef-scancode-other-permissive"
] | permissive | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
1a68dc4df667afdf3cdf3a3483241ba06a780610 | Rust | eugeneia/rush | /vendor/aho-corasick/src/error.rs | UTF-8 | 3,361 | 3.578125 | 4 | [
"Unlicense",
"MIT",
"Apache-2.0"
] | permissive | use std::error;
use std::fmt;
use std::result;
pub type Result<T> = result::Result<T, Error>;
/// An error that occurred during the construction of an Aho-Corasick
/// automaton.
#[derive(Clone, Debug)]
pub struct Error {
kind: ErrorKind,
}
/// The kind of error that occurred.
#[derive(Clone, Debug)]
pub enum Er... | true |
60eefba95b099cd8274132d9ef5d2b0862b09cb6 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/itertools/benches/tuple_combinations.rs | UTF-8 | 2,146 | 2.546875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
criterion
:
:
{
black_box
criterion_group
criterion_main
Criterion
}
;
use
itertools
:
:
Itertools
;
/
/
approximate
100_000
iterations
for
each
combination
const
N1
:
usize
=
100_000
;
const
N2
:
usize
=
448
;
const
N3
:
usize
=
86
;
const
N4
:
usize
=
41
;
fn
tuple_comb_for1
(
c
:
&
mut
Criterion
)
{
c
.
bench_fu... | true |
c2b8f2d65bde107d704c994d17672ec8f5d006cc | Rust | timotree3/aoc-2020 | /day4-pt1/src/main.rs | UTF-8 | 671 | 2.859375 | 3 | [] | no_license | use regex::RegexSet;
use std::io::Read;
fn main() {
#[allow(clippy::trivial_regex)]
let pattern = RegexSet::new(&["cid", "byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"]).unwrap();
let mut data = String::new();
std::io::stdin().read_to_string(&mut data).unwrap();
let passports = data.split("\n\n");... | true |
2cd4a419e89f98fe552129ecaeff6c57daec97ff | Rust | yyuan21/rustydb-release | /src/storage/sstable.rs | UTF-8 | 16,213 | 3.21875 | 3 | [] | no_license | // SSTable: Sorted String Table
// files that contain a set of arbitrary, sorted key-value pairs
use std::io;
use std::fs;
use std::mem;
use std::str;
use std::io::{Read, Write, BufReader, BufWriter, Seek, SeekFrom};
use std::path::{Path, PathBuf};
use std::collections::HashMap;
use byteorder::*;
// There is a separa... | true |
dc56f64fa46b4c2ededc6a53fb663ca231b861ea | Rust | foresterre/miniview | /src/lib.rs | UTF-8 | 8,732 | 3.453125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! MiniView is a small program which allows to show a single image in a graphical window.
//! It supports both windowed mode and fullscreen mode and can be useful for debugging or testing
//! programs dealing with images.
//!
//! MiniView can be used both as a binary executable (usually `miniview` or `miniview.exe`),
... | true |
ce3ac368bf19265696c32de906d98fb8185d2e50 | Rust | mattlknight/rust-win32-bindgen | /src/features/scan.rs | UTF-8 | 3,713 | 3 | 3 | [
"MIT"
] | permissive | /**
Deals with processing a translation unit's tokens to extract a feature set map.
This is mostly in its own module to make it easier to exclude from logging.
*/
use std::collections::BTreeMap;
use clang;
use super::{Features, define_feature, define_feature_expr};
/**
This function will, given a list of token lints,... | true |
338fdec9f3be3a7fa132ca78e61041ff8c97a156 | Rust | sugyan/leetcode | /others/october-leetcoding-challenge/week-3/3498/lib.rs | UTF-8 | 942 | 3.515625 | 4 | [] | no_license | use std::collections::HashMap;
pub struct Solution {}
impl Solution {
pub fn find_repeated_dna_sequences(s: String) -> Vec<String> {
let mut hm: HashMap<&str, usize> = HashMap::new();
if s.len() >= 10 {
(0..s.len() - 9).for_each(|i| *hm.entry(&s[i..i + 10]).or_insert(0) += 1);
... | true |
f00131d0cbdf0f82d2d85c4a96a9737d505bbb8f | Rust | Liby99/llir | /src/values/instruction/indir_br.rs | UTF-8 | 1,716 | 2.546875 | 3 | [
"MIT"
] | permissive | use llvm_sys::core::*;
use llvm_sys::prelude::LLVMValueRef;
use std::marker::PhantomData;
use crate::values::*;
use crate::*;
/// [Indirect Branch instruction](https://llvm.org/docs/LangRef.html#indirectbr-instruction)
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct IndirectBranchInstruction<'ctx>(LLVMValueRef... | true |
729c958e585063d3e68ec597ee4b2cadb371483d | Rust | bytecodealliance/wasmtime | /crates/runtime/src/vmcontext.rs | UTF-8 | 43,135 | 2.734375 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! This file declares `VMContext` and several related structs which contain
//! fields that compiled wasm code accesses directly.
mod vm_host_func_context;
use crate::externref::VMExternRef;
use sptr::Strict;
use std::cell::UnsafeCell;
use std::ffi::c_void;
use std::marker;
use std::ptr::NonNull;
use std::sync::atom... | true |
83f347e32279da1e1f60641a2ef668d947326143 | Rust | gilbertw1/winit | /src/platform/linux/wayland/window.rs | UTF-8 | 8,735 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::{Arc, Mutex};
use std::sync::atomic::{Ordering, AtomicBool};
use std::cmp;
use wayland_client::{EventQueueHandle, Proxy};
use wayland_client::protocol::{wl_display,wl_surface};
use {CreationError, MouseCursor, CursorState, WindowAttributes};
use platform::MonitorId as PlatformMonitorId;
use window::Mon... | true |
bcd690b43404f28f0fc050574f21fe080cce888c | Rust | augustawind/storygamer | /src/lib/types/mod.rs | UTF-8 | 4,290 | 3.21875 | 3 | [] | no_license | mod condition;
pub mod item;
mod variable;
use std::cell::RefCell;
use std::fmt;
use std::rc::{Rc, Weak};
use either::{Either, Either::*};
use serde::de;
use serde::Deserialize;
pub use self::condition::*;
pub use self::item::{Item, ItemDef};
pub use self::variable::*;
pub type PageID = String;
/// A page in a sto... | true |
f5261fe74fc78aa9537239dcaa6d1f9443085c98 | Rust | touilleMan/orion | /tests/mac/nist_cavp_hmac.rs | UTF-8 | 2,911 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::{TestCase, TestCaseReader};
#[test]
fn test_nist_cavp() {
let nist_cavp_fields: Vec<String> = vec![
"Count".into(),
"Klen".into(),
"Tlen".into(),
"Key".into(),
"Msg".into(),
"Mac".into(),
];
let mut nist_cavp_reader = TestCaseReader::new(
... | true |
d73f6fa34f0eb67d523f0420a0cdfd13a3107250 | Rust | r0t0r-r0t0r/r0t0snake | /src/main.rs | UTF-8 | 17,001 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::path::Path;
use sdl2::event::Event;
use sdl2::keyboard::Scancode;
use sdl2::rect::Rect;
use std::time::Instant;
use std::collections::VecDeque;
use rand::Rng;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum Direction {
Up,
Right,
Down,
Left,
}
impl From<u32> for Direction {
fn from(x: ... | true |
824e0024ac6f7430f1b729ee859c4f6cce469831 | Rust | Gamadril/lightoros | /src/plugins/transform/convert/dim/src/lib.rs | UTF-8 | 1,803 | 2.71875 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use lightoros_plugin_base::transform::{CreateTransformPluginResult, PluginTransformTrait};
use lightoros_plugin_base::*;
const NAME: &str = "ConvertDimTransform";
#[derive(Deserialize, Debug)]
struct Config {
brightness: u8,
}
struct ConvertDimTransform {
config: Config,
}
impl std:... | true |
9e17181c6f004961282942b8899bd4faca484e04 | Rust | rnestler/advent_of_code_2019 | /aoc-2019-1/src/main.rs | UTF-8 | 852 | 3.3125 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
fn get_required_fuel(mass: i32) -> i32 {
mass / 3 - 2
}
fn get_required_fuel_part2(mass: i32) -> i32 {
let fuel = get_required_fuel(mass);
if fuel <= 0 {
0
} else {
fuel + get_required_fuel_part2(fuel)
}
}
fn main() -> Result<(), Box<dyn... | true |
9c3805bb76ea417a8221a68528708d98a98085b8 | Rust | korken89/micromath | /src/float/atan.rs | UTF-8 | 2,131 | 3.65625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! arctangent approximation for a single-precision float.
//!
//! Method described at:
//! <https://ieeexplore.ieee.org/document/6375931>
use super::F32;
use core::f32::consts::FRAC_PI_2;
impl F32 {
/// Approximates `atan(x)` approximation in radians with a maximum error of
/// `0.002`.
///
/// Retur... | true |
d8d10b67b245441588c526f87ca9944766017ed9 | Rust | Absolucy/bender | /src/tweaks.rs | UTF-8 | 3,469 | 2.84375 | 3 | [
"BSD-2-Clause"
] | permissive | /*
bender - a CLI interface for configuring libhooker on iOS
copyright (C) 2021, aspen <aspenuwu@protonmail.com>
All rights reserved.
LGBTQ+ rights are human rights. If you disagree, kindly fuck off and don't use my code :)
🏳️🌈🏳️⚧️
*/
use once_cell::sync::Lazy;
use std::{ffi::OsStr, path::PathBuf};
// This... | true |
d0a6151b3ee3b411bafdd4f457d36caf368e8d3b | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc087/src/bin/d.rs | UTF-8 | 1,549 | 2.953125 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Usize1;
use std::collections::VecDeque;
fn topological_sort(e: &Vec<Vec<usize>>) -> Option<Vec<usize>> {
let n = e.len();
let mut c_in = vec![0; n];
for e_u in e.iter() {
for &v in e_u.iter() {
c_in[v] += 1;
}
}
let mut q = VecD... | true |
e71f8aec8b7694926e852c9e199b79169410be43 | Rust | cessen/ropey | /src/iter.rs | UTF-8 | 112,456 | 3.859375 | 4 | [
"MIT"
] | permissive | //! Iterators over a `Rope`'s data.
//!
//! The iterators in Ropey can be created from both `Rope`s and `RopeSlice`s.
//! When created from a `RopeSlice`, they iterate over only the data that the
//! `RopeSlice` refers to. For the `Lines` and `Chunks` iterators, the data
//! of the first and last yielded item will be ... | true |
d67de76e653de0506c761891087cd2c18b17a70c | Rust | kompics/kompact | /core/src/dedicated_scheduler.rs | UTF-8 | 4,887 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{
component::{Component, ComponentDefinition, CoreContainer, SchedulingDecision},
runtime::Scheduler,
utils,
};
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread,
};
use crossbeam_utils::Backoff;
#[derive(Clone)]
pub(crate) struct DedicatedThreadSched... | true |
4663aae5662496868e07ab82eae7ac3137ea3bf2 | Rust | SeSodesa/rustla | /src/parser/tests/test_sections_and_transitions.rs | UTF-8 | 8,436 | 3.046875 | 3 | [
"MIT"
] | permissive | /*!
A submodule for testing sections and transitions.
Copyright © 2020 Santtu Söderholm
*/
use super::*;
#[cfg(test)]
#[test]
fn transition_01() {
let src =
"
Below is a transition.
=======
The line is at least 4 symbols long.
"
.lines()
.map(|s| s.to_string())
.collect::<Vec<String>>();
let... | true |
5497f80ed5b478be5d9e6c096a5f377ced2ff461 | Rust | Keruspe/lapin | /futures/src/client.rs | UTF-8 | 4,548 | 2.78125 | 3 | [
"MIT"
] | permissive | use lapin_async;
use lapin_async::format::frame::Frame;
use std::default::Default;
use std::io;
use futures::{future,Future,Stream};
use tokio_io::{AsyncRead,AsyncWrite};
use tokio_timer::Timer;
use std::sync::{Arc,Mutex};
use std::time::Duration;
use transport::*;
use channel::{Channel, ConfirmSelectOptions};
/// th... | true |
56c50c698dd09da37905c82f8bd1eba969a6250e | Rust | MOZGIII/rust-uritemplate | /tests/test_uritemplate.rs | UTF-8 | 2,338 | 3.65625 | 4 | [] | no_license | extern crate uritemplate;
use uritemplate::{IntoTemplateVar, TemplateVar, UriTemplate};
#[test]
fn test_example() {
let uri = UriTemplate::new("/view/{object:1}{/object,names}{?query*}")
.set("object", "lakes")
.set("names", &["Erie", "Superior", "Ontario"])
.set("query", &[("size", "15"), ... | true |
8d7dd109fe68d263a32f0a7b60b7e6a991c301df | Rust | bolstycjw/kys-rust | /src/engine/math.rs | UTF-8 | 660 | 3.15625 | 3 | [] | no_license | use std::cmp;
use crate::config::*;
#[derive(Copy, Clone, Debug)]
pub struct Point {
pub x: i32,
pub y: i32,
}
impl Point {
pub fn new(x: i32, y: i32) -> Self {
Self { x, y }
}
pub fn to_iso(self) -> Self {
let x = HALF_TILE_WIDTH as i32 * (self.x - self.y) + CENTER_X - 18;
... | true |
b71cd854c6cfdeaea7fef2f5736d958bac7bdf40 | Rust | khachaturh/truck | /truck-shapeops/src/intersection_curve/mod.rs | UTF-8 | 7,115 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | use serde::{Deserialize, Serialize};
use truck_base::cgmath64::*;
use truck_meshalgo::prelude::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IntersectionCurve<C, S> {
surface0: S,
surface1: S,
leader: C,
tol: f64,
}
pub fn double_projection<S>(
surface0: &S,
hint0: Option<(f64, f64)>,
surface1:... | true |
1681866ecf743f32a141024292aaca3695204808 | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/http-body/src/size_hint.rs | UTF-8 | 1,015 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
std
:
:
u64
;
#
[
derive
(
Debug
Default
Clone
)
]
pub
struct
SizeHint
{
lower
:
u64
upper
:
Option
<
u64
>
}
impl
SizeHint
{
#
[
inline
]
pub
fn
new
(
)
-
>
SizeHint
{
SizeHint
:
:
default
(
)
}
#
[
inline
]
pub
fn
with_exact
(
value
:
u64
)
-
>
SizeHint
{
SizeHint
{
lower
:
value
upper
:
Some
(
value
)
}
}
#
[
in... | true |
a9110f0edfbe55fe11685f759f13e1d245f03c5e | Rust | carbidegames/common | /lagato-ggez/src/lib.rs | UTF-8 | 1,585 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate ggez;
#[macro_use] extern crate slog;
extern crate sloggers;
use {
std::path,
ggez::{
Context, GameResult, GameError,
conf::{Conf, WindowMode, WindowSetup},
event::{self, EventHandler},
},
slog::{Logger},
sloggers::{Build, terminal::{TerminalLoggerBuilder}, typ... | true |
58fab2dfd9ea9cc82eee22ba508d99c79f00e1d8 | Rust | alexd6631/aoc2019 | /src/intcode/instruction.rs | UTF-8 | 3,234 | 3.5625 | 4 | [] | no_license | pub type Int = i64;
#[derive(Debug, Eq, PartialEq)]
pub enum Instruction {
Add {
a: Input,
b: Input,
out: Output,
},
Mul {
a: Input,
b: Input,
out: Output,
},
In {
addr: Output
},
Out {
addr: Input
},
JumpIfTrue {
... | true |
259286055ea399bb1d24f0833058957318f018f4 | Rust | Phantomical/xed | /src/structs/flag_set.rs | UTF-8 | 2,735 | 2.6875 | 3 | [] | no_license | use xed_sys2::xed_interface::*;
use crate::util::fmt_helper;
use std::fmt;
macro_rules! bit_accessors {
{ $(
$(#[$attr:meta])*
$name:ident => $set_name:ident,
)* } => {
impl FlagSet {
$(
$(#[$attr])*
pub fn $name(&self) -> bool {
... | true |
e38c94e0b6b00734c50e0f49bed00a5ae3110721 | Rust | nervosnetwork/merkle-mountain-range | /src/tests/test_accumulate_headers.rs | UTF-8 | 5,473 | 2.5625 | 3 | [] | no_license | use super::new_blake2b;
use crate::{leaf_index_to_pos, util::MemStore, MMRStoreReadOps, Merge, MerkleProof, Result, MMR};
use bytes::{Bytes, BytesMut};
use std::fmt;
#[derive(Clone)]
struct Header {
number: u64,
parent_hash: Bytes,
difficulty: u64,
// MMR root
chain_root: Bytes,
}
impl Header {
... | true |
03220127103f46188d514d212a4ba4c6b05c7f09 | Rust | fluffypony/tari | /common/src/lib.rs | UTF-8 | 9,076 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclai... | true |
0c7e2ea54b8324e894571123e1b925edda66c2bf | Rust | mohammadreza-ashouri/RustyJVM | /src/model/class.rs | UTF-8 | 3,626 | 2.703125 | 3 | [] | no_license | use std::io::Cursor;
use super::info::{Attribute, Constant, Field, Method};
use byteorder::{BigEndian, ReadBytesExt};
const MAGIC_VALUE: u32 = 0xCAFEBABE;
#[derive(Debug)]
pub struct Class {
pub minor_version: u16,
pub major_version: u16,
pub constant_pool_count: u16,
pub constant_pool: Box<[Constan... | true |
a2b5c1423a046328e73c56cf499f6089f133f830 | Rust | rafael81/sodiumoxide | /src/utils.rs | UTF-8 | 11,401 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Libsodium utility functions
use ffi;
use std::ptr::{null, null_mut};
/// `memzero()` tries to effectively zero out the data in `x` even if
/// optimizations are being applied to the code.
pub fn memzero(x: &mut [u8]) {
unsafe {
ffi::sodium_memzero(x.as_mut_ptr() as *mut _, x.len());
}
}
/// `memc... | true |
8781c01bae5dd728ea9fc7b024606f39f0c984fa | Rust | metamemelord/Mockerino | /src/boilerplate.rs | UTF-8 | 1,536 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::Result;
use std::io::Write;
static BOILERPLATE_SOURCE_BASE: &str =
"https://raw.githubusercontent.com/metamemelord/Mockerino/main/boilerplate";
pub fn init() -> Result<()> {
log::info!("Initializing the spec and config in current directory");
log::info!("Downloading sample spec. The spec can b... | true |
2c0facf88df818cebbffd1cf5dd43792e7a13f81 | Rust | replit4/rfbproxy | /src/rfb.rs | UTF-8 | 17,313 | 2.546875 | 3 | [
"MIT"
] | permissive | //! A Remote Framebuffer connection that can inject audio messages into the stream.
//!
//! This connection also translates from a TCP socket (server) to a Websocket (client) for use with
//! noVNC.
use crate::audio;
use crate::messages;
use crate::messages::{client, server};
use std::sync::atomic::{AtomicUsize, Orde... | true |
adce463b3f51894a5e6a1db10090bb105a86acf0 | Rust | 98devin/friday | /src/ast.rs | UTF-8 | 6,371 | 2.796875 | 3 | [
"MIT"
] | permissive | use lalrpop_util::lalrpop_mod;
lalrpop_mod!(pub parser, "/ast/parser.rs");
#[derive(Debug, Clone)]
pub struct OwnedToken(pub usize, pub String);
impl From<parser::Token<'_>> for OwnedToken {
fn from(tok: parser::Token) -> OwnedToken {
OwnedToken(tok.0, tok.1.to_owned())
}
}
impl std::fmt::Display fo... | true |
089c87f67e2bd7e408a208bcdef79b2c7c697b2f | Rust | richardanaya/shoji | /src/shoji_test.rs | UTF-8 | 2,039 | 2.875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::*;
use alloc::vec::Vec;
#[test]
fn it_works() -> Result<(), &'static str> {
let mut shoji = Shoji::new();
let top_child = shoji.new_node(
LayoutStyle {
..Default::default()
},
Vec::new(),
);
let bottom_left_child = shoji.new_node(
LayoutStyle {
... | true |
40a806008718320e1e237a7cf2eb2dbce8e44014 | Rust | DrInfy/sc2-pathlib | /tests/common.rs | UTF-8 | 1,434 | 2.953125 | 3 | [
"MIT"
] | permissive | use sc2pathlib::mapping::map::Map;
use sc2pathlib::path_find;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn rot90(vec: Vec<Vec<usize>>) -> Vec<Vec<usize>> {
let new_height = vec.len();
let new_width = vec[0].len();
let mut new_arr: Vec<Vec<usize>> = vec![vec![0; new_height]; new_width];
// T... | true |
b7cbfff163c29e450276932bc100d1e1f1267055 | Rust | kiennq/emacs-module-rs | /src/global.rs | UTF-8 | 5,109 | 3.203125 | 3 | [] | no_license | use std::ops::Deref;
use once_cell::sync::OnceCell;
use emacs_module::emacs_value;
use super::*;
/// A "global reference" that can live outside the scope of an [`Env`]. This is useful for sharing
/// an otherwise short-lived Lisp [`Value`] across multiple invocations of Rust functions defined
/// with [`defun`]. Ex... | true |
f0bc80e596da8531bdb7fae878b216b07a5458a2 | Rust | e1810/kyopro | /techful/math/number_theory/beginner/a.rs | UTF-8 | 157 | 2.53125 | 3 | [] | no_license | fn main() {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
let n = s.trim().parse::<i64>().unwrap();
println!("{} {}", n+1, n+1);
}
| true |
0c3b6b39fe755e69080c9c42a55ba0b78977b2f4 | Rust | Kamil2601/University | /Studia_inzynierskie/Semestr_5/Rust/Lista_1/zad5/zad5.rs | UTF-8 | 931 | 3.34375 | 3 | [] | no_license | fn printer_error(s: &str) -> String {
let n = s.chars().count();
let mut errors = 0;
for c in s.chars()
{
if c > 'm'
{
errors+=1;
}
}
return format!("{}/{}",errors.to_string(),n.to_string());
}
fn main(){
}
mod tests {
use super::printer_error;
#[t... | true |
26549c8f7a3237d285e616ba01033c40ae1f14a6 | Rust | maueki/lambda-rust-sample | /src/main.rs | UTF-8 | 2,071 | 2.703125 | 3 | [] | no_license | use env_logger;
use failure::format_err;
use lambda_http::{lambda, IntoResponse, Request, Response};
use lambda_runtime::{error::HandlerError, Context};
use log::{debug, error, info, warn};
use rusoto_core::Region;
use serde_derive::{Deserialize, Serialize};
use serde_dynamodb;
use serde_json::{json, Value};
use std::c... | true |
367a039c02e646176a5a3e12ca471898b0b98669 | Rust | favu100/b2program | /btypes_primitives/src/main/rust/btypes/src/bobject.rs | UTF-8 | 444 | 2.78125 | 3 | [] | no_license | use std::hash::Hash;
use std::clone::Clone;
use std::fmt;
use crate::bboolean::{BBoolean, BBooleanT};
pub trait BObject: Eq + Hash + Ord + Clone + fmt::Display {
fn is_struct(&self) -> BBoolean { BBoolean::new(false) }
}
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Dummy {}
impl fmt::Display ... | true |
6962619ff443059416b1010f15c8b479df18c22d | Rust | Dineshs91/x-ray | /src/parser/mod.rs | UTF-8 | 22,525 | 2.703125 | 3 | [] | no_license | mod util;
#[macro_use]
mod mac;
use std;
use nom;
use structures::{Function};
#[derive(Debug, Eq, PartialEq)]
pub struct Item {
pub node: ItemKind,
}
#[derive(Debug, Eq, PartialEq)]
pub enum ItemKind {
Import {path: String},
ImportFrom {module: String, name: String, level: i32},
Shebang {path: Stri... | true |
e1fff7f4c1abca79a913cd307675b5448354a007 | Rust | shilpakancharla/learning-rust | /14_06_match_option/end/match_option/src/main.rs | UTF-8 | 218 | 3.25 | 3 | [] | no_license | fn main() {
let countdown = [5, 4, 3, 2, 1];
let number = countdown.get(2);
let number = match number {
Some(number) => number + 1,
None => 0
};
println!("number is {:?}", number);
} | true |
e4ebc89ea3bc47160aa81d92bdc9a67e7e22ba5c | Rust | SiegeEngine/siege-example-server | /src/bin/generate_keypair.rs | UTF-8 | 686 | 2.515625 | 3 | [
"MIT"
] | permissive |
extern crate ring;
extern crate untrusted;
use std::fs::File;
use std::io::Write;
use ring::{rand, signature};
fn main() {
let rng = rand::SystemRandom::new();
let pkcs8_bytes = signature::Ed25519KeyPair::generate_pkcs8(&rng).unwrap();
let mut keyfile = File::create("/tmp/pkcs8.der").unwrap();
keyfi... | true |
049ee28190d8914f7b6212c97d64bab5825ded59 | Rust | cdlm/poisson-surface.rs | /src/point.rs | UTF-8 | 1,757 | 3.703125 | 4 | [] | no_license | use rand::distributions::{IndependentSample, Range};
#[derive(Debug, Copy, Clone)]
pub struct Point {
pub x: f64,
pub y: f64,
}
impl Point {
pub fn new(x: f64, y: f64) -> Point {
Point { x: x, y: y }
}
pub fn origin() -> Point {
Point::new(0.0, 0.0)
}
pub fn distance(&se... | true |
8d0eb638278c7199fea4236806f1b8a5f671e640 | Rust | cda-group/arc | /arc-runtime/tests/allocation.rs | UTF-8 | 1,165 | 2.625 | 3 | [] | no_license | use comet::api::Collectable;
use comet::api::Finalize;
use comet::api::Gc;
use comet::api::Trace;
use comet::api::Visitor;
use comet::gc_base::AllocationSpace;
use comet::immix::instantiate_immix;
use comet::immix::Immix;
use comet::immix::ImmixOptions;
pub enum List<T: Collectable> {
Nil,
Cons(T, Gc<List<T>, ... | true |
d8b6b85291f8b00664b031eef473bd56d42c498c | Rust | dimus/rustlrn | /sherborn/src/main.rs | UTF-8 | 3,755 | 3.078125 | 3 | [] | no_license | use regex::{Captures, Regex};
use std::convert::TryFrom;
use std::fs::File;
use std::io::{BufRead, BufReader};
use zstd;
#[macro_use]
extern crate lazy_static;
#[derive(Debug)]
struct Record {
id: String,
name: String,
canonical: String,
meta: String,
}
impl Record {
fn normalize(&mut self) {
... | true |
94d425959470868aa0d5c1fef9f30aa8fc07c1af | Rust | DrSlowpokePhd/rfetch | /src/main.rs | UTF-8 | 2,676 | 3.171875 | 3 | [] | no_license | /* * * * * * * * /
* rfetch
* a fetch script written in rust
* because im bored lol
* made by James Doherty
* RIPBETTY
* * * * * */
use std::time::SystemTime;
use std::env;
#[cfg(test)]
// tests for the helper functions
mod test {
#[test]
#[ignore]
fn test_name() {
use crate::boxed;
boxed(... | true |
08945d6b46ce5c5fb3a4eb3dfcb160889f451434 | Rust | TanNgocDo/hbbft | /src/subset/message.rs | UTF-8 | 1,078 | 2.9375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use rand::Rand;
use rand_derive::Rand;
use serde_derive::{Deserialize, Serialize};
use binary_agreement;
use broadcast;
/// Message from Subset to remote nodes.
#[derive(Serialize, Deserialize, Clone, Debug, Rand)]
pub struct Message<N: Rand> {
/// The proposer whose contribution this message is about.
pub pr... | true |
d30041c8a07b1610ccae43348b687d2ea7c630af | Rust | 00mjk/veritas | /src/main.rs | UTF-8 | 6,547 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use]
extern crate serde_derive;
extern crate toml;
extern crate git2;
extern crate serde;
extern crate clap;
extern crate colored;
extern crate semver;
use std::path::Path;
use std::io::{Write, Read, BufWriter};
use std::fs::File;
use std::fs::create_dir_all;
use std::process;
use git2::build::{ RepoBuilder };... | true |
0cfbe113997d599251f3528076c2be186114f4fb | Rust | RoaringBitmap/roaring-rs | /src/bitmap/serde.rs | UTF-8 | 2,412 | 2.984375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::de::SeqAccess;
use serde::de::Visitor;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use crate::RoaringBitmap;
impl<'de> Deserialize<'de> for RoaringBitmap {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struc... | true |
e3e738080837b45b9532ff4b2301971547144887 | Rust | niofis/light | /light/src/ilios/generic_vector.rs | UTF-8 | 2,514 | 3.046875 | 3 | [] | no_license | use crate::ilios::float::Float;
use std::ops;
#[derive(Debug, Clone, Copy)]
pub struct GVector4(pub Float, pub Float, pub Float, pub Float);
impl ops::Add<GVector4> for GVector4 {
type Output = GVector4;
fn add(self, rhs: GVector4) -> Self::Output {
GVector4(
self.0 + rhs.0,
s... | true |
097861d040d845b0178a0a4feef5000e5d934553 | Rust | viktorstrate/toy-sat | /src/parser/dimacs.rs | UTF-8 | 2,454 | 3.015625 | 3 | [] | no_license | use super::{CNFHeader, ParseBuffer, CNF};
pub fn parse(data: &str) -> CNF {
// println!("Parsing cnf dimacs format...");
let mut buf = ParseBuffer::new(data);
let header = parse_header(&mut buf);
let result = parse_body(&mut buf);
CNF {
header: header,
clauses: result,
}
}
fn parse_header(buf:... | true |
0b724d3d829b2983f70c365709bf45cd9b4a2b72 | Rust | elimirks/miscprojects | /leetcode/rust/src/p0001_twosum.rs | UTF-8 | 835 | 3.6875 | 4 | [
"MIT"
] | permissive | // https://leetcode.com/problems/two-sum/
use std::collections::HashMap;
// O(n) complexity, O(n) memory
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut values = HashMap::<i32, usize>::new();
for (index, &n) in nums.iter().enumerate() {
let diff = target - n;
if ... | true |
d95b8129f9164e1ff705dc1e79609f7d99b480ab | Rust | shadowsocks/shadowsocks-rust | /crates/shadowsocks/src/net/sys/mod.rs | UTF-8 | 3,724 | 2.875 | 3 | [
"MIT"
] | permissive | use std::{
io::{self, ErrorKind},
net::{IpAddr, SocketAddr},
};
use cfg_if::cfg_if;
use log::{debug, warn};
use socket2::{SockAddr, Socket};
use tokio::net::TcpSocket;
use super::ConnectOpts;
cfg_if! {
if #[cfg(unix)] {
mod unix;
pub use self::unix::*;
} else if #[cfg(windows)] {
... | true |
4997b9aac44732773dbe146b74178f30a3107211 | Rust | EdginAround/edgin_around_rendering | /edgin_around_rendering/src/renderers/fixed.rs | UTF-8 | 6,392 | 2.59375 | 3 | [] | no_license | use std::time::Instant;
use crate::{
animations::{Sprite, ACTION_NAME_DEFAULT},
game::Sprites,
utils::{defs::prelude::*, defs::SIZE_FLOAT, errors as err, tile::Tile},
};
#[derive(Debug)]
pub struct FixedRenderer {
sprite: Sprite,
start_instant: Instant,
vao: gl::types::GLuint,
vbo: gl::typ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.