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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
285daea3932d2409b126c8f1ca9826e3a5316245 | Rust | tlowerison/tilings | /rust/client/geometry/src/interval.rs | UTF-8 | 2,779 | 3.3125 | 3 | [
"MIT"
] | permissive | use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
pub const EMPTY_INTERVAL: Interval = Interval(0,0,0);
pub struct Interval(u8, u8, u64);
// SizedInterval is only concerned with size in terms of ordering.
pub struct SizedInterval(pub Interval);
// PositionedInterval is only concerned with positioning in ter... | true |
64d7652ce2afa1e4074ca0191f02fc247d40a538 | Rust | RPG59/FGIN2 | /src/core/IndexBuffer.rs | UTF-8 | 590 | 2.609375 | 3 | [] | no_license | use web_sys::{WebGlBuffer, WebGl2RenderingContext};
use crate::core::EngineCore::GL;
struct IndexBuffer {
gl: GL,
buffer: WebGlBuffer,
}
impl IndexBuffer {
pub fn new(gl: &GL, data: &[u32], usage: u32) -> Self {
IndexBuffer {
gl: gl.clone(),
buffer: gl.create_buffer().unwra... | true |
b4d0222c81e6d356f3bd84dc6c4424cad28181fd | Rust | Spread0x/rome | /crates/rome_js_semantic/src/tests/scopes.rs | UTF-8 | 1,927 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::assert_semantics;
// Statements
assert_semantics! {
ok_scope_if, "if(true) {/*START A*/}/*END A*/",
ok_scope_if_no_block, "if(true) ;/*NOEVENT*/;",
ok_scope_if_without_block_else_with_block, "if(true) ;/*NOEVENT*/ else {/*START A*/}/*END A*/;",
ok_scope_if_without_block_else_without_block, "... | true |
de40c7cb68cb0f3790250665f52bb56f507b3721 | Rust | MohamedHajr/Problem-Solving | /CTCI/chapter_5_bit_manipulation/5_4.rs | UTF-8 | 1,245 | 3.578125 | 4 | [] | no_license | fn main() {
let number = 13948;
let bigger = get_next(number);
let smaller = get_prev(number);
println!("{:32b}", bigger);
println!("{:32b}", smaller);
}
fn get_next(number: i32) -> i32{
let mut n = number;
let mut c0 = 0;
let mut c1 = 0;
while (n & 1) == 0 && n != 0 {
c0 ... | true |
2869aa491c7b6d46104921ef1183a063ed702ada | Rust | dnbaumann/launchy | /src/launchpad_mk2/input.rs | UTF-8 | 3,730 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use super::Button;
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
/// A Launchpad MK2 input message
pub enum Message {
/// A button was pressed
Press { button: Button },
/// A button was released
Release { button: Button },
/// Emitted after a text scroll was initiated
TextEndedOrLoope... | true |
6c928b2a070d1b1689e2d62ba16cefd696515d88 | Rust | DomtronVox/JRPG_Game | /src/ecs/render_system.rs | UTF-8 | 1,907 | 3 | 3 | [] | no_license | use specs::{WriteExpect, ReadStorage, System};
use super::position_component::PositionComponent;
use super::gfx_components::VisualComponent;
use crate::assets::{AssetDatabase, AssetContainer};
//the render system draws stuff onto the next frame before the core application
// applies it to the screen
pub struct Ren... | true |
085c028dad9d2b7aac0c6ca42e65a5a9840a348d | Rust | dopitz/vulkanism | /nobs-vkpipes/nobs-vkpipes-macro/src/lib.rs | UTF-8 | 6,087 | 2.9375 | 3 | [
"MIT"
] | permissive | //! # nobs-vkpipes-macro
//! Proc-Macro crate for nobs-vkpipes
//!
//! This crate defines the actual proc macros for the pipeline and shader stage code generation
//!
//! ## Example
//! This is a simple example that sets up a compute pipeline.
//!
//! All the magic happens in `vk::pipes::pipeline!` macro!
//! We define... | true |
95d071fb93e95b0f6e090ae82146b50222d98d6c | Rust | iPixelOldC/winsafe | /src/w_string.rs | UTF-8 | 7,973 | 3.328125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::ffi::OsStr;
use std::os::windows::ffi::OsStrExt;
use crate::ffi::kernel32;
/// Stores a `Vec<u16>` buffer for an
/// [Unicode UTF-16](https://docs.microsoft.com/en-us/windows/win32/intl/unicode-in-the-windows-api)
/// wide string natively used by Windows.
///
/// Performs UTF-8 conversions and can b... | true |
46109a69e10fd9647358e8a466f73ab42ed1b58b | Rust | lespea/atuin | /src/command/stats.rs | UTF-8 | 2,562 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use chrono::prelude::*;
use chrono::Duration;
use chrono_english::parse_date_string;
use cli_table::{format::Justify, print_stdout, Cell, Style, Table};
use eyre::{eyre, Result};
use structopt::StructOpt;
use atuin_client::database::Database;
use atuin_client::history::History;
use atu... | true |
13de8bba17f83e5ee3ec7cee74c6d2e6c5ee15c5 | Rust | sierra-zero/rg3d | /src/scene2d/base.rs | UTF-8 | 4,858 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::scene::base::PhysicsBinding;
use crate::{
core::{
algebra::{Matrix4, Vector2},
pool::Handle,
visitor::prelude::*,
},
scene2d::{graph::Graph, node::Node, transform::Transform},
};
use std::cell::Cell;
#[derive(Visit)]
pub struct Base {
transform: Transform,
pub(in ... | true |
a6611ebe5cc0220cb0969fb33288e7bab1349bfd | Rust | cch123/wrkrs | /src/main.rs | UTF-8 | 5,931 | 2.75 | 3 | [] | no_license | use ansi_term::Colour::Blue;
use clap::{App, Arg};
use futures::future::join_all;
use tokio::{
net::TcpStream,
prelude::*,
signal,
sync::{Mutex, MutexGuard},
time::delay_for,
};
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
time::{Duration, Instant},
};
#[... | true |
9ac03a1709a76239105640d61c4bb220e0264824 | Rust | commodis/docuum | /src/run.rs | UTF-8 | 40,733 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::{
format::CodeStr,
state::{self, Image, State},
Settings,
};
use byte_unit::Byte;
use chrono::DateTime;
use regex::RegexSet;
use scopeguard::guard;
use serde::{Deserialize, Serialize};
use std::{
cmp::max,
collections::{HashMap, HashSet},
io::{self, BufRead, BufReader},
mem::drop,... | true |
488340b69ae8104c904f3b5e793720b0d5ea4e79 | Rust | daikichiba9511/atcoder_for_myself | /rust/abc281/src/bin/b.rs | UTF-8 | 1,444 | 3.421875 | 3 | [] | no_license | use proconio::marker::Chars;
use proconio::{fastout, input};
fn is_number(s_i: char) -> bool {
s_i.is_digit(10)
}
#[fastout]
fn solve1() {
input! {s: String};
if s.len() != 8 {
println!("No");
return;
}
// assert!(!is_number("Q".chars().next().unwrap()));
// assert!(is_number(... | true |
46e7dcf4a8c5b75b32635dbfae9d784f2fc7c9b2 | Rust | IceDynamix/rust_nonogram | /src/nonogram.rs | UTF-8 | 5,221 | 2.8125 | 3 | [
"MIT"
] | permissive | use ggez::{
event::MouseButton,
graphics::{self, Color},
nalgebra::Point2,
Context, GameError, GameResult,
};
use graphics::{DrawMode, Mesh, Rect};
use std::fs;
pub type Nonogram = Vec<Vec<Block>>;
pub const BLOCK_CHAR: char = '#';
const BLOCK_SIZE: f32 = 35.0;
const BLOCK_COLOR: graphics::Color = gra... | true |
9e841eab02d058aad34bd9757843383869dacc1e | Rust | derekdreery/termbuffer | /src/lib.rs | UTF-8 | 2,503 | 2.6875 | 3 | [] | no_license | pub use crate::screen::{Char, Color, Frame};
use std::{
io::{self, Write},
ops::{Deref, DerefMut},
};
pub use termion::event::{Event, Key, MouseButton, MouseEvent};
use termion::{
async_stdin, clear, cursor,
input::{Events, TermRead},
raw::IntoRawMode,
raw::RawTerminal,
terminal_size, AsyncR... | true |
a1a1d01b081b99e83cb6fb32a9e3ba4c109f6424 | Rust | erplsf/adventofcode | /rust/src/2020/15/main.rs | UTF-8 | 1,299 | 3.609375 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
// key is the number, value is the turns at which it was spoken
fn parse_input(string: &str) -> (HashMap<usize, (usize, usize)>, (usize, usize)) {
let iter = string.split(',').filter_map(|n| n.parse().ok());
let turn = iter.clone().count();
let last = iter.clone().last().unw... | true |
6139e66b646e01ff6003e17193712ee0ca5aaa15 | Rust | rust-bio/rust-bio | /src/io/newick.rs | UTF-8 | 6,781 | 2.90625 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Franklin Delehelle.
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! A struct to read phylogenetic trees in the Newick format.
//!
//! # Example
//!
//! In this example, we parse a... | true |
4f2da39ba6a6beb70d4acce87c3e8f0598474937 | Rust | solana-labs/solana | /measure/src/macros.rs | UTF-8 | 5,590 | 3.953125 | 4 | [
"Apache-2.0"
] | permissive | /// Measure this expression
///
/// Use `measure!()` when you have an expression that you want to measure. `measure!()` will start
/// a new [`Measure`], evaluate your expression, stop the [`Measure`], and then return the
/// [`Measure`] object along with your expression's return value.
///
/// Use `measure_us!()` whe... | true |
a92d539cdb94479745be74f8e5567d351f1c258f | Rust | Doyko/website | /src/main.rs | UTF-8 | 2,394 | 3 | 3 | [] | no_license | use std::sync::Arc;
use handlebars::Handlebars;
use serde::Serialize;
use serde_json::json;
use std::fs;
use warp::Filter;
struct WithTemplate<T: Serialize> {
name: String,
value: T,
}
fn render<T: Serialize>(template: WithTemplate<T>, hbs: Arc<Handlebars>) -> impl warp::Reply {
let render = hbs.render(&... | true |
dacc574313730ec8c9255449573e0817ed78bac6 | Rust | thejpster/monotronian | /src/lib.rs | UTF-8 | 2,271 | 3.28125 | 3 | [] | no_license | //! # Monotronian
//!
//! A BASIC-alike language for Monotron. See README.md.
#![cfg_attr(not(test), no_std)]
#![cfg_attr(not(test), feature(alloc))]
#[cfg(test)]
use std as core;
#[macro_use]
extern crate nom;
#[cfg(not(test))]
extern crate alloc;
#[cfg(not(test))]
use alloc::prelude::*;
pub mod lexer;
pub mod pa... | true |
3982bcc076af6f7503a5a37a2db94c1d4697c0b8 | Rust | rome/tools | /crates/rome_json_formatter/src/json/lists/array_element_list.rs | UTF-8 | 2,605 | 3.203125 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use crate::separated::FormatAstSeparatedListExtension;
use rome_formatter::write;
use rome_json_syntax::{AnyJsonValue, JsonArrayElementList};
use rome_rowan::{AstNode, AstSeparatedList};
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsonArrayElementList;
impl FormatRule<JsonArrayElem... | true |
d17e64d5f6d85d9cb9478f7c776e27e3d03566ef | Rust | nambrosini/adventofcode | /2017/src/day18.rs | UTF-8 | 9,338 | 2.859375 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::HashMap;
use std::convert::{From, Into};
#[aoc_generator(day18)]
pub fn generator(input: &str) -> Vec<Instruction> {
input.lines().map(|l| l.into()).collect_vec()
}
#[aoc(day18, part1)]
pub fn part1(input: &[Instruction]) -> i64 {
let mut duet = Duet::new(input.... | true |
64534da4c8ecd0495ffdaee06f92dace3c313143 | Rust | emreyalvac/project-management-system | /commands/src/command_handlers/board_command_handlers/insert_board_command_handler.rs | UTF-8 | 1,314 | 2.734375 | 3 | [] | no_license | use crate::commands::board_commands::insert_board_command::InsertBoardCommand;
use domain::command::command::TCommandHandler;
use domain::common::command_response::CommandResponse;
use async_trait::async_trait;
use domain::common::command_type::CommandType;
use data_access::generic_repository::generic_repository::{Gen... | true |
9bb9e1285619a4dabeca5f7e4a16de5965b87692 | Rust | kamiyaa/portage-parser | /src/lib.rs | UTF-8 | 3,033 | 2.953125 | 3 | [] | no_license | use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::fs::File;
use std::io::{self, BufRead, BufReader};
#[cfg(test)]
mod tests {
use crate::parse_package_use;
#[test]
fn it_works() {
println!("Map: {:#?}", parse_package_use());
assert!(false, true);
}
}
#[derive(Cl... | true |
4e4ad907942aa53652dc48d35d9639c546f9ec50 | Rust | solana-labs/solana | /bucket_map/src/bucket_map.rs | UTF-8 | 23,428 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | //! BucketMap is a mostly contention free concurrent map backed by MmapMut
use {
crate::{bucket_api::BucketApi, bucket_stats::BucketMapStats, MaxSearch, RefCount},
solana_sdk::pubkey::Pubkey,
std::{convert::TryInto, fmt::Debug, fs, path::PathBuf, sync::Arc},
tempfile::TempDir,
};
#[derive(Debug, Defau... | true |
5779cbf89e7c4647d9eff04ad7416b2cf1a1d206 | Rust | barollet/baba_solver | /src/levels_list.rs | UTF-8 | 914 | 3.03125 | 3 | [] | no_license | //! A definition of all the levels
use crate::level::*;
use crate::square::*;
const LEVELS_NUMBER: usize = 1;
lazy_static! {
pub static ref LEVELS_LIST: [Level; LEVELS_NUMBER] = [
level_1(),
];
}
fn level_1() -> Level {
let mut level = Level::new(15, 11);
// Walls
level.add_square_line(... | true |
7faa3b74e1a8fb499aa898e190645958cbf4ac4c | Rust | longshorej/signal-http | /src/chat.rs | UTF-8 | 13,995 | 3.21875 | 3 | [] | no_license | //! Contains the primary logic for the chat server,
//! which has a pure domain logic implementation,
//! `ChatServer`.
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::str;
use std::usize;
/// Id type for chats, messages, users
pub type Id = u64;
/// Response representation of a chat
#[d... | true |
120882b478c62e27e95d4bac831468168bc1d2aa | Rust | aromatt/rust-minimax | /src/lib.rs | UTF-8 | 2,441 | 3.15625 | 3 | [] | no_license | use std::cmp;
pub trait Game<State: Clone, Move: Copy> {
fn get_moves(&self, &State) -> Vec<Move>;
fn eval(&self, &State, my_turn: bool) -> i32;
fn apply(&self, &State, Move) -> State;
fn gameover(&self, &State) -> bool;
}
pub struct Minimax;
impl Minimax {
pub fn best_move<State, Move, GameType>(... | true |
d345262f19876973ba8fffa924db9d7e51148844 | Rust | xpeerchain/xpeerchain | /benchmark/src/ruben_opt.rs | UTF-8 | 8,370 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | use clap::arg_enum;
use config::config::NodeConfig;
use failure::prelude::*;
use logger::prelude::*;
use regex::Regex;
use std::{fs, net::IpAddr, path::PathBuf, str::FromStr};
use structopt::StructOpt;
arg_enum! {
#[derive(Debug)]
pub enum Executable {
TestLiveness,
MeasureThroughput,
}
}
... | true |
c928ad6a918aae0b0d5b023e8c080de05b7a3cee | Rust | timando/rsip | /src/headers/untyped/max_forwards.rs | UTF-8 | 554 | 2.6875 | 3 | [
"MIT"
] | permissive | use rsip_derives::UntypedHeader;
/// The `Max-Forwards` header in its [untyped](super) form.
#[derive(UntypedHeader, Debug, PartialEq, Eq, Clone)]
pub struct MaxForwards(String);
impl Default for MaxForwards {
fn default() -> Self {
Self("70".into())
}
}
impl MaxForwards {
pub fn num(&self) -> Re... | true |
b8c6081646d706df28c1c36d7b41f6acc6c38843 | Rust | hfantin/cursos | /rust/c3/celsius-fahrenheit/src/main.rs | UTF-8 | 53 | 2.765625 | 3 | [] | no_license | fn main() {
println!("Celsius do fahrenheit");
}
| true |
dbadec331cf6e9dc9c831cba60678f560dbfbf5f | Rust | baoziv587/LoxLang | /src/frontend/keywords.rs | UTF-8 | 1,010 | 2.59375 | 3 | [] | no_license | use super::token::TokenType;
use std::collections::HashMap;
lazy_static! {
pub static ref LoxKeywords: HashMap<&'static str, TokenType> = {
let mut keywords = HashMap::new();
keywords.insert("and", TokenType::AND);
keywords.insert("class", TokenType::CLASS);
keywords.insert("else", ... | true |
ff396cc1d3d995bbdc397c4492c63eb2b3151c5b | Rust | pjtsearch/mconnect-gtk | /src/views/device_display/mod.rs | UTF-8 | 4,083 | 2.609375 | 3 | [] | no_license | use crate::utils::device::{Device, DeviceType};
use vgtk::lib::gtk::*;
use vgtk::{gtk, Component, UpdateAction, VNode};
#[derive(Clone, Debug, Default)]
pub struct DeviceDisplay {
pub device: Device,
}
#[derive(Clone, Debug)]
pub enum Message {}
impl DeviceDisplay {
pub fn battery_icon(&self) -> String {
... | true |
1e5cbd0376e40a944ca92e3dbace9062cba88889 | Rust | kildevaeld/freja-lang | /freja-vm/src/runner.rs | UTF-8 | 17,559 | 2.875 | 3 | [] | no_license |
use super::context::Context;
use super::error::{RuntimeError, RuntimeResult};
use super::frames::*;
use super::objects::*;
use super::stack::Stack;
use super::utils::Pointer;
use super::value::*;
use freja_compiler::{Constant, OpCode};
use std::rc::Rc;
macro_rules! push {
($stack: expr, $val: expr) => {
$... | true |
b2b9de928fab83c1406e3d84906c933493e481a8 | Rust | MediocreBoris/gitgud | /bezout/main.rs | UTF-8 | 833 | 3.296875 | 3 | [
"MIT"
] | permissive | extern crate num;
use std::io;
use num::Integer;
fn main(){
let mut a = String::new();
let mut b = String::new();
io::stdin()
.read_line(&mut a)
.expect("Failed to read input.");
let a = a.trim().parse::<i64>().expect("Invalid input");
io::stdin()
.read_line(&mut... | true |
045818e5e72aed1e7ef22cf9f0aa9a890561653a | Rust | xpe/rs-uttt | /src/accessors/mod.rs | UTF-8 | 14,155 | 3.109375 | 3 | [] | no_license | /// Accessor functions, some of which might be considered 'conversion'
/// functions. This module does not include constants, constructors, data
/// structure definitions, or game logic.
use data::*;
use constants::*;
// -- -> game ------------------------------------------------------------------
// -- -> board ---... | true |
82c87798a40f7af0abea4b13b17b4c8e084b2ba6 | Rust | nest-rs/nest | /src/color.rs | UTF-8 | 2,603 | 3.453125 | 3 | [
"MIT"
] | permissive | //! Provides an easy-to-use Color struct for doing color manipulation
//! and providing colors to nest.
use glium::uniforms::{AsUniformValue, UniformValue};
/// Color in `(red, green, blue, alpha)` tuple form.
#[derive(Copy, Clone, Debug)]
pub struct Color(pub [f32; 4]);
impl Color {
/// Scale the brightness of ... | true |
eb4c81e777322581515e881378ce93172f9fbe2c | Rust | thedodd/dockerfile | /src/builder.rs | UTF-8 | 3,884 | 3.4375 | 3 | [
"Apache-2.0"
] | permissive | use std::{
borrow::Cow,
fmt,
};
use crate::{
instructions::{
Arg,
Directive,
From,
Instruction,
},
};
/// A Dockerfile represented in code.
///
/// A Dockerfile, conceptually, is a series of instructions. In code, that is exactly how they are
/// represented here. A wra... | true |
b43defe94cc06c81da91c84458fc1fb2987cc406 | Rust | leontoeides/google_maps | /src/time_zone/response/mod.rs | UTF-8 | 3,154 | 3.359375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Resources (enums, structs) for processing the _Time Zone API_ response from
//! the Google Maps Platform. Look in here for more information about the data
//! returned from Google's server and how to parse it with your program.
pub mod status;
use chrono_tz::Tz;
use crate::time_zone::response::status::Status;
use... | true |
c65ae45f7940a0d69ff8a18eb5c7af7a8237b54f | Rust | muzudho/rattle-items-match | /src/machine.rs | UTF-8 | 12,977 | 3.171875 | 3 | [
"MIT"
] | permissive | use crate::{
ActualVal, Condition, ConditionsVal, Control, ExpectedVal, MachineBuilder, MachineState,
MachineVal, MatchingResult, Operator, RangeIncludesMaxVal,
};
use std::fmt;
impl<T> Default for MachineBuilder<T>
where
T: std::clone::Clone,
{
fn default() -> Self {
MachineBuilder {
... | true |
169188a5668eddd53af16ae18c1a8d524fc3a4c5 | Rust | zdannar/mvt | /src/error.rs | UTF-8 | 1,504 | 3.09375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // error.rs
//
// Copyright (c) 2019 Minnesota Department of Transportation
//
use protobuf::error::ProtobufError;
use std::fmt;
/// MVT Error types
#[derive(Debug)]
pub enum Error {
/// The tile already contains a layer with the specified name.
DuplicateName(),
/// The layer extent does not match the tile... | true |
fa7276314cf41c5ed4b7e842d4f113b4a3257683 | Rust | cetusDownfall/exercises | /graphical/rdg/src/entities/ball.rs | UTF-8 | 2,095 | 2.828125 | 3 | [] | no_license | use piston_window::{Context, UpdateArgs, Size, Transformed};
use piston_window::ellipse;
use opengl_graphics::GlGraphics;
use entities::veloc::Veloc;
use entities::{Collide, Drawn, Positioned, Updated};
const PPM: f64 = 15.0;
const GRAVITY: f64 = 0.0;
const FRICTION: f64 = 0.1;
pub struct Ball {
pub pos: Veloc,
... | true |
1404a1170792f3fd80be4fdc6b13908b699dcd05 | Rust | PM4Rs/promi | /src/stream/observer.rs | UTF-8 | 11,612 | 3.28125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! A stateful observer that allows for registering callbacks to handle stream components
use crate::error::{Error, Result};
use crate::stream::{AnyArtifact, Component, ComponentType, Event, Meta, ResOpt, Stream, Trace};
/// Gets registered with an observer while providing callbacks
///
/// All callback functions are... | true |
8e4d49e3c5ad7296380cc52bf74ed9606283de0c | Rust | rbrich/sdf-text | /examples/text.rs | UTF-8 | 7,091 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | /* Draw text
*
* Controls:
* Escape quit
* mouse wheel zoom in/out
*/
#[macro_use] extern crate glium;
extern crate sdf_text;
use std::env;
use glium::{glutin, Surface};
use glium::glutin::{Event, WindowEvent, ElementState, VirtualKeyCode, MouseScrollDelta, TouchPhase};
use sdf_text::*;
... | true |
e832c6936b5ab934b5df9d8c7e7f1fc13040a03a | Rust | jpeterson1823/AdventOfCode | /2022/rust/day8/src/main.rs | UTF-8 | 2,995 | 3.515625 | 4 | [] | no_license | use std::fs;
fn main() {
let input = parse_input();
part1(&input);
part2(&input);
}
fn parse_input() -> Vec<Vec<u32>> {
fs::read_to_string("input.txt")
.expect("Failed to open input.txt")
.split('\n')
.filter(|s| s.len() > 0)
.map(|s| s.chars().map(|c| c.to_digit(10).un... | true |
ee8d4ee3003e3058201a0ade07dfa397a1f72bcc | Rust | sile/cannyls | /src/nvm/memory.rs | UTF-8 | 4,486 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::io::{self, Cursor, Read, Seek, SeekFrom, Write};
use block::BlockSize;
use nvm::NonVolatileMemory;
use {ErrorKind, Result};
type Memory = Cursor<Vec<u8>>;
/// メモリベースの`NonVolatileMemory`の実装.
///
/// # 注意
///
/// これは主にテストや性能計測用途を意図した実装であり、
/// `NonVolatileMemory`が本来要求する"不揮発性"は満たしていない.
#[derive(Debug)]
pub str... | true |
1df161c92aca0d3aa3be244a0bfdb4c27efe072e | Rust | galacticfungus/ArtRef | /renderer/src/pipeline/color_blending.rs | UTF-8 | 4,040 | 2.703125 | 3 | [
"MIT"
] | permissive | use super::{ColorBlendingSettings, ColorBlendingType, traits::{ConfigureColorBlending, ConfigureDynamicState}};
use crate::ConfigurePipeline;
use erupt::vk1_0 as vk;
impl<'a> ConfigureColorBlending for ConfigurePipeline<'a> {
fn configure_blending(
&mut self,
configure_blending: &mut dyn FnMut(&mut ... | true |
665e739928b680479f0911a0c5cafa9552b3e076 | Rust | kstrohbeck/aoc-2020 | /src/day_19.rs | UTF-8 | 4,406 | 2.90625 | 3 | [] | no_license | use crate::utils::usize_;
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{anychar, char as char_, space0, space1},
combinator::{all_consuming, map, value},
multi::separated_list1,
sequence::tuple,
IResult,
};
use std::collections::{HashMap, HashSet};
pub fn star_1(data: ... | true |
1be198ea0562261c454ea3c609969531bf0f29c9 | Rust | manokara/bencode-rs | /src/value.rs | UTF-8 | 45,151 | 3.390625 | 3 | [] | no_license | use std::{cmp::Ordering, collections::BTreeMap, fmt};
#[derive(Debug, PartialEq)]
enum TraverseState {
Dict,
List,
Done,
}
/// Describes an action to be taken when traversing a Value container.
///
/// See [`Value::traverse`](enum.Value.html#method.traverse).
#[derive(Debug)]
pub enum TraverseAction {
... | true |
3a5e323d407bd7a1c7882aa2853c8d4db2a8a3b8 | Rust | sammyne/signatures | /ecdsa/src/lib.rs | UTF-8 | 2,249 | 2.59375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Elliptic Curve Digital Signature Algorithm (ECDSA) as specified in
//! [FIPS 186-4][1] (Digital Signature Standard)
//!
//! This crate doesn't contain an implementation of ECDSA itself, but instead
//! contains [`Asn1Signature`] and [`FixedSignature`] types which are generic
//! over elliptic [`Curve`] types (e.g. ... | true |
efc9c8bd6a71c32715ad2577ef68a831f9dab8ed | Rust | i1i1/pido | /src/colorize.rs | UTF-8 | 5,519 | 2.875 | 3 | [] | no_license | use super::{draw::*, selection::*, *};
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Colors {
// 512 of those
cols: HashMap<Color, i32>,
n: i32,
}
#[derive(Debug, Clone)]
pub struct DNA<'a> {
width: u32,
height: u32,
ref_img: &'a image::RgbImage,
colors: Colors,
bg:... | true |
e876172624c0bce214bde6d932cdc44e1cd5e070 | Rust | andrewnturner/ray_tracer | /src/util/random.rs | UTF-8 | 1,340 | 3.28125 | 3 | [] | no_license | use rand::{Rng, thread_rng};
use crate::geometry::vector::Vector3;
pub fn random_in_unit_sphere() -> Vector3 {
loop {
let p = random_in_unit_cube();
if p.length_squared() < 1.0 {
return p;
}
}
}
pub fn random_in_unit_disk() -> Vector3 {
let mut rng = thread_rng();
... | true |
4f8d7e6d8e08bffe28e7f63acc232180f3b6ed28 | Rust | MShahzad-pk/learning_rust | /struct_string/src/main.rs | UTF-8 | 657 | 3.328125 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let mut name = String::new();
let mut names:Vec<String> = Vec::new();
let mut scores : HashMap <String,u8>= HashMap::new();
println!("enter your name");
std::io::stdin().read_line(&mut name).expect("error");
let clone_name = name.trim().to_string().... | true |
0a81300cda4146f03dd8564f8012004ab9f71b74 | Rust | Javran/exercism-solutions | /rust/triangle/src/lib.rs | UTF-8 | 914 | 3.59375 | 4 | [
"Apache-2.0"
] | permissive | pub struct Triangle((u64, u64, u64));
impl Triangle {
pub fn build(sides: [u64; 3]) -> Option<Triangle> {
use std::mem::swap;
let [mut a, mut b, mut c] = sides;
// Apply sorting network on 3 elements.
if a > b {
swap(&mut a, &mut b);
}
if b > c {
... | true |
a9036f139ad7e8bea69fcd5962395f865cf5ec09 | Rust | eth-p/joinerator | /src/content/clipboard.rs | UTF-8 | 3,865 | 2.75 | 3 | [
"MIT"
] | permissive | // -------------------------------------------------------------------------------------------------
// joinerator | Copyright (C) 2019 eth-p
// -------------------------------------------------------------------------------------------------
use clipboard::{ClipboardContext, ClipboardProvider as SystemClipboard};
use ... | true |
431d786034a8a877c0bdebb403c6b4d64432bb1c | Rust | timvermeulen/advent-of-code | /src/solutions/year2015/day12.rs | UTF-8 | 2,422 | 3.125 | 3 | [] | no_license | use super::*;
#[derive(Debug)]
enum JSON<'a> {
Array(Vec<JSON<'a>>),
Object(Vec<(&'a str, JSON<'a>)>),
Number(i32),
String(&'a str),
}
impl JSON<'_> {
fn sum(&self) -> i32 {
match self {
JSON::Array(vec) => vec.iter().map(JSON::sum).sum(),
JSON::Object(vec) => vec.i... | true |
b85d9af93efb58c388b007e8bfe5ee07b28840be | Rust | bonedaddy/nebula-rs | /cert/src/cert_state.rs | UTF-8 | 2,133 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use crate::cert::NebulaCertificate;
use anyhow::Result;
use std::sync::{Arc, RwLock};
#[derive(Debug, PartialEq, Clone)]
pub struct CertStateInner<'a> {
pub certificate: &'a NebulaCertificate,
pub raw_certificate: Vec<u8>,
pub raw_certificate_no_key: Vec<u8>,
pub public_key: Vec<u8>,
pub private_ke... | true |
ec228c73aa5ac310d53bf37857b9b37765e78fbe | Rust | snoyberg/actix-website | /examples/request-handlers/src/handlers_arc.rs | UTF-8 | 905 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // <arc>
use actix_web::{web, Responder};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
#[derive(Clone)]
struct AppState {
count: Arc<AtomicUsize>,
}
async fn show_count(data: web::Data<AppState>) -> impl Responder {
format!("count: {}", data.count.load(Ordering::Relaxed))
}
async fn ad... | true |
2babe674549e6a3c569ae7a7909a75f9699c8a62 | Rust | kondrak/rust64 | /src/c64/memory.rs | UTF-8 | 8,908 | 3.390625 | 3 | [
"MIT"
] | permissive | // memory banks
use std::cell::RefCell;
use std::rc::Rc;
use utils;
pub type MemShared = Rc<RefCell<Memory>>;
pub enum MemType {
Ram,
Basic,
Chargen,
Io,
Kernal,
}
// specific memory bank - RAM, ROM, IO
pub struct MemBank {
bank_type: MemType, // what am I?
read_only: bool, // RAM or ... | true |
1e9264d3123adf698ffd1988202eee685d2a2c95 | Rust | haata/embassy | /embassy-traits/src/delay.rs | UTF-8 | 387 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use core::future::Future;
use core::pin::Pin;
pub trait Delay {
type DelayFuture<'a>: Future<Output = ()> + 'a;
/// Future that completes after now + millis
fn delay_ms<'a>(self: Pin<&'a mut Self>, millis: u64) -> Self::DelayFuture<'a>;
/// Future that completes after now + micros
fn delay_us<'a>... | true |
f3a74618514acd6463377e01af959b3df36393d3 | Rust | MariuszBielecki288728/rust-course | /lab01/task1/src/main.rs | UTF-8 | 445 | 3.515625 | 4 | [] | no_license |
fn string_to_number(s: &str) -> i32 {
s.parse::<i32>().unwrap()
}
#[cfg(test)]
mod tests {
use super::string_to_number;
#[test]
fn returns_expected_above_0() {
assert_eq!(string_to_number("1234"), 1234);
}
#[test]
fn returns_expected_prefix_0() {
assert_eq!(string_to_number(... | true |
fd7c73abe3932468d345421ff7e1867df809b1c2 | Rust | ifukazoo/LanguageExercises | /03_文字列リテラル内のエスケープ/rust/src/main.rs | UTF-8 | 363 | 3.453125 | 3 | [
"MIT"
] | permissive | use std::io;
use std::io::Write;
fn main() -> Result<(), std::io::Error> {
print!("Who said it? ");
io::stdout().flush()?;
let mut text = String::new();
io::stdin().read_line(&mut text)?;
let text = text.trim();
println!(
"{} {} {}",
text, "says,", r#""These aren't the droids y... | true |
520f07d93bcb7fb2b5b954e18e06107c868fd80f | Rust | HANDZCZ/tacodns | /src/options.rs | UTF-8 | 1,796 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::fs::read_to_string;
use std::net::{IpAddr, SocketAddr};
use resolv_conf::Config;
use crate::clap::Clap;
/// A powerful, developer-friendly, authoritative DNS server.
#[derive(Clap)]
#[clap(version = "0.1", author = "Chris Smith")]
#[derive(Debug, Clone)]
pub struct Options {
/// The address to listen on.
... | true |
89ed121f5d50ed8f557c284ad8038d3cc3efc792 | Rust | 9uapaw/fordragon-backend | /server/src/game/map/zone.rs | UTF-8 | 920 | 2.75 | 3 | [] | no_license | use crate::common::quad_tree::QuadTree;
use crate::game::location::pos::{Area, LocatableGameObject, Position};
use legion::Entity;
use std::borrow::Borrow;
use std::collections::HashMap;
pub struct Zone {
id: String,
pub grid: QuadTree<LocatableGameObject>,
}
impl Zone {
pub fn new(id: String, grid: QuadT... | true |
cf141fcc6e4f952b1a45f9a7dcf002aac60a7137 | Rust | gereeter/dither | /src/main.rs | UTF-8 | 36,530 | 2.734375 | 3 | [] | no_license | extern crate clap;
extern crate image;
extern crate rayon;
extern crate rand;
mod palettes;
mod color;
mod geom;
use color::{Srgb8, LinearRgb, Lab, PseudoLab};
use geom::{Vec3, determinant, subtract};
use image::Pixel;
use rand::Rng as _;
use rayon::iter::{IntoParallelIterator, ParallelIterator, ParallelBridge};
//... | true |
f8ae432567deabda23968b423bdce68a83d679e6 | Rust | dorucioclea/oso | /languages/rust/oso/src/host/mod.rs | UTF-8 | 5,777 | 2.609375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashMap;
use std::sync::Arc;
use polar_core::terms::{self, ExternalInstance, Numeric, Operator, Symbol, Term};
use crate::errors::OsoError;
use crate::Polar;
mod class;
mod class_method;
mod from_polar;
mod method;
mod to_polar;
mod value;
pub use value::*;
pub use class::{Class, ClassBuilder... | true |
7bb955a00bdf09ab204d832d986be0123f101a58 | Rust | JonathanGin52/rust-playground | /leetcode/city_skyline.rs | UTF-8 | 861 | 3.171875 | 3 | [] | no_license | use std::cmp;
fn main() {
let grid = vec![
vec![3, 0, 8, 4],
vec![2, 4, 5, 7],
vec![9, 2, 6, 3],
vec![0, 3, 1, 0]
];
assert_eq!(max_increase_keeping_skyline(grid), 35);
}
pub fn max_increase_keeping_skyline(grid: Vec<Vec<i32>>) -> i32 {
let mut sum: i32 = 0;
let n =... | true |
2e952895e785a9fb293ff3c5df1a292e3a471eed | Rust | micmarsh/rust-bitcoin | /src/wallet/bip32.rs | UTF-8 | 17,974 | 2.640625 | 3 | [
"CC0-1.0"
] | permissive | // Rust Bitcoin Library
// Written in 2014 by
// Andrew Poelstra <apoelstra@wpsoftware.net>
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//... | true |
0d4a274d259a6f09e39282be55966679abf3d353 | Rust | grtlr/mbd-wasm | /tests/web.rs | UTF-8 | 518 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | //! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen_test;
use wasm_bindgen_test::*;
// For now we test with Node only.
// wasm_bindgen_test_configure!(run_in_browser);
extern crate mbd;
#[wasm_bindgen_test]
fn test_fully_contained() {
let rows = 2;
le... | true |
59f67057908564551ffafd8128b4ae2a29926adf | Rust | fredpallen/rust-project-euler | /src/p0031.rs | UTF-8 | 677 | 3.34375 | 3 | [] | no_license | fn count_ways(coins: &[u64], change: u64) -> u64 {
match coins.len() {
0 => if change == 0 { 1 } else { 0 },
1 => if change % coins[0] == 0 { 1 } else { 0 },
_ => {
let (value, rest) = coins.split_last().unwrap();
(0..)
.map(|k| k * value)
... | true |
822a8e3f30e3b5637c984ec96045c0c8e617a83f | Rust | erdos-project/erdos | /erdos/src/dataflow/operator.rs | UTF-8 | 16,726 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use serde::Deserialize;
use crate::{
dataflow::{context::*, AppendableState, Data, ReadStream, State, WriteStream},
node::NodeId,
OperatorId,
};
/*************************************************************************************************
* Source: sends data with type T ... | true |
d162953a81f64fa0225a55e7b3dc86e0b4c71996 | Rust | CreativeWolfies/patpat.rs | /src/parser/construct/functions.rs | UTF-8 | 3,914 | 3 | 3 | [
"MIT"
] | permissive | use super::{ast, ASTKind, ASTNode, Token, TokenTree, AST};
use crate::Location;
use crate::error::CompError;
use std::rc::Rc;
pub fn construct_pattern_declaration<'a>(
tree: Rc<TokenTree<'a>>,
offset: &mut usize,
) -> Option<(ASTNode<'a>, Location<'a>)> {
/*! Tries to match pattern declarations:
*
... | true |
f5980b51e77f3367287293cd58c3f5b98270f4a3 | Rust | fridge-dev/lost-cities-game | /src/crates/storage/src/v2/task/sender.rs | UTF-8 | 3,261 | 2.75 | 3 | [] | no_license | use crate::v2::db_api::GameDatabase;
use crate::v2::db_types::{DbGameSummary, DbError, DbGameData, DbErrorCause};
use crate::v2::task::events::{DbTaskEvent, WriteTargetTable};
use crossbeam::channel::Sender;
use tokio::sync::{oneshot, oneshot::Receiver, oneshot::error::RecvError};
#[derive(Clone)]
pub struct DatabaseC... | true |
99a0e231073e43708bff729ef257aee24070908d | Rust | okanIz/microfw | /rs/src/address.rs | UTF-8 | 580 | 3.09375 | 3 | [] | no_license | use crate::parse_result::ParseResult;
#[derive(Debug)]
pub struct Address {
name: String,
v4: String,
v6: String,
lineno: usize
}
impl Address {
fn from_words(words: Vec<&str>, lineno: usize) -> ParseResult<Address> {
ParseResult::Ok(Address {
name: words[0].to_stri... | true |
255d1835eb73a3dcd24d2772ff25bf9ea0b00c1c | Rust | mrsadengineer/LANetworkAnalysis | /src/output_slicing.rs | UTF-8 | 1,411 | 2.96875 | 3 | [] | no_license | use std::process::Command;
#[allow(dead_code)]
pub fn slice_up_output() {
let ipstr01: String = String::from("192.168.0.1");
call_ping_and_parse_results(ipstr01);
}
fn call_ping_and_parse_results(ipstrnp: String) {
println!("{}", ipstrnp);
let mut cmd = Command::new("ping");
cmd.ar... | true |
0efa868004e0e4423555ddb7dfc05867643bc20d | Rust | tangentstorm/bex | /src/vid.rs | UTF-8 | 4,618 | 3.296875 | 3 | [
"MIT"
] | permissive | //! Variable IDs (used interally by Base implementations)
use std::cmp::Ordering;
use std::fmt;
/// this will probably go away in favor of a bitmask at some point
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
enum VidEnum {
// How I (eventually) want the ordering, to be (once biggest vars go on... | true |
859791c80ae8527a67241f984d1ed54dd92adf60 | Rust | rcore-os/riscv | /src/register/hypervisorx64/vstvec.rs | UTF-8 | 976 | 2.84375 | 3 | [
"ISC"
] | permissive | //! Virtual Supervisor Trap Vector Base Address Register.
use bit_field::BitField;
#[derive(Copy, Clone, Debug)]
pub struct Vstvec {
bits: usize,
}
impl Vstvec {
#[inline]
pub fn bits(&self) -> usize {
return self.bits;
}
#[inline]
pub fn from_bits(x: usize) -> Self {
return Vs... | true |
abd2aa15a60660ff6fbed3d6c0de937adb977db8 | Rust | dmgolembiowski/RustyKitchen | /Patterns/else_if_let/src/main.rs | UTF-8 | 314 | 3.1875 | 3 | [] | no_license | fn main() {
let fav_colo: Option<&str> = None;
let is_tuesday = false;
let age: Result<u8, _> = "34".parse();
if let Some(color) = fav_colo { println!("{}", color); }
else if is_tuesday { println!("It's Tuesday"); }
else if let Ok(age) = age { if age > 30 { } else { } }
else { }
}
| true |
d7a3bf43578aabb30947e11faf7702f7a8fb6993 | Rust | agmcleod/advent-coder | /advent-twelve/src/main.rs | UTF-8 | 1,437 | 3.078125 | 3 | [] | no_license | extern crate rustc_serialize;
use rustc_serialize::json::Json;
use rustc_serialize::json::Object;
use rustc_serialize::json::Array;
use std::fs::File;
use std::io::Read;
fn parse_json_object(object: &Object, total: &mut i32) {
let values = object.values().cloned().collect::<Vec<Json>>();
let mut has_red = fals... | true |
44b028dd9e99bfa3e87b4d1acececb0e000cf7b6 | Rust | McRaeAlex/AdventOfCode | /2018/day16/src/part2a.rs | UTF-8 | 9,768 | 3.109375 | 3 | [] | no_license | use std::io::{self, prelude::*};
/**
* SCRATCH NOTES:
* we need to create a list of all the functions each opcode could be.
* then we need to iterate over that list removing all of the ones that only
* have one opcode.
* like if we see that 9 is addr we can remove addr from the other lists. if we
* do this each ... | true |
540c6327b2fe78fb3cc7c2b8612e3ca80367fb8d | Rust | cch123/test | /rust/assoc/src/main.rs | UTF-8 | 1,090 | 3.609375 | 4 | [] | no_license | trait Graph {
type Node; // associated type
type Edge; // associated type
fn get_visited(&self, n: &Self::Node) -> bool;
fn set_visited(&mut self, n: &Self::Node);
fn get_successors(&self, n: &Self::Node) -> Vec<Self::Node>;
}
impl <T>Graph for T {
type Node = T;
type Edge = T;
fn get... | true |
bfb4074fecc80d670bd2b0a702e9d82f807c57fd | Rust | ncalibey/mini-projects | /rust/blog-actix/src/models.rs | UTF-8 | 5,862 | 2.84375 | 3 | [] | no_license | use crate::errors::AppError;
use crate::schema::comments;
use crate::schema::posts;
use crate::schema::users;
use diesel::prelude::*;
type Result<T> = std::result::Result<T, AppError>;
#[derive(Queryable, Identifiable, Serialize, Debug, PartialEq)]
pub struct User {
pub id: i32,
pub username: String,
}
#[der... | true |
039f22b8d3e18c3772b47593717ddc345b42c3ad | Rust | bchretien/rust-ncmpc | /src/help.rs | UTF-8 | 4,709 | 2.609375 | 3 | [] | no_license | use std::cmp;
use crate::config::{Config, ControlKey};
use ncurses as nc;
use crate::model::ACTION_DESCRIPTION;
use crate::view::{bold, get_color};
pub struct Help {
pad: nc::WINDOW,
max_x: i32,
max_y: i32,
start_y: i32,
cur_y: i32,
config: Config,
current_row: i32,
total_rows: i32,
tab_size: i32,
... | true |
fe25b359e464b5132119a38813be2b02f86201f1 | Rust | s3bk/bullet | /src/builder.rs | UTF-8 | 8,689 | 2.953125 | 3 | [] | no_license | use crate::prelude::*;
use std::cell::RefCell;
use crate::func::Func;
use crate::func::Transient::*;
use crate::poly::Poly;
use crate::lang::ExprParser;
use std::collections::HashMap;
use std::iter::once;
use crate::diff::diff;
pub type NodeResult = Result<NodeRc, Error>;
pub struct Builder {
cache: RefCell<Cache... | true |
5f4592a2690b13d4e660190a1a9ed86e891c1b49 | Rust | forkkit/dipa | /crates/dipa-derive/src/parsed_enum/generate_dipa_impl/single_variant_enum/generate_one_batch_create_delta_tokens.rs | UTF-8 | 5,567 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::dipa_attribute::DipaAttrs;
use crate::multi_field_utils::ChangedFieldIndices;
use crate::parsed_enum::{delta_type_name, EnumVariantFields, ParsedEnum};
use syn::__private::TokenStream2;
use syn::spanned::Spanned;
use syn::Ident;
impl ParsedEnum {
/// Generate create_delta_towards tokens for an enum that... | true |
46040fab07690e720cba512d6a708c41e114ee60 | Rust | IQ-Inc/rusty-foos | /src/main.rs | UTF-8 | 3,047 | 2.984375 | 3 | [] | no_license | use clap::{App, Arg};
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::sync::mpsc;
use std::sync::mpsc::{Receiver, Sender};
mod events;
mod game;
use events::FoosInputPins;
use game::{FoosEvent, FoosStateMachine};
/// Foosball Game Configuration
#[deri... | true |
df3df142fc76bcd997001b7ed590b9b412e5acde | Rust | wtfiscrq/octocrab | /src/api/apps.rs | UTF-8 | 1,742 | 2.71875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::Octocrab;
mod installations;
/// A client to [GitHub's apps API][apps-api].
///
/// Created with [`Octocrab::apps`].
///
/// [apps-api]: https://docs.github.com/en/rest/reference/apps
pub struct AppsRequestHandler<'octo> {
crab: &'octo Octocrab,
}
impl<'octo> AppsRequestHandler<'octo> {
pub(crate)... | true |
f04935d42eba94428aba1a6ed6d5005e8f2bb7c9 | Rust | hinohi/rust-eom | /tests/common/harmonic_oscillator.rs | UTF-8 | 2,873 | 3.0625 | 3 | [
"MIT"
] | permissive | use eom_sim::*;
/// 単振動+減衰+強制振動
///
/// 運動方程式は
///
/// ```math
/// a + 2 \zeta \omega_0 v + \omega_0^2 x = f \cos \omega t
/// ```
#[derive(Clone)]
pub struct Oscillator {
x0: [f64; 6],
v0: [f64; 6],
zeta: [f64; 6],
omega0: [f64; 6],
omega: [f64; 6],
f: [f64; 6],
}
impl Oscillator {
pub fn... | true |
6d0d1d99eec642968755e27bb7313591e2f2eb71 | Rust | eshyong/find-rust | /src/main.rs | UTF-8 | 1,309 | 2.96875 | 3 | [] | no_license | extern crate clap;
use std::path::Path;
use clap::{App, Arg};
mod finder;
fn validate_file_type(v: String) -> Result<(), String> {
match v.as_str() {
"file" | "dir" | "symlink" | "any" => Ok(()),
_ => Err(String::from("should be one of \"file\", \"dir\", or \"symlink\""))
}
}
fn main() {
... | true |
4987bb231ac2dfdee31220c67cbc716552d4d034 | Rust | studio3104/learning_rust | /branches/src/main.rs | UTF-8 | 250 | 3.421875 | 3 | [] | no_license | fn main() {
let num = 7;
if num < 5 {
println!("true");
} else {
println!("false");
}
let condition = true;
let num = if condition {
5
} else {
6
};
println!("num is {}", num);
}
| true |
c5469593ddf01b9501fa78208aeface905c6d187 | Rust | apache/avro | /lang/rust/avro/benches/serde_json.rs | UTF-8 | 2,617 | 2.53125 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"Zlib",
"GPL-1.0-or-later",
"FSFAP",
"MIT",
"LicenseRef-scancode-other-permissive",
"zlib-acknowledgement",
"GPL-2.0-only",
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-generic-cla",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
73c6fe851913a230c3c0ea06b7f7271a22f9e873 | Rust | yeahnoob/rustbot | /src/plugins/insults.rs | UTF-8 | 2,088 | 2.765625 | 3 | [] | no_license | extern crate time;
extern crate mi_insults;
use std::rand::{ mod, TaskRng };
use irc::{ IrcWriter, IrcCommand, BotInfo, Plugin, IrcPrivMsg };
use util;
use self::mi_insults::Insults as MiInsults;
pub struct Insults<'a> {
insults: MiInsults,
/// (last insult sent, retort we want)
last: Option<(&'a str, &... | true |
b0945920d623664c2a1dd00bd9140339af1dca8d | Rust | dmarcuse/batnotify | /src/main.rs | UTF-8 | 3,390 | 3.078125 | 3 | [
"MIT"
] | permissive | use battery::Manager;
use notify_rust::{Notification, NotificationHint, NotificationUrgency, Timeout};
use std::num::NonZeroU32;
use std::thread::sleep;
use std::time::Duration;
use structopt::StructOpt;
#[derive(StructOpt)]
#[structopt(about, author)]
struct Opts {
/// The battery percentage at which to warn the ... | true |
19e784da9c5e76a6e06864319325a5efeaa083ff | Rust | eeeeeta/sqa-jack | /examples/sawtooth.rs | UTF-8 | 1,881 | 2.890625 | 3 | [
"Unlicense",
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate sqa_jack;
use sqa_jack::{JackPort, JackConnection, JackCallbackContext, JackControl, JackHandler, JackResult, PORT_IS_OUTPUT, PORT_IS_INPUT, PORT_IS_PHYSICAL};
use std::thread;
struct Sawtooth {
out1: JackPort,
out2: JackPort,
left_saw: f32,
right_saw: f32
}
impl JackHandler for Sawtooth {... | true |
e24eb8fa49fd3f22b45b308c933db3706b066885 | Rust | boymaas/streaker | /common/src/ws.rs | UTF-8 | 1,996 | 2.59375 | 3 | [] | no_license | use chrono::{DateTime, Duration, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
pub use crate::streak_logic::StreakState;
type VisitorId = String;
type Token = String;
type AccessNodeLabel = String;
/// This type is used as a request which sent to websocket connection.
#[derive(Serialize, Deserialize, De... | true |
48cc33fe4a61a5dc629684e6b569e4e1736c4b5c | Rust | prisma/prisma-engines | /query-engine/prisma-models/src/native_type_instance.rs | UTF-8 | 827 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use psl::datamodel_connector::{Connector, NativeTypeInstance as PslNativeTypeInstance};
/// Represents an instance of a native type declared in the Prisma schema.
#[derive(Clone)]
pub struct NativeTypeInstance {
pub native_type: PslNativeTypeInstance,
pub connector: &'static dyn Connector,
}
impl NativeTypeIn... | true |
b80c229bcd60a4efb324b4e1c14e183797cffc06 | Rust | starfys/csci4350_project4 | /src/room.rs | UTF-8 | 3,223 | 2.78125 | 3 | [
"MIT"
] | permissive | use super::Context;
use gleam::gl::{self, GLint, GLsizei};
use matrix::{identity, matmul, vec3};
use render::{quad, Drawable, Vertex};
pub struct Room {
room_width: f32,
room_height: f32,
room_depth: f32,
vert_start: GLint,
num_verts: GLsizei,
}
impl Room {
pub fn new(room_width: f32, room_hei... | true |
192e6e6e8f17a72134c57dd50b69f3038e7d4fea | Rust | thequux/tn3270s | /src/tn3270/screen.rs | UTF-8 | 5,208 | 2.765625 | 3 | [] | no_license | use crate::tn3270::stream::{ExtendedFieldAttribute, AID, WriteCommand, WriteCommandCode, WCC, WriteOrder, BufferAddressCalculator, FieldAttribute, StreamFormatError, IncomingRecord};
use crate::tn3270::Session;
use snafu::{Snafu, ResultExt};
#[derive(Copy, Clone, Debug)]
pub struct Address {
pub row: u16,
pub ... | true |
feae23f1565d163c50c5e79f4bb8fa17c52c8aa0 | Rust | agrinman/tunnelto | /tunnelto_server/src/remote.rs | UTF-8 | 11,384 | 2.578125 | 3 | [
"MIT"
] | permissive | use super::*;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::io::{ReadHalf, WriteHalf};
use tokio::net::TcpStream;
use tracing::debug;
use tracing::{error, Instrument};
async fn direct_to_control(mut incoming: TcpStream) {
let mut control_socket =
match TcpStream::connect(format!("localhost:{}", ... | true |
4c066226461af6fd0f53ee300c8620e14066f348 | Rust | 16meyrat/gbcemu | /src/gbc/ppu.rs | UTF-8 | 19,142 | 2.53125 | 3 | [] | no_license | use super::bus::Busable;
use arrayvec::ArrayVec;
use num_enum::IntoPrimitive;
use crate::gui;
pub struct Ppu {
background_palette: ArrayVec<Color, 4>,
obj_palette0: ArrayVec<Color, 4>,
obj_palette1: ArrayVec<Color, 4>,
scx: u8,
scy: u8,
wx: u8, // real_WX - 7
wy: u8,
ly: u8,
lyc: u... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.