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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4c6a1285af8a12d4563168774e4ae4a31d4669a9 | Rust | lucifer1004/AtCoder | /abc189/src/bin/b.rs | UTF-8 | 342 | 2.734375 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
mut x: usize,
liquor: [(usize, usize); n],
}
x *= 100;
let mut tot = 0;
for i in 0..n {
tot += liquor[i].0 * liquor[i].1;
if tot > x {
println!("{}", i + 1);
return;
}
}
... | true |
9f1e0ca737b58cb698026c14aba7dfb6a072f6d0 | Rust | yoava333/ctf-writeups | /googlectf_quals/2019/sandstone/ex.rs | UTF-8 | 4,187 | 2.8125 | 3 | [] | no_license | {
use std::io;
use std::io::prelude::*;
trait A {
fn my_func(&self) -> &mut [u64];
}
struct B {
b: u64,
}
struct C {
c: u64,
}
impl A for B {
fn my_func(&self) -> &mut [u64] {
get_dangling()
}
}
impl A for C {
fn... | true |
48e43606ab657088197690c51f5fca784a0b3442 | Rust | prabhugopal/Sprocket | /src/uart.rs | UTF-8 | 2,116 | 2.796875 | 3 | [
"MIT"
] | permissive | use x86::shared::io;
use traps;
use picirq;
use core::sync::atomic::{AtomicBool, Ordering};
const COM1: u16 = 0x3f8;
static UART_INITIALIZED: AtomicBool = AtomicBool::new(false);
pub struct Uart;
impl Uart {
pub fn new() -> Result<Uart, ()> {
// Consume token and init the UART (if present)
if !U... | true |
704e216fb72fc3487bfcd276ed9354ffbca54642 | Rust | Antiarchitect/rust_rectangle | /src/main.rs | UTF-8 | 1,597 | 4.03125 | 4 | [] | no_license | trait TraitPoint {
fn new(x: f64, y: f64) -> Self;
fn x(&self) -> &f64;
fn y(&self) -> &f64;
fn distance_to(&self, other: &Self) -> f64 {
((*other.x() - *self.x()).powi(2) + (*other.y() - *self.y()).powi(2)).sqrt()
}
}
struct Point {
x: f64,
y: f64
}
impl TraitPoint for Point {
... | true |
064957fb38024e382dda62595bef0f6adf8f8d3c | Rust | igowen/dashing | /src/graphics/render/tests.rs | UTF-8 | 8,966 | 2.90625 | 3 | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | // Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | true |
73f84c991b2218155e097afeed0b7456fc039c2c | Rust | willdoescode/william_lane_connect_four | /src/tests/test_new.rs | UTF-8 | 276 | 2.703125 | 3 | [] | no_license | use crate::*;
use std::io::stdout;
#[test]
fn test_new() {
let board = Game::new();
let normal = Game {
count: [6; 7],
board: [['-'; 7]; 6],
player: 'O',
moves: 0,
stdout: stdout(),
};
assert_eq!(board.display_board(), normal.display_board());
}
| true |
f46495786d14b20877fd97a8fb13c019aefe18c2 | Rust | trevday/rust-raytracer | /src/texture.rs | UTF-8 | 4,305 | 2.75 | 3 | [] | no_license | use crate::base::BasicTwoTuple;
use crate::color::RGB;
use crate::point::Point3;
use crate::utils::{clamp, noise, turbulence};
use image::{DynamicImage, GenericImageView};
use serde::Deserialize;
use std::{convert::TryFrom, ops, sync::Arc};
#[derive(Deserialize)]
pub struct TexCoord(pub BasicTwoTuple<f32>);
impl Cop... | true |
19b125e1f1a82c774884c64a43c3f22c618581d4 | Rust | Henning-K/exercism-tasks | /queen-attack/src/lib.rs | UTF-8 | 634 | 3.578125 | 4 | [] | no_license | pub struct ChessPosition {
x: i32,
y: i32,
}
pub struct Queen {
pos: ChessPosition,
}
impl ChessPosition {
pub fn new(x: i32, y: i32) -> Result<Self, String> {
if x < 0 || y < 0 || x > 7 || y > 7 {
return Err("Invalid Position".to_string());
}
Ok(ChessPosition { x: ... | true |
1dc92434201ac9796a74de289c7fd1fa7a99ecca | Rust | mdaffin/adventofcode | /2017/src/lib.rs | UTF-8 | 934 | 2.890625 | 3 | [
"MIT"
] | permissive | extern crate failure;
#[macro_use]
extern crate failure_derive;
use std::path::Path;
use std::fs::File;
use std::str::FromStr;
use std::io::{self, BufReader, Read};
#[derive(Fail, Debug)]
pub enum ParsePartError {
#[fail(display = "{} is not a valid part.", _0)]
InvalidPartNumber(String),
}
pub enum Part {
... | true |
29ad69dc37b6912d69dc4e3a8b6dae920a0cf9f8 | Rust | joelverhagen/adventofcode | /2017/rust/day8/src/main.rs | UTF-8 | 3,709 | 3.65625 | 4 | [] | no_license | use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::collections::HashMap;
#[derive(Debug)]
enum Operator {
LessThan,
LessThanOrEqual,
GreaterThan,
GreaterThanOrEqual,
Equal,
NotEqual,
}
#[derive(Debug)]
struct Condition {
register: String,
operator: Operator,
... | true |
498b83dfc3d09ea4beeed66df0843d09448d0000 | Rust | Geraet/kompositum-rs | /src/tests.rs | UTF-8 | 787 | 2.546875 | 3 | [
"MIT"
] | permissive | // Copyright(c) 2021 René Hansen.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#[cfg(test)]
mod tests {
use crate::{builder, printer::Printer, IDType};
use multimap::MultiMap;
const TREE_MAP_DEF: &[(IDType, IDType)] = &[(1, 2), (1, 3), (1, 4), (4, 5), (4, 6), (1, 7)];
#[t... | true |
afdba96152f21bbc30e902012dc5cb7fb547977e | Rust | Logicalshift/flowbetween | /animation/src/storage/storage_error.rs | UTF-8 | 326 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | ///
/// Errors from the storage API
///
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum StorageError {
/// General failure
General,
/// The storage could not be initialised
FailedToInitialise,
/// The storage cannot continue because of an eariler error
CannotContinueAfterEr... | true |
6b560be340c378479745eb241cf77d06fea6bf2f | Rust | cryptoballot/cryptoballot | /cryptoballot/src/ballot.rs | UTF-8 | 10,078 | 3.265625 | 3 | [] | no_license | use indexmap::IndexMap;
use prost::Message;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Ballot {
pub id: String,
pub contests: Vec<u32>, // List of contest indexes
/// Application specific properties.
///
/// Hashmaps are not allowed because their unstable ordering leads to non-dete... | true |
d6d6c662d018baebd23e5bfde9bd3daedf53804b | Rust | Lakret/aoc2020 | /src/d06.rs | UTF-8 | 1,533 | 3.40625 | 3 | [] | no_license | use std::collections::HashSet;
pub fn solve(input: &str) -> Option<Box<usize>> {
let sum_of_counts = input
.trim_end()
.split("\n\n")
.map(|group| group.chars().filter(|ch| *ch != '\n').collect::<HashSet<_>>().len())
.sum();
Some(Box::new(sum_of_counts))
}
pub fn solve2(input: &str) -> Option<Box... | true |
bc4a024fabc61af2ce4d81df31164215a66913be | Rust | gyng/rcue | /src/parser.rs | UTF-8 | 20,090 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use cue::{Command, Cue, CueFile, Track};
use errors::CueError;
use util::{next_string, next_token, next_values, timestamp_to_duration};
/// Parses a CUE file at `path` into a [`Cue`](struct.Cue.html) struct.
///
/// Strict mode (`strict: true`) will ... | true |
0b65979d722623554e3a4b08e49d3802e46553be | Rust | Excloudx6/freq-word-counter-rust | /src/utils/traverse.rs | UTF-8 | 6,161 | 3 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use anyhow::Result;
use serde::Serialize;
use std::fmt::Display;
use std::path::PathBuf;
const STDIN: &str = "-";
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Input {
FsGlob { pattern: String, ignore_case: bool },
FsPath(PathBuf),
Stdin,
String(String),
}
impl Serialize for... | true |
7c28e7e518c8a7bcfa68c73e2b92d34d25753221 | Rust | maxueshan/quick_get_start_rust | /src/bin/mpsc_test.rs | UTF-8 | 445 | 3.40625 | 3 | [
"MIT"
] | permissive | use std::sync::mpsc;
use std::thread;
fn main() {
// 创建一个通道
let (tx, rx): (mpsc::Sender<i32>, mpsc::Receiver<i32>) =
mpsc::channel();
// 创建线程用于发送消息
thread::spawn(move || {
// 发送一个消息,此处是数字id
tx.send(1).unwrap();
});
// 在主线程中接收子线程发送的消息并输出
println!("receive {}", rx.recv(... | true |
5f0c4a3fae092772b258809a8bb279b00788fa3b | Rust | peter-suggate/cef-sys | /build.rs | UTF-8 | 5,019 | 2.59375 | 3 | [
"MIT"
] | permissive | extern crate bindgen;
use std::env;
use std::fs;
use std::io::Write;
use std::path::PathBuf;
fn cef_dir() -> PathBuf {
PathBuf::from(env_var("CEF_DIR"))
}
// The wrapper file is the entry point to the native code we are creating bindings for.
fn create_wrapper_file() {
let wrapper_file = PathBuf::from(env_va... | true |
ce73e9123687cb380e7bb60b16e8a310d552b843 | Rust | kyle-mccarthy/blackjack-rs | /src/blackjack/blackjack_hand.rs | UTF-8 | 8,331 | 3.0625 | 3 | [] | no_license | use crate::blackjack::hand_value::{HandValue, WithHandValue};
use crate::blackjack::player::PlayerType;
use crate::blackjack::wager::{Wager, WithWager};
use crate::cards::{Card, Hand};
use std::sync::Arc;
pub enum HandState {
Default,
WagerPlaced,
CardsDealt,
HandPlayed,
}
pub enum ResultsState {
... | true |
bbe862c809525ed0b94f174f3eb20b8857fd3991 | Rust | oky-123/build_your_own_x | /ProgrammingLanuage/iridium/src/assembler/integer_parsers.rs | UTF-8 | 859 | 3.1875 | 3 | [] | no_license | use nom::digit;
use nom::types::CompleteStr;
use crate::assembler::Token;
named!(pub integer<CompleteStr, Token>,
ws!(
do_parse!(
tag!("#") >>
reg_num: digit >>
(
Token::IntegerOperand{value: reg_num.parse::<i32>().unwrap()}
)
)
)... | true |
fbbdb0697c554df31d4b931a8d1a6a7f81cc2d97 | Rust | YruamaLairba/wm8731-alt | /src/command/sampling.rs | UTF-8 | 22,809 | 3.234375 | 3 | [
"MIT"
] | permissive | //! Command builder for sampling configuration.
//!
//! This module offer two style for building a command, a nice style using a master clock and a raw
//! style allowing more advance use.
//!
//! # Style with master clock
//! With this method, the builder is instantiated with a marker to indicate the internal master c... | true |
0089bd058d57d1551f2b161364544098976aa9f4 | Rust | mluluz/lighthouse | /beacon_node/db/src/stores/beacon_block_store.rs | UTF-8 | 7,951 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use super::BLOCKS_DB_COLUMN as DB_COLUMN;
use super::{ClientDB, DBError};
use ssz::Decodable;
use std::sync::Arc;
use types::{BeaconBlock, Hash256, Slot};
#[derive(Clone, Debug, PartialEq)]
pub enum BeaconBlockAtSlotError {
UnknownBeaconBlock(Hash256),
InvalidBeaconBlock(Hash256),
DBError(String),
}
pub s... | true |
982a7a18f8c37a6ba242937c6ebea6a4adb7bedd | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/crossbeam-utils/src/atomic/atomic_cell.rs | UTF-8 | 19,180 | 2.703125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #
!
[
allow
(
clippy
:
:
unit_arg
)
]
use
crate
:
:
primitive
:
:
sync
:
:
atomic
:
:
{
self
AtomicBool
}
;
use
core
:
:
cell
:
:
UnsafeCell
;
use
core
:
:
cmp
;
use
core
:
:
fmt
;
use
core
:
:
mem
:
:
{
self
ManuallyDrop
MaybeUninit
}
;
use
core
:
:
sync
:
:
atomic
:
:
Ordering
;
use
core
:
:
ptr
;
#
[
cfg
(
feature
=... | true |
bf17204e361cf2852381aca655e8fcfc7724f353 | Rust | delandtj/kay | /src/actor.rs | UTF-8 | 625 | 2.609375 | 3 | [
"MIT"
] | permissive | use compact::Compact;
use crate::id::{RawID, TypedID};
use crate::storage_aware::StorageAware;
pub trait ActorOrActorTrait: 'static {
type ID: TypedID;
}
impl<A: Actor> ActorOrActorTrait for A {
type ID = <Self as Actor>::ID;
}
pub trait Actor: Compact + StorageAware + 'static {
type ID: TypedID;
fn ... | true |
c0164e78709438f82109a92ce7728126cead297b | Rust | kennytm/borsholder | /src/args.rs | UTF-8 | 2,103 | 3.140625 | 3 | [
"MIT"
] | permissive | //! Argument parsing
use reqwest::Url;
use serde::Serializer;
use std::net::SocketAddr;
use std::path::PathBuf;
/// Stores the command line argument.
#[derive(Debug, StructOpt, Serialize)]
pub struct Args {
/// The token to access the GitHub APIs.
#[structopt(short = "t", long = "token", help = "GitHub token"... | true |
52878630ad486c4e22dca0785dfc6f9afc61a73d | Rust | dflemstr/rq | /src/value/messagepack.rs | UTF-8 | 3,886 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use std::io;
use ordered_float;
use rmpv;
use crate::error;
use crate::value;
#[derive(Debug)]
pub struct MessagePackSource<R>(R)
where
R: io::Read;
#[derive(Debug)]
pub struct MessagePackSink<W>(W)
where
W: io::Write;
#[inline]
pub fn source<R>(r: R) -> MessagePackSource<R>
where
R: io::Read,
{
Me... | true |
eaae369f9c009aaabd7abcdb7e99ca1796a1266c | Rust | declanvk/scalable-concurrent-containers | /src/tree_index.rs | UTF-8 | 21,782 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | //! The module implements [`TreeIndex`].
mod error;
mod leaf;
mod leaf_node;
mod node;
use crate::ebr::{Arc, AtomicArc, Barrier, Tag};
use error::{InsertError, RemoveError, SearchError};
use leaf::{Leaf, Scanner};
use node::Node;
use std::borrow::Borrow;
use std::cmp::Ordering;
use std::fmt;
use std::iter::FusedIter... | true |
e2b95d034b5e7e1fdb3eed5fde0199ae11a86d91 | Rust | xshade-lang/xshade-parser | /src/error/mod.rs | UTF-8 | 2,716 | 3.078125 | 3 | [
"MIT"
] | permissive | use ::std::convert::From;
use ::std::error::Error;
use ::std::fmt;
use ::ast::Span;
pub type ParseResult<T> = Result<T, ParseError>;
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
pub enum ParseErrorKind {
Unknown = 0,
UnrecognizedCharacter = 1,
InvalidTopLevelItem = 1000,
InvalidStructName = 2... | true |
c31f410dd04fc3b4cd12b8cf48b6bee1ec617e67 | Rust | poma/clap | /examples/21_aliases.rs | UTF-8 | 1,275 | 3.46875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use clap::{App, Arg};
fn main() {
let matches = App::new("MyApp")
.subcommand(
App::new("ls")
.aliases(&["list", "dir"])
.about("Adds files to myapp")
.version("0.1")
.author("Kevin K.")
.arg(
Ar... | true |
7aa8ff12d2bbaeb9e6549f26947122160c5c4542 | Rust | silverweed/ecsde | /inle/inle_common/src/stringid.rs | UTF-8 | 4,414 | 2.890625 | 3 | [] | no_license | use std::convert::From;
#[cfg(debug_assertions)]
use {std::collections::hash_map::Entry, std::collections::HashMap, std::sync::RwLock};
#[derive(PartialEq, Hash, Copy, Clone, PartialOrd, Eq, Ord)]
pub struct String_Id(u32);
#[cfg(debug_assertions)]
lazy_static! {
static ref STRING_ID_MAP: RwLock<HashMap<String_I... | true |
503011710ba89eeb2667fe15bc2a8d243b957ea7 | Rust | binh-vu/semantic-modeling | /gmtk/src/graph_models/domains/int_domain.rs | UTF-8 | 753 | 3.125 | 3 | [
"MIT"
] | permissive | use graph_models::traits::Domain;
pub struct IntDomain {
min: i32,
max: i32,
}
impl IntDomain {
pub fn new(min: i32, max: i32) -> IntDomain {
return IntDomain { min, max }
}
}
impl Domain for IntDomain {
type Value = i32;
fn numel(&self) -> usize {
(self.max - self.min + 1) a... | true |
04dcb28bec7efb17dce54e7e2e8338cf16e3854f | Rust | shirvan/fastlyzer | /src/rw.rs | UTF-8 | 1,222 | 2.984375 | 3 | [
"Unlicense",
"MIT"
] | permissive | use crate::FastResult;
use concat_reader::concat_path;
use std::{
fs::OpenOptions,
io::{BufRead, BufReader},
path::Path,
};
/// Main input interface.
///
/// We wanted to allow users to read a directory or a file without having to choose a different
/// flag for each. This way users don't have to remember ... | true |
428544c71a467fbe5581fed8c53c6981a3ba8128 | Rust | y-oksaku/Competitive-Programming | /AtCoder/abc/161e_2.rs | UTF-8 | 1,179 | 2.546875 | 3 | [] | no_license | #![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::*;
use std::collections::*;
use std::cmp::*;
use std::mem::swap;
use std::f64::consts::*;
const MO... | true |
edb48e1fe69724e183e47937500776ca2a60795e | Rust | mgw854/adventofcode2019 | /src/day7/mod.rs | UTF-8 | 8,747 | 2.78125 | 3 | [] | no_license | use super::intcode_8086::{Intcode8086};
use bus::BusReader;
pub struct Amplifier {
processor: Intcode8086,
pub output: BusReader<i32>
}
impl Amplifier {
pub fn create(phase_setting: u8, input_signal: i32, mut cpu: Intcode8086, mut input: BusReader<i32>) -> Amplifier {
let cpu_input : crossbeam_channel::Send... | true |
ba0fed58c21409a8a0acb8a7117b811facb6a182 | Rust | zeroDivisible/advent-of-code | /2019/day_02/src/main.rs | UTF-8 | 3,261 | 3.609375 | 4 | [] | no_license | use std::{
fs::File,
io::{prelude::*, BufReader},
path::Path,
};
fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> {
let file = File::open(filename).expect("no such file");
let buf = BufReader::new(file);
buf.lines()
.map(|l| l.expect("Could not parse line"))
.collec... | true |
0e03be4fc969966944526400efc9ef1f06ccd276 | Rust | duchainer/sea-query | /src/backend/postgres/types.rs | UTF-8 | 1,879 | 2.890625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::*;
use crate::extension::postgres::types::*;
impl TypeBuilder for PostgresQueryBuilder {
fn prepare_type_create_statement(&self, create: &TypeCreateStatement, sql: &mut SqlWriter, collector: &mut dyn FnMut(Value)) {
write!(sql, "CREATE TYPE ").unwrap();
if let Some(name) = &create.name ... | true |
00de287bd08343e89a8c9c4e068f7474b0e998db | Rust | po-gl/Raytracer | /src/pattern/ring_pattern.rs | UTF-8 | 2,067 | 3.71875 | 4 | [
"MIT"
] | permissive | /// # Ring Patterns
/// `ring_pattern` is a module to represent ring patterns (bull's eye)
use crate::color::Color;
use crate::tuple::Tuple;
use crate::matrix::Matrix4;
use crate::pattern::Pattern;
use std::fmt::{Formatter, Error};
use std::any::Any;
use crate::float::Float;
#[derive(Debug, PartialEq, Copy, Clone)]
p... | true |
e689ae3e6bd1514cbe7a350f6ead3e52f05c2e40 | Rust | JohnTitor/crates.io | /conduit-axum/examples/server.rs | UTF-8 | 1,111 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![deny(clippy::all)]
use axum::routing::get;
use conduit_axum::{
server_error_response, spawn_blocking, ConduitRequest, HandlerResult, ServiceError,
};
use axum::response::IntoResponse;
use std::io;
use std::thread::sleep;
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
let router = a... | true |
7cb53a3fba9bccf0b1872161bf7c261e1d587db9 | Rust | microvm/immix-rust | /src/heap/immix/immix_space.rs | UTF-8 | 12,853 | 2.671875 | 3 | [] | no_license | use heap::immix;
use heap::gc;
use common::Address;
use common::AddressMap;
extern crate std;
extern crate memmap;
extern crate libc;
use std::*;
use std::collections::LinkedList;
use std::sync::Mutex;
use std::sync::Arc;
// this table will be accessed through unsafe raw pointers. since Rust doesn't provide a data s... | true |
82e1bcd0988973908b9a4832290b59f0d72f4e90 | Rust | Syphonx/aoc-2019 | /src/day3.rs | UTF-8 | 6,554 | 3.234375 | 3 | [] | no_license | /*
--- Day 3: Crossed Wires ---
*/
use failure::Error;
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum WireDirection {
Invalid,
Up,
Right,
Down,
Left,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Point {
x: i32,
y: i32,
}
impl Point {
const INVALID_POINT: Point = Point { x: 0, y: 0 };
pub fn n... | true |
42633cc44a662285ee4a36a50b43686629df1052 | Rust | guilhemSmith/mod1 | /src/algo/heightmap.rs | UTF-8 | 4,244 | 2.84375 | 3 | [] | no_license | use super::{Map, DIM};
use crate::engine::{Entity, EntityStore, Mesh};
use glam::{Vec2, Vec3};
use std::any::Any;
use std::fs::File;
use std::io::{BufRead, BufReader};
const WEIGHT_DIST: f32 = 5.0;
const MAP_SIZE: usize = DIM * DIM;
const MAP_SCALE: f32 = 1.0;
#[derive(Debug)]
pub struct HeightMap {
points: Map<MAP... | true |
f78e9c4b4d3a91192a8862ec79e20aeef209c17c | Rust | Jason-S-Ross/stylish-stringlike | /src/widget/hbox.rs | UTF-8 | 6,553 | 3.125 | 3 | [] | no_license | use crate::text::{Pushable, Width};
use crate::widget::{Fitable, Truncateable};
use std::iter::FromIterator;
/// A displayable box of text widgets.
pub struct HBox<'a, T: Truncateable> {
elements: Vec<Box<dyn Fitable<T> + 'a>>,
}
impl<'a, T: Truncateable> Default for HBox<'a, T> {
fn default() -> Self {
... | true |
52f83f8b0f6aee4613fc0e4016c6a94ec7e36555 | Rust | fredmorcos/attic | /Projects/Crawl (Rust)/crawl-hyper-2/src/main.rs | UTF-8 | 1,908 | 2.71875 | 3 | [
"Unlicense"
] | permissive | #![warn(clippy::all)]
use futures::future::{self, Future};
use futures::stream::Stream;
use hyper::{
rt::{self, Future as HyperFuture},
service::service_fn,
Body, Error as HyperError, Method, Request, Response, Server, StatusCode,
};
use std::{
error::Error,
fmt::{self, Display},
net::{AddrPars... | true |
40c1c621d3baba83094d0b6ee775c1e67347cac5 | Rust | HolisticCoders/shelob-core | /src/add.rs | UTF-8 | 444 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::attribute::Attribute;
use crate::node::Node;
#[derive(Debug)]
pub struct Add {
a: Attribute,
b: Attribute,
}
impl Node for Add {
fn new() -> Self {
Add {
a: Attribute::new(),
b: Attribute::new(),
}
}
fn evaluate(&self) {
... | true |
1741a78195c5e35cbc5da2ecd7a1cfc3636dbbf2 | Rust | pwin/ferricstore | /src/structure/bitindex.rs | UTF-8 | 7,455 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use byteorder::{ByteOrder,BigEndian};
use super::bitarray::*;
use super::logarray::*;
use futures::prelude::*;
use tokio::prelude::*;
// a block is 64 bit, which is the register size on modern architectures
// Block size is not tunable, and therefore no const is defined here.
/// The amount of 64-bit blocks that go ... | true |
3aa13e6b4d0cb994a01ade97e8f6ae0bf2e8acc3 | Rust | Lyr-7D1h/rust_tutorials | /collections/src/main.rs | UTF-8 | 1,973 | 3.28125 | 3 | [] | no_license | use std::io;
use std::collections::HashMap;
fn main() {
mean_test();
manage_comp_io();
}
fn manage_comp_io() {
let mut departments : HashMap<String, Vec<String>> = HashMap::new();
let mut input = String::new();
while !input.eq("e") {
input.clear();
println!("'a (name) (departmen... | true |
63fa5e67d1c8896d8620f001b3c45b9394e8647b | Rust | leshow/exercism | /hackerrank/src/l4sum.rs | UTF-8 | 1,209 | 3.65625 | 4 | [] | no_license | // 18. 4Sum
// Medium
// Given an array nums of n integers and an integer target, are there elements
// a, b, c, and d in nums such that a + b + c + d = target? Find all unique
// quadruplets in the array which gives the sum of target.
// Note:
// The solution set must not contain duplicate quadruplets.
// Example:... | true |
2781d7ca551ed6f54e7704f861e99cf544777f77 | Rust | Devolutions/devolutions-gateway | /crates/jmux-proxy/src/codec.rs | UTF-8 | 3,915 | 2.90625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use anyhow::Context as _;
use bytes::BytesMut;
use jmux_proto::{Header, Message};
use tokio_util::codec::{Decoder, Encoder};
/// This is a purely arbitrary number
pub const MAXIMUM_PACKET_SIZE_IN_BYTES: usize = 4096;
pub struct JmuxCodec;
impl Decoder for JmuxCodec {
type Item = Message;
type Error = anyhow... | true |
67a6f5f89cff656eefd147a9af2a353b976800b9 | Rust | ramn/dbmigrate | /src/drivers/mod.rs | UTF-8 | 1,269 | 2.921875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | ///! Driver interface and implementations
use url::{SchemeType, UrlParser};
use errors::{MigrateResult, invalid_url};
mod mysql;
mod postgres;
pub trait Driver {
fn ensure_migration_table_exists(&self);
fn remove_migration_table(&self);
fn get_current_number(&self) -> i32;
fn set_current_number(&sel... | true |
46fd28969f2de610ec8a3e4b2cc635601d5fdc45 | Rust | bqqbarbhg/adventofcode | /2022/05/part2.rs | UTF-8 | 1,781 | 3.109375 | 3 | [] | no_license | mod common;
use std::{io::{self, BufRead}};
use std::vec::Vec;
use regex::Regex;
use common::{match_iter, match_capture, ensure_size};
fn get_disjoint<T>(ts: &mut [T], a: usize, b: usize) -> (&mut T, &mut T) {
assert!(a != b, "a ({}) and b ({}) must be disjoint", a, b);
assert!(a < ts.len(), "a ({}) is out of ... | true |
9852efb952fa6c58f4691b4a4e4ff7eb49925193 | Rust | Lol3rrr/rust-facomp | /src/frontend/ir/pretty_print.rs | UTF-8 | 3,154 | 3.34375 | 3 | [] | no_license | use super::{IRExpression, IRFunction, IRNode};
fn print_expression(prefix: &str, exp: &IRExpression) {
let next_prefix = format!("{} ", prefix);
match exp {
&IRExpression::Value(ref value) => {
println!("{}Value: '{:?}'", prefix, value);
}
&IRExpression::Variable(ref name) ... | true |
d1f92512b9bbcf0d1f1cb837aaaf833666aab7eb | Rust | sym233/leetcode_problems | /1010. Pairs of Songs With Total Durations Divisible by 60/1010. Pairs of Songs With Total Durations Divisible by 60.rs | UTF-8 | 339 | 2.515625 | 3 | [] | no_license | impl Solution {
pub fn num_pairs_divisible_by60(time: Vec<i32>) -> i32 {
const T: usize = 60usize;
let mut arr = [0; T];
let mut count = 0;
for &n in time.iter() {
let n = n as usize % T;
count += arr[(T - n) % T];
arr[n] += 1;
}
re... | true |
f3f2589379486646800ccbdc2a97bb6fc3f5d987 | Rust | aaronjamesmarshallau/spaghetti | /src/conversion/units/mod.rs | UTF-8 | 3,319 | 3 | 3 | [] | no_license | use diesel::backend::Backend;
use diesel::deserialize::FromSql;
use diesel::serialize::Output;
use diesel::sql_types::SmallInt;
use diesel::types::ToSql;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, Copy, AsExpression, FromSqlRow)]
#[sql_type = "SmallInt"]
pub enum UnitOfMeasurem... | true |
051044d6ef65a3a3d24a1da26b4758012ec9410c | Rust | Axect/Woroxide | /src/parser/conv.rs | UTF-8 | 2,352 | 2.9375 | 3 | [] | no_license | extern crate puruda;
use crate::parser::word::{TotalWords, Word, Words};
use std::fs::File;
use std::io::{BufRead, BufReader};
use puruda::*;
use rand::prelude::*;
#[allow(dead_code)]
pub fn smart_to_total_words() -> TotalWords {
let mut words_vec: Vec<Words> = Vec::new();
for i in 1..22 {
let words =... | true |
daacdb035f25e4a97c1af6f84d3a4aeead0eb2c4 | Rust | medsec/catena-rust | /src/default_instances/dragonfly.rs | UTF-8 | 1,760 | 2.90625 | 3 | [] | no_license | //! An implementation of Catena-Dragonfly. This variant of Catena provides
//! memory hardness. It should be used in a setting, where the defender can
//! afford to allocate much memory without any problems.
/// The choices for H, H', F, Γ and Φ for Catena-Dragonfly.
///
/// These choices are:
///
/// - H: Blake2b
///... | true |
63ac2ee4b4918832a2c4a9b5d59ce657565771b5 | Rust | Vicfred/codeforces-rust | /fancy_fence_270A.rs | UTF-8 | 487 | 3.015625 | 3 | [
"BSD-3-Clause"
] | permissive | // https://codeforces.com/problemset/problem/270/A
// simple math
use std::io;
fn main() {
let mut t = String::new();
io::stdin()
.read_line(&mut t)
.unwrap();
let t: i64 = t.trim().parse().unwrap();
for _ in 0..t {
let mut a = String::new();
io::stdin()
.read_line(&mut ... | true |
f22e92d99ceec8ef45926b92fb54099eebbc5f3c | Rust | simvux/rust-discord-tui | /src/discord/message.rs | UTF-8 | 1,819 | 3.234375 | 3 | [] | no_license | use std::fmt;
use termion::color;
use tui::style::{Color, Style};
use tui::widgets::Text;
pub enum Embed {
Link(String),
Image(String),
Video(String),
Nothing,
}
pub struct Message {
pub content: String,
pub embed: Embed,
pub author: String,
}
impl Message {
pub fn new(author: &str, c... | true |
0e62debc8ded8d531c8d154a8e5f6da683762e3f | Rust | bgbahoue/amiwo | /src/macros.rs | UTF-8 | 1,711 | 3.09375 | 3 | [
"MIT"
] | permissive | //! ## Macros
//!
//! This module defintes the following macros
//!
//! - hyper_request! : pseudo function `fn hyper_request(hyper::method::Method, url: hyper::client::IntoUrl, [headers: hyper::header::Headers], [body: Into<hyper::body::Body<'a>>]) -> Result<amiwo::contrib::rocket::ResponseJSON, GenericError>
//! - ami... | true |
61c2006fb64792cc2b66ac8a4067c5c5b6071929 | Rust | frankfanslc/evfs | /src/local_fs.rs | UTF-8 | 3,081 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::{EntryType, InternalError, RecvMsg, VfsDriver, VfsError};
use log::*;
use std::fs::File;
use std::io::Read;
use std::path::Path;
#[derive(Clone)]
pub struct LocalFs {
root: String,
}
impl LocalFs {
pub fn new() -> LocalFs {
LocalFs {
root: String::new(),
}
}
}
impl ... | true |
83cdd887147ee089c9b9dfa4f42874c3c64f8d47 | Rust | ftilde/rust-x86asm | /src/test/instruction_tests/instr_btc.rs | UTF-8 | 15,390 | 2.578125 | 3 | [
"MIT"
] | permissive | use instruction_def::*;
use test::run_test;
use Operand::*;
use Reg::*;
use RegScale::*;
use RegType::*;
use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode};
#[test]
fn btc_1() {
run_test(
&Instruction {
mnemonic: Mnemonic::BTC,
operand1: S... | true |
698e6a19185f20d159974b697f9b6d0bc37019ea | Rust | bpowers/liquid-types | /src/eval.rs | UTF-8 | 7,862 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashMap;
use crate::common::Op2;
use crate::lambdal::{Expr, Imm, Op};
type Closure = HashMap<String, Value>;
#[derive(PartialEq, Eq, Debug, Clone)]
pub enum Value {
VInt(i64),
VBool(bool),
VClosure(Box<Closure>, String, Box<Expr>),
VIntArray(Vec<i64>),
}
fn vint(v: Value) -> i6... | true |
5d5acc62235ced530e528fd61b2efdb746e5caa5 | Rust | ponchofiesta/webassembly-tests-rust | /benches/benchmarks.rs | UTF-8 | 482 | 2.578125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[macro_use]
extern crate criterion;
use criterion::Criterion;
//use criterion::black_box;
//fn a(data: &[f64]) -> f64 {
// let mut a = 0.0;
// for i in data {
// let b: f64 = data.len() as f64 * i;
// a += b;
// }
// a
//}
//
//fn criterion_benchmark(c: &mut Criterion) {
// let list = [1... | true |
2fef6da0ea5607167cc677632995f337073dea88 | Rust | jwilm/iron-hmac | /src/error.rs | UTF-8 | 3,041 | 2.796875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt;
use std::io;
use iron::{IronError, status};
use std::str::Utf8Error;
use rustc_serialize::hex::FromHexError;
/// Error type for the hmac middleware
#[derive(Debug)]
pub enum Error {
/// Some sort of io::Error occurred
IoError(io::Error),
/// The request's provided HMAC is invalid.
Invali... | true |
1c1cf3aa403e062f0015b63a216efdea8e05ec67 | Rust | OsProgramadores/op-desafios | /desafio-05/leovano/rust/src/stats/max.rs | UTF-8 | 1,943 | 2.78125 | 3 | [] | no_license | use super::{BuildHasher, Entry, Map};
use super::{Funcionario, Salary};
use fields::Text;
use std::sync::Arc;
// Alias: MaxStats->Data
#[allow(dead_code)]
type MaxData<'a> = (usize, Salary, Vec<Arc<Funcionario<'a>>>);
// Alias: MaxStats->Iter
#[allow(dead_code)]
type MaxIter<'a> = (Text<'a>, Salary, Vec<Arc<Funciona... | true |
141c13e752b0f373f75b7797f1ac77bb4ae87a6b | Rust | vinay-swamy/clustereval | /src/lib.rs | UTF-8 | 12,519 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::fs ;
use std::collections::HashMap;
use std::collections::HashSet;
use std::iter::FromIterator;
use std::iter::Iterator;
use ndarray::Array2;
use rayon;
use rayon::prelude::*;
use flate2::read::GzDecoder;
use std::io::prelude::*;
use glob::glob;
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[derive(Debug)... | true |
f4945730d829c877ed9e66b05b378e251d4b199a | Rust | geofflittle/aws-pass | /src/store/default_pass_store.rs | UTF-8 | 5,894 | 2.703125 | 3 | [] | no_license | use super::pass_store::PassStore;
use crate::{
creds::StsLocalMfaCredsProvider,
dao::{
pass_dao::Tag,
pass_dao::{Filter, PassDao, Password},
sm_pass_dao::SmPassDao,
},
util,
};
use anyhow::Result;
use async_trait::async_trait;
use rusoto_core::Region;
use std::fs;
use std::{path:... | true |
c9bc5ffa1609a3616106a56340f07f63e080cf45 | Rust | ZenGo-X/pps-gc | /pps-garbled-circuits/src/plain.rs | UTF-8 | 3,309 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::{iter, ops};
use anyhow::{ensure, Result};
use rand::Rng;
use super::byte_array::ByteArray;
use super::consts::{INDEX_BYTES, LOCATION_BYTES};
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct TableSize {
pub m: usize,
pub l: usize,
}
// todo: remove const generic
#[derive(PartialEq, Debug, Clone... | true |
5887d143ff1315b0f43f02f770b58cc2bbcb8864 | Rust | Guo-astro/pt2itp | /native/src/classify/mod.rs | UTF-8 | 7,222 | 2.515625 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | use postgres::{Connection, TlsMode};
use std::{
collections::HashMap,
convert::From,
fs::File,
io::{BufWriter, Write},
};
use neon::prelude::*;
use crate::{
pg,
pg::{InputTable, Table},
stream::{AddrStream, GeoStream, PolyStream},
Tokens,
};
#[derive(Serialize, Deserialize, Debug)]
st... | true |
40c2a2930d96faad28200d205e950edfe6672d40 | Rust | input-output-hk/jormungandr | /jcli/src/jcli_lib/transaction/info.rs | UTF-8 | 3,506 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::jcli_lib::{
transaction::{common, Error},
utils::{io, OutputFormat},
};
use chain_addr::AddressReadable;
use chain_impl_mockchain::transaction::{Balance, UnspecifiedAccountIdentifier};
use jormungandr_lib::{crypto::hash::Hash, interfaces::TransactionInputType};
use serde_json::json;
use std::{io::Wri... | true |
229b0fb1df16c43d8bb93030c9e2f76a0ef57830 | Rust | jannikkeye/monkey-rust | /interpreter/src/repl.rs | UTF-8 | 1,366 | 2.875 | 3 | [] | no_license | use crate::evaluator;
use crate::lexer;
use crate::object::Object;
use crate::parser;
use std::io::{stdin, stdout, Write};
const PROMPT: &str = ">> ";
pub fn start() {
println!(
"
WELCOME TO THE MONKEY PROGRAMMING LANGUAGE! HAVE FUN, HUMAN!
"
);
let mut evaluator = evaluator::Evaluator::new();... | true |
e69fedec3021e886fa624ab70ca863f8fec9244d | Rust | facebook/fbthrift | /thrift/lib/rust/src/metadata.rs | UTF-8 | 2,843 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by appl... | true |
297cc6a5589b2361446912ceee84aa7dd97d1f20 | Rust | c410-f3r/rust-smallvec | /src/array.rs | UTF-8 | 1,048 | 3.578125 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | /// Types that can be used as the backing store for a SmallVec
pub unsafe trait Array {
/// The type of the array's elements.
type Item;
/// Returns a mutable pointer to the first element of the array.
fn as_mut_ptr(&mut self) -> *mut Self::Item;
/// Returns a pointer to the first element of the arr... | true |
e5ecfd859d12c8347de7fea22806d2b7e7425b88 | Rust | MichaelBell/tuplesieve | /src/main.rs | UTF-8 | 4,109 | 3 | 3 | [] | no_license | use std::io::{self, Write};
const TUPLE_LEN: usize = 10;
const MAX_PRIME: usize = 1400;
const MAX_PRIME_OVER_2: usize = MAX_PRIME / 2;
const MIN_PRIME: usize = 3;
const SIEVE_SIZE: usize = 1000000;
const MAX_GAP: usize = 120000000;
// 3, 5 at 4
// 7 at 10
// 11 at 14, 16
// So mod 2310 we have (1271, 1691)
//const O... | true |
94dd9152d339f35f9c431441d871c79a2e637bdc | Rust | teohhanhui/makepad | /render/src/pass.rs | UTF-8 | 7,690 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::cx::*;
#[derive(Default, Clone)]
pub struct Pass {
pub pass_id: Option<usize>
}
impl Pass {
pub fn begin_pass(&mut self, cx: &mut Cx) {
if self.pass_id.is_none() { // we need to allocate a CxPass
self.pass_id = Some(if cx.passes_free.len() != 0 {
cx.pas... | true |
d9c45a9c28969970d6038d7b11c434a466c4d12e | Rust | csirkeee/advent2020 | /day9a/src/main.rs | UTF-8 | 831 | 3.03125 | 3 | [] | no_license | use std::error::Error;
use std::io;
use std::io::BufRead;
fn main() -> Result<(), Box<dyn Error>> {
let stdin = io::stdin();
let mut v: Vec<i64> = Vec::new();
for line in stdin.lock().lines() {
if let Ok(n) = line?.parse() {
let len = v.len();
if len >= 25 {
... | true |
6361b62d1f73ddfd9c7e98944c1bc93ef5e0527d | Rust | simonchatts/fsevent-rust | /examples/fsevent-demo.rs | UTF-8 | 435 | 2.515625 | 3 | [
"MIT"
] | permissive | extern crate fsevent;
use std::sync::mpsc::channel;
use std::thread;
#[cfg(not(target_os="macos"))]
fn main() {}
#[cfg(target_os="macos")]
fn main() {
let (sender, receiver) = channel();
let _t = thread::spawn(move || {
let fsevent = fsevent::FsEvent::new(vec![".".to_string()]);
fsevent.obser... | true |
b3bf2a73ec747a462420b6d458c1473861fe4814 | Rust | ziliang8658/CalaRender | /src/RenderManager.rs | UTF-8 | 6,291 | 3.046875 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, BufReader, BufRead};
use std::path::Path;
mod Geometry;
use Geometry::Vec3f;
pub struct SceneManager {
pub models: Vec<Model>,
pub lights: Vec<Light>,
}
pub struct Model {
meshId: i32,
materidId: i32,
position: Vec3f,
rotation: Vec3... | true |
1d8115d738ad11d28d0e2d57233b32e40e032377 | Rust | sdleffler/type-level-logic-rs | /src/strong/mod.rs | UTF-8 | 313 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! "Strongly" enforced (non-SFINAE-style) type operators. Here, "strong" means that if you use
//! a type operator from this module, Rust will complain if it can't guarantee an `impl` for it
//! and you haven't listed it as a trait bound in a `where` clause.
pub mod boolean;
pub mod ternary;
pub mod balanced;
| true |
c37bea4f9610cb231978f27b712ebc8ce0ece744 | Rust | NightRoadIx/IntraLenguaje | /parimpar.rs | UTF-8 | 589 | 3.796875 | 4 | [] | no_license | use std::io;
fn input(user_message: &str) -> io::Result<String> {
use std::io::Write;
print!("{}", user_message);
io::stdout().flush()?;
let mut buffer: String = String::new();
io::stdin().read_line(&mut buffer)?;
Ok(buffer.trim_right().to_owned())
}
fn main() {
let num... | true |
328480ca73d1bb310fe92cdd841dea478975cf74 | Rust | skrapi/ClojureRS | /src/namespace.rs | UTF-8 | 911 | 2.90625 | 3 | [] | no_license | use crate::rust_core::{AddFn, StrFn};
use crate::value::ToValue;
use crate::value::Value;
use crate::Symbol;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
#[derive(Debug, Clone)]
pub struct Namespace {
pub name: Symbol,
mappings: RefCell<HashMap<Symbol, Rc<Value>>>,
}
impl Namespace ... | true |
a634884cbfa961aaf57619eea61816debc6b7c7d | Rust | bytecodealliance/wasmtime | /crates/test-programs/wasi-http-tests/src/bin/outbound_request_get.rs | UTF-8 | 1,068 | 2.53125 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use anyhow::{Context, Result};
use wasi_http_tests::bindings::wasi::http::types::{Method, Scheme};
struct Component;
fn main() {}
async fn run() -> Result<(), ()> {
let res = wasi_http_tests::request(
Method::Get,
Scheme::Http,
"localhost:3000",
"/get?some=arg&goes=here",
... | true |
a0264408127c08a67439167c69f6c30a4051614a | Rust | EngineersBox/NES-Emulator | /src/cpu/utils.rs | UTF-8 | 185 | 2.6875 | 3 | [] | no_license | // Verifies if hex address in a legal range.
pub fn check_hex_range(addr: u16) -> bool {
return if addr < 0x0000 || addr > 0xFFFF {
false
} else {
true
};
}
| true |
148673a1d4f93b40d8d6ddd769ac210e8bee6093 | Rust | gnoliyil/fuchsia | /src/devices/bin/driver_tools/src/subcommands/i2c/subcommands/transact/args.rs | UTF-8 | 846 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2022 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 {argh::FromArgs, std::path::PathBuf};
#[derive(FromArgs, Debug, PartialEq)]
#[argh(
subcommand,
name = "transact",
description = "Sends a ... | true |
15688589aa3c4acc4477eeb27642d73c399f5af7 | Rust | diath/ayame | /src/services/nickserv.rs | UTF-8 | 4,690 | 2.90625 | 3 | [] | no_license | use std::collections::HashMap;
use async_trait::async_trait;
use tokio::sync::Mutex;
use crate::client::Client;
use crate::service::Service;
pub struct NickServ {
pub nicks: Mutex<HashMap<String, String>>,
}
impl NickServ {
pub fn new() -> NickServ {
NickServ {
nicks: Mutex::new(HashMap... | true |
4b940ec0c20860f03678722ddec6eb4cf695f97e | Rust | kotnik/rustful | /examples/handler_storage.rs | UTF-8 | 2,400 | 3.34375 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate rustful;
use std::io::{self, Read};
use std::fs::File;
use std::path::Path;
use std::sync::{Arc, RwLock};
use std::error::Error;
use rustful::{Server, Context, Response, Handler, TreeRouter};
use rustful::Method::Get;
fn main() {
println!("Visit http://localhost:8080 to try this example... | true |
67966d047395ad3d734a7cd4ad144fd28b9a8269 | Rust | IThawk/rust-project | /rust-master/src/bootstrap/doc.rs | UTF-8 | 25,194 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | //! Documentation generation for rustbuilder.
//!
//! This module implements generation for all bits and pieces of documentation
//! for the Rust project. This notably includes suites like the rust book, the
//! nomicon, rust by example, standalone documentation, etc.
//!
//! Everything here is basically just a shim ar... | true |
5d2f73cf25fa341765e065d0c679edf9d897efcc | Rust | aptend/leetcode-rua | /Rust/src/n0945_minimum_increment_to_make_array_unique.rs | UTF-8 | 518 | 2.96875 | 3 | [] | no_license | pub fn min_increment_for_unique(a: Vec<i32>) -> i32 {
let mut A = a;
A.sort_unstable();
let mut n = -1i32;
let mut ans = 0i32;
for &x in A.iter() {
if n < x {
n = x;
} else {
ans += n - x + 1;
n += 1;
}
}
ans
}
#[test]
fn test_945(... | true |
9e13fc897a49106118c298a8624ad5095f102b30 | Rust | 0x192/iced_aw | /src/graphics/card.rs | UTF-8 | 8,253 | 2.828125 | 3 | [
"MIT"
] | permissive | //! Displays a [`Card`](Card).
//!
//! *This API requires the following crate features to be activated: card*
use iced_graphics::{
backend, defaults, Backend, Color, Defaults, HorizontalAlignment, Point, Primitive, Rectangle,
Renderer, VerticalAlignment,
};
use iced_native::{mouse, Element, Layout};
pub use cr... | true |
216b647ea72657a8aaef254ad0c0e3d3e2fd25a1 | Rust | Sam-Gebhardt/ChessGame | /src/AI/min_max.rs | UTF-8 | 4,054 | 3.1875 | 3 | [] | no_license | /*
Chess AI that is built upon min/max with alpha pruning
https://www.chessprogramming.org/Minimax
https://www.chessprogramming.org/Alpha-Beta
https://vitcapstoneproject.wordpress.com/2018/02/26/evaluating-a-board-position/
*/
use crate::board::Board;
use crate::pieces::piece_type;
use crate::pieces::sign_checker;
... | true |
2a1152836773d6b0b14d9bc8def3416744badbaa | Rust | abalmos/etcd-client | /src/lib.rs | UTF-8 | 6,792 | 2.5625 | 3 | [
"MIT"
] | permissive | //! An [etcd](https://github.com/etcd-io/etcd) v3 API client for Rust.
//! It provides asynchronous client backed by [tokio](https://github.com/tokio-rs/tokio) and [tonic](https://github.com/hyperium/tonic).
//!
//! # Supported APIs
//!
//! - KV
//! - Watch
//! - Lease
//! - Auth
//! - Maintenance
//! - Cluster
//! - L... | true |
c183f30ed722617a356c78c129b68c49e4f2ac82 | Rust | Dherse/secs | /codegen/src/entity.rs | UTF-8 | 2,183 | 2.71875 | 3 | [] | no_license | use proc_macro2::TokenStream;
use crate::{component::Component, ecs::ECS, GenericOutput};
pub(crate) fn make_entity_builder(
main: &ECS,
components: &[Component],
generics: &GenericOutput,
) -> TokenStream {
let name = main.as_entity_builder_ident();
let fields = components.iter().map(|comp| {
... | true |
a666beb63614eb5764e64f411973b9f07e541bb3 | Rust | rusterlium/rustler | /rustler/src/resource.rs | UTF-8 | 9,922 | 3.1875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Support for storing Rust data in Erlang terms.
//!
//! A NIF resource allows you to safely store Rust structs in a term, and therefore keep it across
//! NIF calls. The struct will be automatically dropped when the BEAM GC decides that there are no
//! more references to the resource.
use std::marker::PhantomData;... | true |
ee8c490a49a4839349561cbb12d2d35de05a76f1 | Rust | Kryndex/tfs | /atomic-hashmap/src/lib.rs | UTF-8 | 2,071 | 3.125 | 3 | [
"MIT"
] | permissive | //! Implementation of a lock-free, atomic hash table.
//!
//! This crate provides a high-performance implementation of a completely lock-free (no mutexes, no
//! spin-locks, or the alike) hash table.
//!
//! The only instruction we use is CAS, which allows us to atomically update the table.
//!
//! # Design
//!
//! The... | true |
03278843363ed80b2fd6f9c45e019135710c38d6 | Rust | luojia65/emu6 | /libemu6/src/riscv/exec.rs | UTF-8 | 20,800 | 2.5625 | 3 | [] | no_license | use super::fetch::*;
use super::imm::{Imm, Uimm};
use super::regfile::{Csr, XReg, FReg};
use super::*;
use crate::error::Result;
use crate::mem64::Physical;
use crate::size::{Isize, Usize};
use thiserror::Error;
#[derive(Error, Clone, Debug)]
pub enum ExecError {
#[error("extension is not supported")]
Extensio... | true |
437141bc0a9638b2fc0e35cf864d38851ccb5326 | Rust | kingxsp/filewatcher | /src/lib.rs | UTF-8 | 4,793 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use std::fs::File;
use std::io::SeekFrom;
use std::io::BufReader;
use std::io::prelude::*;
use std::os::unix::fs::MetadataExt;
use std::io::ErrorKind;
pub struct FileWatcher {
filename: String,
inode: u64,
position: u64,
reader: BufReader<File>,
finish: bool
}
impl Clone for FileWatcher {
fn clon... | true |
6730004fb0160376db60b3ad0202430ea377b8df | Rust | Metastone/automaton-rules | /src/compiler/lexer.rs | UTF-8 | 12,020 | 3.640625 | 4 | [
"MIT"
] | permissive | /// This module provides lexical analysis functions
use std::fs::File;
use std::io;
use std::io::{BufReader, Read, Seek, SeekFrom};
use std::fmt;
static DELIMITERS: [char; 5] = ['{', '}', '(', ')', ','];
static SINGLE_CHAR_OPERATORS: [char; 2] = ['<', '>'];
static TWO_CHAR_OPERATORS: [&str; 6] = ["&&", "||", "==", "!... | true |
2fb3ca2c0bc8952c78c7dad0a5f733a77cbe5acd | Rust | google/rrg | /crates/rrg/src/action/deprecated/stat.rs | UTF-8 | 19,541 | 2.671875 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Google LLC
//
// Use of this source code is governed by an MIT-style license that can be found
// in the LICENSE file or at https://opensource.org/licenses/MIT.
//! A handler and associated types for the file stat action.
//!
//! A file stat action collects filesystem metadata associated with a parti... | true |
3a23873497097fb9f4d6918b8c4988a4fda4203c | Rust | shun159/vr_types | /src/netlink/message.rs | UTF-8 | 2,602 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use super::raw::{nlmsghdr, NLMSG_LENGTH};
use super::Serialize;
use crate::genetlink::GenericNetlinkMessage;
use netlink_sys::Socket;
use std::process;
use zerocopy::LayoutVerified;
#[derive(Debug)]
pub struct NetlinkMessage<P> {
pub ty: u16,
pub flags: u16,
pub seq: u32,
pub pid: u32,
pub payload:... | true |
c4be8cdf17ed008d310934810155f374a3f96201 | Rust | thejpster/mcp794xx-rs | /src/common/datetime.rs | UTF-8 | 2,811 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Common date/time function
use super::super::{BitFlags, DateTime, Error, Hours, Mcp794xx, Register, Rtcc};
use super::{decimal_to_packed_bcd, hours_from_register, hours_to_register, packed_bcd_to_decimal};
use interface;
impl<DI, E> Rtcc for Mcp794xx<DI>
where
DI: interface::WriteData<Error = Error<E>> + inter... | true |
046fceba178613b5c001ae77cda1697cc31212da | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/chrono/src/div.rs | UTF-8 | 985 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive |
pub use num_integer::{div_floor, div_mod_floor, div_rem, mod_floor};
#[cfg(test)]
mod tests {
use super::{div_mod_floor, mod_floor};
#[test]
fn test_mod_floor() {
assert_eq!(mod_floor(8, 3), 2);
assert_eq!(mod_floor(8, -3), -1);
assert_eq!(mod_floor(-8, 3), 1);
ass... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.