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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8d9bbfbbfd116027e2f21b7b8677142928678286 | Rust | robertohuertasm/futurify | /src/futures_01.rs | UTF-8 | 3,836 | 3.671875 | 4 | [
"MIT"
] | permissive | //! A library to help you convert your sync functions into non-blocking thread futures.
//!
//! Futurify uses `futures 0.1` if you opt-in by using the `futures_01` feature and opting out of the default features.
//!
//! # Examples
//!
//! A simple `actix-web` server serving async endpoints:
//!
//! ```rust,no_run
//! u... | true |
1d6b1533ee06110e6dc55513861b18d7ef24910e | Rust | ultracold273/leetcode-rs | /src/contest_191/pr4.rs | UTF-8 | 2,000 | 3.140625 | 3 | [] | no_license |
// Calculate combination
fn C(a: usize, b: usize) -> f64 {
let denominator = (1..=b).fold(1f64, |prod, i| prod * i as f64);
let nominator = ((a-b+1)..=a).fold(1f64, |prod, i| prod * i as f64);
nominator / denominator
}
// dp[c][i][p][q]
// * c - color assigned to the first box
// * i - number of balls i... | true |
518b79c713b77a31fffa14c2fc0e940c21285673 | Rust | myg133/otpl-core | /src/util.rs | UTF-8 | 1,713 | 3.71875 | 4 | [
"Apache-2.0"
] | permissive | pub trait VecSliceCompare<T: PartialEq> {
fn compare(&self, s: &[T]) -> bool;
}
impl<T: PartialEq> VecSliceCompare<T> for Vec<T> {
fn compare(&self, s: &[T]) -> bool {
if self.len() != s.len() {
return false;
}
for i in 0..self.len() {
if self[i] != s[i] {
... | true |
1992499222a1b16785f8303f4a9265832802ea97 | Rust | aethertap/audio | /audio/src/dynamic.rs | UTF-8 | 29,043 | 3.546875 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! A dynamically sized, multi-channel audio buffer.
use audio_core::{
Buf, Channel, ChannelMut, Channels, ChannelsMut, ExactSizeBuf, ResizableBuf, Sample,
};
use std::cmp;
use std::fmt;
use std::hash;
use std::mem;
use std::ops;
use std::ptr;
use std::slice;
mod iter;
pub use self::iter::{Iter, IterMut};
/// A ... | true |
dbf24aeb1ce76400972607b1013f4df179bd2564 | Rust | termapps/enquirer | /src/multi_select.rs | UTF-8 | 2,431 | 3.4375 | 3 | [
"MIT"
] | permissive | use clap::Parser;
use dialoguer::theme::ColorfulTheme;
use std::{io::Result, iter::repeat};
/// Prompt that allows the user to select multiple items from a list of options
#[derive(Debug, Parser)]
pub struct MultiSelect {
/// Message for the prompt
#[clap(short, long)]
message: String,
/// Makes the ... | true |
aafaa3eadbe08df0fb55e48509f950f8514612fe | Rust | TrionProg/server_game | /newModule.rs | UTF-8 | 4,205 | 3.515625 | 4 | [] | no_license | use std::thread;
use std::thread::JoinHandle;
use std::sync::{Mutex,Arc,RwLock,Weak};
struct AppData{
module:RwLock<Option<Arc<Module>>>,
}
#[derive(PartialEq, Eq, Copy, Clone)]
enum ModuleState{
Initialization,
Processing,
Finish,
Error,
}
struct Module{
appData:Weak<AppData>,
threadHa... | true |
bd1af0f33854e1bcda4c9fb020f53128794c3373 | Rust | alyti/aoc-2019 | /src/common/sif.rs | UTF-8 | 2,542 | 3.515625 | 4 | [
"MIT"
] | permissive | //! Implements the Space Image Format from day 8.
use std::str;
pub type Row = Vec<u8>;
pub type Layer = Vec<Row>;
#[derive(Debug, Clone)]
pub struct SpaceImage {
pub resolution: (u32, u32),
pub layers: Vec<Layer>
}
impl SpaceImage {
pub fn load((x, y): (u32, u32), raw: &str) -> Self {
// TODO: T... | true |
01cd5b8017a8275077c7c6dea0e6ec0920195853 | Rust | dcramer/volta | /crates/volta-core/src/shell/bash.rs | UTF-8 | 2,131 | 2.8125 | 3 | [
"BSD-2-Clause-Views",
"BSD-2-Clause"
] | permissive | use std::path::{Path, PathBuf};
use super::{Postscript, Shell};
pub(crate) struct Bash {
pub(crate) postscript_path: PathBuf,
}
impl Shell for Bash {
fn postscript_path(&self) -> &Path {
&self.postscript_path
}
fn compile_postscript(&self, postscript: &Postscript) -> String {
match p... | true |
ec0fbbe2ecca39431666249908fe58d4103be96c | Rust | azinit/backend | /api-internal/src/routes/cards/create.rs | UTF-8 | 1,734 | 2.625 | 3 | [] | no_license | use crate::generated::components::responses::{CardsCreateError, CardsCreateFailed};
use crate::generated::{
components::{
request_bodies::CardsCreateRequestBody, responses::CardsCreateSuccess, schemas::Card,
},
paths::cards_create::{Error, Response},
};
use actix_web::web::{self, Data};
use cardbox_... | true |
5336abab8e6f1b773f05c2669dda6287b6fe3329 | Rust | paritytech/parity-common | /kvdb-shared-tests/src/lib.rs | UTF-8 | 9,206 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2020 Parity Technologies
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except accor... | true |
60b1e59e094882500fa021130c40c2fa353ea4a8 | Rust | eviltak/physics2d-rs | /src/world/body/mod.rs | UTF-8 | 3,633 | 2.78125 | 3 | [
"MIT"
] | permissive | mod pair;
pub use self::pair::BodyPair;
use crate::math::{Vec2, Cross};
use crate::shapes::{Shape, Matter};
use crate::world::Transform;
use crate::math::Bounds;
use crate::collision::broad_phase;
/// The identifier used for looking up a `Body` in a `World`.
///
/// An identifier is used to avoid the need for an `... | true |
f80c61075ffec0aa23126019dbb1c2b4e2d461e5 | Rust | davidgovea/advent-of-code-18 | /2022/src/bin/06.rs | UTF-8 | 1,033 | 3.28125 | 3 | [
"WTFPL"
] | permissive | use std::collections::HashSet;
fn find_first_preamble_index(input: &str, size: usize) -> Option<u32> {
for (i, candidate) in input.chars().collect::<Vec<_>>().windows(size).enumerate() {
let set: HashSet<&char> = HashSet::from_iter(candidate.iter());
if set.len() == size {
return Some((... | true |
d44cf9fcf806daca276c3603b5dea371f2f30053 | Rust | twh2898/lib_dice | /src/lib.rs | UTF-8 | 2,601 | 3.484375 | 3 | [
"MIT"
] | permissive | #![deny(missing_docs,
missing_debug_implementations, missing_copy_implementations,
trivial_casts, trivial_numeric_casts,
unstable_features,
unused_import_braces, unused_qualifications)]
//! A library for parcing dice rolls using nom.
//!
//! ## Usage
//! ```no-run
//! extern crate lib_d... | true |
6d57ae7ac164db16da97f7dbddb3ccffdd9fb491 | Rust | azaharakis/toy-robot-rust | /src/main.rs | UTF-8 | 2,027 | 3.015625 | 3 | [] | no_license | #[macro_use]
extern crate failure;
use crate::board::Board;
use crate::commands::{run_commands_against, Commands};
use crate::direction::Direction;
use crate::errors::ApplicationErrors;
use crate::robot::Robot;
mod board;
mod commands;
mod direction;
mod errors;
mod movement;
mod parse_input;
mod point;
mod robot;
st... | true |
c0430a77d28552e0cb472646d29cb29ce1518e98 | Rust | Sentido-Labs/mvnc | /examples/mnist.rs | UTF-8 | 3,652 | 2.984375 | 3 | [] | no_license | extern crate half;
extern crate mvnc;
extern crate rand;
use std::fs::File;
use std::io::{self, Read};
use half::{consts, f16};
use mvnc::{Device, Graph};
use mvnc::graph::Blocking;
use mvnc::log;
use rand::{Rng, ThreadRng};
pub fn main() {
log::set_log_level(&log::LogLevel::Verbose).expect("Setting log level ... | true |
6f9fa1762d8e507d829e5087cc0a1ddda5089437 | Rust | cmaughan/practice | /rust/aoc/src/bin/year_2021/day8.rs | UTF-8 | 1,848 | 3.203125 | 3 | [] | no_license | use std::collections::HashMap;
fn solve1((_,b): &(Vec<&str>, Vec<&str>)) -> usize {
b.iter().filter(|x| [2,3,4,7].contains(&x.len())).count()
}
pub fn part1(data: &Vec<(Vec<&str>, Vec<&str>)>) -> usize {
data.iter().map(solve1).sum::<usize>()
}
pub fn solve2((ins, outs): &(Vec<&str>, Vec<&str>)) -> usize {
... | true |
3f959d30b21cdf104da8eabf62c433098891a06b | Rust | pleasewhy/unicycle | /src/lock.rs | UTF-8 | 4,846 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![no_std]
#[cfg(not(feature = "parking-lot"))]
mod internals {
//! Manual implementation using atomics.
use core::sync::atomic::{AtomicIsize, Ordering};
/// A simplified RwLock implementation which only supports voluntary locking.
#[repr(C)]
pub struct RwLock {
state: AtomicIsize,
}
... | true |
69cea14854c4de624b64a84a24c1972a617fe451 | Rust | wisehead/rust_lib | /01.basic/11.error_handling/error.rs | UTF-8 | 257 | 3.21875 | 3 | [] | no_license | use std::fs::File;
fn main() {
let f = File::open("hello.txt");
match f {
Ok(file) => {
println!("File opened successfully.");
},
Err(err) => {
println!("Failed to open the file.");
}
}
}
| true |
4dead5ae7527d676415c816c7c328e48d86cae40 | Rust | shaileshaanand/learning_rust | /05/02_array.rs | UTF-8 | 401 | 3.3125 | 3 | [] | no_license | fn main() {
let arr1 = [1, 2, 3, 4, 5];
let arr2: [i32; 5] = [1, 2, 3, 4, 5];
let mut arr3: [i32; 5] = [0; 5];
println!("{:?} {:?} {:?}", arr1, arr2, arr3);
arr3[2] = 10;
println!("{:?}", arr3);
println!("at ind 2 {}", arr3[2]);
println!("len {}", arr3.len());
show(arr3)
}
fn show(a... | true |
e8ce11b9fa778c3c1077dfa5252bd40069282ccc | Rust | EthanYidong/riimote | /src/flags.rs | UTF-8 | 815 | 2.859375 | 3 | [] | no_license | use bitflags::bitflags;
use std::convert::TryInto;
bitflags! {
pub struct ButtonFlags: u16 {
const D_PAD_LEFT = fb(0);
const D_PAD_RIGHT = fb(1);
const D_PAD_DOWN = fb(2);
const D_PAD_UP = fb(3);
const PLUS = fb(4);
const TWO = sb(0);
const ONE = sb(1);
... | true |
4486c91b022333f433b62231d4177b67c95c43be | Rust | 01intelligence/hulk | /src/jwt/parser.rs | UTF-8 | 1,224 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use jsonwebtoken::{decode, decode_with_key_fn, Algorithm, DecodingKey, Validation};
use super::{JwtError, MapClaims, StandardClaims};
const ALGORITHMS: &[Algorithm] = &[Algorithm::HS256, Algorithm::HS384, Algorithm::HS512];
pub fn parse_with_standard_claims(token: &str, key: &[u8]) -> anyhow::Result<StandardClaims> ... | true |
8bdd5f4ecc4b971d417481dc7c6d2d8f12534a3a | Rust | tildeio/libcruby-sys | /src/encoding.rs | UTF-8 | 2,136 | 2.75 | 3 | [] | no_license | use super::*;
use libc::c_int;
extern {
/// Returns the encoding index of the provided Ruby object
///
/// * `obj` - a variety of different Ruby object types are accepted
/// * Returns an integer value corresponding to the encoding index or `-1`
/// if encoding cannot be determined.
///
///... | true |
3fc187a259aacae713e7fb9825e953ba4294ad0c | Rust | scottwillmoore/chip16 | /src_old/cpu.rs | UTF-8 | 1,764 | 3.109375 | 3 | [
"MIT"
] | permissive | use failure::Error;
use flags::Flags;
use instruction::{Condition, Instruction, Operation};
use memory::{Load, Memory, Store, VideoMemory};
use registers::Registers;
use rom::Rom;
use self::Condition::*;
use self::Operation::*;
#[derive(Default)]
pub struct Cpu {
memory: Memory,
registers: Registers,
fla... | true |
ffc468c58a9c506e0b8d25a3cc8e64ae60689ccf | Rust | mactsouk/introRustLC | /day2/L4/using_mutex.rs | UTF-8 | 671 | 3.515625 | 4 | [] | no_license | use std::sync::{Arc, Mutex};
use std::thread;
fn fibonacci(n: i32) -> i32 {
if n == 0 {
return 0;
}
if n <= 1 {
return 1;
}
else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
fn main() {
let sum = Arc::new(Mutex::new(0));
let mut threads_vec = vec![];
... | true |
011b68329c42fe272612bb9b8365623bfed9c28e | Rust | digideskio/haret | /src/vr/vr_ctx_summary.rs | UTF-8 | 1,556 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use rabble::Pid;
use super::replica::VersionedReplicas;
use super::vr_ctx::VrCtx;
/// This is all the state about a `VrCtx` that can be retrieved and sent over the wire to admin
/// clients.. There is a lot of informatio... | true |
4cf7f7f58999e9908fbdec70d6cc0ef46da40429 | Rust | ThomasZumsteg/project-euler | /problem_0026.rs | UTF-8 | 2,584 | 3.4375 | 3 | [] | no_license | #[macro_use]
extern crate clap;
use common::set_log_level;
use std::collections::HashMap;
struct Fraction {
remainer: usize,
divisor: usize,
}
impl Fraction {
fn new(num: usize, denom: usize) -> Fraction {
Fraction { remainer: num, divisor: denom }
}
}
impl Iterator for Fraction {
type I... | true |
23d5df25c0741935eb9f9208057bb71171542825 | Rust | synapticarbors/exercism | /rust/phone-number/src/lib.rs | UTF-8 | 626 | 3.53125 | 4 | [] | no_license | fn is_valid(nums: &[char]) -> bool {
nums.iter().enumerate().all(|(i, c)| match i {
0 | 3 => matches!(c, '2'..='9'),
_ => true,
})
}
pub fn number(user_number: &str) -> Option<String> {
let nums: Vec<char> = user_number.chars().filter(char::is_ascii_digit).collect();
match nums.len() {... | true |
700c375b3c72b41f4d1204f9fe30fb8ce93ef634 | Rust | nirya-istari/dumb_os | /kernel/src/io/buffered/buf_writer.rs | UTF-8 | 3,160 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use crate::io::{Error, Result, Write, DEFAULT_BUF_CAPACITY};
use alloc::vec::Vec;
use core::fmt::Display;
#[derive(Debug)]
pub struct BufWriter<W> {
inner: W,
buffer: Vec<u8>,
}
impl<W: Write> BufWriter<W> {
pub fn new(inner: W) -> BufWriter<W> {
BufWriter::with_capacity(DEFAULT_BUF_CAPACITY, inne... | true |
042568e46910db03a54be346ddd19b246a8a5889 | Rust | scotow/minecrust | /src/game/map/mod.rs | UTF-8 | 1,163 | 2.9375 | 3 | [] | no_license | pub mod generator;
use crate::game::map::generator::ChunkGenerator;
use crate::packets::play::{Block, Chunk};
use piper::{Lock, LockGuard};
use std::collections::HashMap;
pub struct Map {
chunks: Lock<HashMap<(i32, i32), Lock<Chunk>>>,
generator: Box<dyn ChunkGenerator + Sync + std::marker::Send + 'static>,
}... | true |
1a778d11336189f0b1d6e586d55ca4bb1204afb3 | Rust | sezna/Inflector | /src/numbers/ordinalize/mod.rs | UTF-8 | 5,255 | 4.1875 | 4 | [
"BSD-2-Clause"
] | permissive | /// Orginalizes a `&str`
///
/// ```
/// use inflector::numbers::ordinalize::ordinalize;
/// let mock_string: &str = "a";
/// let expected_string: String = "a".to_owned();
/// let asserted_string: String = ordinalize(mock_string);
/// assert!(asserted_string == expected_string);
///
/// ```
/// ```
... | true |
ef6c1308caacf85a29afbfe73cc5013a94fbde92 | Rust | felixwatts/t2_bus | /src/protocol.rs | UTF-8 | 4,006 | 2.609375 | 3 | [] | no_license | use crate::err::{BusError, BusResult};
use flate2::read::GzDecoder;
use flate2::write::GzEncoder;
use flate2::Compression;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{fmt, io::prelude::*};
pub trait PublishProtocol: Serialize + DeserializeOwned + Send + 'static + std::fmt::Debug {
fn prefi... | true |
89f9198c185f95707e48631ba1d4516f5153263e | Rust | tylerlowrey/cast-mesh | /cast-mesh-web-ui/src/lib.rs | UTF-8 | 4,473 | 2.703125 | 3 | [] | no_license | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
pub mod cors;
pub mod types;
pub const SQLITE_DB_PATH: &str = "./data.db";
pub const ROCKET_SERVER_PORT: u16 = 50050;
pub const GRPC_SERVER_PORT: u16 = 50055;
pub mod routes {
use crate::types... | true |
088a86999ab8a1cfad1cd2098c253d1a02b9ded4 | Rust | J-F-Liu/geom3d | /src/surface/plane.rs | UTF-8 | 3,061 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::surface::{EdgeLoop, Surface};
use crate::utils;
use crate::{Float, Point2, Point3, TriangleMesh, Vec3};
#[derive(Debug)]
pub struct Plane {
pub origin: Point3,
pub normal: Vec3,
pub u_axis: Vec3,
pub v_axis: Vec3,
}
impl Plane {
pub fn project(&self, point: Point3) -> Point2 {
l... | true |
f9c1696d6f0e73326b3e1a4d9dc8e7d60b0f869c | Rust | Yasu-umi/sudachiclone-rs | /src/darts/double_array_trie.rs | UTF-8 | 1,911 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | use std::io::Cursor;
use std::mem::size_of;
use byteorder::{LittleEndian, ReadBytesExt};
use super::double_array_builder::DoubleArrayBuilder;
use super::double_array_unit::DoubleArrayUnit;
use super::keyset::Keyset;
#[derive(Default)]
pub struct DoubleArrayTrie {
array: Vec<u32>,
size: usize,
}
impl DoubleArray... | true |
0e7fcdc6dde17030ff3ea3e4b5d5bb2cbcad9450 | Rust | 10allday-kai/api-daemon | /third-party/android_logger/src/lib.rs | UTF-8 | 13,240 | 2.609375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2016 The android_logger Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except a... | true |
093e793e0e9b412fda791677cbc07e71f99279cd | Rust | pvdbrand/cnc-z-perpendicularity | /gui/src/main.rs | UTF-8 | 2,195 | 2.8125 | 3 | [
"MIT"
] | permissive | #![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate rocket;
extern crate rocket_contrib;
extern crate serialport;
use rocket::State;
use serialport::prelude::*;
use rocket_contrib::json::{Json};
use std::time::Duration;
use std::sync::Mutex;
use rocket_contrib... | true |
511574d48272a7be298f7dd14e04e135c5666683 | Rust | commiebstrd/cryptopals_rs | /src/challenges/chal1.rs | UTF-8 | 614 | 3.0625 | 3 | [] | no_license | use hex_d_hex::dhex;
use utils::println;
use base64::encode;
static DECODED: &'static str = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
static ENCODED: &'static str = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t";
fn hex2str64(input:&str) ->... | true |
1250915b251218678668c081989b98850a58aa28 | Rust | fqliao/rust_lab | /geektime/ch02/src/expression02/mod.rs | UTF-8 | 1,016 | 2.828125 | 3 | [] | no_license | //! ## 5 rust编译器计算
//! ### 5.1 常量函数
//! CTFE(compile time function evaluation)最早由C++和Lisp语言支持
//! rust编译期计算支持:常量函数和常量泛型
//! Build脚本,例如生成c头文件的cbindgen库
//! 谨记:
//! 1. 常量上下文是编译器唯一运行进行编译期求值的地方
//! 2. 在非常量上下文的地方,常量表达式不一定会在编译期求值
//! MIR 解释器执行中间语言实现编译器计算
//!
//! ### 5.2 while true与loop 之争
//! while true其实属于一种特殊的情况,更为普遍的是 whi... | true |
d1840e9422ebd0285bf43d517942edaafb616e85 | Rust | Fantom-foundation/fantom-rust-vm | /fvm/src/memory.rs | UTF-8 | 5,924 | 3.609375 | 4 | [
"MIT"
] | permissive | //! Module for the volatile memory that is cleared between transactions
use bigint::{M256, U256};
use errors::*;
/// A volatile area of memory that is created per-transaction. The following constraints must be
/// observed when interacting with it:
/// 1. A Read must be 256 bits
/// 2. A Write can be 8 bits or 256 bi... | true |
5b9d6fee0bcc4f6d228abe7443446e220638ee3b | Rust | kmyzhang/Assignment6 | /Assignment6.rs | UTF-8 | 2,722 | 3.796875 | 4 | [] | no_license | use std::collections::HashMap;
//DATA STRUCTURES
enum ExprC {
NumC { n: f32 },
IdC { s: String },
StringC { s: String },
IfC { cond: Box<ExprC>, thenn: Box<ExprC>, elsee: Box<ExprC> },
LamC { args: Vec<String>, body: Box<ExprC> },
AppC { func: Box<ExprC>, args: Vec<Box<ExprC>> },
}
enum Value ... | true |
635ed0967372b14ce25cc9f7f5458be55d956f57 | Rust | poljar/ruma-client | /src/lib.rs | UTF-8 | 12,938 | 3.09375 | 3 | [
"MIT"
] | permissive | //! Crate `ruma_client` is a [Matrix](https://matrix.org/) client library.
//!
//! # Usage
//!
//! Begin by creating a `Client` type, usually using the `https` method for a client that supports
//! secure connections, and then logging in:
//!
//! ```no_run
//! use futures::Future;
//! use ruma_client::Client;
//!
//! l... | true |
a5c0070d018a7c83710260b4e2016d67b7920e2f | Rust | vsl-lang/vsl-objc-bindgen | /src/vsl_ast/vsl_type.rs | UTF-8 | 721 | 2.890625 | 3 | [
"MIT"
] | permissive | use vsl_ast::VSLEntity;
use std::fmt;
pub enum VSLType {
Primitive { name: String },
Generic { name: String, types: Vec<VSLType> }
}
impl VSLEntity for VSLType {}
impl fmt::Display for VSLType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
VSLType::Primitive { r... | true |
cf5165c7b0537c326e61c6bd0726bb47b6319d69 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/crc32fast/src/lib.rs | UTF-8 | 6,442 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | /
/
!
Fast
SIMD
-
accelerated
CRC32
(
IEEE
)
checksum
computation
.
/
/
!
/
/
!
#
#
Usage
/
/
!
/
/
!
#
#
#
Simple
usage
/
/
!
/
/
!
For
simple
use
-
cases
you
can
call
the
[
hash
(
)
]
convenience
function
to
/
/
!
directly
compute
the
CRC32
checksum
for
a
given
byte
slice
:
/
/
!
/
/
!
rust
/
/
!
let
checksum
=
crc32... | true |
7bef43804487dee395a1d4fcab335f40f41aa452 | Rust | marmistrz/FabChess | /src/testing/async_communication.rs | UTF-8 | 3,279 | 2.609375 | 3 | [
"BSD-3-Clause"
] | permissive | use crate::logging::Logger;
use crate::testing::queue::ThreadSafeString;
use std::io::BufReader;
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::prelude::*;
pub fn print_command(
runtime: &mut tokio::runtime::Runtime,
input: tokio_process::ChildStdin,
command: String,
) -> tokio_process:... | true |
92209554c407163b3b58aae040fc582f40f01b0a | Rust | guduan/Tutorials | /rust/rustbyexample/23_1_borrow_checker.rs | UTF-8 | 1,812 | 3.078125 | 3 | [] | no_license | fn main() { // `'main` starts ────────────────────────────────────────────┐
let stack_integer: int = 5; // `'a` starts ─────────────────────────┐ │
let boxed_integer = box 4; // `'b` starts ────────────────────────┐ │ │
// │ │ │
// This is a... | true |
dd365d9d5f684fede02326123061606b2d501bdf | Rust | rust-lang/rust | /src/tools/tidy/src/alphabetical.rs | UTF-8 | 3,275 | 3.40625 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | //! Checks that a list of items is in alphabetical order
//!
//! To use, use the following annotation in the code:
//! ```rust
//! // tidy-alphabetical-start
//! fn aaa() {}
//! fn eee() {}
//! fn z() {}
//! // tidy-alphabetical-end
//! ```
//!
//! The following lines are ignored:
//! - Lines that are indented with mor... | true |
08e8a52abf1d1a5db33fad0a1feaa3e06d42585c | Rust | cessen/led | /src/string_utils.rs | UTF-8 | 3,730 | 3.640625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! Misc helpful utility functions for TextBuffer related stuff.
use ropey::{str_utils::byte_to_char_idx, RopeSlice};
pub fn is_line_ending(text: &str) -> bool {
match text.chars().nth(0) {
Some(c) if (c >= '\u{000A}' && c <= '\u{000D}') => true,
Some('\u{0085}') | Some('\u{2028}') | Some('\u{2029... | true |
9c889275f398bcc8713d3096b6c27d12176de745 | Rust | yelhousni/zexe | /algebra/src/rand.rs | UTF-8 | 311 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use rand::{Rng, distributions::{Distribution, Standard}};
pub trait UniformRand: Sized {
fn rand<R: Rng + ?Sized>(rng: &mut R) -> Self;
}
impl<T> UniformRand for T
where
Standard: Distribution<T>
{
#[inline]
fn rand<R: Rng + ?Sized>(rng: &mut R) -> Self {
rng.sample(Standard)
}
}
| true |
74ff223e5d1c5f9f48a764f541c8e3e37df57959 | Rust | Byron/gitoxide | /gix-odb/src/store_impls/dynamic/init.rs | UTF-8 | 5,479 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::{iter::FromIterator, path::PathBuf, sync::Arc};
use arc_swap::ArcSwap;
use crate::{
store::types::{MutableIndexAndPack, SlotMapIndex},
Store,
};
/// Options for use in [`Store::at_opts()`].
#[derive(Clone, Debug)]
pub struct Options {
/// How to obtain a size for the slot map.
pub slots: Slo... | true |
3563341edb7323e8de9d3c15eb732ad3681a61e5 | Rust | tsionyx/nonogrid | /src/solver/sat.rs | UTF-8 | 21,031 | 2.84375 | 3 | [
"MIT"
] | permissive | //! The algorithm based on the ideas
//! from the [article](https://habr.com/ru/post/433330/)
#![allow(clippy::option_if_let_else)]
use std::{
collections::{HashMap, HashSet},
iter::{from_fn, once},
ops::{Deref, Range},
};
use log::{debug, info, warn};
use varisat::{solver::Solver, CnfFormula, ExtendFormu... | true |
bff66dfd3568228ccd261e88f3c931fe95ba9894 | Rust | vorner/corona | /test/early_cleanup.rs | UTF-8 | 5,008 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::cell::Cell;
use std::panic::{self, AssertUnwindSafe};
use std::rc::Rc;
use corona::prelude::*;
use tokio::prelude::*;
use tokio::runtime::current_thread::Runtime;
#[derive(Clone, Default)]
struct Status(Rc<Cell<bool>>, Rc<Cell<bool>>);
impl Status {
fn before_drop(&self) {
// Check it got to the... | true |
e9b1ab47fa2f6cea8b283dcbcd76fdd92c9e8447 | Rust | wolfgang/tbac | /src/parser/print_node.rs | UTF-8 | 968 | 3.078125 | 3 | [] | no_license | use std::any::Any;
use crate::parser::node::{Node, NodeBox};
use crate::parser::node_evaluator::NodeEvaluator;
use crate::parser::string_node::StringNode;
pub struct PrintNode {
pub params: Vec<NodeBox>,
pub line: u32,
}
impl PrintNode {
pub fn with_string_param(param: &str) -> Box<Self> {
let mu... | true |
90df4a82f9368d53f92121524faafa03157747e4 | Rust | nekomaho/client_credentials_client | /src/api.rs | UTF-8 | 3,292 | 2.984375 | 3 | [
"MIT"
] | permissive | use reqwest::header::*;
use crate::color::coloring;
use crate::color_println;
pub struct Api {
config: crate::config::api_config::ApiConfig,
oauth_name: String,
access_token: String,
count: u32,
}
impl Api {
pub fn new(config: &crate::config::api_config::ApiConfig, access_token: &str, oauth_name: ... | true |
81dee2214fd08d8fda9e952180ff030ac95e749e | Rust | sile/fibers_transport | /src/share.rs | UTF-8 | 3,339 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::base::Transport;
use crate::{PollRecv, PollSend, Result, TcpTransport, UdpTransport};
use futures::Async;
use std::cell::RefCell;
use std::fmt;
use std::net::SocketAddr;
use std::rc::Rc;
/// Shareable transporter.
#[derive(Debug)]
pub struct RcTransporter<T: Transport>(Rc<RefCell<Inner<T>>>);
impl<T: Transp... | true |
cac41247d73a358d8b5f7989d4ca5b834543123b | Rust | maxtnuk/gluesql | /core/src/plan/expr/function.rs | UTF-8 | 8,848 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | use {
crate::ast::{Expr, Function},
std::iter::{empty, once},
};
impl Function {
pub fn as_exprs(&self) -> impl Iterator<Item = &Expr> {
#[derive(iter_enum::Iterator)]
enum Exprs<I0, I1, I2, I3, I4, I5> {
Empty(I0),
Single(I1),
Double(I2),
Tri... | true |
51f24ba30e43f9c800fca155e1e0e4294ac62fd4 | Rust | seitamuro/atcoder_base90 | /p009/src/main.rs | UTF-8 | 2,627 | 3.0625 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
x: [(f64, f64); n],
}
let mut ans = 0.;
for i in 0..x.len() {
let s = solve(i, &x);
if ans < s {
ans = s;
}
}
println!("{}", ans);
}
fn solve(pos: usize, x: &[(f64, f64)]) -> f64 {
let... | true |
4d53fd4abd152714cd66d4402135dacad6bd164f | Rust | fungos/polaris | /src/ddns.rs | UTF-8 | 1,849 | 2.9375 | 3 | [
"MIT"
] | permissive | use hyper;
use hyper::client::Client;
use hyper::header::{Authorization, Basic};
use std::io;
use std::io::Read;
use std::thread;
use std::time;
#[derive(Debug, Clone)]
pub struct DDNSConfig {
pub host: String,
pub username: String,
pub password: String,
}
#[derive(Debug)]
enum DDNSError {
IoError(io::Error),
Hy... | true |
42a49c85265a0ce9c655625e15f320877dcefd75 | Rust | seveneightn9ne/crb | /src/mode.rs | UTF-8 | 2,530 | 3 | 3 | [
"MIT"
] | permissive | use rustbox::Key;
use std::collections::HashMap;
use state;
#[derive(Debug, Copy, Clone)]
pub enum Mode {
Normal,
Insert,
}
#[derive(Debug, Clone)]
pub enum Command {
MoveLeft(i32),
MoveRight(i32),
MoveUp(i32),
MoveDown(i32),
Scroll(i32),
Quit,
Insert(char),
Delete(Direction),
... | true |
49555c33021f48b59d5577db5eb15cc05f6bc7db | Rust | PaulFurtado/rusty_bars | /src/fftw/audio.rs | UTF-8 | 4,613 | 3.359375 | 3 | [] | no_license | use std::slice;
//use std::num::Float;
use fftw::multichannel::MultiChannelFft;
use fftw::hanning::HanningWindowCalculator;
/// Audio FFT for 16bit little endian audio data (S16LE)
pub struct AudioFft {
/// The multichannel fft object that does the work for us
multichan_fft: MultiChannelFft,
/// The input... | true |
e147402a373e58b2e6cd3504b2c122ca56bf2f49 | Rust | AN3223/lc3vm | /src/memory.rs | UTF-8 | 1,193 | 3.265625 | 3 | [
"MIT"
] | permissive | /* This file is focused on representing the memory of the LC-3 */
use crate::{U16_MAX, MR};
pub struct Memory {
pub contents: [u16; U16_MAX]
}
impl Memory {
pub const fn new() -> Memory {
Memory { contents: [0; U16_MAX] }
}
// Getter for accessing the memory. The memory only
// needs to ... | true |
46218636b62b53a9da12aa71a0578d1103bf6215 | Rust | rtroxler/blackjack.rs | /src/game.rs | UTF-8 | 2,990 | 3.6875 | 4 | [] | no_license | use std::io;
use deck::Deck;
use deck::Card;
#[derive(Debug)]
struct Hand {
cards: Vec<Card>
}
impl Hand {
fn view(&self) {
println!(" Cards: {:?}", self.cards);
println!(" Value: {}", self.value());
}
fn hit(&mut self, deck: &mut Deck) {
self.cards.extend(deck.deal(1));
... | true |
3a721bf274da2e16f7cbf3f7572154cc8b0dfd40 | Rust | buratina/Mastering-Rust-Build-Robust-Concurrent-and-Fast-Applications | /Section 1/Video 1.5/tut4.rs | UTF-8 | 81 | 2.53125 | 3 | [
"MIT"
] | permissive | fn main(){
let k = String::from("Hi");
let b = k.clone();
println!("{}", b);
} | true |
d5f6841384829357cda6190273b7ea891ad6b20c | Rust | rust-rspec/experiments | /macro/src/main.rs | UTF-8 | 11,436 | 3.015625 | 3 | [] | no_license | #![feature(try_from)]
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate derivative;
use std::convert::TryFrom;
use std::fmt::{self, Debug};
pub trait EnvironmentTrait: Clone + PartialEq + Eq + fmt::Debug {}
pub trait TagsTrait: Default + Clone + PartialEq + Eq + fmt::Debug {}
#[derive(Default, Clone, P... | true |
07b8495e8a13efe38c34d5e4034aba44f8e17817 | Rust | kuviman/ludumdare48 | /src/renderer/mod.rs | UTF-8 | 1,745 | 2.671875 | 3 | [
"MIT"
] | permissive | use super::*;
#[derive(ugli::Vertex, Clone)]
pub struct Vertex {
pub a_pos: Vec2<f32>,
}
pub struct Renderer {
quad: ugli::VertexBuffer<Vertex>,
program: ugli::Program,
}
impl Renderer {
pub fn new(geng: &Rc<Geng>) -> Self {
Self {
quad: ugli::VertexBuffer::new_static(
... | true |
4932caaaecd57fe4bdee9c0ea8be9e47062527ce | Rust | attilahorvath/advent-of-code-2017 | /day16/src/lib.rs | UTF-8 | 3,906 | 3.765625 | 4 | [
"MIT"
] | permissive | use std::str::FromStr;
pub enum DanceMove {
Spin(usize),
Exchange(usize, usize),
Partner(char, char),
}
#[derive(Debug)]
pub struct DanceMoveParseError;
impl FromStr for DanceMove {
type Err = DanceMoveParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut chars = s.trim()... | true |
4bdd1d826f30cabb4fc3b2e0b9274dddf3de37e2 | Rust | little-dude/ofpkt | /tests/lib.rs | UTF-8 | 11,001 | 2.515625 | 3 | [
"MIT"
] | permissive | extern crate ofpkt;
use std::fs::File;
use std::io::Read;
use ofpkt::openflow;
use ofpkt::oxm;
use ofpkt::{Repr, Result};
// dummy OxmExperimenter field, since openflow::PacketRepr is generic over it.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct OxmExperimenter;
impl Repr for OxmExperimenter {
fn parse(_... | true |
886b732f9827e462942e18ce303ac3dc19cbad01 | Rust | iansuvak/project_euler | /rust/1.rs | UTF-8 | 512 | 3.78125 | 4 | [] | no_license | use std::iter::AdditiveIterator;
use std::iter;
fn main() {
let mut sum = 0u32;
for i in 1..1000 {
if i % 3 == 0 || i % 5 == 0 {
sum += i;
}
}
println!("Procedural: Sum of numbers between 1 and 1000 divisible by 3 and 5 is {}", sum);
let answer = iter::range(1,1000).filt... | true |
c4a91eedb5f973ffade287ae4b9e4781b453ac9d | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/rand_os-0.1.2/tests/mod.rs | UTF-8 | 1,803 | 2.640625 | 3 | [
"BSD-2-Clause",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate rand_os;
use rand_os::rand_core::RngCore;
use rand_os::OsRng;
#[test]
fn test_os_rng() {
let mut r = OsRng::new().unwrap();
r.next_u32();
r.next_u64();
let mut v1 = [0u8; 1000];
r.fill_bytes(&mut v1);
let mut v2 = [0u8; 1000];
r.fill_bytes(&mut v2);
let mut n_diff_bits... | true |
350981d364dde741e56ff292ebddba150ce367ec | Rust | lorenzoditucci/calyx | /interp/src/primitives/primitive.rs | UTF-8 | 6,377 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::{
environment::{FullySerialize, State},
values::Value,
};
use calyx::ir;
use itertools::Itertools;
use serde::Serialize;
/// A primitive for the interpreter.
/// Roughly corresponds to the cells defined in the primitives library for the Calyx compiler.
/// Primitives can be either stateful or combina... | true |
32d6b31abcdc209dfae93847edd8b48d004b751c | Rust | jordanhendricks/c_wrapper_example | /src/lib.rs | UTF-8 | 1,088 | 3.03125 | 3 | [] | no_license | struct NumWrapper(u8);
pub struct CNumWrapper(NumWrapper);
impl Drop for CNumWrapper {
fn drop(&mut self) {
println!("dropping CNumWrapper (val={})", self.0.0);
}
}
#[no_mangle]
pub extern fn raw_numwrapper(num: u8) -> *mut CNumWrapper {
let val = CNumWrapper(NumWrapper(num));
let boxed = Box:... | true |
d2040ea1965297ee4e46bc3e9bf8e3ce22bb4244 | Rust | hyperium/h3 | /h3/src/server.rs | UTF-8 | 29,329 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! This module provides methods to create a http/3 Server.
//!
//! It allows to accept incoming requests, and send responses.
//!
//! # Examples
//!
//! ## Simple example
//! ```rust
//! async fn doc<C>(conn: C)
//! where
//! C: h3::quic::Connection<bytes::Bytes>,
//! <C as h3::quic::Connection<bytes::Bytes>>::BidiStr... | true |
3570d14cce66dfcc1c3f588169b7d199836912ea | Rust | imorph/vector | /src/top/events.rs | UTF-8 | 901 | 2.5625 | 3 | [
"MPL-2.0"
] | permissive | use crossterm::event::{poll, read, Event, KeyCode};
use tokio::sync::{mpsc, oneshot};
static INPUT_INVARIANT: &str = "Couldn't capture keyboard input. Please report.";
/// Capture keyboard input, and send it upstream via a channel. This is used for interaction
/// with the dashboard, and exiting from `vector top`.
pu... | true |
693cfc2f005aaea4320031d0548380e66c929725 | Rust | LanJian/raytox | /src/algebra/vector.rs | UTF-8 | 4,832 | 3.28125 | 3 | [] | no_license | use std::ops::{Add, Div, Mul, Neg, Sub};
use crate::{entity::Transformable, geometry::Axis};
use super::Matrix4;
#[derive(Default, Debug, Clone, Copy, PartialEq)]
pub struct Vector3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl Vector3 {
pub const ZERO: Self = Self {
x: 0.0,
y: 0.0,
... | true |
0b7a949a6866d6eb2aeb4730cb087f321d17851f | Rust | stuartlynn/geozero | /geozero-bench/benches/geobench.rs | UTF-8 | 17,643 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use criterion::{criterion_group, criterion_main, Criterion};
use geozero::error::Result;
use geozero::ToGeo;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Extent {
pub minx: f64,
pub miny: f64,
pub maxx: f64,
pub maxy: f64,
}
mod fgb {
use super::*;
use flatgeobuf::*;
use std::fs::Fi... | true |
516b05133d5f0228a7c11c2d6142bca976b62e81 | Rust | NathanYee/monkey-rs | /src/main.rs | UTF-8 | 803 | 2.703125 | 3 | [] | no_license | use std::{io, rc::Rc};
mod ast;
mod evaluator;
mod lexer;
mod object;
mod parser;
mod token;
use object::environment;
fn main() {
println!("This is the Monkey programming language!");
println!("Feel free to type in commands");
let env = environment::Environment::new();
loop {
eprint!(">>> ");... | true |
33bf7f7914a4782c771bbe9e5a2d5d93a512e54f | Rust | PotHix/pothix-codes | /rust/random/slice/src/main.rs | UTF-8 | 221 | 2.953125 | 3 | [] | no_license | fn main() {
let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
let b = &a[..];
let c = &a[3..5];
println!("a has {} elements", a.len());
println!("b has {} elements", b.len());
println!("c has {} elements", c.len());
}
| true |
b563e51069e3e93c8f4059c14180392899519d1f | Rust | OlfaKaroui/AdventOfCode2020 | /day08.rs | UTF-8 | 1,999 | 3.296875 | 3 | [] | no_license | pub mod read_data;
fn main() {
let instructions = read_data::get_data_from_file("./data/data_day08");
let (is_infinite_loop , accumulator_part_one) = get_accumulator(&instructions).unwrap();
let accumulator_part_two = part_two(&instructions);
println!("accumulator 1 : {:?} is infinite loop : {:?}", acc... | true |
e7452c255311fd6eab0d4c8cc0b67926ba5fcab0 | Rust | djcsdy/wildflower-codec | /src/decode/tags/actions/go_to_label.rs | UTF-8 | 317 | 2.71875 | 3 | [] | no_license | use crate::decode::tags::common::string::String;
use std::io::{Read, Result};
#[derive(Clone, PartialEq, Debug)]
pub struct GoToLabel {
pub label: String,
}
impl GoToLabel {
pub fn read<R: Read>(reader: &mut R) -> Result<Self> {
let label = String::read(reader)?;
Ok(Self { label })
}
}
| true |
bce98fd410e9c7690a0d4853d23de275dbe6413e | Rust | qy3u/leetcode-rs | /src/array/minimum_window_substring.rs | UTF-8 | 1,308 | 3.15625 | 3 | [] | no_license |
// question 76
pub fn min_window(s: String, t: String) -> String {
let mut result = String::new();
let s: Vec<char> = s.chars().collect();
let t: Vec<char> = t.chars().collect();
let mut remain = t.len();
let mut origin_map = std::collections::HashMap::new();
let mut remain_map = std::collec... | true |
a1f7b147d7b47018128ffb0fdf0ff338d3bc0fea | Rust | solana-labs/solana | /gossip/src/push_active_set.rs | UTF-8 | 12,866 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use {
crate::weighted_shuffle::WeightedShuffle,
indexmap::IndexMap,
rand::Rng,
solana_bloom::bloom::{AtomicBloom, Bloom},
solana_sdk::{native_token::LAMPORTS_PER_SOL, pubkey::Pubkey},
std::collections::HashMap,
};
const NUM_PUSH_ACTIVE_SET_ENTRIES: usize = 25;
// Each entry corresponds to a st... | true |
ecf613f1ebbfb6a2b06fda58eae13b989a067ccb | Rust | boxdot/advent-of-code-2019 | /christian/25/src/main.rs | UTF-8 | 1,699 | 2.640625 | 3 | [] | no_license | use itertools::*;
use std::io::{self, prelude::*};
use vm::Vm;
mod program;
fn force() {
let mut to_checkpoint: String = "south
east
take whirled peas
west
north
north
east
take ornament
north
east
west
north
take dark matter
south
south
west
west
west
take candy cane
west
south
north
west
take tambourine
east
eas... | true |
b10935ed3c94d76b98b1fdb414ac2b51972353ab | Rust | CalebRollins/raytracer | /src/camera.rs | UTF-8 | 1,824 | 3.203125 | 3 | [] | no_license | use super::ray::Ray;
use super::vec3::Vec3;
use rand::random;
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
lens_radius: f32,
}
impl Camera {
pub fn new(
look_from: Vec3,
look_at: Vec3,
vup: Vec3,
... | true |
774c58f208b6160ee0b28b2d654eb7a306729a01 | Rust | mkhstar/star_range | /src/lib.rs | UTF-8 | 1,409 | 4.0625 | 4 | [
"MIT"
] | permissive | pub struct StarRange<T> {
start: T,
end: T,
step: T,
}
impl Iterator for StarRange<isize> {
type Item = isize;
fn next(&mut self) -> Option<Self::Item> {
let res = self.start;
if self.step < 0 {
if res <= self.end {
None
} else {
... | true |
c14da82454ab5efe97719a29625eeb2436402236 | Rust | rochala/ga_pcb | /src/problem/test.rs | UTF-8 | 1,922 | 3.015625 | 3 | [] | no_license | use super::*;
fn setup() -> Individual {
let mut pin_locations = vec![];
pin_locations.push(((1, 3), (5, 3)));
generate_individual((6, 6), pin_locations, Some(1))
}
#[test]
fn test_mutation() {
let mut individual = setup();
println!("{}", individual);
individual.connections[0].mutate_segment... | true |
5951d992064ef28580df9cdbc48790345412278d | Rust | Daniel-del-Castillo/daap8 | /src/problem_solver/greedy_solver.rs | UTF-8 | 3,498 | 3.703125 | 4 | [] | no_license | use super::{Point, ProblemInstance, ProblemSolution, ProblemSolver};
/// A greedy algorithm that creates a solution for the problem by adding
/// to the solution in each step the point which is further from the center
/// of the points already in the solution
pub struct GreedySolver {
number_of_points: usize,
}
i... | true |
def287bfbe6a47285f1db7fa3d1d0ce3e36bf283 | Rust | atthecodeface/glove | /rust/src/traits.rs | UTF-8 | 2,035 | 3.296875 | 3 | [] | no_license | pub trait Arg: Clone + std::fmt::Display + Eq + 'static {}
impl Arg for String {}
pub struct Node<A: Arg> {
bf: Box<dyn Function<A>>,
}
impl<A: Arg> Node<A> {
pub fn new<F: Function<A> + 'static>(bf: F) -> Node<A> {
let bf = Box::new(bf);
Self { bf }
}
}
impl<A: Arg> std::fmt::Display fo... | true |
38f0fee434aa07f10669027dd1d463280721586d | Rust | GeorgeKT/menhir-lang | /src/ast/import.rs | UTF-8 | 3,012 | 2.90625 | 3 | [
"MIT"
] | permissive | use super::Type;
use crate::ast::Function;
use crate::span::Span;
use itertools::join;
use std::collections::HashMap;
use std::fmt;
use std::rc::Rc;
#[derive(Eq, PartialEq, Hash, Clone, Serialize, Deserialize)]
pub struct ImportName {
namespace: Vec<String>,
pub span: Span,
}
impl ImportName {
pub fn new(... | true |
c4b0ee5608175bed99a20282fc3e263d4be747ac | Rust | earlgreytech/neutron-host | /src/element_interfaces/debug_data.rs | UTF-8 | 38,972 | 2.703125 | 3 | [] | no_license | use crate::callsystem::*;
use crate::codata::*;
use crate::comap_abi_decoder::*;
use crate::neutronerror::NeutronError::*;
use crate::neutronerror::*;
use neutron_common::*;
use std::any::type_name;
use std::collections::HashMap;
use std::convert::TryInto;
use std::mem::size_of;
use std::str;
/*
## Debug Data Injector... | true |
12dd931a9006ad28f7a2aa10ef256e50261c6b5f | Rust | bnjbvr/better-rss | /src/thenib.rs | UTF-8 | 780 | 2.703125 | 3 | [] | no_license | use select::document::Document;
use select::predicate::Attr;
use utils::{from_feed, Channel, ContentCreator, GenResult};
struct TheNib;
impl ContentCreator for TheNib {
fn create(&self, doc: &Document) -> Option<String> {
match doc.find(Attr("class", "Layout-layoutContainer")).next() {
Some(di... | true |
bf5660c741c4dc73741c7a4118898fcf1d6a59c1 | Rust | yvt/svgbobdoc | /example/src/lib.rs | UTF-8 | 1,585 | 3.34375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Some module.
//!
//! This figure is referenced by a label (`![diagram]`): ![diagram]
//!
#![doc = transform!(
//! ```svgbob,[diagram]
//! .----------------------.
//! | Another diagram here |
//! `----------------------'
//! ```
)]
#![doc = transform!(
//! ```svgbob,
//! .----------.
//! | Mutex<T> |
//! `---... | true |
1751d9b886718bedc75ecaeb686e133cb96e8481 | Rust | rkbalgi/iso8583_rs | /src/iso8583/iso_spec.rs | UTF-8 | 14,091 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | //! This module contains implementation of specification, its segments and associated operations
//!
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use std::io::Cursor;
use crate::iso8583::{bitmap, IsoError};
use crate::iso8583::field::{Field, ParseError};
use crate::iso8583::yaml_de::YMessageSegme... | true |
fe536f487a2939589389553a01f0e1d314407f3e | Rust | DavidAmison/adventofcode2020 | /day24/src/hexgrid.rs | UTF-8 | 2,600 | 3.953125 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
/// HashMap for storing HexTiles with their corresponding coordinate
pub type HexGrid = HashMap<HexCoordinate, HexTile>;
/// Axial coordinate in a HexGrid
pub type HexCoordinate = (i32, i32);
#[derive(Clone, Debug)]
/// Black or White colour
pub enum Colours {
White,
Black,
}
... | true |
5268f2abae3c0ba6658bce2c2d731860eb1045f0 | Rust | kmdivi/monolith | /src/tests/cli/basic.rs | UTF-8 | 6,051 | 2.65625 | 3 | [
"Unlicense"
] | permissive | // ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝
// ╚═╝ ╚═╝ ╚═╝╚══════... | true |
d4c522cf9715a0f0e96e3e94c774f3060ae5d0b2 | Rust | sroebuck/cc1101 | /src/lowlevel/traits.rs | UTF-8 | 486 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use core::ops::Range;
pub trait OffsetSize {
fn offset(self) -> u8;
fn size(self) -> u8;
}
impl OffsetSize for u8 {
fn offset(self) -> u8 {
self
}
fn size(self) -> u8 {
1
}
}
impl OffsetSize for Range<u8> {
fn offset(self) -> u8 {
self.start
}
fn size(sel... | true |
3edb39670b872f4879b272dcb72608f69fc66c91 | Rust | InnPatron/cyoa | /src/library.rs | UTF-8 | 1,406 | 2.59375 | 3 | [] | no_license | use std::path::PathBuf;
use std::fs;
use std::io::Read;
use toml;
use find_folder;
const MANIFEST_NAME: &'static str = "cyoa.toml";
pub struct StoryHandle {
pub root: PathBuf,
pub metadata: Metadata
}
#[derive(Deserialize)]
pub struct Metadata {
pub name: String,
pub author: Option<String>,
pub ... | true |
6b8426c8f2545b65d88b3dd8efeeb54da080a6a9 | Rust | oberien/refunct-tas | /protocol/src/lib.rs | UTF-8 | 1,478 | 3.015625 | 3 | [] | no_license | use std::sync::atomic::{AtomicU32, Ordering};
use serde::{Serialize, Deserialize};
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Serialize, Deserialize)]
pub struct PlayerId(u32);
// first 1000 ids are for anyone's internal hackery use
static PLAYER_ID_SERIAL: AtomicU32 = AtomicU32::new(1000);
i... | true |
72ed167953828b288d5dead4a6930f5da10dd6ed | Rust | BrianOn99/matasano-crypto-challenges | /src/set1/challenge4.rs | UTF-8 | 2,083 | 2.921875 | 3 | [
"BSD-2-Clause"
] | permissive | extern crate matasano;
extern crate hex;
use std::env;
use std::io::{self, Write};
use std::fs::File;
use hex::FromHex;
use std::io::BufReader;
use std::io::BufRead;
use std::cmp::Ordering;
/*
* To practice using trait, A Iterator is implemented for the decrypted lines.
* It might be a overkill, and actually quit... | true |
2260e17e413af9d7ab0a05f3da9b7067ce8a7b57 | Rust | hummingly/ics | /src/parameters.rs | UTF-8 | 12,937 | 2.953125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! In the RFC5545 and RFC7986 specified parameters except for IANA and
//! non-standard parameters ("X"-prefix parameters).
//!
//! Parameters are key-value pairs which can specify a property in detail. Some
//! of them also specify format definitions or defined values. Those are either
//! defined as enums or associa... | true |
177059cfcb01a81a52d7f4d96763d4fd47bda6e0 | Rust | clux/slack-rs-api | /src/mods/im.rs | UTF-8 | 50,117 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | //! Get info on your direct messages.
#[allow(unused_imports)]
use std::collections::HashMap;
use std::convert::From;
use std::error::Error;
use std::fmt;
use serde_json;
use requests::SlackWebRequestSender;
/// Close a direct message channel.
///
/// Wraps https://api.slack.com/methods/im.close
pub fn close<R>(
... | true |
d63790201b494a8d8a2e582d7a39d04169fafc8f | Rust | Gregory-Meyer/srm | /src/plugin_loader.rs | UTF-8 | 3,125 | 2.5625 | 3 | [
"MIT"
] | permissive | // Copyright 2019 Gregory Meyer
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use, copy,
// modify, merge, publish, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.