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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
da76d9fc7c8c04a51aa7d2da435babcd3643f2d7 | Rust | t-ob/aoc2020 | /day15/src/lib.rs | UTF-8 | 2,686 | 3.5 | 4 | [] | no_license | use std::collections::VecDeque;
pub struct MemoryGame {
turn: usize,
seen: Vec<Option<usize>>,
last_spoken: Option<usize>,
next_spoken: Option<usize>,
starting_numbers: VecDeque<usize>,
}
impl MemoryGame {
pub fn new(starting_numbers: &[usize]) -> MemoryGame {
let turn = 0;
let... | true |
6e83575b745e63e9ea00f80d6e10ea2ef8ffaf74 | Rust | danylaporte/str_utils | /src/char_map/mod.rs | UTF-8 | 1,233 | 3.015625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod human_cmp;
mod lower;
mod lower_no_accent;
pub use human_cmp::human_cmp;
pub use lower::*;
pub use lower_no_accent::*;
use std::str::Chars;
/// Map chars to other chars.
#[derive(Clone)]
pub struct MappedChars<'a> {
chars: Chars<'a>,
mapped: std::str::Chars<'static>,
}
impl<'a> Eq for MappedChars<'a> {}
... | true |
d1cf41562793db65f19e24b74e332c8e8eec1fc3 | Rust | michaelsproul/household-power | /src/main.rs | UTF-8 | 6,682 | 2.90625 | 3 | [] | no_license | extern crate xml;
extern crate serial;
#[macro_use] extern crate log;
extern crate festivus_client;
use std::path::Path;
use std::io::Read;
use std::collections::HashMap;
use std::error::Error;
use xml::EventReader;
use xml::reader::XmlEvent;
use xml::reader::XmlEvent::*;
use xml::reader::Error as XmlError;
use xml::... | true |
aa70c71f972ee993003898c665b0e11389edbcbf | Rust | jasmaa/bandori-puyopuyo | /src/engine/piece.rs | UTF-8 | 418 | 3.28125 | 3 | [
"MIT"
] | permissive | // piece.rs
// PuyoPuyo piece
use super::enums::Sprite;
use super::enums::Direction;
pub struct Piece {
pub row: u32,
pub col: u32,
pub sprite: Sprite,
pub direction: Direction,
}
impl Piece {
pub fn new(row: u32, col: u32, sprite: Sprite) -> Piece {
Piece {
row: row,
... | true |
c34ea214a9689e98c1dcb65d06f9a9c20f5aafc5 | Rust | jpdvi/scout | /src/lib.rs | UTF-8 | 6,646 | 3.265625 | 3 | [] | no_license | mod token;
mod data;
mod lexer;
use lexer::Lexing;
#[derive(Clone)]
pub struct Mark {
pub left_index : Option<usize>,
pub right_index: Option<usize>,
}
impl Mark {
fn new() -> Self {
Self {
left_index : None,
right_index : None,
}
}
}
pub struct Template {
... | true |
78c69a02ac2733cd0b1be30b51a7b4f972d0e486 | Rust | nicholasday/robotics-club-signin | /src/members.rs | UTF-8 | 3,397 | 2.796875 | 3 | [] | no_license | use crate::db::member::{Member, PostMember};
use crate::db::signin::{PostPizza, Signin};
use crate::db::Conn;
use crate::types::JsonResult;
use rocket::http::Status;
use rocket::response::status::Custom;
use rocket::serde::json::Json;
use tera::Context;
#[get("/members", format = "application/json")]
pub async fn get_... | true |
b69b49ecc841f8e8aa3390397c73a5afd54d9a76 | Rust | Afourcat/Gust | /examples/threads.rs | UTF-8 | 1,358 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | /// Threads test.
/// This is a test to draw with the glfw RenderContext shareable between thread.
#[macro_use]
extern crate gust;
extern crate glfw;
use gust::prelude::*;
use gust::shared_window::SharedWindow;
use std::rc::Rc;
use std::sync::mpsc;
use std::thread;
fn main() {
let mut window = Window::new(gust::W... | true |
d81de0b6c8c2f156f67f3bb550cba7b60bb812df | Rust | maidsafe/sn_consensus | /src/mvba/hash.rs | UTF-8 | 2,044 | 3.265625 | 3 | [
"BSD-3-Clause",
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display};
use thiserror::Error;
const HASH32_SIZE: usize = 32;
#[derive(Clone, Copy, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord, Hash)]
pub struct Hash32([u8; HASH32_SIZE]);
#[derive(Error, Debug, Eq, PartialEq)]
#[error("invalid length: expected... | true |
2dfb288b53604da79c7cfe9dcbc8da202f749886 | Rust | PKAuth/rmp | /src/rmp/sub.rs | UTF-8 | 456 | 3.390625 | 3 | [
"Apache-2.0"
] | permissive | use std::ops::{Sub};
use super::Integer;
impl Integer {
// Borrowed subtraction.
pub fn sub_borrow( &self, rhs : &Integer) -> Integer {
let mut r = self.clone();
r.sub_mut( rhs);
r
}
// Mutable borrowed subtraction.
pub fn sub_mut( &mut self, rhs : &Integer) {
self.add_mut( &rhs.neg_borrow())
}
}
impl... | true |
5f6550ee43c5abc104fed46d181b402e021d2b04 | Rust | clemson-cal/gridiron | /src/overlap.rs | UTF-8 | 2,398 | 3.546875 | 4 | [] | no_license | use core::ops::Bound;
use core::ops::RangeBounds;
/// Extension trait to determine whether two range bounds objects overlap. Two
/// ranges that line up end-to-end do not overlap, regardless of whether the
/// endpoints that touch are included or exluded.
pub trait Overlap<T>: RangeBounds<T> {
fn overlaps<S: Overl... | true |
c1d619f6ee3db7704c34763978db07f2a8cc14d0 | Rust | vaibhavantil2/third-party-api-clients | /docusign/src/group_brands.rs | UTF-8 | 3,280 | 3.015625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use crate::Client;
pub struct GroupBrands {
pub client: Client,
}
impl GroupBrands {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
GroupBrands { client }
}
/**
* Gets the brand information for a group.
*
* This function performs a `GET` to the `/v... | true |
73eac0352443a0f1cc465a4c66630eb78e1573b4 | Rust | veber-alex/rilox | /src/model/instance.rs | UTF-8 | 2,118 | 2.734375 | 3 | [] | no_license | use super::callable::LoxCallable;
use super::class::LoxClass;
use super::object::LoxObject;
use crate::interpreter::{ACell, ACellOwner, ControlFlow};
use crate::token::Token;
use rustc_hash::FxHashMap;
use std::fmt::Display;
use std::rc::Rc;
#[derive(Clone)]
pub struct LoxInstance {
pub class: LoxClass,
// T... | true |
0fb068141b69f029c5c2884c6b83dc7ae7f4c716 | Rust | gmadrid/imt | /src/finddups/opener.rs | UTF-8 | 2,658 | 2.953125 | 3 | [] | no_license | use result::Result;
use std::ffi::OsString;
use std::time::SystemTime;
use super::args::{DELETE, PREVIEW, PRINT, QUIET};
#[derive(Clone)]
pub struct FileInfo {
pub filename: OsString,
pub create_time: SystemTime,
}
pub trait Opener {
fn open_group(&self, group: Vec<FileInfo>) -> Result<()>;
}
mod print {
use... | true |
1a1f9a3b8d5062e2b6e69491998f2919c7db66ed | Rust | TurtlePU/lispy | /src/function.rs | UTF-8 | 4,062 | 2.96875 | 3 | [] | no_license | use std::vec::IntoIter;
use std::fmt;
use super::{env::*, ast::AST, eval_error::*, qexpr::QExpr};
pub type Builtin = fn(EnvObj, Vec<AST>) -> EvalResult;
#[derive(Clone)]
pub enum Function {
Builtin(Builtin),
Lambda(Lambda),
}
impl Function {
pub fn call(&self, env: EnvObj, args: IntoIter<AST>) -> EvalRes... | true |
b793a851aa6f2535f3835d9041c191c3ca3d11fa | Rust | ijanos/exercism | /rust/robot-name/src/lib.rs | UTF-8 | 826 | 3.5 | 4 | [
"MIT"
] | permissive | extern crate rand;
use rand::{thread_rng, Rng};
pub struct Robot {
name: String,
}
impl Robot {
pub fn new() -> Robot {
Robot { name: Robot::generate_name() }
}
pub fn name<'a>(&'a self) -> &'a str {
&self.name
}
pub fn reset_name(&mut self) {
self.name = Robot::gene... | true |
5d262ee9c0918edb4e84058f98eea670d68c15a4 | Rust | fieldplay/eigenvalues | /src/utils.rs | UTF-8 | 1,511 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | extern crate nalgebra as na;
use na::linalg::SymmetricEigen;
use na::Dynamic;
use na::{DMatrix, DVector};
/// Generate a random highly diagonal symmetric matrix
pub fn generate_diagonal_dominant(dim: usize, sparsity: f64) -> DMatrix<f64> {
let xs = 1..(dim + 1);
let it = xs.map(|x: usize| x as f64);
let vs... | true |
7a1d07109b71c027e0c81436fa6008b054f53703 | Rust | koalp/himalaya | /src/domain/config/entity.rs | UTF-8 | 12,115 | 2.71875 | 3 | [] | permissive | use anyhow::{anyhow, Context, Error, Result};
use log::{debug, trace};
use serde::Deserialize;
use shellexpand;
use std::{collections::HashMap, convert::TryFrom, env, fs, path::PathBuf, thread};
use toml;
use crate::output::utils::run_cmd;
const DEFAULT_PAGE_SIZE: usize = 10;
#[derive(Debug, Default, Clone, PartialE... | true |
dc8633986cb004780bd7959f0256180c90813135 | Rust | forkkit/kas | /examples/layout.rs | UTF-8 | 2,695 | 2.53125 | 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
//! Demonstration of widget and text layouts
use kas::even... | true |
53f9dea89325f30f24472951c41cd665fd00097d | Rust | mana-ysh/nnsearch-rs | /src/hasher.rs | UTF-8 | 4,631 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Implementations of hashers are based on `lsh-rs` crate
// https://github.com/ritchie46/lsh-rs/blob/9e81c018872868b319e5fe4d23495ee031117e91/lsh-rs/src/hash.rs#L1
use crate::type_utils::{FloatScalar, SetItem};
use crate::linalg::utils::{get_rng, to_lowest_b_bit_vector};
use ndarray::prelude::*;
use ndarray::{Array, A... | true |
9c6f56a249a518fb7925d43cf862067ba79305d3 | Rust | PistonDevelopers/hematite | /src/minecraft/model.rs | UTF-8 | 15,801 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::HashMap;
use std::f32::consts::{PI, SQRT_2};
use std::fs::File;
use std::path::Path;
use std::str::FromStr;
use self::OrthoRotation::*;
use crate::array::*;
use crate::cube;
use gfx_voxel::texture::AtlasBuilder;
use rustc_serialize::json... | true |
5c190f79623e810f92a2e914f446b0ee6008b086 | Rust | gnoliyil/fuchsia | /src/lib/cutex/src/list.rs | UTF-8 | 4,374 | 2.875 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::constants::SENTINEL;
use slab::Slab;
struct Node<T> {
value: T,
next: usize,
prev: usize,
}
/// Maintain a list of objects referen... | true |
df2b52c82532b583291da99fbdd93ba5d04b8c19 | Rust | bmcclelland/565-vsm | /src/vm/insts.rs | UTF-8 | 2,242 | 3.265625 | 3 | [] | no_license | use super::val::*;
//#[derive(Clone,Copy,Debug,PartialEq,Eq)]
//pub enum Comparison {
// LT,
// LE,
// EQ,
// NE,
// GE,
// GT,
//}
#[derive(Clone,Copy,Debug)]
pub enum Inst {
Push(Val),
Pop,
Dup,
Dup2,
Add,
Sub,
Mul,
Div,
Print,
Peek,
CmpLT,
CmpLE,
... | true |
5963762b920f5bdb5e62b8645dc964c9292a899d | Rust | Manishearth/mathema | /src/status.rs | UTF-8 | 740 | 2.515625 | 3 | [] | no_license | //! Status subcommand.
use crate::prelude::*;
#[derive(Default)]
crate struct Status {
unknown_card_files: Vec<PathBuf>,
card_files_with_missing_uuids: BTreeMap<PathBuf, Vec<u64>>,
valid_cards: usize,
valid_card_files: usize,
}
crate fn status(options: &MathemaOptions) -> Fallible<()> {
let repo ... | true |
338326f62a54df745a4e18f08bc5331891f46130 | Rust | pythonesque/rustbox | /src/rustbox.rs | UTF-8 | 3,071 | 2.796875 | 3 | [
"MIT"
] | permissive | extern crate libc;
extern crate "termbox-sys" as termbox;
use termbox::RawEvent;
use libc::{c_int, c_uint};
#[deriving(Copy)]
pub enum Event {
KeyEvent(u8, u16, u32),
ResizeEvent(i32, i32),
NoEvent
}
#[deriving(Copy)]
pub enum Color {
Default,
Black,
Red,
Green,
Yellow,
Blue,
... | true |
13633d1e9c7cd16d3935b9c3d7ce045d3d890bfa | Rust | GoX1337/mqtt-broker | /src/mqtt/return_code.rs | UTF-8 | 266 | 2.671875 | 3 | [] | no_license | #[derive(Debug)]
pub enum ReturnCode {
CONNECTION_ACCEPTED,
UNKNOWN
}
impl ReturnCode {
pub fn from_u8(value: u8) -> ReturnCode {
match value {
0 => ReturnCode::CONNECTION_ACCEPTED,
_ => ReturnCode::UNKNOWN
}
}
} | true |
d3d09e9fded610896b59960fa91983fc49eb9e6e | Rust | LaurentMazare/ultra | /src/main.rs | UTF-8 | 1,770 | 2.765625 | 3 | [] | no_license | #![allow(unstable)]
use std::io;
use std::os;
mod encrypt;
mod quadgram_data;
mod cryptanalysis;
fn main_encrypt(args: &Vec<String>) {
if args.len() != 4 {
println!("Usage: {} encrypt KEY RNG", args[0]);
}
else {
let rotor_config = vec![ 0u8, 1, 2 ];
let key = args[2].as_slice();
... | true |
c650b29de829c54b445a8a697a494ef05711608c | Rust | dbohn/learn-rust-ls | /src/util.rs | UTF-8 | 1,813 | 3.125 | 3 | [] | no_license | use chrono::offset::Utc;
use chrono::DateTime;
use std::time::SystemTime;
/// POSIX mask to get the file type from the st_mode field
const S_IFMT: u32 = 0o170000;
// st_mode values
const S_IFSOCK: u32 = 0o140000;
const S_IFLNK: u32 = 0o120000;
const S_IFREG: u32 = 0o100000;
const S_IFBLK: u32 = 0o060000;
const S_IFDI... | true |
0eda8a67bfd0aa7148a24f9831d12b4146f6ee06 | Rust | 1aim/state_machine_future | /tests/visibility.rs | UTF-8 | 1,923 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Test that we handle `pub`, `pub(self)`, `pub(super)`, `pub(crate)`,
//! `pub(in some::module)`, and non-`pub` state machines.
#![feature(futures_api, pin, arbitrary_self_types)]
#![allow(dead_code)]
extern crate futures;
#[macro_use]
extern crate state_machine_future;
#[derive(StateMachineFuture)]
pub enum Pub {... | true |
6c475e2601ac1b03f94d80fd6a63f4a2f3bab19b | Rust | Dirbaio/rp2040-pac | /src/pio/regs.rs | UTF-8 | 28,068 | 3.015625 | 3 | [] | no_license | use crate::generic::*;
#[doc = "FIFO debug register"]
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct Fdebug(pub u32);
impl Fdebug {
#[doc = "State machine has stalled on empty TX FIFO. Write 1 to clear."]
pub const fn txstall(&self) -> u8 {
let val = (self.0 >> 24u32) & 0x0f;
val as u8
... | true |
eabb399d5acd0a3a1ae9318d6268e294caebe5d2 | Rust | jthelin/demikernel | /src/rust/pal/linux/shm.rs | UTF-8 | 13,751 | 2.6875 | 3 | [
"MIT"
] | permissive | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
// TODO: Remove allowances on this module.
//======================================================================================================================
// Imports
//=============================================... | true |
0698494db4c9f5dd69f440f6131707addcd52609 | Rust | internetimagery/to | /src/lib.rs | UTF-8 | 12,588 | 2.90625 | 3 | [
"MIT"
] | permissive | use cpython::{
py_class, py_exception, py_module_initializer, ObjectProtocol, PyClone, PyDrop, PyErr,
PyObject, PyResult, PySequence, PythonObject, exc::{TypeError}
};
use search::Graph;
use std::cell::RefCell;
use std::collections::{BTreeSet, HashMap};
use std::convert::TryInto;
mod search;
#[cfg(feature = "p... | true |
2f438038be344255ffae2e0db658bba1542f654c | Rust | tbelaire/tsp-rust | /src/graph.rs | UTF-8 | 2,861 | 3.296875 | 3 | [] | no_license | use std::num::Float;
use std::num::Int;
pub struct Graph {
size: usize,
nodes: Vec<(char, i32, i32)>,
distances: Vec<Vec<usize>>,
min_cost_edges: Vec<usize>
}
impl Graph {
pub fn new(v : Vec<(char, i32, i32)>) -> Graph {
let dist:Vec<Vec<usize>> = v.iter().map(
|&(_, ax, ay)... | true |
bc7e85a37523f12f63f5b6a1618cf3e167095e90 | Rust | xorpse/nom-bibtex | /src/error.rs | UTF-8 | 684 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use nom::IError;
quick_error! {
#[derive(Debug, PartialEq, Eq)]
pub enum BibtexError {
Parsing (descr: String) {
description(descr)
display(me) -> ("Parsing error. Reason: {}", me.description())
from(err: IError) -> (
match err ... | true |
8e920e325d0a103849674c86db2fee67eeb2e052 | Rust | bevyengine/bevy | /crates/bevy_reflect/src/type_registry.rs | UTF-8 | 24,355 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | use crate::{serde::Serializable, Reflect, TypeInfo, Typed};
use bevy_ptr::{Ptr, PtrMut};
use bevy_utils::{HashMap, HashSet};
use downcast_rs::{impl_downcast, Downcast};
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use serde::Deserialize;
use std::{any::TypeId, fmt::Debug, sync::Arc};
/// A registry of... | true |
85a19cce3201bb590f94d83eeb46a5268b285020 | Rust | richardsj/libra | /api/types/src/error.rs | UTF-8 | 3,543 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use serde::{Deserialize, Serialize};
use std::{
convert::From,
fmt::{self, Display},
};
use warp::{http::StatusCode, reject::Reject};
use crate::U64;
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Error ... | true |
5415b0fc844258c5c57fb35b94936b607252fbff | Rust | Xsivax/Threadpool_Server_Rust | /src/lib.rs | UTF-8 | 6,978 | 3.671875 | 4 | [] | no_license | use std::thread;
//module, message based concurrency over channels
//types Sender, Receiver
use std::sync::mpsc;
//struct, thread-safe reference counting smart-pointer
//for multiple owners of receiver
use std::sync::Arc;
//struct, mutate data from multiple threads, save
//for ensuring that only one thre... | true |
b805b65481234387f8e7e645183208536b526d24 | Rust | andete/atsam4lc8c | /src/pm/rcause/mod.rs | UTF-8 | 5,610 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::RCAUSE {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct PORR {
bits: ... | true |
8ffb830b2ace07a125937027192e1b51b22a1cb5 | Rust | banyan/rust-pretty-bytes | /src/converter.rs | UTF-8 | 604 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::cmp;
pub fn convert(num: f64) -> String {
let negative = if num.is_sign_positive() { "" } else { "-" };
let num = num.abs();
let units = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
if num < 1_f64 {
return format!("{}{} {}", negative, num, "B");
}
let delimiter = 1000_f64;
let ex... | true |
a4f9adffa807ba13d8e00253b7273048b55d7b62 | Rust | KuuDS/guessing-game | /src/main.rs | UTF-8 | 1,394 | 4 | 4 | [] | no_license | use rand::Rng;
use std::cmp::Ordering;
use std::io;
// import io library in std(standard) library
fn main() {
// declare a main method which means the entrance for this program.
println!("Guess the number!");
// println! is a macro
let secret_number = rand::thread_rng().gen_range(1, 101);
println... | true |
90ecd623cb261f097681df48c0b2430eca294676 | Rust | devoidfury/omnichat | /src/tui.rs | UTF-8 | 31,686 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use chan_message::ChanMessage;
use conn::{Conn, DateTime, Event, IString, Message};
use cursor_vec::CursorVec;
use std::cmp::{max, min};
use std::sync::mpsc::{sync_channel, Receiver, RecvTimeoutError, SyncSender};
const CHAN_WIDTH: u16 = 20;
pub struct Tui {
servers: CursorVec<Server>,
longest_channel_name: u... | true |
ed1fa8e2f92561ff56eadc42764dd0fc28408a2e | Rust | chandero/patternfly-yew | /src/popover.rs | UTF-8 | 6,086 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{Button, Icon, Orientation, Popper, PopperContent, Variant};
use yew::prelude::*;
use crate::integration::popperjs;
// tooltip
#[derive(Clone, Debug, PartialEq, Properties)]
pub struct PopoverProps {
/// The target, rendered by the component, to which the popover will be aligned to.
#[prop_or_def... | true |
a8cf6157433eccaa59f7d952d643e9a1bd923d01 | Rust | 27factorial/pfecs | /src/cell.rs | UTF-8 | 5,209 | 3.0625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
any,
cell::UnsafeCell,
mem::{self, ManuallyDrop},
ops::{Deref, DerefMut},
ptr,
sync::atomic::{AtomicUsize, Ordering},
};
#[derive(Debug)]
pub struct AtomicRefCell<T: ?Sized> {
borrow: AtomicUsize,
data: UnsafeCell<T>,
}
impl<T> AtomicRefCell<T> {
pub fn new(data: T) -> S... | true |
1cee9edae5f1356085821888ec8ac7600d4c59f4 | Rust | jeremyletang/rust-sfml | /src/audio/sound.rs | UTF-8 | 7,064 | 3.234375 | 3 | [
"Zlib"
] | permissive | use {
crate::{
audio::{SoundBuffer, SoundSource, SoundStatus},
ffi,
system::{Time, Vector3f},
},
std::{marker::PhantomData, ptr::NonNull},
};
/// Regular sound that can be played in the audio environment.
///
/// `Sound` is the type to use to play sounds.
///
/// It provides:
///
//... | true |
f6eac2e0fbc7c91dffc6ab1c967569a2020d4220 | Rust | kornstar11/wirefilter | /engine/src/types.rs | UTF-8 | 9,016 | 2.9375 | 3 | [
"MIT"
] | permissive | use crate::{
lex::{expect, skip_space, Lex, LexResult, LexWith},
rhs_types::{Bytes, IpRange, UninhabitedBool},
strict_partial_ord::StrictPartialOrd,
};
use failure::Fail;
use serde::{Deserialize, Serialize};
use std::{
borrow::Cow,
cmp::Ordering,
convert::TryFrom,
fmt::{self, Debug, Formatte... | true |
0f7e0b89ba13eff843b8c0dd5d57bc69566873f9 | Rust | DavidWittman/cryptopals-rust | /src/set1/ch5.rs | UTF-8 | 1,578 | 3.421875 | 3 | [] | no_license | /* Implement repeating-key XOR
Here is the opening stanza of an important work of the English language:
> Burning 'em, if you ain't quick and nimble
> I go crazy when I hear a cymbal
Encrypt it, under the key "ICE", using repeating-key XOR.
In repeating-key XOR, you'll sequentially apply each byte of the k... | true |
a56e5a3da93c6bdbae4a9c1d6d8c27ba300cf6f7 | Rust | nickdonnelly/horus-server | /src/models/horus_version.rs | UTF-8 | 1,819 | 2.734375 | 3 | [] | no_license | use chrono::NaiveDateTime;
use schema::horus_versions;
#[derive(Identifiable, Queryable, Serialize, Deserialize, AsChangeset)]
#[table_name = "horus_versions"]
#[primary_key(platform, version_string)]
pub struct HorusVersion
{
id: i32,
deployed_with: String, // hash
aws_bucket_path: String,
version_st... | true |
210dbd9720eaafaf60c498800d3fe7e86ccd024f | Rust | Mandragorian/wirefart | /wirefart_test/src/mocks.rs | UTF-8 | 2,238 | 3.4375 | 3 | [] | no_license | use std::io::Read;
use std::io::Result;
pub struct MockWireReader {
data: Vec<u8>,
ind: usize,
len: usize,
}
impl MockWireReader {
pub fn new(buf: &[u8], len: usize) -> Self {
if len < buf.len() {
panic!("Wire mock MTU less than provided buffer length");
}
let mut ... | true |
1102229c1eeb0e66f539193d5a4d463338107d36 | Rust | Alexnortung/kattis-solutions | /problems/flowfinder/src/flowfinder.rs | UTF-8 | 5,585 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::io;
#[derive(Debug)]
struct Node {
flow: usize,
children: Vec<Box<Node>>,
solved: bool,
}
impl Node {
fn sum_children(&self) -> usize {
let mut accumulator: usize = 0;
for child in &self.children {
accumulator += child.flow as usize;
}
accumulator
... | true |
c8d271031287c75508557ba5be1427d5610f1b2f | Rust | nataliepopescu/qrates | /manager/src/top_crates.rs | UTF-8 | 1,788 | 3 | 3 | [
"MIT"
] | permissive | // Licensed under the MIT license <LICENSE or
// http://opensource.org/licenses/MIT>. This file may not be copied,
// modified, or distributed except according to those terms.
//! Helper functions for obtaining the list of most downloaded crates.
use log::debug;
use log_derive::logfn;
use serde::{Deserialize, Seriali... | true |
042163ce613c5d47954ef672717a731b4c77cf37 | Rust | periklis/rust-web-experiments | /hyper-simple-backend/src/main.rs | UTF-8 | 1,900 | 2.703125 | 3 | [] | no_license | extern crate hyper;
extern crate futures;
extern crate pretty_env_logger;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate serde_json;
use std::str::FromStr;
use futures::future::FutureResult;
use hyper::header::{ContentLength, ContentType};
use hyper::server::{Http, Service, Request, Respon... | true |
c53606566d24f9ccdc963ce64869ee05cf6ed8ee | Rust | coastalwhite/simpleserial-rs | /src/lib.rs | UTF-8 | 7,785 | 2.5625 | 3 | [] | no_license | //! The ChipWhisperer Simple Serial Protocol
//!
#![no_std]
#![warn(missing_docs)]
#![deny(macro_use_extern_crate)]
use array_utils::{array_resize, drift_to_end, superimpose};
pub(crate) mod util;
pub(crate) mod firmware;
use firmware::*;
mod capture_to_target;
mod target_to_capture;
use capture_to_target::CTPacke... | true |
aa2640d7fbca133902733901663934a8f6185a67 | Rust | eric93/squiggle | /src/webapi.rs | UTF-8 | 10,195 | 2.640625 | 3 | [] | no_license | use program::*;
use std::run::{Process, ProcessOptions};
use std::to_str::ToStr;
use std::num::{FromStrRadix,ToStrRadix};
use extra::json;
use extra::json::{Json, ToJson, Object, Number, String, List, Boolean};
use extra::treemap::TreeMap;
static SERVER: &'static str = "http://icfpc2013.cloudapp.net/";
static PRIVAT... | true |
3f7fd37a24a168d886e8d19f6177007b5842ac44 | Rust | 1t2t3t4t/betting_sim | /src/common.rs | UTF-8 | 1,386 | 3.0625 | 3 | [] | no_license | #[derive(Clone, Copy)]
pub struct Environment {
pub win_rate: f64,
pub return_ratio: f64,
pub start_amount: u64,
}
impl Environment {
pub fn new(start_amount: u64) -> Self {
Self {
start_amount,
..Default::default()
}
}
}
impl Default for Environment {
f... | true |
75329066af733d56054825a7e1979afc35cac39f | Rust | torkleyy/fnstack | /src/once.rs | UTF-8 | 3,056 | 2.984375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::marker::PhantomData;
use std::mem::{align_of, forget, size_of};
use std::ptr;
use raw::{Boxed, CallRawOnce, FnBox, Static, Trait};
use {Array, StaticFn};
pub struct FnStackOnce<'a, A, O, D = [u8; 16]>
where
D: Array,
{
data: D,
drop: fn(*const u8),
ptr: fn(*const u8, A) -> O,
marker: Phan... | true |
61660fb25b4935224fd96c18a9ee6cee8fc35210 | Rust | TheKK/progress | /examples/simple_examples.rs | UTF-8 | 1,180 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | extern crate progress;
use std::thread;
fn main() {
let mut pbar = progress::Bar::new();
// Add percentage each time
{
pbar.set_job_title("This...");
pbar.add_percent(20);
thread::sleep_ms(1000);
pbar.set_job_title("is...");
pbar.add_percent(20);
thread::s... | true |
c4acb0ac550ecadc0f52b297cc47179c2baad2b9 | Rust | cjpearce/boolfuck | /src/lib.rs | UTF-8 | 7,759 | 3.515625 | 4 | [] | no_license | pub fn boolfuck(code: &str, input: Vec<u8>) -> Vec<u8> {
let program = Program::compile(code);
let mut runtime = Runtime::new(program, input);
runtime.run();
runtime.output
}
#[derive(Debug, Clone, Copy)]
pub enum Instruction {
Read,
FlipBit,
JmpF(usize),
JmpT(usize),
Write,
Inc... | true |
8601aea36f128feb6fd418fb355655f3f6fe00fa | Rust | alexisvisco/searche.rs | /src/searcher/mod.rs | UTF-8 | 2,311 | 3.125 | 3 | [] | no_license | use std::sync::mpsc;
use std::collections::HashSet;
const BOLD_RED: &str = "\x1b[1;31m";
const RESET: &str = "\x1b[0;0m";
#[derive(Debug)]
pub struct Occurrences {
pub chunk_index: usize,
pub bulk_lines: String,
}
pub fn search(
pool_of_thread: &rayon::ThreadPool,
producer: mpsc::Sender<Occurrences>,... | true |
1ba00e73d14b3a8a55f536cfdf01c28d9e506a1e | Rust | kiwiyou/double-baskin-game | /thirtyone-backend/src/client.rs | UTF-8 | 4,048 | 2.640625 | 3 | [
"MIT"
] | permissive | use futures_util::stream::SplitStream;
use futures_util::StreamExt;
use log::{error, info};
use tokio::net::TcpStream;
use tokio::sync::mpsc::UnboundedSender;
use tokio::sync::oneshot;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::WebSocketStream;
use crate::game::GameRequest;
use crate::matcher:... | true |
e5e5a28ae05601fbad664497ecb4f51e794c8f0a | Rust | BlockCat/minispaceshipgame | /src/systems/move_system.rs | UTF-8 | 1,677 | 2.609375 | 3 | [] | no_license | use amethyst::ecs::System;
use amethyst::ecs::{ WriteStorage, ReadStorage, Join, Read};
use amethyst::core::Transform;
use amethyst::core::Time;
use amethyst::input::{InputHandler, StringBindings};
use crate::components::Velocity;
use crate::components::Ship;
pub struct MoveSystem;
impl<'a> System<'a> for MoveSyste... | true |
b8fb8c5b36b602b47f0f8ee38bc1f07389ee2def | Rust | ChewyGumball/advent_of_code_2020 | /18/a/src/main.rs | UTF-8 | 2,241 | 3.5 | 4 | [
"MIT"
] | permissive | use std::env;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn break_expression_line(line: String) -> Vec<String> {
let expanded = line.replace("(", "( ").replace(")", " )");
return expanded.split(" ").map(|s| String::from(s)).collect();
}
fn parse_file(file_name: &Path) -> Vec<Vec<St... | true |
1cb24afb2df1353b7030fe1a6361dfd673719d55 | Rust | BradHoffman96/word_count | /src/main.rs | UTF-8 | 1,443 | 3.1875 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, Write};
use std::collections::HashMap;
fn main() {
let filename = "src/THEGODFATHER.dat";
let file = File::open(filename).unwrap();
let reader = BufReader::new(file);
let mut words = HashMap::new();
for (_index, line) in reader.li... | true |
d19ce698fb0686faa8983c0672370e306ce4398d | Rust | sugyan/adventofcode | /2019/rust/day05/src/main.rs | UTF-8 | 1,113 | 3.21875 | 3 | [] | no_license | use intcode::Intcode;
use std::io::{BufRead, BufReader};
struct Solution {
program: Vec<i64>,
}
impl Solution {
fn new(inputs: &[String]) -> Self {
Self {
program: inputs[0]
.split(',')
.filter_map(|s| s.parse().ok())
.collect(),
}
... | true |
9d46719310cbf652d26fde1e43d5150b0838d803 | Rust | lesurp/rustycv | /src/core/frame.rs | UTF-8 | 1,638 | 3.0625 | 3 | [] | no_license | use super::base::{Pixel, Point};
pub type RawFrame = ndarray::Array2<Pixel>;
pub struct Frame(pub RawFrame);
impl Frame {
pub fn w(&self) -> usize {
self.0.len_of(ndarray::Axis(0))
}
pub fn h(&self) -> usize {
self.0.len_of(ndarray::Axis(1))
}
pub fn center(&self) -> (usize, usi... | true |
651cf05acb925fe62223301777100856eca2e510 | Rust | shirts/double | /examples/pattern_matching.rs | UTF-8 | 3,013 | 2.640625 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate double;
use double::matcher::*;
pub trait ProfitForecaster {
fn profit_at(&self, timestamp: i32) -> f64;
fn write_report_for(&self, timestamp: i32, dry_run: bool);
fn store_forecast_result(&self, result: Result<u32, String>);
}
mock_trait!(
MockForecaster,
profit_at(i32) ... | true |
40e9fa50850cc0af968193064debb3ac7f7ac9fa | Rust | Mark80/rust-projects | /rustlings/exercises/macros/macros4.rs | UTF-8 | 527 | 3.125 | 3 | [
"MIT"
] | permissive | // macros4.rs
// Make me compile! Execute `rustlings hint macros4` for hints :)
macro_rules! my_macro {
() => {
println!("Check out my macro!");
};
($val:expr) => {
println!("Look at this other macro: {}", $val);
}
}
#[macro_export]
macro_rules! vec2 {
( $( $x:expr ),* ) => {
... | true |
494adee6fe84ed60677acadf88cb9988717632aa | Rust | daniel5151/clicky | /clicky-core/src/devices/util/arcmutex.rs | UTF-8 | 1,915 | 3.125 | 3 | [] | no_license | use crate::devices::prelude::*;
use std::sync::Arc;
use std::sync::{LockResult, Mutex, MutexGuard};
/// Wrapper around Arc<Mutex<_>> which implements the `Device` and `Memory`
/// traits without having to explicitly deref + lock the underlying device.
#[derive(Debug)]
pub struct ArcMutexDevice<D> {
device: Arc<Mu... | true |
4cb01ed1aa8ba541158031a8c325f3633642ad80 | Rust | birkenfeld/ads-rs | /src/netid.rs | UTF-8 | 4,213 | 3.390625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Contains the AMS NetId and related types.
use std::convert::TryInto;
use std::fmt::{self, Display};
use std::io::{Read, Write};
use std::net::Ipv4Addr;
use std::str::FromStr;
use byteorder::{ReadBytesExt, WriteBytesExt, LE};
use itertools::Itertools;
use zerocopy::{AsBytes, FromBytes};
/// Represents an AMS NetI... | true |
c2e3935c87d6e0b27b094be182f91972e4681d96 | Rust | chenbobby/research-labs | /src/hashtable/mod.rs | UTF-8 | 653 | 3.40625 | 3 | [] | no_license | use std::fmt;
/// A trait for buckets of key-value tuples. Keys must be strings.
pub trait Bucket<T> {
fn get(&self, key: &str) -> Option<T>;
fn set(&mut self, key: &str, value: T);
fn remove(&mut self, key: &str);
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result;
}
impl<T> fmt::Debug for dyn Buck... | true |
79269e218dce5b63920d4d6d176515bfe37276ac | Rust | Amdahl-rs/tupleops | /crates/tupleops/src/tpl_concat_many.rs | UTF-8 | 2,652 | 3.09375 | 3 | [
"Apache-2.0",
"ISC",
"MIT"
] | permissive | crate::do_impl!("concat-many", tuple_concat_many, {
use crate::{concat_tuples, ConcatTuples, TupleConcat};
/// The resulting type when two or more tuples are concatenated.
///
/// ```
/// use same_types::assert_same_types;
/// use tupleops::ConcatMany;
///
/// assert_same_types!(
//... | true |
95288d8bc17f7c50afcd26b245f6fd43038116ca | Rust | ZippeyKeys12/seta | /src/util.rs | UTF-8 | 693 | 3.65625 | 4 | [] | no_license | pub trait Stack<T> {
fn push(&mut self, value: T);
fn pop(&mut self) -> Option<T>;
fn peek(&self) -> Option<&T>;
fn peek_mut(&mut self) -> Option<&mut T>;
}
impl<T> Stack<T> for Vec<T> {
fn push(&mut self, value: T) {
self.push(value)
}
fn pop(&mut self) -> Option<T> {
self... | true |
f98f2b7fcbe33bd0ebf3d486046306ead4f57843 | Rust | chabapok/rust_for_moron | /examples/box_example.rs | UTF-8 | 10,458 | 3.3125 | 3 | [] | no_license | /*
Преимущества и недостатки стека и кучи
Часто у новичков возникает вопрос - зачем нужен Box, если есть стек. Боксовый обьект удаляется,
когда Box удаляется. В чем смысл? Просто храним в стеке - и все!
Обьясняю.
Кратко. Используем Кучу если:
1. Размер обьекта неизвестен на этапе компиляции
2. Размер обьект... | true |
c2c08aa3cfc0ab5bb29c7bf977c82860a370f3b8 | Rust | Pauan/seed | /src/storage.rs | UTF-8 | 923 | 3.375 | 3 | [
"MIT"
] | permissive | //! Allows use of the Web Storage API / local storage.
//! MDN docs:
//! https://developer.mozilla.org/en-US/docs/Web/API/Storage
//! web-sys docs:
//! https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Storage.html
//! Example syntax:
//! https://github.com/rustwasm/wasm-bindgen/blob/master/examples/todomvc/sr... | true |
c9ebfb89af8a48f9d87f17879c457b368fdd6167 | Rust | Tmw/hamming-rs | /src/lib/blocks.rs | UTF-8 | 5,429 | 3.453125 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
use std::iter::FromIterator;
use super::bitvec::BitVec;
use super::block::Block;
pub struct Blocks(Vec<Block>);
impl From<&str> for Blocks {
fn from(data: &str) -> Blocks {
Blocks::new(data.as_bytes(), false)
}
}
impl Blocks {
/// `new` will take bytes and convert them to 16 ... | true |
00caea2e05a1a812e8310f8ccb8eb05026bfcb25 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/clap/examples/tutorial_builder/03_04_subcommands.rs | UTF-8 | 611 | 2.5625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
clap
:
:
{
arg
command
Command
}
;
fn
main
(
)
{
let
matches
=
command
!
(
)
/
/
requires
cargo
feature
.
propagate_version
(
true
)
.
subcommand_required
(
true
)
.
arg_required_else_help
(
true
)
.
subcommand
(
Command
:
:
new
(
"
add
"
)
.
about
(
"
Adds
files
to
myapp
"
)
.
arg
(
arg
!
(
[
NAME
]
)
)
)
.
get_ma... | true |
78f64d5b93db0e53dad2e20380f965833d770936 | Rust | PKAuth/rs-crypto-abstract | /src/asym/enc/x25519.rs | UTF-8 | 3,255 | 2.671875 | 3 | [] | no_license |
use ring::agreement::*;
use ring::rand::SystemRandom;
use untrusted::Input;
// use internal::{sha256};
use sym::enc as se;
// TODO: Figure out how to import this... XXX
// use sym::enc::aesgcm256;
// use ToAlgorithm;
pub(super) fn gen( rng : &SystemRandom) -> Option<ReusablePrivateKey> {
ReusablePrivateKey::gen... | true |
c69b0a5749316b715c11a2cd3a68b549b2d888a0 | Rust | Zheoni/ray-tracing | /src/object/translate.rs | UTF-8 | 1,034 | 3.09375 | 3 | [] | no_license | use super::*;
/// Translate transformation
pub struct Translate<H: Hittable> {
pub object: H,
pub offset: Vec3,
}
impl<H: Hittable> Translate<H> {
/// Creates a new translated object by a given offset
pub fn new(object: H, offset: Vec3) -> Self {
Self { object, offset }
}
}
impl<H: Hittab... | true |
0c8fd8876a94b0147a676b53c19dc0d7c362ff96 | Rust | mikialex/rivermesh | /src/main.rs | UTF-8 | 8,543 | 2.953125 | 3 | [] | no_license | #[derive(Debug, Copy, Clone)]
struct Vector3<T> {
x: T,
y: T,
z: T,
}
impl<T> Vector3<T> {
pub fn new(x: T, y: T, z: T) -> Vector3<T> {
Vector3 { x, y, z }
}
}
struct HalfEdgeVertex<T> {
position: Vector3<T>,
normal: Vector3<T>,
edge: *mut HalfEdge<T>, // one of the half-edges ... | true |
3c64682688ce476a2b7dd6a59beabb14889d7512 | Rust | pando85/miso | /src/style.rs | UTF-8 | 1,357 | 2.671875 | 3 | [] | no_license | use iced::{container, slider, Background, Color};
pub struct Container;
impl container::StyleSheet for Container {
fn style(&self) -> container::Style {
container::Style {
background: Some(Background::Color(Color::from_rgb8(0x36, 0x39, 0x3F))),
text_color: Some(Color::WHITE),
... | true |
58321e9d2c8f3d0f2c1771cbce4f2d13c2378cd9 | Rust | asny/metal-ray-tracing-rs | /metal_lib/src/rayintersector.rs | UTF-8 | 5,216 | 2.53125 | 3 | [
"MIT"
] | permissive |
use super::*;
use cocoa::foundation::{NSUInteger};
#[repr(u64)]
#[allow(non_camel_case_types)]
#[derive(Copy, Clone, Debug)]
pub enum MPSIntersectionDataType {
distance = 0,
distancePrimitiveIndex = 1,
distancePrimitiveIndexCoordinates = 2,
distancePrimitiveIndexInstanceIndex = 3,
distancePrimitiv... | true |
ef504565ac577c46b77f438f18a0dcfc38729b13 | Rust | seanpianka/rust-mongodb-ddd-repository | /src/lib.rs | UTF-8 | 3,930 | 2.953125 | 3 | [
"MIT"
] | permissive | pub mod mongo;
pub mod primitives;
mod user;
#[cfg(test)]
mod tests {
use crate::{
mongo,
primitives::{AggregateReadRepository, AggregateWriteRepository},
user::{ReadRepository, User},
};
use lazy_static;
const MONGODB_URL: &str = "mongodb://0.0.0.0:27017";
const MONGODB_TE... | true |
e51cbb380dea23bdf5806892a0d6589022c1b24e | Rust | ykafia/plotly | /plotly/examples/basic_charts_pure.rs | UTF-8 | 720 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use itertools_num::linspace;
use plotly::common::{
ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
};
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
use plotly::{Bar, NamedColor, PlotData as Plot, Rgb, Rgba, Scatter};
// Scatter Plots
fn simple_scatt... | true |
0357da3767b2144e87c4594ca50a1720ab3c8876 | Rust | mardiros/janeiro | /examples/echo_client.rs | UTF-8 | 2,013 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | extern crate janeiro;
#[macro_use]
extern crate log;
extern crate env_logger;
use std::str;
use std::io;
use janeiro::{Rio, Transport, Protocol, Reason};
struct EchoClientProtocol {
running: bool
}
impl EchoClientProtocol {
fn new() -> EchoClientProtocol {
EchoClientProtocol{running: true}
}
... | true |
105b1964bead1a226333f47c02a6d8a07ea308ae | Rust | FuGangqiang/RustPractices | /src/structure/unsafe_deque.rs | UTF-8 | 6,344 | 3.375 | 3 | [] | no_license | pub struct Deque<T> {
head: NodePtr<T>,
tail: NodePtr<T>,
}
struct NodePtr<T>(*mut Node<T>);
struct Node<T> {
elem: T,
next: NodePtr<T>,
prev: NodePtr<T>,
}
impl<T> Drop for Deque<T> {
fn drop(&mut self) {
while let Some(_) = self.pop_front() {}
}
}
impl<T> Deque<T> {
pub fn ... | true |
7c206ca4c965c44278506b3f126d0dffdfca49c3 | Rust | hanepjiv/column79-rs | /src/line_type.rs | UTF-8 | 4,790 | 2.90625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // -*- mode:rust; coding:utf-8-unix; -*-
//! line_type.rs
// Copyright 2016 hanepjiv
// @author hanepjiv <hanepjiv@gmail.com>
// @copyright The MIT License (MIT) / Apache License Version 2.0
// @since 2016/10/21
// @date 2020/04/12
// ////////////////////////////////////////////////////////////////////////////
... | true |
9103191142356b7abec6f1aa6b3e64bb467ac255 | Rust | mitrid-labs/bezier | /tests/io/store/eval/eval_result.rs | UTF-8 | 4,394 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use mitrid_core::base::Sizable;
use mitrid_core::base::Checkable;
use mitrid_core::base::Serializable;
use bezier_lib::io::Session;
use bezier_lib::io::eval::StoreEvalResult;
#[test]
fn test_new_none() {
let result = StoreEvalResult::new_none();
assert_eq!(result, StoreEvalResult::None);
}
#[test]
fn test_new... | true |
43a7bbfad79e6a8f771103d054ffe65503525a13 | Rust | dc25/errtest | /src/error_rc.rs | UTF-8 | 1,332 | 3.171875 | 3 | [] | no_license | use std::sync::Arc;
#[allow(dead_code)]
pub type Result<T> = std::result::Result<T, Error>;
#[allow(dead_code)]
pub fn general_error<T>(s:&'static str) -> Result<T> {
Err(Error::General(s))
}
#[derive(Debug, Clone)]
#[allow(dead_code)]
pub enum Error {
General(&'static str),
IO(Arc<std::io::Error>),
... | true |
22f4d8380d6a2b92204cb18aeb871892751b1a5d | Rust | Escapingbug/easy-repl | /src/completion.rs | UTF-8 | 3,004 | 2.828125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::rc::Rc;
use rustyline::{
completion::{Completer, FilenameCompleter, Pair},
hint::Hinter,
};
use rustyline_derive::{Helper, Highlighter, Validator};
use trie_rs::Trie;
use crate::repl::split_args;
#[derive(Helper, Validator, Highlighter)]
pub(crate) struct Completion {
pub(crate) trie: Rc<Trie<u8... | true |
3520fe34b05d838ccdcbd44f27868b25545da356 | Rust | andrewwhitehead/brangetree | /rust/src/lib.rs | UTF-8 | 1,521 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | mod error;
mod hash;
mod input;
mod path;
mod range;
mod tree;
pub use error::Error;
pub use hash::Digest;
pub use input::process_zipped_bits;
pub use path::{Path, PathJoin};
pub use range::{range_hasher, range_path_hasher, RangeParser, RangePathTracker, RangeTreeFolder};
pub use tree::{TreeFold, TreeFolder};
pub str... | true |
f7f683f0159b5fa03b548f3747622fee2889cf38 | Rust | charles1303/rust_api | /src/controller/user_controller.rs | UTF-8 | 214 | 2.59375 | 3 | [] | no_license | use service::user_service;
use std::vec;
use model::user::User;
pub fn get_users() -> vec::Vec<User>{
user_service::get_users()
}
pub fn create_user(user: User) -> User{
user_service::create_user(&user)
} | true |
8f2770dba64ce16f0fb42129b0c65239aa825c80 | Rust | 0xJonas/p5.colorSpaces | /src/cieluv.rs | UTF-8 | 4,667 | 2.765625 | 3 | [] | no_license | use wasm_bindgen::prelude::*;
use crate::TristimulusColor;
use crate::CIEXYZColor;
const CORRECTION_FACTOR_3RD_ROOT: [f32; 5] = [
0.6299605249474366,
0.7937005259840998,
1.0,
1.2599210498948732,
1.5874010519681994
];
#[wasm_bindgen]
#[derive(Debug)]
pub struct CIELuvColor(pub f32, pub f32, pub f3... | true |
be0927d707f36519cee23157e0ad1e251566d02b | Rust | arun-gupta/firecracker | /logger/src/metrics.rs | UTF-8 | 19,244 | 3.328125 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//! Defines the metrics system.
//!
//! # Design
//! The main design goals of this system are:
//! * Use lockless operations, preferably ones that don't require anything other than
//! simple reads/write... | true |
f72adfbbf49e81876030fca8b15dffabdd2455ce | Rust | Norbytus/wallhave_api | /src/main.rs | UTF-8 | 1,719 | 2.859375 | 3 | [] | no_license | use clap::{App, load_yaml};
use serde_derive::{Deserialize, Serialize};
use std::error::Error;
use std::fs::File;
use std::io::Read;
use toml::de::from_str;
use std::path::{Path, PathBuf};
use std::env::home_dir;
use std::fs::DirBuilder;
fn main() -> Result<(), Box<dyn Error>> {
let yml = load_yaml!("../arg.yml")... | true |
00ede8fec8908aea50cb954927d9fed093c5afff | Rust | kirkpetersen/rust-examples | /src/trie.rs | UTF-8 | 593 | 3.5 | 4 | [] | no_license | #[derive(Debug)]
pub struct TrieNode<K, V> {
key: K,
value: V,
l: Option<Box<TrieNode<K, V>>>,
r: Option<Box<TrieNode<K, V>>>
}
impl <K, V> TrieNode<K, V> {
pub fn new(k: K, v: V) -> TrieNode<K, V> {
TrieNode { key: k, value: v, l: None, r: None }
}
}
#[test]
fn check_the_trie_stuff() ... | true |
be5889a9d7b60a22a4f629bfedadf2901dc58f97 | Rust | peterallin/rideways | /ecs_systems/src/player_control_system.rs | UTF-8 | 1,046 | 2.65625 | 3 | [] | no_license | use ecs_components::{IsPlayer, Velocity};
use sdl_input::ControlState;
use specs::{Read, ReadStorage, System, WriteStorage};
pub struct PlayerControl;
impl<'a> System<'a> for PlayerControl {
type SystemData = (
Read<'a, ControlState>,
ReadStorage<'a, IsPlayer>,
WriteStorage<'a, Velocity>,
... | true |
8e928a4d86604843e8befeed1b2b89326b12a76a | Rust | abdullahwaqar/leetcode | /389.Find_the_Difference/src/main.rs | UTF-8 | 353 | 3.296875 | 3 | [] | no_license | struct Solution {}
impl Solution {
pub fn find_the_difference(s: String, t: String) -> char {
let mut ret = 0;
for _char in s.as_bytes() {
ret ^= _char;
}
for _char in t.as_bytes() {
ret ^= _char;
}
return ret as char;
}
}
fn main() {
... | true |
420e71aefb5d46ecf059f2629972f55314607ba0 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/futures-lite-1.11.3/src/stream.rs | UTF-8 | 78,016 | 3.25 | 3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Combinators for the [`Stream`] trait.
//!
//! # Examples
//!
//! ```
//! use futures_lite::stream::{self, StreamExt};
//!
//! # spin_on::spin_on(async {
//! let mut s = stream::iter(vec![1, 2, 3]);
//!
//! assert_eq!(s.next().await, Some(1));
//! assert_eq!(s.next().await, Some(2));
//! assert_eq!(s.next().await, S... | true |
62c237b98441d6f408d8b347f41dc948359659b8 | Rust | gabriel376/exercism | /rust/pythagorean-triplet/src/lib.rs | UTF-8 | 507 | 2.8125 | 3 | [] | no_license | use std::collections::HashSet;
use rayon::iter::{IntoParallelIterator, ParallelIterator};
pub fn find(sum: u32) -> HashSet<[u32; 3]> {
(1..sum / 3)
.into_par_iter()
.filter_map(|a| {
let b = ((sum - a).pow(2) - a.pow(2)) / (2 * (sum - a));
let c = sum - a - b;
m... | true |
66830fb892d259394df3c0315fb4396fb83080f1 | Rust | warp-tech/warpgate | /warpgate-core/src/state.rs | UTF-8 | 4,064 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::{Arc, Weak};
use anyhow::{Context, Result};
use sea_orm::{ActiveModelTrait, DatabaseConnection, EntityTrait};
use tokio::sync::{broadcast, Mutex};
use tracing::*;
use uuid::Uuid;
use warpgate_common::{ProtocolName, SessionId, Target};
use warpgate... | true |
d2055219a1d3a66300772ffb2c384364a2cbd90f | Rust | jblebrun/wrausmt | /src/syntax/indices.rs | UTF-8 | 2,029 | 2.84375 | 3 | [
"MIT"
] | permissive | /// ResolvedState is used to track whether or not the symbolic indices in the module have been
/// resolved into the proper numeric values. This needs to happen in a second pass after the
/// initial parse, since index usage may occur before the index has been defined.
///
pub trait ResolvedState: std::fmt::Debug {}
/... | true |
ab4ff2996da50600a848647b8d45a5da9a6cc4cf | Rust | TonalidadeHidrica/taiko-wiki-data-analysis | /src/range_slice.rs | UTF-8 | 1,503 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::ops::{Range, RangeFrom, RangeFull, RangeTo};
pub trait RangeSlice<T> {
fn start_bound_slice(&self) -> Option<&T>;
fn end_bound_slice(&self) -> Option<&T>;
}
impl<T> RangeSlice<T> for Range<T> {
fn start_bound_slice(&self) -> Option<&T> {
Some(&self.start)
}
fn end_bound_slice(&se... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.