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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
03bc0cdd0bc5a3eac57f9a2f08615edf52e8c12c | Rust | sketchpunk/fungi_rs | /src/wasm/vao.rs | UTF-8 | 3,176 | 2.71875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
#![allow(unused_imports)]
use std::ops::{ Drop, Deref, DerefMut };
use std::cell::RefCell;
use std::collections::HashMap;
use web_sys::{ WebGlVertexArrayObject }; //WebGlBuffer,
use super::{ glctx, Buffer, AttribLoc };
use crate::storage::RecycleStorage;
//######################################... | true |
d80804d376d596d3f14fb0e8164549357e0d7bd5 | Rust | chryslovelace/advent-of-code-2020 | /src/bin/day12/main.rs | UTF-8 | 5,594 | 3.375 | 3 | [
"MIT"
] | permissive | use either::Either;
use lazy_static::lazy_static;
use std::str::FromStr;
enum Direction {
N,
S,
E,
W,
L,
R,
F,
}
struct Action {
dir: Direction,
value: i32,
}
#[derive(Debug)]
struct UnrecognizedAction(Option<char>);
impl FromStr for Action {
type Err = Either<UnrecognizedAct... | true |
6506542a3f98838ef8b945c85adfd44afb7c087d | Rust | Awsomv30/arab-memes-pros | /src/imageutil.rs | UTF-8 | 2,355 | 3.1875 | 3 | [] | no_license | use image::GenericImage;
use image;
use image::imageops::resize;
use image::Pixel;
use image::GrayImage;
use image::RgbaImage;
use image::Rgba;
use std::cmp::min;
pub fn paste_image<D: GenericImage + 'static, S: GenericImage<Pixel = D::Pixel> + 'static>(
source: &S,
destination: &mut D,
x: u32,
y: u32,... | true |
c002aeda2ba75bae52e59ec4ddb29c984c981fb2 | Rust | cloew/KaoBoy | /src/cpu/instructions/add/add.rs | UTF-8 | 4,043 | 3.203125 | 3 | [] | no_license | use super::super::utils::{check_half_carry};
use super::super::super::instruction_context::InstructionContext;
pub fn add(context: &mut InstructionContext, left_value: u8, right_value: u8) -> u8 {
let (new_value, overflow) = left_value.overflowing_add(right_value);
context.registers_mut().zero_flag.... | true |
79b4aa51342a3292f8e7b030c420941cc4c01dc8 | Rust | shibe23/portal | /src/portals.rs | UTF-8 | 3,812 | 3.203125 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use serde::Serialize;
use std::fmt;
use std::fs::{File, OpenOptions};
use std::io::{Result, Seek, SeekFrom};
use std::path::PathBuf;
#[derive(Debug, Deserialize, Serialize)]
pub struct Portal {
pub label: String,
pub path: String,
}
impl Portal {
pub fn new(label: String, path: Str... | true |
193291a899f97098aa0854290842daf9274efd9e | Rust | sre/rust-gpiochip | /src/lib.rs | UTF-8 | 17,439 | 2.78125 | 3 | [
"ISC"
] | permissive | // © 2018 Sebastian Reichel
// SPDX-License-Identifier: ISC
#![crate_type = "lib"]
#![crate_name = "gpiochip"]
//! The `gpiochip` crate provides access to Linux gpiochip devices
//! from rust. The interface is wrapped, so that rust types are being
//! used instead of C types.
//!
//! # Examples
//!
//! ```
//! extern... | true |
a0576fa1c7e58ed7b53aa0ff20ad6266a3c5c7f7 | Rust | sime1/raspi4-rust | /raspi4/src/mbox.rs | UTF-8 | 2,621 | 2.515625 | 3 | [
"MIT"
] | permissive | use core::intrinsics::transmute;
use super::mmio;
use super::mmio::MMIO;
use macros::mailbox_request;
#[repr(u32)]
#[derive(Clone, Copy)]
pub enum MailboxStatus {
Full = 0x8000_0000,
Empty = 0x4000_0000,
}
#[repr(u32)]
#[derive(Clone, Copy)]
pub enum MailboxCode {
Request = 0x0,
ResponseSuccess = 0x... | true |
c8db891aab669724efc478d34ea7ac7c6591bcb2 | Rust | schmidtDTN/advent-of-code-2020 | /day5/src/main.rs | UTF-8 | 2,861 | 3.5625 | 4 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
// Get input file
let file = File::open("./input.txt").unwrap();
let file_reader = BufReader::new(file);
let mut seat_ids: Vec<isize> = Vec::new();
let mut max_seat_id = 0;
// Iterate through the lines
for line in file_read... | true |
b5580098524f000a91ffe444f88e63c695a9e75e | Rust | Telixia/leetcode-2 | /src/_975.rs | UTF-8 | 1,592 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::collections::{BTreeMap, HashSet};
pub struct Solution;
impl Solution {
pub fn odd_even_jumps(a: Vec<i32>) -> i32 {
let end_idx = a.len() - 1;
let mut inv_map: BTreeMap<i32, usize> = BTreeMap::new(); // mapping <value, idx>
let mut poi_odd: HashSet<usize> = HashSet::new(); // idx c... | true |
18b1a27ea0052932ad6d9b8d66291fe12240cd1e | Rust | slowli/arithmetic-parser | /eval/src/exec/registers.rs | UTF-8 | 22,597 | 2.75 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! `Registers` for executing commands and closely related types.
use core::iter;
use crate::{
alloc::{vec, Box, HashMap, Rc, String, ToOwned, Vec},
arith::OrdArithmetic,
error::{Backtrace, CodeInModule, EvalResult, TupleLenMismatchContext},
exec::command::{Atom, Command, CompiledExpr, FieldName, Span... | true |
7dfc2b4f6ec841d56b88e14636356be7d6e5d6db | Rust | lnicola/lnx | /lnxcli/src/main.rs | UTF-8 | 2,266 | 2.65625 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate log;
use benchmark::{self, BenchMode, BenchTarget};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "lnxcli", about = "A utility cli for benchmarking and testing")]
pub enum Commands {
Bench {
/// The address of the server to benchmark.
#[structop... | true |
75d90cef5a10056362a2b340927cfb7bdf8de699 | Rust | bcdevorg/metis | /crates/components/token/erc777/src/basic.rs | UTF-8 | 24,646 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | pub use super::module::Data;
use ink_prelude::{
string::String,
vec::Vec,
};
pub use metis_lang::{
Env,
EnvAccess,
Storage,
};
/// The ERC-777 error types.
#[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Error {
/... | true |
6fb622bd796891658f146bf1879cf28b46ada0e1 | Rust | yamash723/nes-hello-world-rust | /src/nes/cpu/calculator/tests/txs.rs | UTF-8 | 210 | 2.921875 | 3 | [] | no_license | use super::*;
#[test]
fn TXS_test() {
let mut registers = Registers::new();
registers.X = 0x89;
registers.S = 0x00;
Calculator::TXS(&mut registers);
assert_eq!(registers.S, registers.X);
} | true |
d24a9ec2c936c30ecfe78ebccda17eea0ee98577 | Rust | cloew/KaoBoy | /src/cpu/instructions/common/no_op.rs | UTF-8 | 1,003 | 3.140625 | 3 | [] | no_license | use super::super::super::InstructionContext;
pub fn byte_no_op(_context: &mut InstructionContext, value: u8) -> u8 {
return value;
}
pub fn short_no_op(_context: &mut InstructionContext, value: u16) -> u16 {
return value;
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{as_hex};
u... | true |
48f99f08d175489bbc40ba2fba559d556cf02e8f | Rust | frisbm/Rust-Data-Structures | /Stack with Linked List/Stack_with_LL.rs | UTF-8 | 2,494 | 3.515625 | 4 | [
"MIT"
] | permissive | #![allow(unused)]
use std::io::{stdin, stdout, Write};
type Stackelem = Option<Box<Valnode>>;
#[derive(Debug, Clone)]
struct Stack {
head: Stackelem,
}
#[derive(Debug, Clone)]
struct Valnode {
elem: String,
next: Stackelem,
}
impl Stack {
fn push(&mut self, name: String) {
match self.head.clon... | true |
1a11abad0cddd8570e0e4d8775851268153ed8b9 | Rust | gnoliyil/fuchsia | /src/lib/fuchsia-url/src/host.rs | UTF-8 | 2,358 | 3 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::errors::ParseError;
// The host of a fuchsia-pkg:// URL.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub(crate) struct Host(S... | true |
d82bee5fa90dee1ba8d089b0b9f78d9e8da4610c | Rust | luisgabrielroldan/gamebrust | /core/src/cpu/alu.rs | UTF-8 | 4,783 | 2.671875 | 3 | [] | no_license | use super::registers::R16;
use super::CPU;
pub fn daa(cpu: &mut CPU) {
let mut a = cpu.reg.a;
let mut adjust = if cpu.reg.flags.c { 0x60 } else { 0x00 };
if cpu.reg.flags.h {
adjust |= 0x06;
};
if !cpu.reg.flags.n {
if a & 0x0F > 0x09 {
adjust |= 0x06;
};
... | true |
da1d10a69b0a60d3eab61c563aaf12b1cd6419d8 | Rust | Artemkaaas/indy-sdk | /vcx/libvcx/src/v3/messages/basic_message/message.rs | UTF-8 | 1,457 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | use v3::messages::a2a::{MessageId, A2AMessage};
use v3::messages::localization::Localization;
use chrono::prelude::*;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub struct BasicMessage {
#[serde(rename = "@id")]
pub id: MessageId,
pub sent_time: String,
pub content: String,
... | true |
be5ee8a9b36fb71e0b948bab6924386d627b9231 | Rust | SaltyAom/floor-of-literature | /apps/sign/src/sign/services.rs | UTF-8 | 9,401 | 2.59375 | 3 | [] | no_license | use actix::Addr;
use actix_identity::Identity;
use actix_redis::{Command, Error, RedisActor};
use actix_web::{
get, post,
web::{Data, Json, ServiceConfig},
HttpResponse,
};
use std::time::Duration;
use tokio::time::delay_for;
use redis_async::resp::FromResp;
use uuid::Uuid;
use crate::sign::models::{API... | true |
e2ed867309fd29315d322f575563aac15fc63983 | Rust | pabloalonsos/matasano-crypto-challenges | /src/set_1/repeating_key_xor.rs | UTF-8 | 279 | 2.640625 | 3 | [] | no_license | use super::super::utils::crypto_data::CryptoData;
pub fn repeating_key_xor(input_str: &str, key: &str) -> CryptoData {
let input_crypto = CryptoData::new_from_str(input_str);
let key_crypto = CryptoData::new_from_str(key);
input_crypto.xor(key_crypto).to_hex()
}
| true |
6ff142069295c7301bbed927563d12459fe780b6 | Rust | opticaline/pjoin | /src/main.rs | UTF-8 | 1,108 | 2.765625 | 3 | [] | no_license | mod opt;
use std::fs;
use std::io;
use std::path::PathBuf;
fn main() {
let input = std::env::args().nth(1).unwrap_or(".".to_owned());
let input = fs::canonicalize(&input).unwrap();
let output = std::env::args()
.nth(2)
.unwrap_or(input.to_str().unwrap().to_owned());
let output = PathBuf... | true |
a4640e13acd555f62d9648ca85cee45025ace84f | Rust | TroyNeubauer/100-cent-change | /src/main.rs | UTF-8 | 3,443 | 3.125 | 3 | [] | no_license | extern crate argparse;
extern crate polynomial;
#[macro_use]
extern crate uint;
use uint::construct_uint;
use argparse::{ArgumentParser, Collect, Store, StoreTrue};
use polynomial::Polynomial;
use Vec;
use std::str::FromStr;
construct_uint! {
pub struct U512(8);
}
fn main() {
let mut verbose = fals... | true |
dabc2dc9cea965a9decd227cf4447b5dcced6b9b | Rust | tene/glow | /src/m6.rs | UTF-8 | 2,315 | 2.90625 | 3 | [] | no_license | use heapless::{consts, String, Vec};
use lazy_static::lazy_static;
use num_rational::Ratio;
use crate::hsv::HSV;
use crate::knob::Direction;
use core::iter::once;
#[derive(Clone, Copy, Debug)]
pub enum Region {
Center,
Inner,
Ray,
Outer,
}
impl Region {
pub fn r(&self) -> usize {
use Reg... | true |
f7448c69ce44d04a8d4e499de7b020be333241d0 | Rust | vain0x/pattern-matching-exhaustivity-checking | /pmxc_analyzer/src/syntax/parse.rs | UTF-8 | 2,503 | 2.890625 | 3 | [
"Unlicense"
] | permissive | use super::parse_context::ParseContext;
use super::parse_stmts::parse_root;
use super::*;
use std::rc::Rc;
pub(crate) fn parse_tokens(tokens: Rc<[TokenData]>) -> NodeData {
let mut p = ParseContext::new(tokens);
let mut root = parse_root(&mut p);
p.finish(&mut root);
root
}
pub(crate) fn parse(source_... | true |
7e741089a86023d8eb5a58c013bc2b90d0ab41e3 | Rust | fdncred/weather_util_rust | /src/pressure.rs | UTF-8 | 2,069 | 3.4375 | 3 | [
"MIT"
] | permissive | use anyhow::{format_err, Error};
use derive_more::Into;
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;
const HECTO: f64 = 1.0; // hPa 100 hundred Pa
const KILO: f64 = 1_000.0 / 100.0;
const ATM: f64 = 98.0665 * HECTO / KILO;
const PSI: f64 = 14.223 / (98.0665 * HECTO / KILO);
/// Pressure struct, dat... | true |
40eef0e9cb0a7733cfd8471d4fc513a705caf537 | Rust | tock/tock | /capsules/core/src/test/random_timer.rs | UTF-8 | 2,514 | 2.6875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.
//! Test that a Timer implementation is working by trying a few edge
//! cases on the interval, including intervals of 1 and 0. Depends
//! on a working UART and debu... | true |
b8fdfe62ce2a0c1fde878bfddc7667124c9b2480 | Rust | avik-das/gitters | /src/revisions.rs | UTF-8 | 5,053 | 3.328125 | 3 | [
"BSD-2-Clause"
] | permissive | //! Provides any functionality related to specifying and resolving revisions that name specific
//! objects. See gitrevisions(7) for the full specification on how revisions are specified, of
//! which this module will provide a subset.
use std::{error, fmt, fs};
use std::fs::File;
use std::io::Read;
use std::path::Pat... | true |
1d0483382d9a18d9d8000a9109e78d41462fea40 | Rust | kestred/web-analyzer-wip | /utils/grammar/src/ast.rs | UTF-8 | 2,465 | 2.953125 | 3 | [] | no_license | use crate::syntax_error::SyntaxError;
use rowan::{SyntaxElement, SyntaxKind, SyntaxNode, TransparentNewType, TreeArc, WalkEvent};
use std::fmt::Write;
/// The main trait to go from untyped `SyntaxNode` to a typed ast. The
/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
/// the same repr... | true |
b513900e9cd3ecf0427f225d900b1e93f694eb12 | Rust | jameswhang/Rust_Chatserver | /games/src/multiindex.rs | UTF-8 | 948 | 3.015625 | 3 | [] | no_license | #[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub struct MultiIndex (pub usize, pub usize);
impl MultiIndex {
fn is_vertical(i1 : MultiIndex, i2 : MultiIndex) -> bool {
let beside = i1.0 == i2.0;
let stacked = i1.1 + 1 == i2.1 || i1.1 - 1 == i2.1;
beside && stacked
}
fn is_horizonta... | true |
e168e1ff08d5cb9407bde85ad644053c86d2eee6 | Rust | avranju/iotedge-k8s | /edgelet/docker-rs/src/apis/mod.rs | UTF-8 | 1,467 | 2.640625 | 3 | [
"MIT"
] | permissive | use hyper;
use serde;
use serde_json;
#[derive(Debug)]
pub enum Error<T> {
Hyper(hyper::Error),
Serde(serde_json::Error),
Api(ApiError<T>),
}
#[derive(Debug)]
pub struct ApiError<T> {
pub code: hyper::StatusCode,
pub content: Option<T>,
}
impl<'de, T> From<(hyper::StatusCode, &'de [u8])> for Erro... | true |
be38111bc6f2ce9de73b0ce86e7a3921bb13ba36 | Rust | Im-Oab/One-Man-ggj21 | /src/gameplay/particle_types/explosion.rs | UTF-8 | 2,705 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use tetra::math::Vec2;
use tetra::Context;
use crate::gameplay::particle_manager::{Particle, ParticleSpawnNode, ParticleType};
use crate::image_assets::ImageAssets;
use crate::sprite::{AnimationMultiTextures, Sprite};
pub struct ExplosionParticleType {
animations: HashMap<String, A... | true |
3450c322ab4f12bf276303fb2b48ddc89da3cc93 | Rust | hkarim/note_effects_vst | /util/src/raw_message.rs | UTF-8 | 703 | 2.8125 | 3 | [
"Unlicense"
] | permissive | use core::clone::Clone;
use core::convert::{From, Into};
use core::ops::Index;
use super::messages::ChannelMessage;
#[derive(Copy)]
pub struct RawMessage([u8; 3]);
impl ChannelMessage for RawMessage {
fn get_channel(&self) -> u8 {
self.0[0] & 0x0F
}
}
impl Clone for RawMessage {
fn clone(&self) -... | true |
e436a6e8e27438f98e9cc98b7d8ba653337cbe02 | Rust | rahulanand16nov/gsoc-wasm-filters | /cache-filter/src/configuration.rs | UTF-8 | 694 | 2.828125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::Deserialize;
#[derive(Deserialize, Debug, Clone)]
#[serde(default)]
pub struct FilterConfig {
/// Behaviour in case of a cache miss and authorize call gets failed.
pub failure_mode_deny: bool,
/// Number of retries for setting data to cache
pub max_tries: u32,
/// Max memory in bytes tha... | true |
5d87dd69cc6197b839ae20506e09fb8d0dc8190f | Rust | danieldk/conllx-utils | /src/bin/conllx-cleanup.rs | UTF-8 | 2,120 | 2.96875 | 3 | [] | no_license | use std::env::args;
use std::io::BufWriter;
use conllx::{Sentence, WriteSentence};
use conllx_utils::{or_exit, simplify_unicode, Normalization};
use getopts::Options;
use stdinout::{Input, OrExit, Output};
fn print_usage(program: &str, opts: Options) {
let brief = format!("Usage: {} [options] [INPUT_FILE] [OUTPUT... | true |
0c5d98f8509b153aa92c2d701f3c6c6fb407e46c | Rust | blasrodri/cmdex | /src/commands/new_command.rs | UTF-8 | 903 | 2.796875 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use crate::commands::command::CommandExample;
fn load_new_command(filename: &Path) -> Result<String, String> {
let mut buffer = String::new();
let mut f = File::open(filename).map_err(|e| e.to_string())?;
f.read_to_string(&mut buffer)
... | true |
76500b07c14af130d6a93d62d770fb76104a4433 | Rust | jinlf/waiir | /tests/evaluator_test.rs | UTF-8 | 7,322 | 3.203125 | 3 | [] | no_license | extern crate waiir;
use waiir::ast::*;
use waiir::environment::*;
use waiir::evaluator::*;
use waiir::lexer::*;
use waiir::object::*;
use waiir::parser::*;
fn test_eval(input: &str) -> Box<dyn Object> {
let mut env = new_environment();
let mut l = Lexer::new(input);
let mut p = Parser::new(&mut l);
let... | true |
868d7ea89048e4cf08e5b1cd6a4c65f3b0cac2aa | Rust | Abrar124/Rust-Hackathon1 | /src/main.rs | UTF-8 | 7,515 | 3.515625 | 4 | [] | no_license | use std::io;
///////////////////// Task 1 //////////////////////
// use std::io;
// fn main() {
// let mut radius = String::new();
// let pi = 3.14159;
// println!("Input the radius of the circle");
// io::stdin()
// .read_line(&mut radius)
// .expect("failed to read input.");
// ... | true |
54cd941f728d43c9ca6b3a4f42d6dd3272ab13e7 | Rust | Aiden01/yt-downloader | /src/youtube/mod.rs | UTF-8 | 1,814 | 2.796875 | 3 | [] | no_license |
extern crate reqwest;
extern crate json;
pub mod search_result;
use super::get_api_key;
use reqwest::StatusCode;
pub fn search(query: String, max_results: String) -> Option<Vec<search_result::Video>> {
let mut response = reqwest::get(&format!("https://www.googleapis.com/youtube/v3/search?q={}&maxResults={}&part=... | true |
492812f43ecc423af81999998567c167095795b6 | Rust | MJohnson459/SpareParts | /src/main.rs | UTF-8 | 1,843 | 2.765625 | 3 | [] | no_license | extern crate linux_embedded_hal as hal;
extern crate picoborgrev;
extern crate robot_traits;
extern crate tiny_http;
extern crate hcsr04;
extern crate bme280;
use hal::I2cdev;
use std::path::Path;
use std::thread::sleep;
use std::time::Duration;
use hcsr04::measure_time;
use picoborgrev::PicoBorgRev;
fn main() {
... | true |
f9a2e00b3c77dda7f4b367fc3c1495f3a9cc5446 | Rust | tekjar/take-on-tokio | /basics/combinators/stream/foreach/src/main.rs | UTF-8 | 1,572 | 3.421875 | 3 | [] | no_license | extern crate futures;
extern crate tokio_core;
use futures::{future, Stream};
use futures::stream;
use tokio_core::reactor::Core;
/// Poll<T, E>
/// --------------------
/// Ok(Async::Ready(t))
/// Ok(Async::NotReady)
/// Err(e)
/// Stream Poll => Poll<Option<T>, E>
/// -------------------
/// Ok(Async::Ready(Some(t... | true |
42845d42004ac313b42981ac5fd8ed7b97887330 | Rust | fredrik-jansson-se/rust-advent-of-code-2020 | /src/aoc25.rs | UTF-8 | 1,058 | 3.125 | 3 | [] | no_license | use std::collections::HashMap;
const SUB_DIV: usize = 20201227;
pub fn run() {
println!("25:1 {}", run_1(17773298, 15530095));
}
fn transform_subject_number(subject_number: usize, loop_size: usize) -> usize {
let mut value = 1;
for _ in 0..loop_size {
value = (value * subject_number) % SUB_DIV;
... | true |
deaa200da4bcb6e0c0406c3f0bd58212f746260c | Rust | tari-project/tari | /base_layer/core/src/proof_of_work/proof_of_work.rs | UTF-8 | 3,889 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclai... | true |
43a8bb9c127e337db899db27c11aab5081173c9d | Rust | josephlr/rak | /src/paging.rs | UTF-8 | 3,401 | 2.765625 | 3 | [] | no_license | use crate::Plat;
use core::{fmt, mem::align_of};
use x86_64::{
structures::paging::{PageSize, PageTableFlags as Flags, Size2MiB},
PhysAddr,
};
/// Alternative to x86_64::PageTableEntry that can be used with static pointers.
struct Entry(*const u8);
unsafe impl Send for Entry {}
unsafe impl Sync for Entry {}
i... | true |
b9cd9d57a4187c8e1e1e099590bf711cdc838211 | Rust | Techcable/minecraft-mappings | /libs/engine/src/lib.rs | UTF-8 | 1,945 | 2.59375 | 3 | [
"MIT"
] | permissive | //! Any combination of the following mapping systems are supported for any given minecraft version:
//! - `srg` - MCP's unique srg mappings, which are the same for each minecraft version.
//! - `mcp` - MCP's crowd sourced deobfuscated mappings, fetched from `MCPBot`
//! - These have a independent version based on the... | true |
9942f60c02727c40f16c89df2642e10f48c2a12e | Rust | MrAwesome/faerie | /src/lambda.rs | UTF-8 | 758 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | #[derive(Debug)]
pub struct ActionSuccess {
pub messages: Vec<String>,
room_move: bool,
}
impl ActionSuccess {
pub fn new(messages: Vec<String>) -> ActionSuccess {
ActionSuccess {
messages,
room_move: false,
}
}
pub fn set_was_room_move(&mut self) {
... | true |
2dae9d3cfd6d8aa4c525b50cab68939690717725 | Rust | JHowell45/rust-practise | /chapter_4/slice_type/src/main.rs | UTF-8 | 2,731 | 4.0625 | 4 | [
"MIT"
] | permissive | fn main() {
let my_string = String::from("hello world");
// first_word works on slices of `String`s
let word = first_word(&my_string[..]);
let word_two = second_word(&my_string[..]);
println!("Word: '{}' || First word (&my_string[..]): {} || Second word (&my_string[..]): {}", my_string, word, word_two);
... | true |
29fbacbc5aff17622ed4b7c5b8a56de083ab7d13 | Rust | mk12/euler | /rust/problem_10.rs | UTF-8 | 366 | 2.953125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2014 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 10
// Summation of primes
use problem_07::is_prime;
pub fn solve() -> int {
let max = 2000000;
let mut sum = 2 + 3;
let mut n = 1;
loop {
n += 4;
if n >= max { break; }
if is_prime(n) { sum += n; }
n += 2;
if n >= m... | true |
2b63af6838868c1403f9f84b10ef5fe1e13c51dd | Rust | jbertovic/data-watch | /src/actors/consumer/csvwriter.rs | UTF-8 | 2,038 | 2.6875 | 3 | [] | no_license | // TODO: Have a file name created for name of measure set on initiation of actor
// - don't try to do this with every measure to store or you can combine measures to store
// - maybe keep a vector of names to store in file
// - or create a unique routing name from name+description?
use crate::actors::messages::... | true |
6d81e1099d26116b47aa4913c50df4f2e7e08e2d | Rust | togglebyte/nightmaregl | /src/viewport.rs | UTF-8 | 2,069 | 3.3125 | 3 | [
"MIT"
] | permissive | #![deny(missing_docs)]
use nalgebra::Matrix4;
use num_traits::NumCast;
use crate::{Position, Size};
/// A viewport that can be rendered into.
/// ```
/// use nightmaregl::{Size, Position, Viewport};
///
/// let viewport = Viewport::new(
/// Position::zero(),
/// Size::new(800, 600)
/// );
/// ```
#[derive(Deb... | true |
5d4284f81252665b6a2942445509b55cd8922c7e | Rust | oberien/krakenx62 | /src/cooler/mod.rs | UTF-8 | 5,794 | 2.578125 | 3 | [] | no_license | use std::mem::ManuallyDrop;
use std::time::Duration;
use libusb::{Context, DeviceHandle, LogLevel, Result as UsbResult};
mod modes;
pub use self::modes::*;
const VENDOR: u16 = 0x1e71;
const PRODUCT: u16 = 0x170e;
const ZERO: Duration = Duration::from_secs(0);
#[derive(Debug)]
pub struct Status {
pub liquid_tem... | true |
d302c26e7e7db20a875c43975f46528ba3670dba | Rust | mohoff/punch | /src/cmd/edit.rs | UTF-8 | 559 | 2.859375 | 3 | [] | no_license | use std::process::{Command, ExitStatus};
use std::env;
use crate::card::Card;
use crate::err::*;
pub fn run() -> Result<ExitStatus> {
let card: Card = Default::default();
let env_editor = "EDITOR";
match env::var_os(env_editor) {
None => Err(ErrorKind::EnvVarNotFound(env_editor.into()).into()),
... | true |
b8063c00e3fa4d47f6636dab9b7aaf672e7a2954 | Rust | bmacnaughton/napi-rs | /crates/backend/src/typegen/fn.rs | UTF-8 | 2,519 | 2.828125 | 3 | [
"MIT"
] | permissive | use convert_case::{Case, Casing};
use quote::ToTokens;
use super::{ty_to_ts_type, ToTypeDef, TypeDef};
use crate::{CallbackArg, FnKind, NapiFn};
impl ToTypeDef for NapiFn {
fn to_type_def(&self) -> TypeDef {
let def = format!(
r#"{prefix} {name}({args}){ret}"#,
prefix = self.gen_ts_func_prefix(),
... | true |
3222a69506a350674fd621f73b9541a194c3a2a6 | Rust | stevedonovan/moi | /src/bin/moi/strutil.rs | UTF-8 | 4,779 | 3.125 | 3 | [
"MIT"
] | permissive | // miscelaneous string handling things
use moi::*;
pub fn is_ipv4(addr: &str) -> bool {
let res: Result<Vec<_>,_> = addr.split('.').map(|p| p.parse::<u32>()).collect();
res.is_ok()
}
pub fn strings<T: ToString>(slice: &[T]) -> Vec<String> {
slice.iter().map(|s| s.to_string()).collect()
}
pub fn split_at_... | true |
30d437689ab2bb696948b961425df5ce1f70c75c | Rust | vodkatypique/blob | /src/main.rs | UTF-8 | 1,125 | 2.75 | 3 | [] | no_license | extern crate blobwar;
//use blobwar::board::Board;
use blobwar::configuration::Configuration;
use blobwar::strategy::{Greedy, Human, MinMax, AlphaBeta};
use std::fs::File;
use std::io::prelude::*;
fn main() {
//let board = Board::load("x").expect("failed loading board");
let mut file = File::create("Gre... | true |
9250a37385a760044caa7812c900bd5e5947c7e5 | Rust | kalgynirae/sudoku | /server/src/board.rs | UTF-8 | 6,708 | 3.109375 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::digit::{Digit, DigitBitFlags};
use crate::error::SudokuError;
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct BoardSquare {
pub number: Option<Digit>,
pub corners: DigitBitFlags,
pub cente... | true |
7efba8dd34c59fdbdc6836c745bb44f9ade704e0 | Rust | elsid/CodeSide | /src/common.rs | UTF-8 | 2,404 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | use std::ops::Mul;
macro_rules! log {
($tick_index:expr, $message:tt) => {
if cfg!(feature = "enable_log") {
let f = || {
use std::io::{stdout, Write};
write!(&mut stdout(), "[{}] {}\n", $tick_index, $message).unwrap();
};
f();
}
... | true |
f6e69a94e7ea8d3cbcf1e486a0fdf80c0990d071 | Rust | ScrantonHacks/YADQL | /client/src/main.rs | UTF-8 | 726 | 2.890625 | 3 | [
"MIT"
] | permissive | extern crate yadql;
use yadql::Database;
fn main() {
let db = Database::connect();
println!("A Test YADQL Client");
println!("First, we'll insert the value 'x': 'y'.");
println!("Insert 'x' 'y';");
println!(db::execute("Insert 'x' 'y';"));
println!(db::execute("Read 'x'"));
println!("Then ... | true |
1b26dad81616460fb2ef293d7bf0d640a0f552f2 | Rust | dalance/sv-parser | /sv-parser-parser/src/declarations/let_declarations.rs | UTF-8 | 3,694 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::*;
// -----------------------------------------------------------------------------
#[tracable_parser]
#[packrat_parser]
pub(crate) fn let_declaration(s: Span) -> IResult<Span, LetDeclaration> {
let (s, a) = keyword("let")(s)?;
let (s, b) = let_identifier(s)?;
let (s, c) = opt(paren(opt(let_por... | true |
ed07fc5e1c86ccec2303a80075df7a0160b2e379 | Rust | namalkanti/DynamicEntryBot | /src/dynamic_bot.rs | UTF-8 | 2,238 | 3.234375 | 3 | [] | no_license | use std::fs;
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use crate::api::api::DiscordApi;
use crate::api::api::ApiMessage::{User, LogoutWithToken, Logout};
impl DynamicBot
{
///Constructor returns LoggedOutDBot with registered user list
pub fn new(config_path: String) -> LoggedOutDBot... | true |
18cb1900dd0bf872419c838fc882162e0dafb82f | Rust | pepsighan/mime-detective | /src/lib.rs | UTF-8 | 4,662 | 3.375 | 3 | [
"MIT"
] | permissive | //! The [`MimeDetective`](struct.MimeDetective.html) spies for the magic number of a file or buffer
//! and spits out strongly typed Mimes.
//!
//! # Example
//!
//! ```
//! use mime_detective::MimeDetective;
//!
//! let detective = MimeDetective::new().unwrap();
//! let mime = detective.detect_filepath("Cargo.toml").u... | true |
ea1dd4fec2e7a9ac5b08fe40cc03b989775178a2 | Rust | hpistor/rust_raytracer | /src/main.rs | UTF-8 | 999 | 3.03125 | 3 | [] | no_license | extern crate minifb;
use minifb::{Key, Window, WindowOptions};
const WIDTH: usize = 640;
const HEIGHT: usize = 360;
fn main() {
let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
let mut window = Window::new(
"Test - ESC to exit",
WIDTH,
HEIGHT,
WindowOptions::default(),
... | true |
2463fa7020d71db36a15aaf11cf40dd43e57934e | Rust | davidji/quadrature | /microcontroller/src/hardware/motor.rs | UTF-8 | 4,083 | 2.921875 | 3 | [] | no_license |
// use super::super::int_pid::IntPid;
use core::cmp::{ min, max };
use core::option::Option;
use embedded_hal::PwmPin;
// use stm32f1xx_hal::prelude::_embedded_hal_PwmPin as PwmPin;
pub enum Mode {
Free, Brake
}
pub trait DcMotorOut {
fn free(&mut self);
fn brake(&mut self);
fn drive(&mut self, duty:... | true |
9fe4a5aca025f40dd6f1b7e4c3f8621c2c9bcb5c | Rust | mb64/mish | /src/funcs/n.rs | UTF-8 | 363 | 3.125 | 3 | [
"MIT"
] | permissive | use Flt;
pub fn is_nan<T: Flt>(f: T) -> bool {
f == T::NAN
}
pub fn is_inf<T: Flt>(f: T) -> bool {
f == T::INF || f == T::NEG_INF
}
pub fn is_fin<T: Flt>(f: T) -> bool {
!(is_inf(f) || is_nan(f))
}
pub fn signum<T: Flt>(f: T) -> T {
if is_nan(f) {
T::NAN
} else if f < T::ZERO {
-... | true |
68fe749c7b22b90944f66c99bdad78fa34b91a49 | Rust | linclelinkpart5/anagma | /src/types/number.rs | UTF-8 | 23,012 | 3.703125 | 4 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::ops::{Add, Sub, Mul, Div, Rem, Neg};
use rust_decimal::Decimal;
/// Wrapper type to smooth over the differences between integers and decimals.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum Number {
Integer(i64),
Decimal(Decimal),
}
impl Number {
/// Does a c... | true |
a25f2bc920d37965573d3e9e329263486f1a57f8 | Rust | mackilinen/playing-with-rust-lang | /introduction-to-tdd-with-rust/Series 1 - Fractions/tests/reduction_tests.rs | UTF-8 | 938 | 3.21875 | 3 | [] | no_license | extern crate fractions;
use fractions::Fraction;
#[test]
fn different_denominators_without_reducing() {
assert_eq!(
Fraction {
numerator: 5,
denominator: 6,
},
Fraction {
numerator: 1,
denominator: 2,
}.plus(&Fraction {
nu... | true |
170ba9c93599c34b7b33d76e992bad840068a93c | Rust | ihcsim/rust-101 | /src/bin/conversion.rs | UTF-8 | 267 | 4 | 4 | [] | no_license | fn main() {
let x = 32.0;
println!("{}C = {}F", x, to_fahrenheit(x));
let y = 81.0;
println!("{}F = {}C", y, to_celsius(y));
}
fn to_fahrenheit(x: f32) -> f32 {
x * 9.0 / 5.0 + 32.0
}
fn to_celsius(x: f32) -> f32 {
(x - 32.0) * 5.0 / 9.0
}
| true |
35debcecb05594d6c66223a94dc933ac36eb01d0 | Rust | VladimirMarkelov/rterm | /src/lib.rs | UTF-8 | 2,170 | 3 | 3 | [
"MIT"
] | permissive | //! A library for terminal/console-based applications
//!
//! The library contains a set of basic functions that makes possible creation
//! of full-featured terminal applications with mouse and keyboard support.
//!
//! Terminal management includes
//! * output to terminal
//! * reading the current terminal content
//... | true |
6df5b068b9142a9c22ad0e20612a9646ddc770b8 | Rust | QingQiz/NMSqL | /src/backend/VirtualMachine/src/VirtualMachine/VmAgg.rs | UTF-8 | 7,100 | 2.890625 | 3 | [
"WTFPL"
] | permissive | use super::VmMem::VmMem;
use intrusive_collections::intrusive_adapter;
use intrusive_collections::rbtree::{Cursor, CursorMut};
use intrusive_collections::{Bound, KeyAdapter, RBTree, RBTreeLink};
use std::cell::Cell;
struct AggData {
link: RBTreeLink,
key: VmMem,
value: Vec<VmMem>,
}
intrusive_adapter!(AggAdaptor=... | true |
728424224fce2f0b91a2294debbf59c5d3b66fd5 | Rust | MariuszBielecki288728/rust-course | /lab05/task3/src/main.rs | UTF-8 | 1,386 | 3.4375 | 3 | [] | no_license | use std::cmp::Ordering;
fn main() {
println!("Hello, world!");
}
fn solution(n: f64) -> f64 {
match n.fract().partial_cmp(&0.5) {
Some(Ordering::Less) => match n.fract().partial_cmp(&0.25) {
Some(Ordering::Less) => n.trunc(),
_ => n.trunc() + 0.5
},
Some(Orderi... | true |
ea6f9cb9051cbf8166b55bdc25c825eb71232291 | Rust | slasyz/slasyz_ru | /src/middleware/middleware_log.rs | UTF-8 | 890 | 2.625 | 3 | [
"MIT"
] | permissive | use log::info;
use tide::{Middleware, Next, Request};
pub struct LogMiddleware {}
impl LogMiddleware {
pub fn new() -> LogMiddleware {
LogMiddleware {}
}
}
#[tide::utils::async_trait]
impl<State: Clone + Send + Sync + 'static> Middleware<State> for LogMiddleware {
async fn handle(&self, req: Requ... | true |
4bde2e308b37b57bf8f46f914edbd4f252ce30d9 | Rust | Metaswitch/floki | /src/command.rs | UTF-8 | 6,437 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::errors::{FlokiError, FlokiSubprocessExitStatus};
use anyhow::Error;
use std::ffi::{OsStr, OsString};
use std::path;
use std::process::{Command, Stdio};
#[derive(Debug, Clone)]
pub struct DockerCommandBuilder {
name: String,
volumes: Vec<OsString>,
environment: Vec<OsString>,
switches: Vec<Os... | true |
80450408693b2b7ce7fdcf6cc0c4e2114217baac | Rust | Patryk27/janet | /libs/database/src/features/projects/find.rs | UTF-8 | 1,360 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::features::prelude::*;
use crate::Project;
#[derive(Clone, Debug, Default)]
pub struct FindProjects {
/// Internal project id
pub id: Option<Id<Project>>,
/// GitLab's project id
pub ext_id: Option<gl::ProjectId>,
}
impl FindProjects {
pub fn id(id: Id<Project>) -> Self {
Self {... | true |
2f90fcd8c2a5851d7a238b765ca6ba79e77d5dee | Rust | bombless/rustc-chinese | /src/test/run-pass/trait-contravariant-self.rs | UTF-8 | 1,313 | 2.75 | 3 | [
"MIT",
"Apache-2.0",
"Unlicense",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"bzip2-1.0.6",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | // ignore-test
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// ... | true |
e3733320588a20bf2d96e2deb87c42409a1f1fe5 | Rust | fewensa/rtdlib | /src/types/phone_number_authentication_settings.rs | UTF-8 | 3,867 | 2.875 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
/// Contains settings for the authentication of the user's phone number
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct PhoneNumberAuthenticationSettings {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
... | true |
27bff51bcf35496856b04edee6be7464cc843521 | Rust | luksamuk/wasm-platformer-rs | /src/main.rs | UTF-8 | 3,982 | 2.671875 | 3 | [
"MIT"
] | permissive | #![recursion_limit="2048"]
#[macro_use]
extern crate stdweb;
extern crate ref_eq;
#[macro_use]
extern crate bitflags;
use stdweb::unstable::TryInto;
use stdweb::traits::IMouseEvent;
use stdweb::web::html_element::CanvasElement;
use stdweb::web::{
self,
IEventTarget,
INonElementParentNode
};
use stdweb::we... | true |
79b56136335220988de9198a2a8f011fc1eed826 | Rust | MalteT/rust-rrule | /src/rrule.rs | UTF-8 | 2,033 | 3.0625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | use crate::options::*;
use crate::rrulestr::build_rrule;
use chrono::prelude::*;
use chrono_tz::Tz;
use std::str::FromStr;
#[derive(Clone, Debug)]
pub struct RRule {
pub options: ParsedOptions,
}
impl RRule {
pub fn new(options: ParsedOptions) -> Self {
Self { options }
}
/// Returns all the ... | true |
bc6d787068f5b7698cbd69c3574e19f7d65da44e | Rust | meldron/aoc-2019 | /day-12/src/main.rs | UTF-8 | 2,900 | 3.109375 | 3 | [] | no_license | use regex::Regex;
use std::fs;
use std::path::PathBuf;
use unroll::unroll_for_loops;
fn load_input(path: &PathBuf) -> Result<Vec<[i64; 3]>, String> {
let re = Regex::new(r"<x=(-?\d*?), y=(-?\d*?), z=(-?\d*?)>").map_err(|e| e.to_string())?;
let input_raw = fs::read_to_string(path).map_err(|e| e.to_string())?;... | true |
35400c2e18e22dd7c866a91c9adbd92740803664 | Rust | awygle/regex-automata | /regex-automata-debug/main.rs | UTF-8 | 5,645 | 2.671875 | 3 | [
"MIT",
"Unlicense"
] | permissive | use std::error::Error;
use std::fs;
use std::io::{self, Write};
use std::mem::size_of;
use std::path::{Path, PathBuf};
use std::process;
use std::result;
use std::time::Instant;
use regex_automata::{DFA, Regex, RegexBuilder, DenseDFA, SparseDFA};
type Result<T> = result::Result<T, Box<dyn Error>>;
macro_rules! err {... | true |
bfe01fcd2f7de7cfd82bcd1debd9f58102219b56 | Rust | garethkcjones/rays | /src/texture/noise.rs | UTF-8 | 695 | 3.09375 | 3 | [] | no_license | use super::Texture;
use crate::{Colour, Perlin, Vec3};
use std::sync::Arc;
/**
* Type for representing a random noise texture.
*/
#[derive(Debug)]
pub struct Noise {
noise: Perlin,
scale: f64,
}
impl Noise {
#[must_use]
pub fn new(scale: f64) -> Self {
Self {
noise: Perlin::new()... | true |
1de5bd8412a4050c816b385ed1352dbb5d19fb5a | Rust | rust-lang/rust-analyzer | /crates/hir-def/src/macro_expansion_tests/mbe/matching.rs | UTF-8 | 2,928 | 2.921875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Test that `$var:expr` captures function correctly.
use expect_test::expect;
use crate::macro_expansion_tests::check;
#[test]
fn unary_minus_is_a_literal() {
check(
r#"
macro_rules! m { ($x:literal) => (literal!();); ($x:tt) => (not_a_literal!();); }
m!(92);
m!(-92);
m!(-9.2);
m!(--92);
"#,
ex... | true |
d2e8c256a47cc9b06b47586b0b2914c1228388aa | Rust | Riey/rune | /crates/runestick/src/key.rs | UTF-8 | 10,414 | 3.34375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
Bytes, FromValue, Shared, StaticString, ToValue, Tuple, TypeInfo, Value, Vec, VmError,
VmErrorKind,
};
use serde::{de, ser};
use std::fmt;
use std::sync::Arc;
use std::vec;
/// A key that can be used as an anonymous object key.
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum... | true |
748482bcdbfb33d0bb73777c24f30b78b768e0df | Rust | kamranajabbar/ch_10_generic_trait_lifetime | /src/one_generic_in_method.rs | UTF-8 | 475 | 3.828125 | 4 | [] | no_license | #[derive(Debug)]
struct Point<T> {
x: T,
y: T,
}
impl<T> Point<T> {
fn x(&self) -> &T {
&self.x
}
fn y(&self) -> &T {
&self.y
}
}
pub fn run() {
let p = Point { x: 100, y: 101};
let f = Point { x: 10.11, y: 20.22};
//For x points of p and f struct
println!("p.... | true |
3e156ed0a74597a268ef159a556224dd0a766ae4 | Rust | rivertam/rust-clippy | /tests/ui/booleans.rs | UTF-8 | 3,659 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![warn(clippy::nonminimal_bool, clippy::logic_bug)]
#[allow(unused, clippy::many_single_char_names)]
fn main() {
let a: bool = unimplemented!();
let b: bool = unimplemented!();
let c: bool = unimplemented!();
let d: bool = unimplemented!();
let e: bool = unimplemented!();
let _ = a && b || a;
... | true |
743e251a457c73118283dd1d256a269c09b5a2f0 | Rust | cgm616/pupil-server | /src/error.rs | UTF-8 | 3,231 | 2.703125 | 3 | [] | no_license | use std::{io, fmt, error};
use std::error::Error as StdError;
use diesel::result::Error as DieselError;
use diesel::result::{DatabaseErrorKind, DatabaseErrorInformation};
use rocket::response::{Responder, Response};
use rocket::http::{ContentType, Status};
use r2d2::GetTimeout;
use serde_json;
#[derive(Debug)]
pub... | true |
1004ecc136ae3542edd19e825cdf5efec9d8cde1 | Rust | bauhaus93/world-gen | /core/src/player.rs | UTF-8 | 5,001 | 2.953125 | 3 | [] | no_license | use crate::traits::{Rotatable, Translatable, Updatable};
use crate::Point3f;
use crate::{graphics::create_direction, Camera, Float, Model, UpdateError};
pub struct Player {
model: Model,
momentum: Point3f,
forward: Point3f,
speed: f32,
jumping: bool,
}
impl Player {
pub fn align_camera(&self, ... | true |
8d94bb2ae02f43d3ace0cb066cc8b3319611ae77 | Rust | paul-lysak/2019-10-rust-excercises | /netwc/src/main.rs | UTF-8 | 2,334 | 3.03125 | 3 | [] | no_license | use std::sync::{Arc, Mutex};
use tokio::prelude::*;
use tokio::net::TcpStream;
use tokio::net::TcpListener;
use std::net::SocketAddr;
use tokio::codec::{BytesCodec, Decoder};
#[derive(Debug, Default)]
struct Counts {
lines: i32,
words: i32,
bytes: i32,
}
impl Counts {
fn add(&self, other: Counts) -> C... | true |
c3696b38ebf698da01b0d275444171ad71050a97 | Rust | charles-wangkai/exercism | /rust/decimal/src/lib.rs | UTF-8 | 2,265 | 3.421875 | 3 | [] | no_license | use std::{
cmp::Ordering,
ops::{Add, Mul, Sub},
str::FromStr,
};
use num_bigint::BigInt;
/// Type implementing arbitrary-precision decimal arithmetic
#[derive(Debug, PartialEq)]
pub struct Decimal {
amount: BigInt,
neg_scale: u32,
}
struct DecimalAlignment {
self_amount: BigInt,
other_amo... | true |
a3f62b14a04f43333bf78fb874d194e00be72360 | Rust | nyctef/ray-tracer-challenge-rust | /src/rtc/world.rs | UTF-8 | 913 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::*;
// this extra type is needed to avoid E0225
// because of https://github.com/rust-lang/rust/issues/32220
pub trait IntersectableShape: Shape + RayIntersection {}
impl<T: Shape + RayIntersection> IntersectableShape for T {}
#[derive(Debug)]
pub struct World {
pub objects: Vec<Box<dyn IntersectableSha... | true |
2b6170fb5f6fd2c8640e8a705f0a766d46cc501a | Rust | pfugate/moxie | /ofl/src/published.rs | UTF-8 | 3,898 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use cargo_metadata::{Metadata, Package, PackageId};
use crates_io_api as crates;
use failure::{bail, Error, ResultExt};
use gumdrop::Options;
use semver::Version;
use std::collections::BTreeMap;
use tracing::*;
#[derive(Debug, Options)]
pub struct EnsurePublished {
help: bool,
/// Disables publishing to crates... | true |
e7790ed2409a7368838de85c0eb93df3ab248cb9 | Rust | yingliufengpeng/rust_learning | /src/main16.rs | UTF-8 | 539 | 3.265625 | 3 | [] | no_license | // 通道介绍, mpsc:多个生产者,一个消费者, spmc一个生产者,多个消费者
use std::thread;
use std::sync::mpsc;
fn get_str() -> &'static str {
"kkk"
}
fn main() {
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let val = String::from("kk");
tx.send(val).unwrap(); // 调用Send的时候会发生move这样的动作
// println!("v... | true |
9167c2e6fc9c7f52c505465beb85560eb25bf5bb | Rust | skriems/muttmates | /src/tests.rs | UTF-8 | 2,279 | 2.953125 | 3 | [
"Unlicense"
] | permissive | #![allow(unused_imports)]
#[cfg(test)]
use muttmates::fields::*;
use muttmates::VCard;
#[test]
fn test_email_with_type() {
let email = EMail::new("EMAIL;TYPE=WORK:john@doe.example");
assert_eq!(email.addr, "john@doe.example");
assert_eq!(email.kind, EMailKind::Work);
}
#[test]
fn test_email_with_type_and_... | true |
ff514b0b9d69dc0f6941b2f26df74cf28cc97a48 | Rust | GaloisInc/crucible | /crux-mir/test/conc_eval/iter/zip.rs | UTF-8 | 283 | 2.515625 | 3 | [
"BSD-3-Clause"
] | permissive | #![cfg_attr(not(with_main), no_std)]
#[cfg_attr(crux, crux::test)]
pub fn f() {
let arr = [1, 2, 3, 4];
let arr = &arr[..];
for (&a, &b) in arr.iter().zip(arr.iter().skip(1)) {
assert!(a < b);
}
}
#[cfg(with_main)] pub fn main() { println!("{:?}", f()); }
| true |
e98f549b27b6d885a03065353af89ad323eb5fc9 | Rust | apognu/aoc2019 | /src/util/intcode/circuit.rs | UTF-8 | 939 | 2.9375 | 3 | [] | no_license | use super::Program;
pub struct Circuit<F> {
programs: Vec<Program>,
inputs: F,
feedback: bool,
}
impl<F> Circuit<F>
where
F: Fn(usize, usize, i128) -> Vec<i128>,
{
pub fn with_copies(
count: usize, stack: Vec<i128>, inputs: F, feedback: bool,
) -> Self {
let programs =
(0..count).map(|_| Pro... | true |
97616d830edd5bff81aa105400f1a067460a8947 | Rust | gelendir/aoc2020 | /day12/src/main.rs | UTF-8 | 5,553 | 3.796875 | 4 | [] | no_license | use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
type Unit = i32;
enum Instruction {
North(Unit),
East(Unit),
South(Unit),
West(Unit),
Left(Unit),
Right(Unit),
Forward(Unit)
}
#[derive(Clone)]
enum Direction {
North,
South,
East,
West
}
st... | true |
7fc3118e01525a3d86f724059019f6cbb28b616b | Rust | ekump/wopr-tag | /src/lib.rs | UTF-8 | 3,878 | 2.890625 | 3 | [
"Unlicense"
] | permissive | use log::{debug, info};
mod models;
mod renderer;
use models::action::ActionType;
use models::field_of_play::FieldOfPlay;
use models::player::Player;
use models::stats::Stats;
use std::{thread, time};
// If this were a real project we would test the actual simulation somehow. But that would eat up
// quite a bit of ti... | true |
3abb70d3c0c7149848d1c71c2bd053f87cf9ef69 | Rust | azriel91/autexousious | /crate/workspace_tests/src/team_model/play/independent_counter.rs | UTF-8 | 583 | 2.9375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #[cfg(test)]
mod tests {
use team_model::play::IndependentCounter;
#[test]
fn get_and_increment_returns_incremented_value() {
let mut independent_counter = IndependentCounter::new(5);
let get = independent_counter.get_and_increment();
assert_eq!(IndependentCounter::new(5), get);
... | true |
9b2909c3855b2630a3c7c7bfb3767c4fe4ba194d | Rust | ashvin021/AdventOfCode2019 | /src/bin/09.rs | UTF-8 | 1,085 | 2.78125 | 3 | [] | no_license | use std::thread;
use aoc2019::{intcode::*, *};
fn part01(mem: &[i64]) -> i64 {
let (mut computer, s, r) = IntcodeComputer::with_io(mem.to_owned());
thread::spawn(move || {
computer.run();
});
let input = 1;
println!("Input: {}", input);
s.send(input).unwrap();
let mut output = V... | true |
ee2480955a2d951cb98d64e97850eac9a27586b6 | Rust | ricky26/chunked | /packages/chunked/src/world/transaction.rs | UTF-8 | 9,490 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::mem::transmute;
use std::sync::{Arc, Mutex};
use rayon::iter::{IndexedParallelIterator, ParallelIterator};
use rayon::iter::plumbing::{bridge, Consumer, Producer, ProducerCallback, UnindexedConsumer};
use crate::{Archetype, Chunk, Snapshot};
use crate::archetype::ComponentSetExt;
use crate::chunk_set::ChunkS... | true |
467587bf64de419016864294cd9d4d2b4e54ed52 | Rust | compenguy/pandora-api-derive | /src/lib.rs | UTF-8 | 8,511 | 2.921875 | 3 | [
"MIT"
] | permissive | /*!
Derive macros for automatically adding an implementation of
pandora_api::Pandora<Json|Rest>ApiRequest to a struct.
The name of the Pandora API method that will be called defaults to the
result of converting the struct name to lower camel case (GetFoo -> getFoo).
This may be overridden using the #[pandora_request(m... | true |
7cbf116c61225f355961f0b0ace733af5522819a | Rust | taylorsmcclure/valheim-docker | /src/utils/mod.rs | UTF-8 | 2,270 | 3.171875 | 3 | [] | no_license | use std::env;
use clap::ArgMatches;
use std::process::{exit};
use log::{info,debug, error};
use std::path::Path;
use sysinfo::{System, Signal, SystemExt, ProcessExt};
pub fn get_working_dir() -> String {
match env::current_dir() {
Ok(current_dir) => current_dir.display().to_string(),
_ => {
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.