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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
751a2fd63de8d440cbb843005df566800b4b1d67 | Rust | Twinklebear/light_arena | /src/lib.rs | UTF-8 | 9,254 | 3.421875 | 3 | [
"MIT"
] | permissive | //! **Temporarily a more simple memory pool for keeping stack alloc objects
//! in copied into a shared heap rather than a true placement new memory arena.**
//! Unfortunately the path forward for placement new in Rust does not look
//! good right now, so I've reverted this crate to work more like a memory
//! heap whe... | true |
1dbcc26a6d8426a596e8138f0e0a47529252b843 | Rust | kbknapp/usbwatch-rs | /src/state.rs | UTF-8 | 5,912 | 2.921875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::{
collections::HashMap,
fs::{self, File},
path::Path,
};
use tracing::{self, debug, info, span, Level};
use yaml_rust::YamlLoader;
use crate::{
rule::{Rule, Rules},
usb::{UsbDevice, UsbDevices, UsbPort, UsbPorts},
};
#[derive(Default)]
pub struct State {
ports: Vec<UsbPort>,
devi... | true |
e942eef8a7b54c5bea48e16e4c8115fb3e7edce2 | Rust | baitcenter/gdlk | /api/src/util.rs | UTF-8 | 1,566 | 3.078125 | 3 | [] | no_license | //! General utility functions and types.
#[cfg(test)]
pub use tests::*;
use diesel::{r2d2::ConnectionManager, PgConnection};
/// Type aliases for DB connections
pub type Pool = r2d2::Pool<ConnectionManager<PgConnection>>;
pub type PooledConnection =
r2d2::PooledConnection<ConnectionManager<PgConnection>>;
#[cfg... | true |
69b8a13cedffdf5f63a897310fe5a57949ab4a19 | Rust | chromium/chromium | /third_party/rust/semver/v1/crate/src/lib.rs | UTF-8 | 19,858 | 2.828125 | 3 | [
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! [![github]](https://github.com/dtolnay/semver) [![crates-io]](https://crates.io/crates/semver) [![docs-rs]](https://docs.rs/semver)
//!
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?... | true |
48d11db5ccb940b2f1803cbd9b0a3329d5c2043c | Rust | vikrem/linkerd2-proxy | /linkerd/proxy/detect/src/lib.rs | UTF-8 | 4,987 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use linkerd2_error::Error;
use linkerd2_io::{BoxedIo, Peek};
use linkerd2_proxy_core as core;
use pin_project::{pin_project, project};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
/// A strategy for detecting values out of a client transport.
pub trait Detect<T>: Clone {
type Target;... | true |
b6d81c360fc9e5655ca5c00740708a5d33511de0 | Rust | aldhsu/fuzzy-matcher | /src/skim.rs | UTF-8 | 10,511 | 2.8125 | 3 | [
"MIT"
] | permissive | ///! The fuzzy matching algorithm used by skim
///! It focus more on path matching
///
///! # Example:
///! ```edition2018
///! use fuzzy_matcher::skim::{fuzzy_match, fuzzy_indices};
///!
///! assert_eq!(None, fuzzy_match("abc", "abx"));
///! assert!(fuzzy_match("axbycz", "abc").is_some());
///! assert!(fuzzy_match("ax... | true |
c32c64587b0b9c1ef7b7f2f9c2a046575b6ebf8e | Rust | lukisko/rust_chap_10 | /src/main.rs | UTF-8 | 1,857 | 3.65625 | 4 | [] | no_license |
fn main() {
println!("Hello, world!");
let poin = Point {x:10.0,y:20.0};
println!("x part of point is {} and distance from origin is {}.",poin.x(),poin.distance_from_origin());
}
fn largest(list: &[i32]) -> i32 {
let mut largest = list[0];
for &number in list {
if number > largest {
... | true |
74c1c06e568a2010de3eb55578c441a9c2c94dc9 | Rust | SnakeSolid/rust-gantt-diagram | /src/database/mod.rs | UTF-8 | 4,849 | 2.6875 | 3 | [
"MIT"
] | permissive | mod error;
pub use self::error::DatabaseError;
pub use self::error::DatabaseResult;
use fallible_iterator::FallibleIterator;
use postgres::params::ConnectParams;
use postgres::params::Host;
use postgres::Connection;
use postgres::TlsMode;
use time::strptime;
use time::Timespec;
#[derive(Debug)]
pub struct PostgreSQL... | true |
d7165d8f059af78c4249d911b03d72631a456a78 | Rust | adcopeland/peuler | /rust/peuler/src/bin/p10.rs | UTF-8 | 147 | 2.890625 | 3 | [] | no_license | fn main() {
let mut sum: u64 = 0;
for i in 1..2000000 {
if peuler::is_prime(i) {
sum += i as u64
}
}
println!("{}", sum);
}
| true |
a863b5d07a247b004ad140a36da00e116924662e | Rust | rhysd/Shiba | /v2/src/markdown/parser.rs | UTF-8 | 36,182 | 2.546875 | 3 | [
"MIT"
] | permissive | use super::sanitizer::{should_rebase_url, Sanitizer, SlashPath};
use crate::renderer::RawMessageWriter;
use aho_corasick::AhoCorasick;
use emojis::Emoji;
use memchr::{memchr_iter, Memchr};
use pulldown_cmark::{
Alignment, CodeBlockKind, CowStr, Event, HeadingLevel, LinkType, MathDisplay, Options, Parser,
Tag,
}... | true |
ea6f2d2b290899bebb21159217cfdf59f8c8008c | Rust | fnune/exercises | /linked_list/linked_list.rs | UTF-8 | 3,121 | 3.734375 | 4 | [
"MIT"
] | permissive | #![feature(alloc)]
#![feature(shared)]
extern crate alloc;
extern crate core;
use alloc::boxed::{Box};
use core::ptr::{Shared};
struct Node<T> {
content: T,
next: Option<Shared<Node<T>>>,
}
impl<T> Node<T> {
fn new(content: T) -> Self {
Node {
next: None,
content,
... | true |
daf52c17056783913857ced97bf466c4c89609f4 | Rust | lain-dono/klein-rs | /glsl_shim.rs | UTF-8 | 4,759 | 3.296875 | 3 | [] | no_license | pub fn swizzle_index(c: char) -> usize {
match c {
'x' => 0,
'y' => 1,
'z' => 2,
'w' => 3,
_ => unimplemented!(),
}
}
/*
#define SWIZZLE(a, b, c, d) \
swizzle<swizzle_index(#a[0]), \
swizzle_index(#b[0]), \
swizzle_index(#c[0]), \
... | true |
b6b508f2a95329f89a910c7d75cf8c779b10e643 | Rust | nimiq/core-rs | /beserial/src/types.rs | UTF-8 | 6,198 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | use crate::{Deserialize, ReadBytesExt, Serialize, SerializingError, WriteBytesExt};
use num;
#[allow(non_camel_case_types)]
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Copy, Clone)]
pub struct uvar(u64);
impl From<uvar> for u64 {
fn from(u: uvar) -> Self { u.0 }
}
impl From<u64> for uvar {
fn from(u: u64... | true |
4ae52db70e06e474eaa4596b8c39bbea4af6524a | Rust | rust-lang/rust | /library/portable-simd/crates/core_simd/src/alias.rs | UTF-8 | 4,097 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-other-permissive"
] | permissive | macro_rules! number {
{ 1 } => { "one" };
{ 2 } => { "two" };
{ 4 } => { "four" };
{ 8 } => { "eight" };
{ $x:literal } => { stringify!($x) };
}
macro_rules! plural {
{ 1 } => { "" };
{ $x:literal } => { "s" };
}
macro_rules! alias {
{
$(
$element_ty:ty = {
... | true |
e776a4de65e77bd610a53df3de60d70b76f4baed | Rust | cGuille/adventofcode | /src/bin/2020-day4-part1.rs | UTF-8 | 759 | 3.015625 | 3 | [] | no_license | use std::collections::HashSet;
fn main() {
let batch = include_str!("../../input/2020-day4.txt");
let valid_passport_count = batch
.split("\n\n")
.filter(|passport_str| has_required_attributes(passport_str))
.count();
println!("{}", valid_passport_count);
}
fn has_required_attrib... | true |
6df5798a8f6e64debc86bb99cb243cd84ebb9111 | Rust | guillaumebreton/ruin | /src/main.rs | UTF-8 | 3,674 | 2.71875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate diesel;
#[macro_use]
extern crate diesel_migrations;
use chrono::NaiveDate;
use clap::{Parser, Subcommand};
use diesel::prelude::*;
use crossterm::{
event::{DisableMouseCapture, EnableMouseCapture},
execute,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, Leav... | true |
7cd4f120aa60dc79f2e38c804d383a2851c17fb5 | Rust | juneym/rust-lang-tutorial | /src/cli.rs | UTF-8 | 344 | 3.34375 | 3 | [] | no_license | // sample cli's use of arguments
use std::env;
pub fn run() {
let args: Vec<String> = env::args().collect();
let command = args[1].clone(); //why do you have to use .clone()??
println!("\nargs: {:?}", args);
println!("\ncommand: {}", command);
if command == "hello" {
println!("Hey ... | true |
1a8de1b6017c58016b2e6bb96b4df43836dc20c0 | Rust | akshayknarayan/simulator | /src/node/switch/drop_tail_queue.rs | UTF-8 | 3,712 | 3.015625 | 3 | [] | no_license | use std::collections::VecDeque;
use node::Link;
use node::switch::Queue;
use packet::Packet;
#[derive(Debug)]
pub struct DropTailQueue{
limit_bytes: u32,
link: Link,
pkts: VecDeque<Packet>,
forced_next: Option<Packet>,
active: bool,
paused: bool,
}
impl DropTailQueue {
pub fn new(limit_by... | true |
132709ffc8d95dd0ef2df42d5535185e7b8d1939 | Rust | nigelgray/rust-audio-analyser | /src/wav_helpers.rs | UTF-8 | 1,689 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::sync::atomic::{Ordering};
// To find the RMS gain
// - Calculate the RMS value of the generated audio
// - Calculate the RMS value of the recorded audio
// - Calculate the power between the signals, using the generated audio as the reference
// (positive value means amplification, negative means attenuat... | true |
88a2a4ed3d920a6b50652f055c8c530333ae91e5 | Rust | sria91-rlox/cat-lox | /src/lexer/core.rs | UTF-8 | 5,111 | 3.6875 | 4 | [
"MIT"
] | permissive | use super::token::*;
pub struct Lexer {
input: Vec<char>,
index: usize,
}
impl Iterator for Lexer {
type Item = Token;
fn next(&mut self) -> Option<Token> {
match self.advance() {
None => None,
// Operators
Some('+') => Some(Token::Plus),
Some('... | true |
1e121ec8be3577093268d22579675c828345cb74 | Rust | cloew/KaoBoy | /src/cpu/instructions/jump/conditions.rs | UTF-8 | 3,242 | 2.828125 | 3 | [] | no_license | use super::super::utils::{check_half_carry};
use super::super::super::instruction_context::InstructionContext;
pub fn always(context: &InstructionContext) -> bool {
return true;
}
pub fn is_carry_flag_off(context: &InstructionContext) -> bool {
return context.registers().carry_flag.get() == false;
}
... | true |
01efae5778d259345ebd37771f1ae6a59908cae6 | Rust | aicacia/rs-lexer | /src/token.rs | UTF-8 | 714 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::TokenMeta;
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug, Eq, PartialOrd, Ord, Hash)]
pub struct Token<T> {
meta: TokenMeta,
value: T,
}
unsafe impl<T> Send for Token<T> where T: Send {}
unsafe impl<T> Sync for Token<T> where T: Sync {}
impl<T> Token<T> {
#[inline(always)]
pub fn new(me... | true |
73dafda5b5dd20fc668be9760d08a4cdbd4a9861 | Rust | chromium/chromium | /third_party/rust/getrandom/v0_2/crate/src/error.rs | UTF-8 | 8,110 | 2.640625 | 3 | [
"MIT",
"Apache-2.0",
"BSD-3-Clause",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] | permissive | // Copyright 2018 Developers of the Rand project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
/... | true |
454b656776ef9ea552c3c6d8a0b47eb502367581 | Rust | vanhtuan0409/aoc | /2022/src/bin/day6/main.rs | UTF-8 | 595 | 2.5625 | 3 | [] | no_license | use aoc_2022::get_input_file;
use itertools::Itertools;
use std::fs::File;
use std::io::{self, BufRead};
fn main() {
let f: io::Result<File> = get_input_file!("input1.txt");
let r = io::BufReader::new(f.unwrap());
r.lines().map(|line| line.unwrap()).for_each(|line| {
println!("======");
le... | true |
01839d034cd249a1e9dc8685da3c8a47731c3bf0 | Rust | ErisMik/minecator | /src/minecraft/chunk.rs | UTF-8 | 786 | 2.75 | 3 | [] | no_license | use byteorder::{BigEndian, ByteOrder};
use nbt;
use std::io::Cursor;
#[derive(Debug)]
pub struct Chunk {
timestamp: u32,
blob: nbt::Blob,
}
impl Chunk {
pub fn new(timestamp: u32, data: Vec<u8>) -> std::io::Result<Chunk> {
let chunk_length = BigEndian::read_u32(&data[0..4]) as usize;
let c... | true |
d1827d3f85c8e79749a0f2c183e4134b86d74ae0 | Rust | femnad/leth | /src/main.rs | UTF-8 | 2,851 | 2.5625 | 3 | [] | no_license | extern crate regex;
extern crate skim;
extern crate structopt;
use std::collections::HashMap;
use std::io::Cursor;
use std::io::{self, Read};
use std::process::{Command, Stdio};
use regex::Regex;
use skim::prelude::*;
use structopt::StructOpt;
const LINE_SPLITTER: char = '=';
const URL_REGEX: &str = r"(http(s)?://[a... | true |
45ab8b0a952d1ebd042a38d187027ee3fb551320 | Rust | DanMaycock/fortunes_algorithm_rs | /src/boundingbox.rs | UTF-8 | 17,186 | 3.359375 | 3 | [] | no_license | use super::*;
use std::f64;
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Side {
Left,
Right,
Top,
Bottom,
None,
}
impl Side {
// Iterates round the sides in an anti clockwise direction
fn next(self) -> Side {
match self {
Side::Left => Side::Bottom,
Sid... | true |
13aae36a5299459fc447b9505026e6a796e511ad | Rust | Xudong-Huang/radiotap | /src/lib.rs | UTF-8 | 12,446 | 3.234375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A parser for the [Radiotap](http://www.radiotap.org/) capture format.
//!
//! # Usage
//!
//! The `Radiotap::from_bytes(&capture)` constructor will parse all present
//! fields into a [Radiotap](struct.Radiotap.html) struct:
//!
//! ```
//! use radiotap::Radiotap;
//!
//! fn main() {
//! let capture = [
//! ... | true |
f44f5a594c915e78aba56d4941978cd9c394ea29 | Rust | BurntSushi/rust-analyzer | /xtask/src/codegen.rs | UTF-8 | 2,791 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! We use code generation heavily in rust-analyzer.
//!
//! Rather then doing it via proc-macros, we use old-school way of just dumping
//! the source code.
//!
//! This module's submodules define specific bits that we generate.
mod gen_syntax;
mod gen_parser_tests;
mod gen_assists_docs;
use std::{mem, path::Path};
... | true |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 26