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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
d4a3523d30ba4c7540238755c804b4a167a034a2 | Rust | ZNielsen/dust | /src/utils/platform.rs | UTF-8 | 916 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use jwalk::DirEntry;
fn get_block_size() -> u64 {
// All os specific implementations of MetatdataExt seem to define a block as 512 bytes
// https://doc.rust-lang.org/std/os/linux/fs/trait.MetadataExt.html#tymethod.st_blocks
512
}
#[cfg(target_family = "unix")]
pub fn get_metadata(d: &DirEntry, use_apparen... | true |
2c96e19f4ab00719bb7c9172df5afd72b07f90b0 | Rust | Herbert-Karl/project_euler | /src/problem_0007.rs | UTF-8 | 320 | 3.203125 | 3 | [
"MIT"
] | permissive | //! module containing problem 7
use crate::common::is_prime;
/// problem 7
///
/// calculates and returns the Nth prime number
pub fn nth_prime(n: u128) -> u128 {
let mut x: (u128, u128) = (1, 2);
while x.0<n {
x.1 = x.1+1;
if is_prime(x.1) {
x.0 = x.0+1;
}
}
x.1
}
| true |
c13a40408c6bbb5a318e46574f87f1b32d0af74e | Rust | RECturtle/Learn-Rust | /error_handle/src/main.rs | UTF-8 | 1,553 | 3.859375 | 4 | [] | no_license | use std::fs::File;
use std::io::ErrorKind;
use std::io,
use std::io::Read;
fn main() {
// Test to see the type File::open returns by setting f to expect u32
// let f: u32 = File::open("Hello.txt");
let f = File::open("Hello.txt");
let f = match f {
Ok(file) => file,
Err(error) => ... | true |
da236e4af374f32f5e4aa7815696b362e691c979 | Rust | thallada/advent-of-code-2018 | /src/day8.rs | UTF-8 | 2,735 | 3.34375 | 3 | [] | no_license | use std::error::Error;
use std::fs;
use std::result;
type Result<T> = result::Result<T, Box<Error>>;
const INPUT: &str = "inputs/8.txt";
pub fn solve_part1() -> Result<u32> {
let license = read_license(INPUT)?;
Ok(sum_metadata(&license, 0, 0).0)
}
pub fn solve_part2() -> Result<u32> {
let license = read... | true |
91ad8d5adfc25e8d28ea341a0ffea31ba70a447c | Rust | ratel-rust/ratel-core | /ratel/src/lexer/mod.rs | UTF-8 | 32,274 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | mod token;
mod labels;
mod util;
pub use lexer::token::*;
use lexer::labels::*;
use lexer::token::Token::*;
use std::str;
use error::Error;
use toolshed::Arena;
macro_rules! expect_byte {
($lex:ident) => ({
match $lex.read_byte() {
0 => return $lex.token = UnexpectedEndOfProgram,
... | true |
007e3794005d3dda6e3a88a838d15c990a15ff7f | Rust | tempbottle/flame | /tests/tests.rs | UTF-8 | 2,256 | 3.078125 | 3 | [] | no_license |
extern crate flame;
#[test]
fn implicit_guarded_event() {
flame::clear();
flame::start_guard("foo");
}
#[test]
fn named_guarded_event() {
flame::clear();
let _name = flame::start_guard("foo");
}
#[test]
fn dropped_guarded_event() {
flame::clear();
let name = flame::start_guard("foo");
na... | true |
57986ac543919a7d4ff6e5e7d910b45a60063125 | Rust | Canop/lapin | /src/display/screen.rs | UTF-8 | 1,423 | 3.046875 | 3 | [
"MIT"
] | permissive | use {
anyhow::Result,
crossterm::{
cursor,
terminal::{Clear, ClearType},
QueueableCommand,
},
std::io::Write,
super::*,
termimad::Area,
};
pub struct Screen {
area: Area, // the complete screen
pub areas: Areas, // the areas of the different sub parts
layout:... | true |
e628bba245d5949bb2d8d244559a21a164bbe691 | Rust | arqunis/framework | /command_attr/src/impl_command/mod.rs | UTF-8 | 3,811 | 2.65625 | 3 | [
"ISC"
] | permissive | use crate::utils::{self, Attr, AttributeArgs};
use proc_macro::TokenStream;
use proc_macro2::{Ident, TokenStream as TokenStream2};
use quote::{format_ident, quote};
use syn::parse;
use syn::{Attribute, ItemFn, Result, Type};
mod options;
pub fn impl_command(attr: TokenStream, input: TokenStream) -> Result<TokenStrea... | true |
8ae78e004a3628ef20f24ea4275d620804d9b660 | Rust | korken89/biquad-rs | /src/coefficients.rs | UTF-8 | 17,668 | 3.53125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! # coefficients
//!
//! Module for generating filter coefficients for second order IIR biquads, where the coefficients
//! form the following Z-domain transfer function:
//! ```text
//! b0 + b1 * z^-1 + b2 * z^-2
//! H(z) = --------------------------
//! 1 + a1 * z^-1 + a2 * z^-2
//! ```
//!
//! Th... | true |
fea72149c890b50fcb26b228433370699bcb7a1e | Rust | MabezDev/hm11 | /src/command.rs | UTF-8 | 836 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive |
//! AT Commands
pub enum Command<'a> {
/// 0 -------- 9600
Baud9600,
/// 1 -------- 19200
Baud19200,
/// 2 -------- 38400
Baud38400,
/// 3 -------- 57600
Baud57600,
/// 4 -------- 115200
Baud115200,
/// 5 -------- 4800
Baud4800,
/// 6 -------- 2400
Baud2400,
... | true |
572d8317c64d05d46a849a1409c4047569247cfe | Rust | mayah/puyoai.rs | /puyoai-core/src/control/controller.rs | UTF-8 | 7,814 | 3.234375 | 3 | [
"MIT"
] | permissive | use field::{FieldHeight, FieldIsEmpty};
use decision::Decision;
pub struct PuyoController {
}
impl PuyoController {
pub fn new() -> PuyoController {
PuyoController {
}
}
pub fn is_reachable<F: FieldHeight + FieldIsEmpty>(&self, field: &F, decision: &Decision) -> bool {
debug_asser... | true |
078fa7171d081bc85a27f50845214013b0e196eb | Rust | vitali2y/rust-u2f | /u2fhid-protocol/src/protocol_state_machine.rs | UTF-8 | 22,436 | 2.5625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::io;
use std::mem;
use std::time::Duration;
use crate::definitions::*;
use futures::future;
use futures::{Async, Future};
use slog::Logger;
use tokio_core::reactor::Handle;
use tokio_core::reactor::Timeout;
use u2f_core::{self, Service};
macro_rules! try_some {
($e:expr) => {
match $e {
... | true |
83ef00098e51658e55533476fd970705c0968abf | Rust | Ryman/rust-rosetta | /src/four_bit_adder.rs | UTF-8 | 5,335 | 3.125 | 3 | [
"LicenseRef-scancode-public-domain",
"Unlicense"
] | permissive | // Implements http://rosettacode.org/wiki/Four_bit_adder
extern crate arena;
use arena::Arena;
static TRUE: bool = true;
static FALSE: bool = false;
trait Gate {
fn get(&self) -> bool;
}
impl Gate for bool {
fn get(&self) -> bool {
*self
}
}
struct NotGate<'a>{
inp: &'a Gate,
}
impl<'a> Gate for NotG... | true |
ee3a134bbbc7afaf18c9b76ebc8f3b95ddfca815 | Rust | shadow/shadow | /src/main/utility/shm_cleanup.rs | UTF-8 | 5,825 | 2.984375 | 3 | [
"LicenseRef-scancode-public-domain"
] | permissive | use std::collections::HashSet;
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::str::FromStr;
use anyhow::{self, Context};
pub const SHM_DIR_PATH: &str = "/dev/shm/";
const PROC_DIR_PATH: &str = "/proc/";
const SHADOW_SHM_FILE_PREFIX: &str = "shadow_shmemfile";
// Get the paths from the given direc... | true |
7fe54dbd2554b9e8ed512b47f82307cd52d9eb1c | Rust | azdavis/advent-of-code | /years/y2021/src/d16.rs | UTF-8 | 3,750 | 3.46875 | 3 | [
"MIT"
] | permissive | struct Packet {
version: usize,
kind: Kind,
}
enum Kind {
Lit(usize),
Add(Vec<Packet>),
Mul(Vec<Packet>),
Min(Vec<Packet>),
Max(Vec<Packet>),
Gt(Box<Packet>, Box<Packet>),
Lt(Box<Packet>, Box<Packet>),
Eq(Box<Packet>, Box<Packet>),
}
fn parse_num(iter: &mut dyn Iterator<Item = bool>, digits: usize... | true |
0a96899943a8db4fe9256012075dddbbf3509795 | Rust | nickel-org/rust-mustache | /src/data.rs | UTF-8 | 1,358 | 3.453125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashMap;
use std::cell::RefCell;
use std::fmt;
// for bug!
use log::{log, error};
pub enum Data {
Null,
String(String),
Bool(bool),
Vec(Vec<Data>),
Map(HashMap<String, Data>),
Fun(RefCell<Box<dyn FnMut(String) -> String + Send>>),
}
impl PartialEq for Data {
#[inline... | true |
0c1d0a3df5e76e37fd6f442dcf8c948111fe9d45 | Rust | dtolnay/erased-serde | /src/lib.rs | UTF-8 | 5,230 | 3.453125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! [![github]](https://github.com/dtolnay/erased-serde) [![crates-io]](https://crates.io/crates/erased-serde) [![docs-rs]](https://docs.rs/erased-serde)
//!
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
//! [crates-io]: https://img.shields.io/badge... | true |
2675508a19fb6f1051f6badf723fa6f3b1f6b393 | Rust | GordonHaak/sudokusolver | /src/sudoku.rs | UTF-8 | 6,687 | 3.109375 | 3 | [] | no_license | #![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
use std::str::FromStr;
use std::string::ToString;
pub mod index;
pub mod iterator;
#[derive(Debug, PartialEq, Clone)]
pub struct Classic {
fields: Vec<Option<u8>>,
}
use iterator::{ColumnIterator, FieldIterator, LineIterator};
type IndexTy... | true |
2da5d09c10e3cc5c0ceaaedff9c9b56c0899bf72 | Rust | ju6ge/atsame70q21 | /src/smc.rs | UTF-8 | 4,612 | 2.515625 | 3 | [
"MIT"
] | permissive | #[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - SMC Setup Register (CS_number = 0)"]
pub smc_cs_number: [SMC_CS_NUMBER; 4],
_reserved1: [u8; 64usize],
#[doc = "0x80 - SMC OCMS MODE Register"]
pub smc_ocms: SMC_OCMS,
#[doc = "0x84 - SMC OCMS KEY1 Register"]
pu... | true |
88b142f6f82b5b1a4c20846fb4ec8667fa0aea4b | Rust | LEON-HYZ/ece598-block-chain | /src/miner.rs | UTF-8 | 12,141 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::network::message::{Message};
use crate::network::server::Handle as ServerHandle;
use std::sync::{Arc, Mutex};
use crate::crypto::hash::{H256, Hashable, H160};
use crate::blockchain::Blockchain;
use crate::block::{Block,Header,Content};
use crate::crypto::merkle::{MerkleTree};
use crate::transaction::{Transa... | true |
c5f26c4315f3d7677e03f13a6be762640cde72ae | Rust | redox-os/coreutils | /src/bin/clear.rs | UTF-8 | 863 | 2.765625 | 3 | [
"MIT"
] | permissive | extern crate arg_parser;
extern crate extra;
use std::env;
use std::io::{stdout, stderr, Write};
use std::process::exit;
use arg_parser::ArgParser;
use extra::option::OptionalExt;
const MAN_PAGE: &'static str = /* @MANSTART{clear} */ r#"
NAME
clear - clear the terminal screen
SYNOPSIS
clear [ -h | --help]
D... | true |
d71f872515021d44ac17c06ac3c28a55d07d0791 | Rust | peahonen/cv-rs | /examples/hog.rs | UTF-8 | 2,914 | 2.671875 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | extern crate cv;
extern crate getopts;
use cv::*;
use cv::highgui::*;
use cv::imgcodecs::*;
use cv::objdetect::*;
#[cfg(feature = "cuda")]
use cv::cuda::GpuHog as Hog;
#[cfg(not(feature = "cuda"))]
use cv::objdetect::HogDescriptor as Hog;
use std::fs;
use std::fs::File;
use std::io::{Read, Result};
use std::path::P... | true |
b6c608ded830ab4dbf69e0c40de0c93f016e49b8 | Rust | karlmdavis/fhir-benchmarks | /fhir-bench-orchestrator/src/servers/docker_compose.rs | UTF-8 | 10,959 | 2.984375 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-public-domain"
] | permissive | //! Provides utility functions for [ServerPlugin] and [ServerHandle] implementations that use Docker Compose.
//!
//! These functions all assume that the server has a dedicated directory, which contains a custom shell
//! script that wraps `docker-compose` with any setup, environment variables, etc. needed to run thing... | true |
f57ecb4fb80237d6160e7dc0a02f71129cf77c7c | Rust | Stahl99/rust-cmp | /src/player_interface.rs | UTF-8 | 6,510 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::util::app;
use crate::util::stateful_list::StatefulList;
use crate::util::stateful_selected_list::CurrentElement;
use crate::player::Player;
use crate::player;
use mpd::Song;
pub struct PlayerInterface {
music_player: Player,
playlist_name: String,
playlist_length: u32,
track_list: Vec<Strin... | true |
ebac8673ae5a5123f374d9bb50282e0472fab7a8 | Rust | hasezoey/yt-downloader-rust | /crates/libytdlr/src/spawn/editor.rs | UTF-8 | 358 | 2.875 | 3 | [
"MIT"
] | permissive | //! Module that contains all logic for spawning the "editor" command
use std::{
path::Path,
process::Command,
};
/// Create a new editor instance with the given filepath as a argument
#[inline]
pub fn base_editor(editor: &Path, filepath: &Path) -> Command {
let mut cmd = super::multiplatform::spawn_command(&editor)... | true |
160dbeaa05b0f4a00df8aba83f35e8c46fb226ff | Rust | OJFord/tapioca | /src/query.rs | UTF-8 | 1,162 | 3.265625 | 3 | [
"MIT"
] | permissive | pub type QueryPair = (String, String);
pub trait QueryString {
fn as_query_kv(&self) -> Vec<QueryPair>;
fn as_query(&self) -> String {
self.as_query_kv().iter()
.map(|&(ref k, ref v)| format!("{}={}", k, v))
.collect::<Vec<_>>()
.join("&")
}
}
pub trait QueryPa... | true |
0ba866032e2f53b9d20c15ad666c8144f57a15b8 | Rust | tobz1000/advent-of-code-2017 | /src/day18/mod.rs | UTF-8 | 1,778 | 3.296875 | 3 | [] | no_license | mod part1;
mod part2;
pub use self::part1::part1;
pub use self::part2::part2;
use std::str::FromStr;
#[derive(Debug)]
enum Instruction {
Snd(char),
Set(char, InstructionArg),
Add(char, InstructionArg),
Mul(char, InstructionArg),
Mod(char, InstructionArg),
Rcv(char),
Jgz(InstructionArg, In... | true |
ca11badce66ddcfbef91b7f70f3c402d79137f59 | Rust | SINHASantos/rust-rocks | /src/table_properties.rs | UTF-8 | 22,397 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | //! contains a bunch of read-only properties of its associated
//! table.
use std::u32;
use std::slice;
use std::str;
use std::fmt;
use std::mem;
use std::marker::PhantomData;
use std::ops;
use std::os::raw::{c_char, c_void};
use rocks_sys as ll;
use crate::types::SequenceNumber;
use crate::to_raw::{FromRaw, ToRaw};... | true |
6e6aad77babae599aad3ac7f295144f4d0df749f | Rust | tarunganwani/rust101 | /src/main.rs | UTF-8 | 287 | 2.796875 | 3 | [] | no_license | // mod leetcode;
fn main() {
// leetcode::arrays::l1_two_sum::execute();
partial();
}
fn partial() {
let m = 10;
match m {
1..=3 => println!("a"),
10 | 12 | 13 => println!("c"),
15..=30 => println!("b"),
_ => println!("default")
}
}
| true |
3556395a99ac758164268f9af03e072bab668d0a | Rust | victor-zed/tink-rust | /core/src/verifier.rs | UTF-8 | 1,667 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 The Tink-Rust Authors
//
// 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 applicable law or ag... | true |
2f51daed2c2e09decaefd2b6c1684dcaecd3ce33 | Rust | GuillaumeGomez/sysinfo | /src/linux/utils.rs | UTF-8 | 3,272 | 2.9375 | 3 | [
"MIT"
] | permissive | // Take a look at the license at the top of the repository in the LICENSE file.
use std::fs::File;
use std::io::{self, Read, Seek};
use std::path::{Path, PathBuf};
use crate::sys::system::REMAINING_FILES;
pub(crate) fn get_all_data_from_file(file: &mut File, size: usize) -> io::Result<String> {
let mut buf = Str... | true |
3d57ced9327ae2c30bb349f1f4948531840c66b4 | Rust | twizmwazin/weechat-dingy | /libdingy/src/message.rs | UTF-8 | 16,722 | 2.984375 | 3 | [
"BSD-3-Clause"
] | permissive | #![allow(dead_code)]
use backtrace::Backtrace;
use byteorder::{ByteOrder, BE};
use libflate::zlib;
use std::clone::Clone;
use std::io::{Cursor, Error, Read};
//
// Types
//
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone)]
pub struct Hdata {
pub h_path: Vec<String>,
pub keys: Vec<(String, String)>,
... | true |
576a008dd9477f50613697b8d65517c7f4a14fd3 | Rust | fetsorn/epochal_extractor | /api_server/src/main.rs | UTF-8 | 2,670 | 2.625 | 3 | [] | no_license | use database;
extern crate env_logger;
use actix_web::{get, middleware, web, App, Error, HttpResponse, HttpServer};
use diesel::prelude::*;
use diesel::r2d2::{self, ConnectionManager};
use serde::{Deserialize, Serialize};
type DbPool = r2d2::Pool<ConnectionManager<PgConnection>>;
#[derive(Serialize,Deserialize)]
#[a... | true |
469a18bdb57da979d38fa785a2701f426da90e70 | Rust | ChrisPWill/rustines | /src/cart.rs | UTF-8 | 2,702 | 3.078125 | 3 | [] | no_license | use std::iter::repeat;
use mem::Mem;
pub struct Cart
{
prg_rom_pages: Vec<PrgRom>,
prg_ram_pages: Vec<PrgRam>,
chr_rom_pages: Vec<ChrMem>,
chr_ram_pages: Vec<ChrMem>,
sram_pages: Vec<Sram>,
}
impl Cart
{
pub fn new(num_prg_ram: usize, num_chr_ram: usize, num_sram: usize) -> Cart
{
... | true |
23d7303af4cca431f15fdfb09bd4fca3c2ed5eda | Rust | RustyGecko/cargo-linkargs | /src/lib.rs | UTF-8 | 3,171 | 2.96875 | 3 | [] | no_license | #![deny(warnings)]
extern crate cargo;
use std::process::Output;
use cargo::ops::{ExecEngine, CommandPrototype};
use cargo::util::{ProcessError, ProcessBuilder};
type ExecResult = Result<Option<Output>, ProcessError>;
#[derive(Debug)]
pub struct LinkArgsEngine {
pub targets: Vec<String>,
pub link_args: Opt... | true |
b954034f40c1df0a952f1c8935574398a7d1a520 | Rust | sanisoclem/preint-test | /src/routes.rs | UTF-8 | 756 | 2.53125 | 3 | [] | no_license | use meta::{AppMetadata, APP_META};
use rocket::http::Status;
use rocket_contrib::json::{Json, JsonValue};
// root endpoint routes
#[get("/")]
pub fn get() -> &'static str {
"Hello World!"
}
#[get("/metadata")]
pub fn get_metadata() -> Json<AppMetadata<'static>> {
Json(APP_META)
}
#[get("/health")]
pub fn get... | true |
c1038334be226b3456d697e8a5a0472928bdedcc | Rust | guo-cheng/trio_binning | /src/threads.rs | UTF-8 | 7,164 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::{thread, error, result};
use std::sync::{Arc, Mutex, mpsc};
use std::io::{Read, Write};
use classify::{count_kmers_in_read, calc_scaling_factors};
use seq;
use kmer;
// number of Records that can be kept in the channel buffer at once
const BUFFER_SIZE: usize = 100;
struct CountResult {
hap_a_count: u32,
... | true |
65f9565ba83236cd518f45f4e3189905960febcf | Rust | nwtnni/advent-of-code | /aoc-22/src/day_22.rs | UTF-8 | 3,718 | 3.296875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use aoc::*;
#[derive(Clone, Debug)]
pub struct MonkeyMap {
size: i64,
grid: HashMap<Pos, Tile>,
path: Vec<Move>,
}
#[derive(Clone, Debug)]
enum Move {
Turn(bool),
Forward(i64),
}
#[derive(Clone, Debug)]
enum Tile {
Wall,
Floor,
}
impl Fro for MonkeyMap {
... | true |
69dfcddf0772b7345461b5a8886db4f35d028335 | Rust | jozanza/re-winit | /vendor/calloop/src/sys/epoll.rs | UTF-8 | 2,882 | 2.625 | 3 | [
"MIT",
"ISC"
] | permissive | use std::{io, os::unix::io::RawFd};
use super::{Interest, Mode, PollEvent, Readiness, Token};
use crate::no_nix_err;
use nix::sys::epoll;
pub struct Epoll {
epoll_fd: RawFd,
}
fn make_flags(interest: Interest, mode: Mode) -> epoll::EpollFlags {
let mut flags = match interest {
Interest::Readable => ... | true |
f95521565cc9c35dda84512ec9b4937529cab2e2 | Rust | abhyuditjain/leetcode_30_day_challenge | /src/walking_robot_simulation.rs | UTF-8 | 3,838 | 3.53125 | 4 | [] | no_license | /*
874. Walking Robot Simulation
A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands:
-2: turn left 90 degrees
-1: turn right 90 degrees
1 <= x <= 9: move forward x units
Some of the grid squares are obstacles.
The i-th obstacle is at gri... | true |
ca0839d8eeab208cca7e256d8249500ab855661e | Rust | fl0w99/farbe | /src/main.rs | UTF-8 | 3,126 | 3.125 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
#[macro_use]
extern crate nom;
use clap::{App};
use std::{fmt, process};
use std::str::FromStr;
const DEFAULT_WIDTH: u8 = 10;
const DEFAULT_HEIGHT: u8 = 5;
#[derive(Debug)]
pub struct Color {
pub red: u8,
pub green: u8,
pub blue: u8,
}
impl fmt::Display for Color {
... | true |
ed135059b701db85198402c4ce2ee7d59e20b04a | Rust | dobrite/yoga-rs | /src/style.rs | UTF-8 | 2,975 | 2.75 | 3 | [
"MIT"
] | permissive | use std::default::Default;
use yoga_wrapper;
#[derive(Debug, PartialEq)]
pub enum BackgroundColor<C> {
Color(C),
Transparent,
}
impl<C> Default for BackgroundColor<C> {
fn default() -> BackgroundColor<C> {
BackgroundColor::Transparent
}
}
#[derive(Debug)]
pub struct Style<C> {
color: Opt... | true |
66b8858b87f6aa8a5bad62b26c36b02c093f81b2 | Rust | repnop/rcc | /src/ir/mod.rs | UTF-8 | 11,816 | 2.59375 | 3 | [
"BSD-3-Clause"
] | permissive | mod expr;
mod static_init;
mod stmt;
use std::collections::{HashMap, VecDeque};
use std::convert::TryFrom;
use crate::data::{prelude::*, types::FunctionType, Initializer, Scope, StorageClass};
use cranelift::codegen::{
self,
ir::{
entities::StackSlot,
function::Function,
stackslot::{St... | true |
cccbda366b9dd9b9015395f7ed1aa2199f142470 | Rust | rust-lang/regex | /regex-automata/src/util/prefilter/aho_corasick.rs | UTF-8 | 6,119 | 2.75 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unicode"
] | permissive | use crate::util::{
prefilter::PrefilterI,
search::{MatchKind, Span},
};
#[derive(Clone, Debug)]
pub(crate) struct AhoCorasick {
#[cfg(not(feature = "perf-literal-multisubstring"))]
_unused: (),
#[cfg(feature = "perf-literal-multisubstring")]
ac: aho_corasick::AhoCorasick,
}
impl AhoCorasick {
... | true |
2360fc4e53c920d49664d153c4e2c6ce331946ee | Rust | junichi-tanaka/learn-rust-with-tests | /iteration/src/main.rs | UTF-8 | 363 | 3.609375 | 4 | [] | no_license | fn repeat(s: &str) -> String {
let mut repeated = s.to_string();
let repeat_count = 5;
for _i in 1..repeat_count {
repeated = repeated + s;
}
return repeated
}
fn main() {
println!("{}", repeat("a"));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
... | true |
9ac7f474550ca0506446c6fb13d4ef8f67408a8e | Rust | 49nord/utimeseries-rs | /src/database.rs | UTF-8 | 1,976 | 2.921875 | 3 | [
"MIT"
] | permissive | use super::{Error, TimeseriesReader, TimeseriesWriter};
use std::{fs, path, time};
#[derive(Debug)]
pub struct TimeseriesDatabase {
base_path: path::PathBuf,
}
impl TimeseriesDatabase {
#[inline]
pub fn new<P: AsRef<path::Path>>(p: P) -> TimeseriesDatabase {
TimeseriesDatabase {
base_p... | true |
966e121070f7cf24b5c6dd6988428640d36b6a39 | Rust | andy-hanson/rs | /crates/compile/src/module_resolver.rs | UTF-8 | 1,400 | 2.671875 | 3 | [] | no_license | use util::arena::Arena;
use util::path::Path;
use host::document_provider::DocumentProvider;
use model::document_info::DocumentInfo;
pub fn get_document_from_logical_path<'a, D: DocumentProvider<'a>>(
document_provider: &mut D,
logical_path: Path,
arena: &'a Arena,
) -> Result<GetDocumentResult<'a>, D::Error> {
... | true |
f887917bf0aa49c09b4a12bcd4bdfd35c43a2456 | Rust | styleex/rust-bplustree-example | /src/bin/node.rs | UTF-8 | 2,432 | 2.875 | 3 | [] | no_license | use crate::types::{PageId, PageHeader};
const MAX_KEY_SIZE: usize = 32;
type Key = [u8; MAX_KEY_SIZE];
type NodeId = usize;
// Указатель на данные дерева. Может указывать на:
// 1. memory mapping файла бд;
// 2. данные аллоцированные в хипе (vector) в ходе транзакции;
pub enum HeapValue<'a> {
MMapped(&'a [u8]),... | true |
b029651d5c3a7a6ae4e624411ad73bc77fd72380 | Rust | yyotti/euler_rust | /src/p0009.rs | UTF-8 | 1,176 | 3.09375 | 3 | [
"MIT"
] | permissive | //! [Problem 9](https://projecteuler.net/problem=9)([JP](http://www.odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%209))
use super::common;
pub const MAX_NUM: usize = 1000;
pub fn solve(input: usize) -> i64 {
// ピタゴラス数の一般項は、互いに素な正の整数 m, n (m > n, m - n は奇数) を用いて、
// a = m^2 - n^2, b = 2mn, c... | true |
872ad3f7f844f1df1ea08de683e65f8a2acde73d | Rust | nuta/archives | /resea2/libs/arch_common/bootinfo.rs | UTF-8 | 501 | 2.671875 | 3 | [] | no_license | use arrayvec::ArrayVec;
use crate::{paddr::PAddr, vaddr::VAddr};
const NUM_FREE_RAM_AREAS_MAX: usize = 8;
/// A continuous physical memory space available for OS.
#[derive(Debug)]
pub struct FreeRamArea {
/// The base vaddr.
pub vaddr: VAddr,
/// The base paddr.
pub paddr: PAddr,
/// The length i... | true |
9ecd2ba2e48358c812b6dd8080ec8d1cadbfce4a | Rust | darksv/libsyntax2 | /crates/libsyntax2/src/utils.rs | UTF-8 | 2,597 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fmt::Write;
use {
algo::walk::{preorder, walk, WalkEvent},
SyntaxKind, File, SyntaxNodeRef, TreeRoot,
};
/// Parse a file and create a string representation of the resulting parse tree.
pub fn dump_tree(syntax: SyntaxNodeRef) -> String {
let mut errors: Vec<_> = syntax.root.syntax_root().errors.it... | true |
bd52a493a5dfca4c3c90218fe93e3dfba46c7472 | Rust | bzm3r/rust-ncc | /simulator/src/utils/display.rs | UTF-8 | 238 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::math::round;
use crate::NVERTS;
pub fn stringify_f64_arr(arr: &[f64; NVERTS], round_to: u32) -> String {
arr.iter()
.map(|&x| round(x, round_to).to_string())
.collect::<Vec<String>>()
.join(", ")
}
| true |
36d5fd56cfad8c605accdad6505d1f8df07ba0b0 | Rust | chatziko/libalpaca | /src/aux.rs | UTF-8 | 266 | 3.15625 | 3 | [] | no_license | /// Converst a Result<T,E> to Result<T,String> by calling .to_string() on the error
pub fn stringify_error<T,E:ToString>(res: Result<T,E>) -> Result<T, String> {
match res {
Ok(res) => return Ok(res),
Err(e) => return Err(e.to_string()),
}
}
| true |
d8edd0820e0e40c7a257a39de9e25dde881c8a2d | Rust | iyzana/advent-of-code-2019 | /src/day4.rs | UTF-8 | 2,821 | 3.265625 | 3 | [] | no_license | use std::ops::{Range, RangeInclusive};
#[aoc_generator(day4)]
fn parse(input: &str) -> RangeInclusive<u32> {
let start = input[..6].parse().unwrap();
let end = input[7..].parse().unwrap();
start..=end
}
#[aoc(day4, part1)]
fn part1(range: &RangeInclusive<u32>) -> usize {
combinations1(range, 0, 6, fal... | true |
3dc3d2a523a75500c8c24a08ee47cf514be908c2 | Rust | askoufis/advent-of-code-2020 | /src/day18.rs | UTF-8 | 8,796 | 3.515625 | 4 | [] | no_license | fn contains_brackets(s: &str) -> bool {
s.contains('(') || s.contains(')')
}
fn is_symbol(c: char) -> bool {
c == '+' || c == '*'
}
fn is_mul(s: &str) -> bool {
s.contains('*')
}
fn is_add(s: &str) -> bool {
s.contains('+')
}
fn clean_string(s: &str) -> String {
s.trim().chars().filter(|&c| c !=... | true |
63ece8aa3d8a768388008a5613b5d8e1ea4c391f | Rust | kamirr/blogrs_backend | /src/api/manage_posts.rs | UTF-8 | 2,353 | 2.8125 | 3 | [] | no_license | use crate::guards::auth::AuthGuard;
use crate::db::connection::Pool;
use crate::db::manage_posts::*;
use crate::db::models::WebPost;
use crate::auth::*;
use rocket_contrib::json::{Json, JsonValue};
use rocket::State;
fn status_ok(status: &str, id: u64, pool: &State<Pool>) -> JsonValue {
json!({
"status": ... | true |
b6073d415d9b5d1ab156bef7c48f259870c7676b | Rust | elauffenburger/sixty-five-oh-too | /src/cpu/status_reg.rs | UTF-8 | 1,904 | 2.90625 | 3 | [] | no_license | use super::util;
use std::fmt;
#[derive(Clone)]
pub struct ProcessorStatusRegister {
pub negative: bool,
pub overflow: bool,
pub brk: bool,
pub decimal_mode: bool,
pub irq_disable: bool,
pub zero: bool,
pub carry: bool,
}
impl Into<u8> for ProcessorStatusRegister {
f... | true |
8e170a7ab62fba862ad304099646169ec05398fe | Rust | sunguru98/escrow-solana | /program/src/processor.rs | UTF-8 | 17,317 | 2.515625 | 3 | [] | no_license | use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
msg,
program::{invoke, invoke_signed},
program_error::ProgramError,
program_pack::{IsInitialized, Pack},
pubkey::Pubkey,
sysvar::{rent::Rent, Sy... | true |
09bcccac00ca80b133d241199ccd4135ee7b2724 | Rust | ThomasZumsteg/adventofcode2018 | /day18.rs | UTF-8 | 5,059 | 3.390625 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::hash_map;
use common::get_input;
use common::point::Point;
#[derive(Clone)]
struct TreeMap {
map: HashMap<Point, char>,
upper_left: Point,
lower_right: Point,
}
impl TreeMap {
fn new(input: String) -> TreeMap {
let mut map = HashMap::new();... | true |
12c390d94c7710b32ffdb0eef54762b63e1ff575 | Rust | hhanh00/adventofcode2017 | /d4/src/d11.rs | UTF-8 | 902 | 3.296875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead};
pub fn main() {
let f = File::open("d11.txt").expect("Cannot open file");
let r = BufReader::new(&f);
let line = r.lines().next().unwrap().unwrap();
let steps = line.split(",");
let mut x: i32 = 0;
let mut y: i32 = 0;
let mut z: i32 = 0;
let mut m... | true |
9008265b04b1813c4b297e054dd8420e7d582d22 | Rust | jazz-lang/WaffleLink | /src/bytecompiler/register_id.rs | UTF-8 | 898 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
pub struct RegisterID {
rc: u32,
virtual_register: VirtualRegister,
is_tmp: bool,
}
impl RegisterID {
pub fn ref_(&mut self) {
self.rc += 1;
}
pub fn deref(&mut self) {
self.rc -= 1;
}
pub fn rc(&self) -> u32 {
self.rc
}
pub fn is_tmp(&se... | true |
52dc36f919b8bd5fc976adf34864e0a9fba03f54 | Rust | shashankhacker730/feroxbuster | /src/scanner/requester.rs | UTF-8 | 39,254 | 2.546875 | 3 | [
"MIT"
] | permissive | use std::{
cmp::max,
sync::{atomic::Ordering, Arc, Mutex},
};
use anyhow::Result;
use leaky_bucket::LeakyBucket;
use tokio::{
sync::{oneshot, RwLock},
time::{sleep, Duration},
};
use crate::{
atomic_load, atomic_store,
config::RequesterPolicy,
event_handlers::{
Command::{self, AddE... | true |
af5e22ece601e73be9850c6034fa4fe94541be5d | Rust | triptec/raycast_dqn | /sandbox/src/ray.rs | UTF-8 | 2,778 | 2.875 | 3 | [] | no_license | use crate::utils;
use geo::{Coordinate, Line, LineString, Point, Rect};
pub struct Ray {
pub angle: f64,
pub length: f64,
pub max_length: f64,
pub line_string: LineString<f64>,
pub line: Line<f64>,
pub in_fov: bool,
pub angle_adj: f64,
}
impl Ray {
pub fn new(
angle: f64,
... | true |
14e84391c9785096429b35fd3386f9226371802c | Rust | superdump/partyarty | /src/ray.rs | UTF-8 | 453 | 3.15625 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | use glam::Vec3A;
pub struct Ray {
pub origin: Vec3A,
pub direction: Vec3A,
}
impl Ray {
pub fn new(o: Vec3A, d: Vec3A) -> Ray {
Ray {
origin: o,
direction: d,
}
}
pub fn at_t(&self, t: f32) -> Vec3A {
self.origin + self.direction * t
}
}
impl D... | true |
413d808d9998fd42fb72df1e4acc8268e5d57535 | Rust | chansuke/arith-parser | /src/main.rs | UTF-8 | 677 | 3.28125 | 3 | [] | no_license | use arith_parser::eval;
use arith_parser::Parser;
use rustyline::Editor;
fn main() {
let mut rl = Editor::<()>::new();
loop {
let input = rl.readline("Please enter the arithmetric >> ");
match evaluate(input.unwrap()) {
Ok(val) => println!("Computed number is: {}", val),
... | true |
de16f2b8b11fa316bac4f12231100e9c4d0e45b2 | Rust | hussein-aitlahcen/async_ib | /src/domain/contract.rs | UTF-8 | 4,291 | 2.625 | 3 | [
"MIT"
] | permissive | use domain::tag_value::TagValue;
use std::default::Default;
use std::io;
#[derive(Debug, Clone, Default)]
pub struct DeltaNeutralContract {
pub con_id: i32,
pub delta: f64,
pub price: f64,
}
impl DeltaNeutralContract {
pub fn new(con_id: i32, delta: f64, price: f64) -> Self {
DeltaNeutralContr... | true |
02ae31a49ae56591a57f1392ee58c33c2c3c4d2b | Rust | zmilan/devand | /devand-ui/src/app/components/code_now_page.rs | UTF-8 | 3,048 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use crate::app::components::affinities_table::view_affinities_table;
use crate::app::elements::busy_indicator;
use crate::app::services::CodeNowService;
use crate::app::{AppRoute, RouterAnchor};
use devand_core::CodeNow;
use yew::{prelude::*, Properties};
#[derive(Default)]
pub struct State {
code_now: Option<Code... | true |
3361130354d3d63db5bca91dfd633fdb94bab37c | Rust | vn-ki/ftrace-rs | /src/function/mod.rs | UTF-8 | 1,402 | 2.890625 | 3 | [
"MIT"
] | permissive | mod dwarf;
mod heuristic;
use crate::defs::Register;
use crate::error::ParamFindingFailure;
pub use dwarf::{get_functions_dwarf, dwarf_get_line_breakpoints};
pub use heuristic::get_functions;
#[derive(Debug)]
pub struct Function {
pub address: u64,
pub prologue_end_addr: Option<u64>,
pub name: String,
... | true |
2a1c201a5ee71f9997fb28e6250bc14e7b582cd4 | Rust | Lunderberg/advent-of-code-2020 | /src/bin/day21.rs | UTF-8 | 3,385 | 3.109375 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use itertools::Itertools;
#[derive(Debug)]
struct Recipe {
ingredients: HashSet<String>,
allergens: HashSet<String>,
}
impl std::str::FromStr for Recipe {
type Err = util::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut sections = s.... | true |
df1d319fadee18e98abf0b1f261df7777f7bbd17 | Rust | virgesmith/rust101 | /cons.rs | UTF-8 | 2,006 | 3.796875 | 4 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq, Eq)]
enum List<T: Clone> {
Node(T, Box<List<T>>),
End
}
// use std::iter::{self, Sum};
// use std::ops::Add;
// use std::Zero;
impl<T: Clone> List<T> {
pub fn new(head: T, tail: Self) -> Self {
List::Node(head, Box::new(tail))
}
pub fn to_vec(&self) -> Vec<T> {
match self... | true |
c50894650f946b8eff8798d980bd7c21420637e1 | Rust | nilq/zubtime | /src/zubtime/io.rs | UTF-8 | 3,617 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::fs::{ self, File };
use std::io::prelude::*;
use std::path::Path;
use colored::*;
use serde::{Deserialize, Serialize};
use serde_json::Result;
#[derive(Serialize, Deserialize)]
pub struct SubTask {
pub name: String,
pub content: String,
}
#[derive(Serialize, Deserialize)]
pub struct Task {
pub ... | true |
37ac21e5ec121d0f86cf7337f5ce3b97d1e20f56 | Rust | xeals/sunk | /src/collections/artist.rs | UTF-8 | 7,826 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Artist APIs.
use std::{fmt, result};
use serde::de::{Deserialize, Deserializer};
use serde_json;
use crate::query::Query;
use crate::{Album, Client, Error, Media, Result, Song};
/// Basic information about an artist.
#[allow(missing_docs)]
#[derive(Debug, Clone)]
pub struct Artist {
pub id: usize,
pub n... | true |
763624d974f112e737c96fb8d72026eb47a666f0 | Rust | lencx/rust-learn-demo | /modules/nested_modules/src/main.rs | UTF-8 | 678 | 3.171875 | 3 | [] | no_license | pub mod test_modules {
pub mod series {
pub mod of {
pub fn nested_mod() {
println!("nested modules");
}
}
}
}
#[derive(Debug)]
enum TrafficLight {
Red,
Yellow,
Green,
}
// use test_modules::series::of; // ①
use test_modules::series::of::nes... | true |
897491f8c64f2af564eb4b11a6072fe911d870bd | Rust | rcore-os-infohub/ossoc2020-Yufei-YAO-daily | /Lab2/src/main.rs | UTF-8 | 2,723 | 2.59375 | 3 | [] | no_license | //! # 全局属性
//! - `#![no_std]`
//! 禁用标准库
#![no_std]
//!
//! - `#![no_main]`
//! 不使用 `main` 函数等全部 Rust-level 入口点来作为程序入口
#![no_main]
//!
//! - `#![deny(missing_docs)]`
//! 任何没有注释的地方都会产生警告:这个属性用来压榨写实验指导的学长,同学可以删掉了
#![warn(missing_docs)]
#![feature(llvm_asm)]
//! # 一些 unstable 的功能需要在 crate 层级声明后才可以使用
//! - `#![f... | true |
89192c2ca7a9cf97d8e4125ebedbe0ddfe80aa01 | Rust | TummeliRuonakoski/CodeWars | /8 kyu/Abbreviate a Two Word Name/Rust.rs | UTF-8 | 404 | 2.984375 | 3 | [] | no_license | fn abbrev_name(name: &str) -> String {
name.split_whitespace().map(|i| i[0..1].to_uppercase()).collect::<Vec<_>>().join(".")
}
// Rust test example:
#[test]
fn sample_tests() {
assert_eq!(abbrev_name("Sam Harris"), "S.H");
assert_eq!(abbrev_name("Patrick Feenan"), "P.F");
assert_eq!(abbrev_name("Evan Cole"),... | true |
fda59f80dbcf11b6786bd8f3a6830cb2a3b73260 | Rust | cthulahoops/aoc2020 | /src/day9.rs | UTF-8 | 1,837 | 3.140625 | 3 | [] | no_license | use std::collections::HashSet;
use std::collections::VecDeque;
fn is_valid(history: &VecDeque<i64>, candidate: i64) -> bool {
let mut previous = HashSet::new();
for item in history {
if previous.contains(&(candidate - item)) {
return true;
}
previous.insert(item);
}
... | true |
9755b5c9bcf917acf2e69781ff3bba8152f25b74 | Rust | digital-asset/rusty-engine | /src/ast/load.rs | UTF-8 | 4,795 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
use regex::Regex;
use std::collections::HashMap;
use std::io::*;
use super::{Expr, ModuleRef, Package, World};
impl Package {
fn load<R: Read>(reader: &mut R) -> Result<Self> {... | true |
45238780d2e0955da7cc70943b325c981e97e281 | Rust | dylni/process_control | /tests/debug.rs | UTF-8 | 949 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::process;
#[cfg(unix)]
use std::os::unix as os;
#[cfg(windows)]
use std::os::windows as os;
use os::process::ExitStatusExt;
use process_control::ExitStatus;
use process_control::Output;
fn test(result: &str, string: &[u8]) {
let exit_status: ExitStatus = process::ExitStatus::from_raw(0).into();
asse... | true |
29ddc028d46c130fdc4c986b47c01fa1605e9f0b | Rust | grubern/vulkano | /vulkano/src/buffer/mod.rs | UTF-8 | 5,298 | 3.171875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright (c) 2016 The vulkano developers
// 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. All files in the project carrying such
// notice may not be co... | true |
7a3c8d222d3d70931e27fe7e38a41adf9af2a5d8 | Rust | bonsairobo/sled-snapshots | /src/delta_set.rs | UTF-8 | 2,350 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::delta::RawDelta;
use std::ops::Deref;
/// A wrapper around a byte slice used for decoding a set of `Delta`s.
///
/// The on-disk encoding is a sequence of [RawDelta](crate::raw_delta::RawDelta).
#[derive(Clone)]
pub struct RawDeltaSet<B> {
pub bytes: B,
}
impl<B> RawDeltaSet<B>
where
B: Deref<Targ... | true |
362f0a871a48fa0e40ac76918516c9c457233b71 | Rust | KomodoPlatform/parity-common | /kvdb-rocksdb/src/iter.rs | UTF-8 | 4,865 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | 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 |
eacf5b8012020341ea0416b53cf51c7836ece11b | Rust | sugyan/leetcode | /others/september-leetcoding-challenge/week-2/3457/lib.rs | UTF-8 | 995 | 3.4375 | 3 | [] | no_license | pub struct Solution {}
impl Solution {
pub fn combination_sum3(k: i32, n: i32) -> Vec<Vec<i32>> {
let mut answer: Vec<Vec<i32>> = Vec::new();
let mut v: Vec<i32> = Vec::new();
Solution::helper(k, n, &mut v, &mut answer);
answer
}
fn helper(k: i32, n: i32, v: &mut Vec<i32>, a... | true |
b23e89aa6057fde945336ba465f7f38949bed43c | Rust | IThawk/rust-project | /rust-master/src/test/ui/anonymous-higher-ranked-lifetime.rs | UTF-8 | 1,250 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | fn main() {
f1(|_: (), _: ()| {}); //~ ERROR type mismatch
f2(|_: (), _: ()| {}); //~ ERROR type mismatch
f3(|_: (), _: ()| {}); //~ ERROR type mismatch
f4(|_: (), _: ()| {}); //~ ERROR type mismatch
f5(|_: (), _: ()| {}); //~ ERROR type mismatch
g1(|_: (), _: ()| {}); //~ ERROR type mismatch
... | true |
cb3e066798c0071f0ee924e77d4a180f0defcd72 | Rust | leshow/tokio-playground | /interval/src/interval.rs | UTF-8 | 1,510 | 3.078125 | 3 | [] | no_license | use futures::task::Task;
use std::{
sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc, Mutex,
},
thread,
time::Duration,
};
pub struct Interval {
counter: Arc<AtomicUsize>,
running: Arc<AtomicBool>,
task: Option<Task>, // i don't think Arc<Mutex<Task>> is necessary
}
... | true |
17f746fbe781431cb7705121538c58c737c52c68 | Rust | eirproject/eir | /util/libeir_util_datastructures/src/aux_traits/mod.rs | UTF-8 | 2,218 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use std::fmt::{Debug, Formatter, Result as FmtResult};
use std::hash::{Hash, Hasher};
mod bforest_impl;
mod entity_impl;
mod std_impl;
pub trait HasAux<Inner> {
fn get_aux(&self) -> &Inner;
}
impl<T> HasAux<T> for T {
fn get_aux(&self) -> &Self {
self
}
}
impl<T> HasAux<T> for &T {
fn get_aux(... | true |
cfdb57b53ed784c1ae889a76741d853148370013 | Rust | a-poor/timeme | /src/main.rs | UTF-8 | 5,088 | 3.296875 | 3 | [
"MIT"
] | permissive | use clap::{App, Arg};
use std::process::Command;
use std::time::{Duration, Instant};
const VERSION: &str = "0.2.4";
/// Calculates the sum of the of the floats
/// in the given `Vector`.
///
/// Note: Only works with `f64` since that's
/// all that's necessary for this program.
///
/// # Arguments
///
/// * `data... | true |
76dd38928d24d4facea9eb917f416b7b0e5fa150 | Rust | shepmaster/humansize | /examples/sizes.rs | UTF-8 | 584 | 2.953125 | 3 | [] | no_license | extern crate humansize;
//Import the trait and the options module
use humansize::{FileSize, file_size_opts};
fn main() {
// Call the file_size method on any non-negative integer with the option set you require
println!("{}", 5456.file_size(file_size_opts::BINARY).unwrap());
println!("{}", 1024.file_size(fi... | true |
3826f315fd221594c249eec91128b83b560d2138 | Rust | dawid2193487/tetrahedrane | /src/renderers/zbuffer.rs | UTF-8 | 4,467 | 2.90625 | 3 | [
"MIT"
] | permissive | use orbclient;
use super::super::geometry;
use super::super::texture;
use std;
pub struct ZBuffer {
w: u32,
h: u32,
data: Box<[f32]>
}
impl ZBuffer {
pub fn new(width: u32, height: u32) -> Self {
use std::f32;
ZBuffer {
w: width,
h: height,
data: vec... | true |
389e3a9a77f8cb37583aaaaad0c52b3df19deede | Rust | adamnemecek/Gestalt | /gestalt/src/voxel/subdivmath.rs | UTF-8 | 5,553 | 3.453125 | 3 | [] | no_license | //! Math helper code that describes an octree-style subdividing voxel space,
//! where each voxel is either a NODE or a LEAF. Each node is cut into eight
//! subunits (split in half along all three cardinal axis), each of which is
//! 1/2 the length of the parent node along each axis and is 1/8th of its volume.
//! E... | true |
5b44b3fc5f90693cf4671cb47bd5b507cdf17267 | Rust | jbr/rust-ops | /src/trillium.rs | UTF-8 | 2,417 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::sync::Arc;
use crate::status::Status;
use crate::Result;
use serde::Serialize;
use trillium::{conn_try, conn_unwrap, Conn, Handler, State};
use trillium_router::Router;
/// Routes to be attached to a Trillium app runtime
pub fn router<S: Status + 'static>(status: S) -> impl Handler {
let status = Arc::n... | true |
5ed24efe68aa5c1b7de43fe3a326fd7603faf6fe | Rust | GreatAttractor/genetic | /src/vm.rs | UTF-8 | 47,243 | 3.328125 | 3 | [
"MIT"
] | permissive | //
// genetic - genetic programming experiments
// Copyright (c) 2019 Filip Szczerek <ga.software@yahoo.com>
//
// This project is licensed under the terms of the MIT license
// (see the LICENSE file for details).
//
//
// File description:
// Module: virtual machine.
//
/// Virtual machine's computational data type... | true |
9f1795d33f82cefad03dce26a2cccdde74b75239 | Rust | Delamare2112/rust-learning-and-practice | /AoC1/src/point.rs | UTF-8 | 325 | 3.171875 | 3 | [] | no_license | #[derive(Debug, Copy, Clone, PartialEq)]
pub struct Point {
pub x: isize,
pub y: isize
}
impl Point {
pub const ZERO: Point = Point {x: 0, y: 0};
pub fn get_distance(&self) -> isize {
self.x.abs() + self.y.abs()
}
}
impl Default for Point {
fn default() -> Point {
Point::ZERO
... | true |
dc52951213362a5b37517f472ae9811b45cd6d70 | Rust | Noah-Kennedy/algorithms-final-project | /benches/reversed.rs | UTF-8 | 5,175 | 2.59375 | 3 | [] | no_license | use criterion::{AxisScale, BenchmarkId, Criterion, criterion_group, criterion_main, PlotConfiguration, Throughput};
use jemallocator::Jemalloc;
use rand::seq::SliceRandom;
use rand::thread_rng;
use sorts_rs::{InPlaceSorter, OutOfPlaceSorterSorter};
use sorts_rs::binary_insertion_sort::BinaryInsertionSorter;
use sorts_... | true |
8246b075f632f99b210aaa61882dae9920363b67 | Rust | eigenform/nil | /src/block/fmt.rs | UTF-8 | 483 | 2.65625 | 3 | [] | no_license |
use std::fmt;
use crate::block::*;
impl fmt::Display for BlockLink {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
BlockLink::Branch(a) => write!(f, "Branch({})", a),
BlockLink::BranchAndLink(addr, lr) =>
write!(f, "BranchAndLink({}, {})",... | true |
ff8d707605d2c6c160d6fd86f5838e1dff5db042 | Rust | valerio-vaccaro/BEWallet | /src/model.rs | UTF-8 | 4,177 | 2.609375 | 3 | [
"MIT"
] | permissive | use crate::error::Error;
use elements::Script;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use elements::bitcoin::hashes::hex::FromHex;
use elements::OutPoint;
use std::fmt::{Debug, Display};
use std::str::FromStr;
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct TXO {
pub outpo... | true |
71afc0f66a6afafa4b6e7529c77a44282b43f199 | Rust | Nertsal/leaderboard_server | /src/database/score.rs | UTF-8 | 481 | 2.84375 | 3 | [] | no_license | use rocket::serde::{Deserialize, Serialize};
// Types allowed in the database:
// i32
// i64
// f32
// f64
// bool
// &'r str
// String
pub type GameScore = i32;
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(crate = "rocket::serde")]
pub struct ScoreRecord {
pub score: GameScore,
pub ext... | true |
0709eff2c040da95328fee00835eafef1200f5d6 | Rust | Bigomby/codingame-texas-holdem | /tests/codingame.rs | UTF-8 | 284 | 3.046875 | 3 | [
"MIT"
] | permissive | extern crate poker;
#[test]
fn test_high_card() {
let player1 = String::from("8D 7C");
let player2 = String::from("7D 6C");
let table = String::from("KS 9D 5C 3S 2D");
let result = poker::play(player1, player2, table);
assert_eq!(result, "1 HIGH_CARD K9875");
}
| true |
1522fa304b5ea846aa1854ddc105f4ecba0fff6c | Rust | CNife/leetcode | /rust/finished/src/next_greater_element_3.rs | UTF-8 | 898 | 3.59375 | 4 | [] | no_license | pub struct Solution;
impl Solution {
pub fn next_greater_element(n: i32) -> i32 {
let mut digits = n.to_string().into_bytes();
let (i, ei) = match digits
.iter()
.enumerate()
.zip(digits[1..].iter())
.rfind(|((_, el), er)| el < er)
{
... | true |
5f525d71e9e313b07167369e606a8f3e19a0d21e | Rust | genya0407/image2aa | /web/src/lib.rs | UTF-8 | 1,529 | 3.203125 | 3 | [
"MIT"
] | permissive | use image::{Rgb, RgbImage};
use imageproc::drawing::draw_text_mut;
use rusttype::Font;
use rusttype::Scale;
pub fn text2image(text: String) -> image::RgbImage {
let font = Vec::from(include_bytes!("../assets/font/VL-Gothic-Regular.ttf") as &[u8]);
let font = Font::try_from_vec(font).unwrap();
let x_font_s... | true |
248dbbb92b210fb2f026d4934cca06a0c3c6703f | Rust | max-block/solana-free-tx | /program/src/lib.rs | UTF-8 | 1,496 | 2.640625 | 3 | [] | no_license | use std::convert::TryInto;
use solana_program::{
account_info::{AccountInfo, next_account_info},
entrypoint,
entrypoint::ProgramResult,
msg,
program::invoke,
program_error::ProgramError,
pubkey::Pubkey,
system_instruction,
};
use solana_program::clock::Clock;
use solana_program::sysvar:... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.