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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
33836ee9c32fde50ee69c84e864f55391e2487c5 | Rust | VersBinarii/spike | /src/controllers/session.rs | UTF-8 | 2,459 | 2.53125 | 3 | [] | no_license | use actix_web::{
error::{ErrorBadRequest, ErrorInternalServerError, ErrorUnauthorized},
web, Error as ActixErr, HttpResponse,
};
use futures::{Future, IntoFuture};
use crate::db;
use crate::models::{LoginUser, LogoutUser};
use crate::AppState;
pub fn login(
user: web::Json<LoginUser>,
state: web::Data... | true |
61fec907976b385159dc3c4e3e23c9f3b975af47 | Rust | databricks/click | /src/duct_mock.rs | UTF-8 | 2,979 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 Databricks, Inc.
// 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 agreed to in writi... | true |
2457a8f46b7867934520b5b5edd4e0e9cd6ce0f5 | Rust | Cassy343/trojan | /src/keyboard.rs | UTF-8 | 8,303 | 2.546875 | 3 | [] | no_license | /*
NOTE: THIS CODE IS NOT ORIGINAL; IT WAS COPIED AND MODIFIED FROM THE PROJECT BELOW
Source: https://github.com/obv-mikhail/InputBot
*/
use std::{
mem::MaybeUninit,
ptr::null_mut,
sync::{atomic::{AtomicPtr, Ordering}, Mutex},
};
use winapi::{
ctypes::*,
shared::{minwindef::*, windef::*},
um::... | true |
1e03a65b5243aafb2afbf02ac2434fec9322684e | Rust | amrosaeed/Fluence-Service | /quickstart/2-hosted-services/src/main.rs | UTF-8 | 2,112 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2021 Fluence Labs Limited
*
* 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 a... | true |
fd0fe1e1c5e399c2566ac2e54eead84899c22e79 | Rust | astral-sh/ruff | /crates/ruff_python_parser/src/soft_keywords.rs | UTF-8 | 7,031 | 3.265625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-free-unknown",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0"
] | permissive | use crate::{lexer::LexResult, token::Tok, Mode};
use itertools::{Itertools, MultiPeek};
/// An [`Iterator`] that transforms a token stream to accommodate soft keywords (namely, `match`
/// `case`, and `type`).
///
/// [PEP 634](https://www.python.org/dev/peps/pep-0634/) introduced the `match` and `case` keywords
/// a... | true |
86bc7a929900074162342b8bcc393010b3c6708a | Rust | Enigmatrix/aoc17 | /src/day12.rs | UTF-8 | 1,360 | 2.84375 | 3 | [] | no_license | use std::collections::*;
use disjoint_sets::UnionFind;
pub fn day12_1(s: String) -> usize {
let m:Vec<_> = s.split('\n').map(|line| {
let dat = line.split(" <-> ").collect::<Vec<&str>>();
(
dat[0].parse::<usize>().unwrap(),
dat[1]
.split(", ")
... | true |
33bcdf9109194696348ae5e26be2a65f7c72181d | Rust | dennisss/dacha | /pkg/fan_controller/src/avr/debug.rs | UTF-8 | 1,931 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | macro_rules! debug {
($a:expr) => {{
let tx = $crate::avr::usart::USART1Transmission::start().await;
($a).debug_write(&mut tx);
drop(tx);
}};
}
// #[inline(never)]
// pub fn uart_send_number_sync(num: u8) {
// num_to_slice(num, |data| uart_send_sync(data));
// }
pub fn num_to_slice... | true |
4d5cf9bc7cad6e42a9f79cc9e34689b7ac618697 | Rust | gogobook/xmr | /p2p/src/net/connect.rs | UTF-8 | 2,099 | 2.59375 | 3 | [] | no_license | use std::io;
use std::sync::Arc;
use std::net::SocketAddr;
use futures::{Future, Poll};
use tokio_core::reactor::Handle;
use tokio_core::net::{TcpStream, TcpStreamNew};
use uuid::Uuid;
use p2p::Context;
use levin::{LevinError, DefaultEndian, Invoke, invoke};
use protocol::handshake::CryptoNoteHandshake;
pub fn conn... | true |
882cbc98ab59cf21c43eebed42b0198c81052d3f | Rust | gleam-lang/gleam | /compiler-core/src/erlang/tests/let_assert.rs | UTF-8 | 857 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | use crate::assert_erl;
#[test]
fn one_var() {
// One var
assert_erl!(
r#"pub fn go() {
let assert Ok(y) = Ok(1)
y
}"#
);
}
#[test]
fn more_than_one_var() {
// More vars
assert_erl!(
r#"pub fn go(x) {
let assert [1, a, b, c] = x
[a, b, c]
}"#
);
}
#[test]
fn pattern_let... | true |
2ff05bb5528573856fe7927aae5288a39f4fdcbc | Rust | shadowkun/wasm-learning | /faas/ocr/src/lib.rs | UTF-8 | 1,356 | 2.75 | 3 | [] | no_license | use std::fs;
use std::str;
use std::fs::File;
use std::io::{Write, Read};
use wasm_bindgen::prelude::*;
use rust_process_interface_library::Command;
use ssvm_wasi_helper::ssvm_wasi_helper::_initialize;
#[wasm_bindgen]
pub fn ocr(img_buf: &[u8]) -> String {
_initialize();
// Create temp file to store image
let pa... | true |
086abd5ad408b2ac589ea73f7f8787f843f14f84 | Rust | qkniep/qdb | /src/disk_manager.rs | UTF-8 | 2,426 | 3.171875 | 3 | [
"MIT"
] | permissive | // Copyright (C) 2021 Quentin Kniep <hello@quentinkniep.com>
// Distributed under terms of the MIT license.
use std::convert::TryInto;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Seek, SeekFrom, Write};
use crate::page::{PageID, PAGE_SIZE};
/// A trivial Disk Manager implementation that has all pages... | true |
6130c0b384f3a1972fcb9ac30e88ba77af97e4c0 | Rust | IThawk/rust-project | /rust-master/src/test/ui/privacy/restricted/auxiliary/pub_restricted.rs | UTF-8 | 263 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![feature(crate_visibility_modifier)]
pub(crate) struct Crate;
#[derive(Default)]
pub struct Universe {
pub x: i32,
pub(crate) y: i32,
crate z: i32,
}
impl Universe {
pub fn f(&self) {}
pub(crate) fn g(&self) {}
crate fn h(&self) {}
}
| true |
bea16555ef6273079691dce18e97a7fba53dff43 | Rust | sankar-boro/loony | /loony-service/src/macros.rs | UTF-8 | 2,180 | 3.484375 | 3 | [
"MIT"
] | permissive | /// An implementation of [`poll_ready`]() that always signals readiness.
///
/// This should only be used for basic leaf services that have no concept of un-readiness.
/// For wrapper or other serivice types, use [`forward_ready!`] for simple cases or write a bespoke
/// `poll_ready` implementation.
///
/// [`poll_read... | true |
4f521786bdb091bb0963fe422d8c7cd5e2df3a49 | Rust | vitiral/defrag-rs | /src/raw_pool.rs | UTF-8 | 28,140 | 2.84375 | 3 | [
"MIT"
] | permissive | /*
Contains all the logic related to the RawPool. The RawPool is
what actually contains and maintains the indexes and memory.
*/
use core::mem;
use core::ptr;
use core::default::Default;
use core::fmt;
use cbuf::CBuf;
use super::types::*;
use super::free::{FreedBins, Free, NUM_BINS};
use super::utils;
// ##########... | true |
27662ef7a6413456156431b1337094f69853eb3c | Rust | Lucretia/Primes | /PrimeRust/solution_4/PrimeRust.rs | UTF-8 | 4,086 | 3.046875 | 3 | [] | no_license | //------------------------------------------------------------------------------------------
// PrimeRust.rs : Ported to Rust by Joshua Allen Based on Dave's Garage Prime Sieve - No warranty for anything!
// Also note: I tried to follow the structure of the CPP version as close as possible and may not be in a perfect ... | true |
d017efd66a21e0de713fcfcd7e6a6dc867f74828 | Rust | netvl/md.rs | /src/parser/config.rs | UTF-8 | 541 | 2.796875 | 3 | [
"MIT"
] | permissive | #[derive(Copy)]
pub struct MarkdownConfig {
pub trim_newlines: bool
}
impl MarkdownConfig {
#[inline]
pub fn default() -> MarkdownConfig {
MarkdownConfig {
trim_newlines: true
}
}
}
macro_rules! impl_setters {
($target:ident; $($name:ident : $t:ty),+) => ($(
imp... | true |
89075a262e008f2e7a3b3eecab009817509c2c29 | Rust | sria91-rlox/rlox-3 | /src/rlox/resolver/mod.rs | UTF-8 | 9,301 | 2.96875 | 3 | [] | no_license | use rlox::parser::Stmt;
use rlox::parser::Expr;
use rlox::token::Token;
use std::collections::hash_map::HashMap;
#[derive(Clone, PartialEq)]
enum ClassType {
Class,
SubClass,
}
#[derive(Clone, PartialEq)]
enum FunctionType {
Function,
Method,
Initializer,
}
pub struct Resolver {
scopes: Vec<H... | true |
e0bced6665d3f2e95ac53645c9a0ee4201da318f | Rust | MiyamonY/atcoder | /abc/040/c/01/src/main.rs | UTF-8 | 2,120 | 2.9375 | 3 | [] | no_license | use std::cmp::min;
#[allow(unused_macros)]
macro_rules! scan {
() => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
};
(;;) => {
{
let mut line: String = String::new(... | true |
fa71c74ef65d8a710a52933f198205d3466b6735 | Rust | dyedgreen/uncertain | /tests/basic_expect.rs | UTF-8 | 2,448 | 3.25 | 3 | [
"MIT"
] | permissive | use rand_distr::{Normal, Poisson};
use rand_pcg::Pcg32;
use uncertain::*;
#[test]
fn basic_gaussian() {
let centers: Vec<f64> = vec![0.0, 3.5, 1.73, 234.23235];
for center in centers {
let x = Distribution::from(Normal::new(center, 1.0).unwrap());
let mu = x.expect(0.1);
assert!(mu.is_o... | true |
9f0263864f260adc464438fc836340982b306cc5 | Rust | redox-os/syscall | /src/call.rs | UTF-8 | 12,001 | 2.84375 | 3 | [
"MIT"
] | permissive | use super::arch::*;
use super::data::{Map, SigAction, Stat, StatVfs, TimeSpec};
use super::error::Result;
use super::flag::*;
use super::number::*;
use core::{mem, ptr};
// Signal restorer
extern "C" fn restorer() -> ! {
sigreturn().unwrap();
unreachable!();
}
/// Close a file
pub fn close(fd: usize) -> Resu... | true |
e9befd833a1b174ea6ac57fcf20678859c7b8466 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/arc006/src/bin/b.rs | UTF-8 | 1,174 | 3.0625 | 3 | [] | no_license | fn read<T: std::str::FromStr>(
stdin_lock: &mut std::io::StdinLock,
buf: &mut Vec<u8>,
delimiter: u8,
) -> T {
buf.clear();
let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
buf.truncate(l - 1); // remove delimiter
let s = unsafe { std::str::from_utf8_unchecked(&buf)... | true |
025dd880a9c92b1e6ab63f4ee8dda1348ee0b6ff | Rust | wata-orz/santa17 | /src/common.rs | UTF-8 | 2,019 | 2.734375 | 3 | [
"MIT"
] | permissive | #[macro_export]
macro_rules! debug {
($($v:expr),*) => { {
use ::std::io::Write;
$(let _ = write!(::std::io::stderr(), "{} = {:?} ", stringify!($v), $v);)*
let _ = writeln!(::std::io::stderr(), "@ {}:{}", file!(), line!());
} }
}
#[macro_export]
macro_rules! mat {
($e:expr) => { $e };
($e:expr; $d:expr $(; $... | true |
9aeaa9e2198efdef8bea822ecf92cb972e4fa2ec | Rust | nylar/java-parser | /src/parser.rs | UTF-8 | 5,567 | 2.546875 | 3 | [] | no_license | use super::{AccessModifier, Annotation, Class, CompilationUnit, Field, FieldType, Import, Method};
use nom::multispace;
fn is_word(b: u8) -> bool {
match b {
b'a'...b'z' | b'A'...b'Z' | b'0'...b'9' | b'.' => true,
_ => false,
}
}
named!(
word<String>,
map_res!(take_while!(is_word), |b... | true |
7f4780e0bee35ec775214db82d33be3286201cc9 | Rust | mbillingr/miniKANREN | /rust-canonical/src/database.rs | UTF-8 | 2,241 | 3.203125 | 3 | [
"MIT"
] | permissive | //! A simple relational database
use crate::core::value::Value;
use std::collections::HashMap;
pub struct Database {
db: HashMap<String, Vec<Vec<Value>>>,
default_table: Vec<Vec<Value>>,
}
impl Database {
pub fn new() -> Self {
Database {
db: HashMap::new(),
default_table:... | true |
aacf8d8ae624ee4dbee23157de1b11d821cbbd9f | Rust | BurntSushi/ripgrep | /crates/matcher/tests/util.rs | UTF-8 | 2,490 | 2.796875 | 3 | [
"MIT",
"Unlicense"
] | permissive | use std::collections::HashMap;
use std::result;
use grep_matcher::{Captures, Match, Matcher, NoCaptures, NoError};
use regex::bytes::{CaptureLocations, Regex};
#[derive(Debug)]
pub struct RegexMatcher {
pub re: Regex,
pub names: HashMap<String, usize>,
}
impl RegexMatcher {
pub fn new(re: Regex) -> Regex... | true |
b6f8afdc42a405e9d619f19c920aea5e3e9e9728 | Rust | YuriMalinov/rlox | /src/main.rs | UTF-8 | 976 | 2.84375 | 3 | [] | no_license | use std::env;
use std::fs;
use std::io;
use std::io::Write;
use std::process::exit;
use rlox::Scanner;
use crate::rlox::StdErrErrorHandler;
mod rlox;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() > 2 {
println!("Usage: rlox [script]");
exit(64);
} else if args.... | true |
282a79c9d0170ee5945b99c11161f03ea7b725e8 | Rust | indragiek/advent-of-code-2020 | /day16part2/src/main.rs | UTF-8 | 4,597 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::{self, BufRead};
#[macro_use]
extern crate lazy_static;
extern crate regex;
use regex::Regex;
enum ParseStage {
Rules,
YourTicket,
NearbyTickets,
}
fn main() {
let args: Vec<String> = env::args().collect();
let filename... | true |
b92948ca91930ffe188933038f549363dcb0c141 | Rust | pvginkel/noisy | /src/gen/simplex.rs | UTF-8 | 12,187 | 2.734375 | 3 | [
"Unlicense"
] | permissive | //! An implementation of [Simplex Noise]
//! (https://en.wikipedia.org/wiki/Simplex_noise).
//!
//! Based on a speed-improved simplex noise algorithm for 2D, 3D and 4D in Java.
//! Which is based on example code by Stefan Gustavson (stegu@itn.liu.se).
//! With Optimisations by Peter Eastman (peastman@drizzle.stanford.e... | true |
020f0d1300b1ebb11077c8d686a2e47616b0a4c4 | Rust | ChylerDev/BAE | /src/utils/mono_resampler.rs | UTF-8 | 3,044 | 3.421875 | 3 | [
"MIT"
] | permissive | //! # MonoResampler
//!
//! Trans codes the given audio signal from it's source sampling rate to the
//! sampling rate BAE runs at.
use super::*;
use sample_format::{SampleFormat, MonoTrackT};
/// Type used for fractional indexing.
type IndexT = SampleT;
/// Struct tracking all of the data required for resampling, ... | true |
8df087eba5eaaf3909e4822617d92bc0a19bbb41 | Rust | zoewithabang/zerotube | /backend/src/services/passwords.rs | UTF-8 | 772 | 2.671875 | 3 | [] | no_license | use crate::messages::error::ErrorResponse;
use argon2rs::verifier::Encoded;
use rand::RngCore;
pub fn compare_password(raw_password: &str, hashed_password: &str) -> Result<bool, ErrorResponse> {
let encoded = Encoded::from_u8(hashed_password.as_bytes()).map_err(|_| {
log::error!("Unable to reconstruct hash... | true |
e42da0cddca1227067733fe21c678041f10a2ddf | Rust | sampersand/quest | /parser/src/token/token.rs | UTF-8 | 3,512 | 3.328125 | 3 | [
"MIT"
] | permissive | use crate::Result;
use crate::stream::Stream;
use crate::token::{ParenType, Operator, Primitive, Tokenizable};
use std::fmt::{self, Display, Formatter};
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Token {
Primitive(Primitive),
Operator(Operator),
Left(ParenType),
Right(ParenType),
Endline(bool), // whether or... | true |
d8b941fde399250ddd55f0f2572a2a3caf283549 | Rust | Pyxxil/tech-interview-as-a-service | /src/traits/help.rs | UTF-8 | 323 | 2.78125 | 3 | [
"MIT"
] | permissive | use serde::Serialize;
pub trait Help {
fn help_message() -> String;
}
impl<T: Serialize + Default> Help for T {
fn help_message() -> String {
format!(
"Help: Try sending a JSON body with the following:\n{}\n",
serde_json::to_string_pretty(&T::default()).unwrap()
)
}... | true |
f902731a34fd9bd7e619911ca2f185b0c1b02710 | Rust | timglabisch/rustinvoice | /src/entity/invoice.rs | UTF-8 | 954 | 2.90625 | 3 | [] | no_license | use entity::address::Address;
use std::default::Default;
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
pub struct Invoices {
pub items : Vec<Invoice>
}
#[derive(Serialize, Deserialize, Default, Debug, Clone)]
pub struct Invoice {
#[serde(default)]
pub short_name : String,
#[serde(default)]
pub pr... | true |
eea992c960069d0e94110f555f9947b1dba8ea39 | Rust | grogers0/advent_of_code | /2016/day19/src/main.rs | UTF-8 | 1,670 | 3.578125 | 4 | [
"MIT"
] | permissive | use std::io::{self, Read};
use linked_list::{LinkedList, Cursor};
fn next_circular(cursor: &mut Cursor<usize>) -> usize {
if let Some(elem) = cursor.next() {
*elem
} else {
*cursor.next().unwrap()
}
}
fn remove_circular(cursor: &mut Cursor<usize>) -> usize {
if let Some(elem) = cursor... | true |
1919de1867a5222b2c89c7a6f6ae737f4c84ef38 | Rust | brianduff/rust-playground | /src/threadfun.rs | UTF-8 | 692 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::Result;
use std::sync::mpsc;
use std::thread;
pub struct Opt {
pub project: Option<String>
}
impl Opt {
pub fn options(&self) -> Options {
match self.project {
Some(ref p) => Options::Third(p.clone()),
None => Options::First
}
}
}
pub enum Options {
First,
Second,
Third(St... | true |
788069f600ddda671e18d17d2d84fd5049d6b41e | Rust | JacobJohansen/psst | /psst-gui/src/data/config.rs | UTF-8 | 3,389 | 2.734375 | 3 | [
"MIT"
] | permissive | use druid::{Data, Lens};
use platform_dirs::AppDirs;
use psst_core::{
audio_player::PlaybackConfig, cache::mkdir_if_not_exists, connection::Credentials,
};
use serde::{Deserialize, Serialize};
use std::{fs::File, path::PathBuf};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Data)]
pub enum PreferencesTab {
Gener... | true |
642cb5800b306ab5587b7087b4d930c07393e88a | Rust | uzzol101/mystore | /tests/product_test.rs | UTF-8 | 1,773 | 2.515625 | 3 | [] | no_license | extern crate mystore;
mod common;
use mystore::model::product::{Person, Product, NewProduct};
use mystore::routes::product::{init_routes, test};
use common::db::establish_connection;
use serde::{Deserialize, Serialize};
#[cfg(test)]
mod tests {
use super::*;
use actix_web::{test, web, App};
... | true |
0188003e078e101c749ed4eab9ba775301ad811d | Rust | pypaut/plants | /plants/src/iterate.rs | UTF-8 | 1,246 | 2.71875 | 3 | [] | no_license | use crate::pattern;
use crate::symbolstring::SymbolString;
use crate::iter_ctx::{IterCtx, LightCtx};
use std::collections::HashMap;
// Apply rules once from left to right on the given word.
pub fn iterate(s : &SymbolString, ctx_list : &mut HashMap<String, IterCtx>) -> SymbolString {
let mut result = SymbolString:... | true |
52ef1baff42a0bc4b725087ab040f9b5b5476812 | Rust | neodigm/foxbot | /src/handlers/channel_photo.rs | UTF-8 | 8,330 | 2.53125 | 3 | [] | no_license | use async_trait::async_trait;
use failure::ResultExt;
use tgbotapi::{requests::*, *};
use super::Status::*;
use crate::needs_field;
use crate::utils::{find_best_photo, get_message, match_image};
pub struct ChannelPhotoHandler;
#[async_trait]
impl super::Handler for ChannelPhotoHandler {
fn name(&self) -> &'stati... | true |
a32996cfc9dff62d82b88bfe720649a38af7a376 | Rust | LibreTuner/LibreTuner-rs | /src/error.rs | UTF-8 | 1,534 | 2.71875 | 3 | [] | no_license | use tuneutils;
use std::{result, io, fmt};
#[derive(Debug)]
pub enum Error {
TuneUtils(tuneutils::error::Error),
Io(io::Error),
NoHome,
#[cfg(feature = "cli")]
InvalidCommand,
#[cfg(feature = "cli")]
Clap(clap::Error),
InvalidPlatform,
UnknownModel,
InvalidDatalink,
DownloadUnsupported,
InvalidRom,
}
pub ... | true |
d7343163b3f6e01756946ad4aa813a2e0c49d257 | Rust | kimkanu/hyperbolic-minesweeper | /wasm/src/utils/math/coord.rs | UTF-8 | 5,741 | 3.328125 | 3 | [] | no_license | use num_complex::Complex;
use num_traits::{Float, Num, Zero};
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug, Default)]
pub struct Normal<T = f64>(pub Complex<T>);
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug, Default)]
pub struct Poincare<T = f64> {
pub norm: T,
pub arg: T,
}
impl<T: Float + HaveConst... | true |
a993a4ab05366aac6184330655c98634c0aed05f | Rust | rust-vmm/vmm-sys-util | /src/syscall.rs | UTF-8 | 1,776 | 3.125 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: BSD-3-Clause
//! Wrapper for interpreting syscall exit codes.
use std::os::raw::c_int;
/// Wrapper to interpret syscall exit codes and provide a rustacean `io::Result`.
#[derive(Debug)]
pub struct SyscallReturnCode... | true |
2365739101ede53beaaa8228780654c90a7aa73a | Rust | MozarellaMan/aylox-lang | /alox-bytecode/src/vm.rs | UTF-8 | 2,530 | 3.296875 | 3 | [
"MIT"
] | permissive | use crate::{chunk::{Chunk, Value}, compiler, opcodes::Op};
const STACK_UNDERFLOW: &str = "Stack underflow!";
macro_rules! binary_op {
($self:ident,$operator:tt) => {
{
let b = $self.pop();
let a = $self.pop();
$self.push(a $operator b);
}
};
}
pub type Inte... | true |
a20087d2865f9bc065f04e6b55053f49a5934aad | Rust | kiwiyou/tgbot | /src/types/chat/mod.rs | UTF-8 | 20,962 | 2.890625 | 3 | [
"MIT"
] | permissive | use crate::types::{
chat::raw::{RawChat, RawChatKind},
message::Message,
primitive::Integer,
};
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
mod member;
mod permissions;
mod photo;
mod raw;
pub use self::{
member::{ChatMember, ChatMemberAdministrator, ChatMem... | true |
43690b62fb05ca2b85539aac936a2572f73631e2 | Rust | zzzzzzzzzzz0/zhscript-rust | /src/keyword.rs | UTF-8 | 1,311 | 3.21875 | 3 | [] | no_license | #[derive(PartialEq, Debug)]
pub enum Id {
No,
Juhao,
Kaiyinhao, Biyinhao,
Eval,
Print,
Cr, Lf, Tab, Esc,
}
#[derive(Debug)]
pub struct Item {
val:&'static str,
val2:Id,
}
impl Item {
pub fn val(&self) -> &str {
self.val
}
pub fn val2(&self) -> &Id {
&self.val2
}
}
const fn new(val:&'static str, val2:... | true |
f2e294f1a5ae66544c5f94a3e1ab2c7724a69feb | Rust | MacTuitui/nannou | /nannou/src/state.rs | UTF-8 | 9,177 | 3.40625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Small tracked parts of the application state. Includes **window**, **keys**, **mouse**, and
//! **time** - each of which are stored in the **App**.
pub use self::keys::Keys;
pub use self::mouse::Mouse;
pub use self::time::Time;
pub use self::window::Window;
/// Tracked state related to the focused window.
pub mod... | true |
9165ba87003bed57dd57e1b1ee72e2da7b4559f5 | Rust | crumblingstatue/advent-of-code | /src/bin/15d2.rs | UTF-8 | 1,450 | 3 | 3 | [] | no_license | fn parse_lwh(text: &str) -> (i32, i32, i32) {
let mut splits = text.split('x');
let l = splits.next().unwrap().parse().unwrap();
let w = splits.next().unwrap().parse().unwrap();
let h = splits.next().unwrap().parse().unwrap();
(l, w, h)
}
fn paper_req_lwh(l: i32, w: i32, h: i32) -> i32 {
let si... | true |
74448f6dfe4ebcca7ca92e656a1a59f24e0292e3 | Rust | Kuzirashi/godwoken | /crates/types/src/generated/godwoken.rs | UTF-8 | 603,483 | 2.78125 | 3 | [
"MIT"
] | permissive | // Generated by Molecule 0.7.2
use super::blockchain::*;
use molecule::prelude::*;
#[derive(Clone)]
pub struct Uint32Vec(molecule::bytes::Bytes);
impl ::core::fmt::LowerHex for Uint32Vec {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
use molecule::hex_string;
if f.alternat... | true |
2096be842770d3c4856391b13d2855613bf532ec | Rust | clinuxrulz/sodium-rust-push-pull | /src/sodium/impl_/latch.rs | UTF-8 | 1,528 | 2.828125 | 3 | [] | no_license | use sodium::gc::Finalize;
use sodium::gc::GcDep;
use sodium::gc::Trace;
use std::cell::UnsafeCell;
use std::rc::Rc;
pub struct Latch<A> {
data: Rc<UnsafeCell<LatchData<A>>>
}
struct LatchData<A> {
thunk: Box<Fn()->A>,
val: A
}
impl<A: Trace> Trace for Latch<A> {
fn trace(&self, f: &mut FnMut(&GcDep))... | true |
2c2e9c6091399f5c51b6c0de771751f078f2ea99 | Rust | ccqpein/Arithmetic-Exercises | /Capacity-To-Ship-Packages-Within-D-Days/C2SPWDD.rs | UTF-8 | 1,603 | 3.578125 | 4 | [
"Apache-2.0"
] | permissive | pub fn ship_within_days(weights: Vec<i32>, days: i32) -> i32 {
//helper(&weights, days).unwrap()
helper2(&weights, days)
}
// beyond time limit
fn helper(w: &[i32], days: i32) -> Option<i32> {
if w.len() == 0 {
return None;
}
if days == 1 {
return Some(w.iter().sum());
}
l... | true |
fa478b2d31812688107125235640b7cdc179fd69 | Rust | wombat-hue/rust-book-code-listings | /listings/ch15-smart-pointers/listing-15-08/src/main.rs | UTF-8 | 110 | 2.65625 | 3 | [] | no_license | struct MyBox<T>(T);
impl<T> MyBox<T> {
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
fn main() {}
| true |
0104d75db46ebdfcf323cf632241e52d93fd9dba | Rust | qinxiaoguang/rs-lc | /src/solution/l029.rs | UTF-8 | 2,025 | 3.484375 | 3 | [] | no_license | pub struct Solution {}
impl Solution {
// 不使用除法,乘法,mod计算两个数相除的商
// 不使用除法,但是可以使用加法,减法,此题可以考虑快速蜜
#![allow(dead_code)]
pub fn divide(dividend: i32, divisor: i32) -> i32 {
let mut is_neg = false;
if (dividend > 0 && divisor < 0) || (dividend < 0 && divisor > 0) {
is_neg = true
... | true |
37bb13ca7e0b2e22c0b5b35aeda49c14f56105ff | Rust | mashiro-no-rabo/pingcap-tp | /examples/bb3-serde.rs | UTF-8 | 2,259 | 3 | 3 | [] | no_license | // serde data format
// Rust types -- (impl Serialize) --> serde data model (types) -- (impl Serializer) --> String/Vec<u8>/Write...
// &str/&[u8]/Read... -- (impl Deserializer) --> serde data model (types) -- (impl Deserialize) --> Rust types
use anyhow::{Context, Result};
use resp_serde::{read_command, read_reply, w... | true |
b8eb8ff12c8e6b4818ce8a7f062a779127fe5457 | Rust | carrotflakes/termaze | /src/main.rs | UTF-8 | 1,048 | 2.609375 | 3 | [] | no_license | mod maze;
mod maze_maker;
mod maze_state;
mod terminal;
use maze_state::MazeState;
use std::time::SystemTime;
fn main() {
let mut seed = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis() as u64;
let maze = maze_maker::make_maze(8, 5, seed);
let mut maze_state = MazeState::new(m... | true |
4a33d4e7ed07f8e1ad16f936fb0a9fce7221226c | Rust | neodes-h/design-pattern-rust | /src/builder/main.rs | UTF-8 | 1,498 | 3.859375 | 4 | [] | no_license | #[derive(Debug, Copy, Clone)]
enum Gender {
Male,
Female,
}
#[derive(Debug)]
struct Person {
name: String,
gender: Gender,
age: u8,
}
#[derive(Debug)]
struct PersonBuilder {
name: String,
gender: Gender,
age: u8,
}
impl Default for PersonBuilder {
fn default() -> Self {
Sel... | true |
6008cfda029b6fde6f315c7cf105e5937aa9bdbc | Rust | piperRyan/rust-postgres-interval | /src/integrations/duration.rs | UTF-8 | 2,713 | 3.625 | 4 | [
"MIT"
] | permissive | use crate::{interval_norm::IntervalNorm, Interval};
use chrono::Duration;
const NANOS_PER_SEC: i64 = 1_000_000_000;
const NANOS_PER_MICRO: i64 = 1000;
impl Interval {
/// Tries to convert from the `Duration` type to a `Interval`. Will
/// return `None` on a overflow. This is a lossy conversion in that
/... | true |
6dbf17ec99006ac6dd118de5d3d4758e31f35426 | Rust | n1tram1/gameboy | /src/main.rs | UTF-8 | 1,037 | 2.640625 | 3 | [] | no_license | use std::path;
use std::time::{Duration, Instant};
use std::thread::sleep;
mod cpu;
mod mbc;
mod mmu;
mod registers;
mod ppu;
mod decode;
mod lcd;
mod palette;
mod joypad;
mod timer;
fn main() {
let start = Instant::now();
let rom_path = path::Path::new("/home/martin/Documents/gameboy-rs/roms/Tetris.GB");
... | true |
81a8da42693c207bc0b02ee338205e9c0083c6c3 | Rust | boyminty/my_horrible_rust_program | /src/main.rs | UTF-8 | 2,042 | 2.921875 | 3 | [] | no_license | use regex::Regex;
extern crate clap;
use clap::{App, Arg};
use reqwest::blocking;
use unicode_segmentation::{UnicodeSegmentation, UnicodeSentences};
// use tokio::io::{AsyncReadExt, AsyncWriteExt};
// use structopt::{StructOpt};
fn main() -> Result<(),Box<dyn std::error::Error>> {
let app = App::new("rr")
... | true |
0a4bf55472b1785eaf4940d50c570d4e92422072 | Rust | tex-other/tex-rs | /src/section_0899.rs | UTF-8 | 2,030 | 2.53125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! ` `
// @<Check that the nodes following |hb| permit hyphenation...@>=
macro_rules! Check_that_the_nodes_following_hb_permit_hyphenation_and_that_at_least_l_hyf_plus_r_hyf_letters_have_been_found__otherwise_goto_done1 {
($globals:expr, $s:expr, $lbl_done1:lifetime) => {{
region_forward_label!(
|'... | true |
41a5346bd437f87e65e7003c9c8b4d0c3bd42c28 | Rust | uwapcs/discord-bot | /src/util.rs | UTF-8 | 1,635 | 2.890625 | 3 | [] | no_license | use serenity::model::{channel::ReactionType, guild::PartialGuild};
pub fn get_string_from_react(react: &ReactionType) -> String {
match react {
ReactionType::Custom {
name: Some(name), ..
} => name.to_string(),
ReactionType::Custom { id, name: None, .. } => id.to_string(),
... | true |
e98ded79e17524170a07f7dd9e8b5eebd7c4bd13 | Rust | ids1024/rust_os | /Kernel/Core/lib/btree_map.rs | UTF-8 | 3,103 | 3.125 | 3 | [
"BSD-2-Clause"
] | permissive | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/lib/btree_map.rs
//! B-Tree map
//!
//! B-Trees are a more memory/cache efficient version of binary trees, storing up to `b` items
//! per node
use prelude::*;
pub struct BTreeMap<K: Ord,V>
{
root_node: Node<K,V>,
max_node_size: usize, // aka 'b'
}
/... | true |
46a0b4b24050a63bb0aab0edebdc32ac8fba56b1 | Rust | mapleFU/md-snippets | /components/ratelimiter/src/leaky_bucket.rs | UTF-8 | 1,996 | 2.75 | 3 | [] | no_license | use crate::{Config, Limiter};
use std::time::SystemTime;
use chrono::Duration as ChronoDuration;
use std::sync::{Arc, Mutex};
fn max_slack_time(slack_seconds: u32) -> ChronoDuration {
ChronoDuration::seconds(slack_seconds as i64) * -1
}
#[derive(Clone)]
pub struct LeakyBucketLimiter {
limiter: Arc<Mutex<Lea... | true |
17fcfc233f29e0cdc0be9bfa8d9f5845584d0bdf | Rust | FreddieRidell/hypertask | /rust/hypertask_engine/src/error.rs | UTF-8 | 4,493 | 3.078125 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum HyperTaskErrorDomain {
Render,
Config,
Input,
Mutation,
Query,
ScoreCalculator,
Task,
Syncing,
}
impl fmt::Display for HyperTaskErrorDomain {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
... | true |
e2540ed6abcd336f28771c6eaa024b6a494d4bdb | Rust | pdav/z33-emulator | /emulator/src/runtime/instructions.rs | UTF-8 | 15,911 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use parse_display::Display;
use tracing::{debug, info};
use crate::constants::*;
use super::{
arguments::{DirIndIdx, ExtractValue, ImmReg, ImmRegDirIndIdx, RegDirIndIdx, ResolveAddress},
exception::Exception,
memory::Cell,
registers::{Reg, StatusRegister},
Computer, Pro... | true |
8c151660f201f7730029ae2baae2a799be106347 | Rust | Origen-SDK/o2 | /rust/origen/src/generator/processors/pin_action_combiner.rs | UTF-8 | 3,984 | 3.234375 | 3 | [
"MIT"
] | permissive | //! A simple processor which will combine pin actions not separated by a cycle into a single PinAction node
use super::super::nodes::PAT;
use crate::Result;
use origen_metal::ast::{Node, Processor, Return};
use std::collections::HashMap;
/// Combines adjacent pin actions into a single pin action
pub struct PinActionC... | true |
6f7ad37c9bd298871788afdf87fda35917ffbcc0 | Rust | bollo35/cryptopals | /src/bin/p026.rs | UTF-8 | 1,491 | 3.078125 | 3 | [] | no_license | extern crate ooga;
use ooga::cipher_utils::ctr_stream;
use ooga::byte_utils::xor;
extern crate rand;
use rand::Rng;
fn main() {
// generate a random key
let mut rng = rand::thread_rng();
let key = rng.gen_iter::<u8>().take(16).collect::<Vec<u8>>();
let mut ciphertext = user_input(b":admin<true", &key);
cipherte... | true |
6e64b33873c9622cf7fb88c5b3c6bc5755b4ab45 | Rust | bnavetta/lifx-rs | /lifx-proto/src/color.rs | UTF-8 | 2,892 | 3.453125 | 3 | [] | no_license | use std::{convert::TryFrom, f32, u16};
use bytes::{Buf, BufMut};
use thiserror::Error;
use crate::ProtocolError;
/// Color and color temperature, represented in HSB and Kelvin
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Hsbk {
pub hue: u16,
pub saturation: u16,
pub brightness: u16,
pub te... | true |
e37ea3490fbcfc096eb12e1b59f039a7ce5ba684 | Rust | lcdsmao/leetcode-rust | /problem/src/solution/p041_first_missing_positive.rs | UTF-8 | 1,051 | 3.546875 | 4 | [
"MIT"
] | permissive | pub struct Solution {}
impl Solution {
pub fn first_missing_positive(nums: Vec<i32>) -> i32 {
let mut nums = nums;
// LeetCode rust version is old
// let valid_range = 1..=(nums.len() as i32);
for i in 0..nums.len() {
let mut n = nums[i];
while n >= 1
... | true |
316b3f38af56da4242c2836ef6f9b4ca9f6713ed | Rust | jimpo/experiments | /bulletproof-gadgets/src/main.rs | UTF-8 | 11,873 | 2.640625 | 3 | [] | no_license | use bulletproofs::r1cs::{
ConstraintSystem,
LinearCombination,
Prover,
R1CSError,
Variable,
Verifier,
};
use bulletproofs::{
BulletproofGens,
PedersenGens,
};
use curve25519_dalek::scalar::Scalar;
use merlin::Transcript;
use rand::Rng;
use std::u64;
struct TaxBrackets(Vec<(u64, u64)>);... | true |
af0e0941a6a367a1015bd215ca4d85fa3f4dd2ff | Rust | amol9/matasano | /src/set1/xorcipher.rs | UTF-8 | 729 | 2.8125 | 3 | [
"MIT"
] | permissive |
use common::{err, challenge, ascii, hex, util};
use common::cipher::one_byte_xor as obx;
pub static info: challenge::Info = challenge::Info {
no: 3,
title: "Single-byte XOR cipher",
help: "",
execute_fn: interactive
};
pub fn interactive() -> err::ExitCode {
let input = rtry!... | true |
28e9fedcfde4d624dbfa2cd3a52ecc198bfba3f5 | Rust | hreinn91/rust_adventofcode_2019 | /src/day2/src/intcode.rs | UTF-8 | 1,692 | 3.1875 | 3 | [] | no_license | pub mod intcode {
use crate::get_input;
pub fn run_intcode_program_part1(file: &str) -> i32 {
let intcode = get_input(file);
run_program(12, 2, intcode)
}
pub fn run_intcode_program_part2(file: &str) -> i32 {
let intcode = get_input(file);
find_noun_verb_prod(19690720, ... | true |
0243d6c60476e0debd7302e72e7f14a6af0d1dc4 | Rust | rust-lang/rust | /tests/rustdoc/inline_cross/auxiliary/ret-pos-impl-trait-in-trait.rs | UTF-8 | 641 | 2.578125 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | #![feature(return_position_impl_trait_in_trait)]
pub trait Trait {
fn create() -> impl Iterator<Item = u64> {
std::iter::empty()
}
}
pub struct Basic;
pub struct Intermediate;
pub struct Advanced;
impl Trait for Basic {
// method provided by the trait
}
impl Trait for Intermediate {
fn creat... | true |
871f9e402ffc529c38359a69647687a735db21c0 | Rust | benkonz/advent_of_code_2019 | /day_03/part_2/src/main.rs | UTF-8 | 3,992 | 3.0625 | 3 | [] | no_license | use std::cmp;
use std::io::{self, Read};
use std::iter::FromIterator;
fn main() -> io::Result<()> {
let mut buffer = String::new();
io::stdin().read_to_string(&mut buffer)?;
let parsed: Vec<&str> = buffer.split_whitespace().collect();
let wire1_path: Vec<(char, i64)> = parsed[0].trim().split(',').map(... | true |
fe2f14a163fcf8c98b57a6e7aa4304572d5753e9 | Rust | pd/tenx | /src/lib.rs | UTF-8 | 7,765 | 2.921875 | 3 | [] | no_license | extern crate rand;
#[macro_use(lazy_static)]
extern crate lazy_static;
extern crate itertools;
pub mod board;
pub mod piece;
use std::iter::Iterator;
use itertools::Itertools;
use std::ops::Not;
use board::{Bitboard, Line, PlacementError};
use piece::{Piece, Points};
pub type PlayResult = Result<(GameState, History)... | true |
78fe7296801cfd9f15ad12c5205fc8c4c79b4cce | Rust | fujitayy/hashmap-benchmark | /rust/hash_bench/src/main.rs | UTF-8 | 1,734 | 3.484375 | 3 | [] | no_license | use std::collections::HashMap;
use std::hash::Hash;
use std::time;
fn main() {
simple_hash();
complex_hash();
}
fn simple_hash() {
let start = time::Instant::now();
let mut m: HashMap<i64, i64> = HashMap::new();
for i in 0..10000 {
m.insert(i, i);
}
let mut ans = 0;
for k in m... | true |
804d6c49115be10fe8d1c2afd41f89605c72dfab | Rust | sulabhkothari/SkRustLearn | /common_collections/src/main.rs | UTF-8 | 11,703 | 3.90625 | 4 | [] | no_license | use std::string::ToString;
fn main() {
vectors();
strings();
hashmaps();
}
fn vectors() {
let v: Vec<i32> = Vec::new();
let mut v = vec![1, 2, 3];
match v.binary_search(&16) {
Ok(pos) => v.insert(pos, 16),
Err(_) => v.push(16)
}
match v.binary_search(&12) {
Ok... | true |
078ec6529a3b56c577953b03d84f1fe124e4e6e9 | Rust | hamza1311/tower-http | /tower-http/src/follow_redirect/policy/clone_body_fn.rs | UTF-8 | 1,089 | 3.390625 | 3 | [
"MIT"
] | permissive | use super::{Action, Attempt, Policy};
use std::fmt;
/// A redirection [`Policy`] created from a closure.
///
/// See [`clone_body_fn`] for more details.
#[derive(Clone, Copy)]
pub struct CloneBodyFn<F> {
f: F,
}
impl<F> fmt::Debug for CloneBodyFn<F> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {... | true |
8b64fb20f7a1a7e4a30dbd70590bab17a4db16cb | Rust | flip1995/rust-clippy | /tests/ui/branches_sharing_code/shared_at_top_and_bottom.rs | UTF-8 | 2,549 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![deny(clippy::branches_sharing_code, clippy::if_same_then_else)]
#![allow(dead_code)]
#![allow(clippy::uninlined_format_args)]
//@no-rustfix
// branches_sharing_code at the top and bottom of the if blocks
struct DataPack {
id: u32,
name: String,
some_data: Vec<u8>,
}
fn overlapping_eq_regions() {
le... | true |
0585c96f69c525928c1c114751577b1b23ac98ee | Rust | kyco/snap-backend | /src/routes/send.rs | UTF-8 | 2,406 | 2.953125 | 3 | [] | no_license | use crate::db::paired::is_paired;
use crate::db::users::device_id_exists;
use crate::push::push_notification;
use crate::routes::json_generic::{JsonGeneric, JsonGenericCodes};
use rocket::response::status::BadRequest;
use rocket_contrib::json::Json;
#[derive(Serialize, Deserialize, Debug)]
pub struct Message {
pub... | true |
3195e26eae0fca4556b0e4db2467faf2aee1b99a | Rust | bcully/rust-crates-index | /src/bare_index.rs | UTF-8 | 17,899 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{Crate, Error, IndexConfig};
use std::marker::PhantomPinned;
use std::{
io,
path::{Path, PathBuf},
};
/// Access to a "bare" git index that fetches files directly from the repo instead of local checkout
///
/// Uses Cargo's cache
pub struct BareIndex {
path: PathBuf,
pub url: String,
}
impl... | true |
2c67c0ec662e561abe904384c1baaad45ad722f3 | Rust | liufoyang/rust_demo | /demobin/src/flycoin.rs | UTF-8 | 5,736 | 3.546875 | 4 | [] | no_license | pub mod fly_coin {
pub struct FlyCoin{
amount:u64,
currency: String,
ownAccountId:String,
}
pub enum Result {
SUCCESS{code:String, msg:String, item:FlyCoin},
SUCCESS_BOTH{code:String, msg:String, credit:FlyCoin, debit:FlyCoin},
FAIL{code:String, msg:String, cr... | true |
6bb6e6a94e3c0042a3a3ea91668729ad37b4d59a | Rust | arafat1/cprocessor | /src/circuit/comparator.rs | UTF-8 | 924 | 3.328125 | 3 | [] | no_license | use crate::gate::logic_gates::{and8, not, xor2};
use crate::memory::register::Register8Bits;
/// Compare two 8 bit words and return 1 if they are equal else return 0
pub fn compare8(r1: &Register8Bits, r2: &Register8Bits) -> u8 {
and8(
not(xor2(r1.a0, r2.a0)),
not(xor2(r1.a1, r2.a1)),
not(x... | true |
d766f13f88509f8dda187d21deccd27bb3405539 | Rust | TheKK/rustnes | /src/opcode/ldx.rs | UTF-8 | 6,918 | 2.9375 | 3 | [] | no_license | use super::Cycle;
use super::OpCode;
use cpu::Registers;
use cpu::Memory;
#[inline]
fn ldx(registers: &mut Registers, val: u8) {
set_flag!(zero -> (registers, val));
set_flag!(sign -> (registers, val));
registers.x = val;
}
opcode_fn_with_mode!(imm -> (ldx_imm, ldx, Cycle(2)));
opcode_fn_with_mode!(zero... | true |
25ecf2058d14ebf0b8a143e8f44d3269908dd8f5 | Rust | ant1441/slack-token | /src/token.rs | UTF-8 | 8,565 | 3.375 | 3 | [] | no_license | //! A `Token` tracks the current "owner" of something, and is unique per channel.
#![allow(dead_code)]
use std::collections::{HashMap, VecDeque};
use std::sync::{Arc, Mutex, RwLock};
use std::fmt;
use slack::{TeamId, ChannelId};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct User {
user_id: String,
user_n... | true |
b0bd1f205c20b5d3d46bf4542e7d32a59b1326aa | Rust | reitermarkus/serverless | /functions/log-data/src/lib.rs | UTF-8 | 2,623 | 2.734375 | 3 | [] | no_license | use std::error::Error;
use http::{HeaderMap, Method, Uri, StatusCode};
use serde::{Deserialize, Serialize};
use serde_json::{self, json, Value};
use openfaas;
const SUPPORTED_DATA_TYPES: [&'static str; 15] = [
"cpu_frequency",
"proximity",
"acceleration",
"cpu_temperature",
"gravity",
"humidity",
"illu... | true |
df1062828cec6380b2c9b515cf9a0f47b9ef3c6b | Rust | pakky94/rnes | /src/ppu/mod.rs | UTF-8 | 33,329 | 2.546875 | 3 | [] | no_license | pub mod buffer;
mod sprite_unit;
use self::sprite_unit::SpriteUnit;
use crate::{bus::PpuAction, memory::PpuMemory};
use buffer::Buffer;
const IMAGE_COLOR_PALETTE_ADDRESS: u16 = 0x3F00;
const SPRITE_COLOR_PALETTE_ADDRESS: u16 = 0x3F10;
const SCREEN_WIDTH: usize = 256;
const SCREEN_HEIGHT: usize = 240;
pub struct Ppu ... | true |
7e1c9cc8f0ab6213aea136bef9ca24749ff3c778 | Rust | seanpianka/slack-blocks-rs | /src/blocks/section.rs | UTF-8 | 11,638 | 3.21875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! # Section Block
//!
//! _[slack api docs 🔗]_
//!
//! Available in surfaces:
//! - [modals 🔗]
//! - [messages 🔗]
//! - [home tabs 🔗]
//!
//! A `section` is one of the most flexible blocks available -
//! it can be used as a simple text block,
//! in combination with text fields,
//! or side-by-side with any o... | true |
f56ef80871732ec71d858325f1220465a3f9cbfa | Rust | NotSoClassy/Moon | /src/parser/parser.rs | UTF-8 | 11,393 | 3.4375 | 3 | [
"MIT"
] | permissive | use crate::parser::ast::{ Stmt, Expr, UnOp, BinOp, Node };
use crate::lexer::{ Lexer, Token };
use std::process::exit;
pub struct Parser {
lex: Lexer,
line: usize,
token: Token,
pub nodes: Vec<Node>
}
impl Parser {
pub fn new(code: String, name: String) -> Self {
let lexer = Lexer::new(code, name);
... | true |
6dbead483d166e1bbd51fd2f4400f9a7a867fa1d | Rust | jfsulliv-zz/thrtest | /src/functional/park.rs | UTF-8 | 2,987 | 3.65625 | 4 | [] | no_license | /// Functional tests for thread parking/unparking.
///
/// # Tested Assertions:
/// * thread::park() pauses execution of a thread.
/// * thread::Thread::unpark() unpauses execution of a thread.
#[cfg(all(test))]
mod tests {
use std::sync::{Arc,Mutex};
use std::thread;
use std::time::{Duration,Instant};
... | true |
c9d7b5410af914224e010a4141c78e0b7b692038 | Rust | StragaSevera/aoc2018 | /src/bin/02b/main.rs | UTF-8 | 1,574 | 3.25 | 3 | [] | no_license | use std::iter::FromIterator;
fn main() {
let input = aoc2018::read_file("src/bin/02b/input.txt");
let result = find_correct_id(input);
println!("{}", result)
}
fn find_correct_id(input: impl Iterator<Item=String>) -> String {
let mut strings: Vec<Vec<char>> = Vec::new();
let input = input.map(|s| ... | true |
e920d062134faa1c903cebc32ce4d46f8b4375a8 | Rust | dennisss/dacha | /pkg/container/src/init.rs | UTF-8 | 6,879 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use nix::sys::signal::Signal;
use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet};
use sys::{sigprocmask, sigsuspend, Errno, SignalSet, SigprocmaskHow};
static mut RECEIVED_SIGNAL: Option<sys::c_int> = None;
pub struct MainProcessOptions {
/// If true, start the child process in a new proces... | true |
ecac16002e82ed90d663afbb57e8fa079ef1147c | Rust | koba-e964/calc-rust | /src/ast.rs | UTF-8 | 1,640 | 3.140625 | 3 | [] | no_license | // AST
#[derive(PartialEq, Clone, Debug)]
pub enum AST {
Num(i64),
Str(String),
Var(String),
OpNode(Op, Box<AST>, Box<AST>),
IfNode(Box<AST>, Box<AST>, Box<AST>), // If the first evaluates to non-zero, return the second. Otherwise, return the third.
LetEx(String, Box<AST>, Box<AST>),
FunApp(... | true |
8a9f1e8f24dae6293802939a62168254160ba382 | Rust | djmittens/learn-rust | /cargo-hal/learn-vulkan/src/main.rs | UTF-8 | 2,576 | 2.625 | 3 | [] | no_license | use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer};
use vulkano::command_buffer::{AutoCommandBufferBuilder, CommandBuffer};
use vulkano::device::{Device, DeviceExtensions, Features};
use vulkano::instance::{Instance, InstanceExtensions, PhysicalDevice};
use vulkano::sync::GpuFuture;
fn main() {
println!("Hell... | true |
395b3c47c1495dc053cca19fe02358e008f4d980 | Rust | wmmxk/OOP_Rust | /bugs/enum_include_structure/ownership/main.rs | UTF-8 | 564 | 3.265625 | 3 | [] | no_license | // source: https://github.com/rust-lang/rust/issues/40666
#[derive(Debug)]
enum myenum {
Number,
Character {x : String, y: String},
}
fn main() {
let aenum = myenum::Character{x:String::from("hello"),y: String::from("world")};
match aenum {
myenum::Character { ref x, ref y} => {
prin... | true |
9d71bc18a0fbafcef108f37103e054480e224585 | Rust | superoles/rescue_block_cipher | /rescue-poseidon/src/common/domain_strategy.rs | UTF-8 | 4,214 | 3.390625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use franklin_crypto::bellman::{Engine, Field, PrimeField};
/// Padding prevents trivial collisions.
/// Each hash function nearly uses same padding strategies.
/// The only difference is that Rescue Prime requires no padding for
/// fixed length input. Rescue and Poseidon require same padding rule
/// for variable len... | true |
9632675940ce55957165f0d620f9d4b150a49404 | Rust | modulus-os/kernel | /src/io/pio/mod.rs | UTF-8 | 1,062 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #[cfg_attr(rustfmt, rustfmt_skip)]
pub fn outb(port: u16, value: u8) {
unsafe{
asm!("outb %al, %dx"
:
: "{dx}"(port), "{al}"(value)
:
: "volatile");
}
}
#[cfg_attr(rustfmt, rustfmt_skip)]
pub fn outw(port: u16, value: u16) {
unsafe{
asm!("outw %ax, %dx"
:
: "{dx}"(port), "{ax}"(value)
:
... | true |
0db22943b51b5682cff916461c03ab16c46b4631 | Rust | age-rs/fast_image_resize | /src/alpha/avx2/mul.rs | UTF-8 | 2,810 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::arch::x86_64::*;
use crate::alpha::native;
use crate::image_view::{TypedImageView, TypedImageViewMut};
use crate::pixels::U8x4;
use crate::simd_utils;
pub(crate) fn multiply_alpha_avx2(
src_image: TypedImageView<U8x4>,
mut dst_image: TypedImageViewMut<U8x4>,
) {
let width = src_image.width().get(... | true |
da1a90d1bcb410dcc1bd68c442bf6a9340267409 | Rust | jonasvandervennet/advent-of-code-2020 | /src/day18.rs | UTF-8 | 5,706 | 3.703125 | 4 | [
"MIT"
] | permissive | use crate::util::{print_part_1, print_part_2};
use std::collections::VecDeque;
use std::fs::read_to_string;
use std::time::Instant;
#[derive(Clone, Copy)]
struct State {
lhs: usize,
op: char,
initialised: bool,
parantheses_state: bool, // reason for push
}
impl State {
fn new(by_parentheses: bool... | true |
70df4876858332c2940ccd40e2a274670bc99a74 | Rust | exercism/rust | /exercises/practice/beer-song/tests/beer-song.rs | UTF-8 | 1,810 | 3.078125 | 3 | [
"MIT"
] | permissive | use beer_song as beer;
#[test]
fn test_verse_0() {
assert_eq!(beer::verse(0), "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n");
}
#[test]
#[ignore]
fn test_verse_1() {
assert_eq!(beer::verse(1), "1 bottle of beer on the wall... | true |
1bb7b3fe12c69c4bdf32fee451dbcde2d1e6286b | Rust | Robbepop/type-metadata | /src/type_id.rs | UTF-8 | 8,042 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019
// by Centrality Investments Ltd.
// and Parity Technologies (UK) Ltd.
//
// 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/... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.