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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
651903d638fc9e7ffa7860489ecec1a018c62d43 | Rust | ulrichji/fraction | /src/decimal/juniper_support.rs | UTF-8 | 4,045 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use juniper::{
meta::MetaType, parser::ScalarToken, Executor, FromInputValue, GraphQLType, InputValue,
ParseScalarResult, ParseScalarValue, Registry, ScalarRefValue, ScalarValue, Selection,
ToInputValue, Value,
};
use generic::GenericInteger;
use num::Integer;
use std::fmt;
use super::GenericDecimal;
imp... | true |
c4f9abb0f3b66719186a154702d506f625d31748 | Rust | Quazie/Advent2016Rust | /Day4/day4.rs | UTF-8 | 1,992 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::io::prelude::*;
use std::fs::File;
use std::collections::btree_map::BTreeMap;
use std::cmp::Ordering;
fn main() {
let mut f = File::open("day4.txt").unwrap();
let mut s = String::new();
f.read_to_string(&mut s).unwrap();
let lines = s.lines();
let mut amount:i32 = 0;
let ascii_iter = (0..26).map... | true |
5c55063f5803b663b5370326116064075a409b72 | Rust | LaplaceKorea/inclavare-containers | /eaa/verdictd/src/policy_engine/opa/opa_engine.rs | UTF-8 | 11,853 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use lazy_static::lazy_static;
use parking_lot::RwLock;
use serde_json::Value;
use std::ffi::CStr;
use std::fs::{remove_file, File};
use std::io::prelude::*;
use std::os::raw::c_char;
use std::path::Path;
use std::process::Command;
/// Link import cgo function
#[link(name = "opa")]
extern "C" {
pub fn makeDecisionG... | true |
c255023b036ac6398b7db20f3b9d0f5a3dd76f79 | Rust | Taiwing/dr_quine | /templates/TEMPLATE_Colleen.rs | UTF-8 | 548 | 3.046875 | 3 | [] | no_license | /* Hey! Loook at me, I am a comment! */
fn print_iterator<T: Iterator<Item = String>>(striter: T, lq: &str, rq: &str) {
for line in striter {
println!("{}{}{}", lq, line, rq);
}
}
fn main() {
/* I am a super useful comment inside main */
let quoted_src_iter = SRC.iter().map(|s| s.escape_debug()... | true |
0ad23dd3c9cdb20843cea2891e2627dda43bbf06 | Rust | Qiskit/rustworkx | /rustworkx-core/src/generators/binomial_tree_graph.rs | UTF-8 | 7,437 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | // Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed ... | true |
4d9883444c5f56491614e4d40e5ed7368f0bc77c | Rust | RustamIbragimov/advent_of_code_2020 | /src/bin/day9.rs | UTF-8 | 1,909 | 3.40625 | 3 | [] | no_license | use std::fs;
fn is_valid(numbers: &Vec<i64>, index: usize, lookback: usize) -> bool {
if (index as i32) - (lookback as i32) < 0 {
return true;
}
let target = numbers[index];
let (start_index, end_index) = (index - lookback, index);
for i in start_index..end_index {
for j in i + 1..e... | true |
e4162a283103ed29ae6683358432dec26fd156c9 | Rust | danloh/rut-server-rust | /src/model/rut.rs | UTF-8 | 4,870 | 2.6875 | 3 | [
"MIT"
] | permissive | // rut typed model and msg handler
use actix::Message;
use actix_web::{error, Error};
use chrono::{NaiveDateTime, Utc};
use crate::errors::ServiceError;
use crate::model::msg::{Msg, RutListMsg, RutMsg, StarStatusMsg};
use crate::model::{re_test_url, test_len_limit, Validate, TITLE_LEN};
use crate::schema::{ruts, star... | true |
efaabf878c2cf0d1b5aa173012e8acc666baa49e | Rust | spliner/advent-of-code-2019 | /rust/day6/src/lib.rs | UTF-8 | 3,402 | 3.421875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use std::error::Error;
use std::fs;
pub mod config;
pub fn run(config: config::Config) -> Result<(), Box<dyn Error>> {
let input = fs::read_to_string(config.filename)?;
match config.part {
config::Part::PartOne => {
let orbits = parse_orbits_part... | true |
ca422b0a0396ccd8f8c670b5539c5e86f9522573 | Rust | isgasho/lateral | /src/gui/lgtk/size.rs | UTF-8 | 676 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | #[derive(Copy, Clone)]
pub struct Size {
pub width: usize,
pub height: usize,
}
impl Size {
pub fn square(size: usize) -> Self {
Self {
width: size,
height: size,
}
}
}
impl core::ops::Sub<usize> for Size {
type Output = Size;
fn sub(self, rhs: usize) -... | true |
d4f81ad451455d802b0556fa2f0daf4ae653da89 | Rust | stackdumper/empty-spaces-rs | /src/resources/clock.rs | UTF-8 | 999 | 3.328125 | 3 | [] | no_license | use std::ops::{AddAssign, Div};
use std::thread;
use std::time::{Duration, Instant};
pub struct Clock {
pub dt: f32,
pub target_dt: f32,
instant: Instant,
duration: Duration,
}
impl Default for Clock {
fn default() -> Self {
Self::new(60)
}
}
impl Clock {
pub fn new(fps: u32) -> ... | true |
2c576185e1bae4910ac21f705bc7047b0e953deb | Rust | parkbearpark/prefix_parser | /src/main.rs | UTF-8 | 1,178 | 3.4375 | 3 | [] | no_license | #[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct Loc(usize, usize);
impl Loc {
fn merge(&self, other: &Loc) -> Loc {
use std::cmp::{max, min};
Loc(min(self.0, other.0), max(self.1, other.1))
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
struct Annot<T> {
value: T,
loc: Loc,
}
im... | true |
089084abe8e6c58e12d05e40236c6e4293c89324 | Rust | jmageau/advent_of_code | /src/year_2019/day_4.rs | UTF-8 | 1,602 | 3.40625 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
pub fn answers() -> String {
format!("{}, {}", answer_one(), answer_two())
}
fn answer_one() -> String {
let range = input()
.split('-')
.map(|s| s.parse().unwrap())
.collect::<Vec<_>>();
(range[0]..=range[1])
.filter(|&n| match_... | true |
1dee82b28f44462b2edcc30cabd83d1cd7d37318 | Rust | vorot93/semicircle | /examples/sleeper.rs | UTF-8 | 1,164 | 2.78125 | 3 | [
"MIT"
] | permissive | use semicircle::RadiusMessage;
use std::time::Duration;
use tokio::net::UdpSocket;
async fn server_handler(
pkt: RadiusMessage,
) -> Result<Vec<RadiusMessage>, Box<dyn std::error::Error + Send + Sync>> {
println!("Received message from {}:\n{:?}", pkt.addr, pkt.data);
// We will just sleep here for now. A... | true |
8feb67218e656af24c7676447f69f11c22e0be60 | Rust | Senna46/linear-algebra-rs | /src/number.rs | UTF-8 | 558 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | pub use blas::c64;
use std::{
fmt::Debug,
iter::Product,
iter::Sum,
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign},
};
pub trait Number:
Clone
+ Copy
+ Debug
+ Default
+ PartialEq
+ Send
+ Sized
+ Sync
+ Add<Output = Self>
+ AddAssign
+ Sub<Output = Self>
+ SubAss... | true |
17d6c6c495ec926569a34eae80e2bbd15a263931 | Rust | akhilpb001/mastering-rust | /quickstart/src/main.rs | UTF-8 | 319 | 3.78125 | 4 | [] | no_license | fn main() {
let x = 1;
let _y = 3.14;
let _boolean = true;
let _greet = "Hello";
println!("Hello, world!");
println!("Value of x is: {}", x);
say_hello("John");
add(10, 20);
}
fn say_hello(name: &str) {
print!("Hello {}!\n", name);
}
fn add(x: i8, y: i8) {
println!("{}", x + y);
} | true |
bd09df0f2384c7dd05039236973f7e7652285b35 | Rust | afaq404alam/cargo-ws-release | /src/data_models/level.rs | UTF-8 | 725 | 2.515625 | 3 | [] | no_license | pub static MAJOR: &'static str = "major";
pub static MINOR: &'static str = "minor";
pub static PATCH: &'static str = "patch";
pub static ALPHA: &'static str = "alpha";
pub static BETA: &'static str = "beta";
pub static RC: &'static str = "rc";
#[derive(Debug, PartialEq)]
pub enum Level {
Major,
Minor,
Patc... | true |
5d040de683a957b5cae8f7c5e5420bf098083e9e | Rust | aftix/aftventure | /src/world.rs | UTF-8 | 6,310 | 2.625 | 3 | [] | no_license | use crate::generation;
use crate::render;
use crate::tile;
use crate::tile::Tile;
use crate::Player;
use chrono::Utc;
use noise::{NoiseFn, OpenSimplex, Seedable};
use std::collections::HashMap;
use std::i32;
pub struct Chunk {
x: i32,
y: i32,
tiles: Vec<usize>,
air_id: usize,
chunk_seed: u32,
}
i... | true |
0d7f1fc41356929d25e8b4b5d269d5fcdd6f0351 | Rust | ddemarco5/anime-machine | /src/scene_parse.rs | UTF-8 | 1,455 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | use std::error::Error;
use csv::ReaderBuilder;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Record {
//We need all these preprocessing shit for the automatic deserialize
#[serde(rename="Scene Number")]
pub scene_number: usize,
#[serde(rename="Start Frame")]
pub start_frame: usiz... | true |
c2a90c3b55f38f073521ba65fdd827013e2dd08a | Rust | siccegge/ctf-gameserver | /rust/src/ipc.rs | UTF-8 | 4,113 | 2.71875 | 3 | [
"ISC",
"MIT"
] | permissive | use crate::Error;
use std::io::Write;
use std::io::BufRead;
use std::io::BufReader;
use std::fs::File;
use std::os::unix::io::FromRawFd;
use serde::{Deserialize, Serialize, de::DeserializeOwned};
pub trait ControlInterface {
fn setup () -> Result<(), Error>;
fn get_flag (&mut self, tick:u32, payload:&Vec<u8... | true |
842923da8eda1bae8bb67f123b593e0b67316735 | Rust | getong/laminar | /src/net/constants.rs | UTF-8 | 1,374 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /// The size of the fragment header.
pub const FRAGMENT_HEADER_SIZE: u8 = 4;
/// The size of the acknowledgment header.
pub const ACKED_PACKET_HEADER: u8 = 8;
/// The size of the arranging header.
pub const ARRANGING_PACKET_HEADER: u8 = 3;
/// The size of the standard header.
pub const STANDARD_HEADER_SIZE: u8 = 5;
///... | true |
3666f486257e46649116347bd3a153c1d02dc24e | Rust | ccdle12/Rust-Book-Notes | /4_Understanding_Ownership/references_and_borrowing/src/main.rs | UTF-8 | 2,518 | 4.28125 | 4 | [] | no_license | fn main() {
// Create a string.
let s1 = String::from("hello");
// 1. Pass the reference of the string to the fn.
// '&' allows passing a reference of the variable,
// meaning it does not change ownership.
// 2. Example:
// s: ptr -> s1: ptr, len, capacity -> index:0, value: h
let le... | true |
3f8e80efbff041981b792668d0df1a7b2e410327 | Rust | akdhubro/modest.bot | /src/postgres/delete.rs | UTF-8 | 1,419 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::discord::shard::PostgresPool;
use serenity::{
client::Context,
model::id::{GuildId, RoleId, UserId},
};
use std::convert::TryFrom;
pub async fn role(ctx: &Context, guild_id: GuildId, role_id: RoleId) {
let data = ctx.data.read().await;
let pool = match data.get::<PostgresPool>() {
Some(v) => v.g... | true |
214f627d1f45bee34a51ba93fdd4b08cc6569468 | Rust | Eliot00/forming | /src/parser/parser.rs | UTF-8 | 760 | 3 | 3 | [
"MIT"
] | permissive | use pest::Parser;
#[derive(Parser)]
#[grammar = "parser/forming.pest"]
struct IdentParser;
pub fn parse(text: &str) {
let pairs = IdentParser::parse(Rule::start, text).unwrap_or_else(|e| panic!("{}", e));
for pair in pairs {
println!("Rule: {:?}", pair.as_rule());
println!("Span: {:?}",... | true |
3768b1e72a0f9ded4cc76ff7cd696a50824062d0 | Rust | winksaville/fuchsia | /src/connectivity/bluetooth/tests/integration/src/harness/expect.rs | UTF-8 | 1,195 | 2.96875 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019 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 failure::{err_msg, format_err, Error};
pub fn expect_eq<T>(expected: &T, actual: &T) -> Result<(), Error>
where
T: std::fmt::Debug + std::cmp::Par... | true |
acff807573c891ec07f3efb15218b3b6843938e8 | Rust | Keksoj/suivre_le_rust_book | /15_Smart_Pointers/la_box/src/main.rs | UTF-8 | 1,498 | 3.4375 | 3 | [] | no_license | // 2019-04-10
// Le smart pointer le plus habituel est la Box<T>, qui garde de la donnée sur
// le tas plutôt que sur la pile. C'est tout. On s'en sert :
// quand on ne connaît pas la taille d'un type à la compilation
// quand on a beaucoup de donnée dont on veut transférer l'ownership mais
// sans que... | true |
ea26fabbb39cd91bac125277cb57c109f4d63b23 | Rust | sinhrks/brassfibre | /src/frame/aggregation.rs | UTF-8 | 4,803 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | use std::borrow::Cow;
use std::hash::Hash;
use nullvec::prelude::{Array, Scalar, Nullable, NullVec};
use nullvec::prelude::BasicAggregation as NBasicAggregation;
use nullvec::prelude::NumericAggregation as NNumericAggregation;
use nullvec::prelude::ComparisonAggregation as NComparisonAggregation;
use super::DataFram... | true |
e8ac2ea6e2f09cb315897137499ad87fed0dc454 | Rust | rust-gjk/rustgrade | /src/lib.rs | UTF-8 | 749 | 2.5625 | 3 | [] | no_license | extern crate time;
extern crate toml;
extern crate serde;
extern crate serde_cbor;
#[macro_use] extern crate serde_derive;
pub mod packets;
pub mod database;
use time::{strftime, now};
use std::fmt::Display;
use std::process::exit;
pub fn get_time_stamp() -> Result<String, String> {
match strftime("%Y-%m-%d %H:... | true |
7c3c5655a84c04282a1067ae72ec0460130985ce | Rust | Jimskapt/rust-book-fr | /FRENCH/listings/ch11-writing-automated-tests/no-listing-03-introducing-a-bug/src/lib.rs | UTF-8 | 956 | 3.515625 | 4 | [
"Apache-2.0",
"MIT",
"Unlicense",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | #[derive(Debug)]
struct Rectangle {
largeur: u32,
hauteur: u32,
}
// ANCHOR: here
// -- partie masquée ici --
impl Rectangle {
fn peut_contenir(&self, other: &Rectangle) -> bool {
self.largeur < other.largeur && self.hauteur > other.hauteur
}
}
// ANCHOR_END: here
#[cfg(test)]
mod tests {
... | true |
d47dbecd709497fe0abbde6ba4910c7b8e40667a | Rust | prajjwaldangal/programming-practice | /learning_rust/minigrep/src/main.rs | UTF-8 | 1,393 | 3.109375 | 3 | [] | no_license | use std::env;
use std::fs;
pub struct Solution {}
impl Solution {
// pub fn new () -> Solution {}
pub fn odd_even_jumps(&self, arr: Vec<i32>) -> i32 {
let n : usize = arr.len();
let mut next_higher : Vec<i32> = Vec::new();
let mut next_lower : Vec<i32> = Vec::new();
l... | true |
3d4ddc21aabe5ff8b0b8ceb163f5a04b6abc6ef6 | Rust | yjhmelody/leetcode-rust | /src/three_sum.rs | UTF-8 | 1,970 | 3.421875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
// sort and three pointers
// let target = nums[j]
// look up i, k when nums[i] + nums[j] = target
pub fn three_sum(nums: Vec<i32>) -> Vec<Vec<i32>> {
if nums.len() < 3 {
return vec![];
}
let mut nums = nums;
nums.sort();
let mut res = vec![];
let mut j = nums.len(... | true |
dbaf34998fa0ab4fd7eb1840c009cee2cdda80ac | Rust | Peternator7/strum | /strum_tests/tests/enum_variant_names.rs | UTF-8 | 2,678 | 3.15625 | 3 | [
"MIT"
] | permissive | use structopt::StructOpt;
use strum::{EnumString, EnumVariantNames, VariantNames};
mod core {} // ensure macros call `::core`
#[test]
fn simple() {
#[allow(dead_code)]
#[derive(EnumVariantNames)]
enum Color {
Red,
#[strum(serialize = "b")]
Blue,
#[strum(to_string = "y", ser... | true |
05634ccecffc2f060626db9c872212b3b30dafc0 | Rust | LaplaceKorea/newton_rootfinder | /src/solver_n_dimensional/solver/parameters.rs | UTF-8 | 4,350 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::ResolutionMethod;
use std::fmt;
/// A minimal struct holding the resolution parameters
///
/// # Parameters
/// ## Damping
/// Activate the damping to improve convergence
///
/// Plain resolution according to Newton is made through the formula
/// X = X - J^-1*F(X)
///
/// However, if the proposed update is... | true |
c1f9176577e792fe791e22d3c3c98b2cf35c11d8 | Rust | nyari/rtrace | /src/tools.rs | UTF-8 | 3,150 | 3.125 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use defs::{Vector3, FloatType, IntType, FLOAT_ULPS_TOLERANCE};
use ::na;
use ::numt::Num;
use ::numt::float::Float;
use ::flcmp::ApproxOrdUlps;
pub trait CompareWithTolerance<T: Float> {
fn compare_eps(&self, rhs: &T) -> Ordering;
fn less_eps(&self, rhs: &T) -> bool;
fn less_eq_eps... | true |
f513e08858b8221e95916ef49c461254f7116f2e | Rust | k-nasa/http-service | /http-service-hyper/src/lib.rs | UTF-8 | 3,229 | 2.625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! `HttpService` server that uses Hyper as backend.
#![forbid(future_incompatible, rust_2018_idioms)]
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, missing_doc_code_examples)]
#![cfg_attr(test, deny(warnings))]
#![feature(async_await)]
use futures::{
compat::{Compat, Compat01As... | true |
b8aa5950caf523a39e2f00988471d6c5a30f1212 | Rust | xen0n/qn-changelog-rs | /src/source/github.rs | UTF-8 | 3,671 | 2.65625 | 3 | [] | no_license | use octocrab;
use regex;
use super::super::config;
use super::super::entry;
use crate::errors::*;
lazy_static! {
static ref MERGE_TITLE_FORMAT_RE: regex::Regex =
regex::Regex::new(r"^Merge pull request #(\d+)").unwrap();
}
#[derive(Deserialize)]
struct CompareCommitsResponse {
commits: Vec<CompareC... | true |
3352bdd0cf0fdd0f2ca6cf6b7f3283ab69c3cffc | Rust | idubrov/proc-macro-madness | /madness-gen/src/main.rs | UTF-8 | 551 | 2.765625 | 3 | [] | no_license | use std::io::Write;
const TYPES: usize = 300;
const FIELDS: usize = 200;
pub fn main() {
let out = std::fs::File::create("madness-types/src/gen.rs").unwrap();
let mut out = std::io::BufWriter::new(out);
for t in 0..TYPES {
writeln!(out, "#[madness]").unwrap();
writeln!(out, "pub struct Typ... | true |
d851dcf5d740aa519109007e205173180101cd1b | Rust | steveklabnik/newrustacean.com | /src/lib.rs | UTF-8 | 546 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"CC-BY-4.0"
] | permissive | //! Read the show notes, as well as fairly detailed comments on all the code
//! samples referenced in the show.
//!
//! Yes, this is a slightly crazy way of building a show notes site for a
//! podcast. But more on that in the future.
#![doc(html_logo_url = "http://newrustacean.com/podcast.png",
html_favicon_u... | true |
9f463e9b0541171d05cad88a4f7cfdf1a62fb4c7 | Rust | blkerby/orc-format | /src/writer/statistics/boolean.rs | UTF-8 | 950 | 3.109375 | 3 | [] | no_license | use super::common::BaseStatistics;
#[derive(Debug, Copy, Clone)]
pub struct BooleanStatistics {
pub num_values: u64,
pub num_true: u64,
pub num_false: u64,
}
impl BooleanStatistics {
pub fn new() -> BooleanStatistics {
BooleanStatistics {
num_values: 0,
num_true: 0,
... | true |
8421339fd4a8426c6d8755f1e13e10085c673b4e | Rust | kaist-cp/hafnium-verification | /hfo2/src/arch/aarch64.rs | UTF-8 | 4,722 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2019 Sanguk Park.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed t... | true |
ab0801585d8ad69d43def431da0c4994935190ad | Rust | tones111/AdventOfCode | /02/main.rs | UTF-8 | 1,331 | 3.25 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::ops::Mul;
fn main() {
let mut total_area = 0;
let mut total_length = 0;
let stdin = io::stdin();
for line in stdin.lock().lines().map(|l| l.unwrap()) {
let mut dims: Vec<usize> = line.split('x')
.map(|n| n.parse().unwrap())
.collec... | true |
354a7c619c1840cc17f5f6d425e46e073307305e | Rust | seaneshbaugh/integrity_check | /src/digest/crc32.rs | UTF-8 | 903 | 2.640625 | 3 | [] | no_license | lazy_static! {
static ref LOOKUP_TABLE: [u32; 256] = {
let mut table: [u32; 256] = [0; 256];
for index in 0..256 {
let mut crc: u32 = index as u32;
for _ in 0..8 {
let and1: u32 = crc & 1;
// See https://internals.rust-lang.org/t/forbid-unsi... | true |
243bb5982d3e8c15bd3b4477d51e148187e7fa39 | Rust | jpJuni0r/WebGrid | /core/src/services/metrics/data_collector.rs | UTF-8 | 8,220 | 2.515625 | 3 | [
"MIT",
"AGPL-3.0-only"
] | permissive | use super::structures::{Metric, MetricType, MetricValue};
use crate::libraries::helpers::keys;
use crate::libraries::metrics::SESSION_STARTUP_HISTOGRAM_BUCKETS;
use redis::{aio::ConnectionLike, AsyncCommands};
static HTTP_METHODS: [&str; 9] = [
"GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "CONNECT", "PATCH",... | true |
b14ed5291fe165ebacb65802a2d5007b42891353 | Rust | oxfist/advent_2018 | /day1/part2/src/main.rs | UTF-8 | 1,109 | 3.046875 | 3 | [] | no_license | use std::env;
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
chronal_calibration(filename.to_string());
}
fn chronal_calibration(filename: String) {
let mut current_frequency: i32... | true |
27da76724bdf5b60996f87e4205d635e7fd36bbf | Rust | PhilipDaniels/projecteuler | /src/matrix.rs | UTF-8 | 3,769 | 4.125 | 4 | [
"MIT"
] | permissive | use std::str::FromStr;
use std::ops;
/// A crude 2d matrix class.
pub struct Matrix<T> {
rows: usize,
cols: usize,
data: Vec<T>
}
impl<T> Matrix<T> {
/// Returns the number of rows in the matrix. 0 for an empty matrix.
#[inline]
pub fn rows(&self) -> usize {
self.rows
}
/// Re... | true |
470dd17be3ff15fafee31e9296f240531c293803 | Rust | gyn/exercism | /rust/sum-of-multiples/src/lib.rs | UTF-8 | 130 | 2.75 | 3 | [
"BSD-2-Clause"
] | permissive | pub fn sum_of_multiples(limit: usize, vec: &[usize]) -> usize {
(0..limit).filter(|x| vec.iter().any(|y| x % y == 0)).sum()
}
| true |
ebc5fab481b5cc44259e035f4b570875821a410f | Rust | zsiciarz/image | /src/gif/bits.rs | UTF-8 | 1,986 | 3.59375 | 4 | [
"MIT"
] | permissive | //! This module provides a bit reader
use std::io;
/// A bit reader.
///
/// Reads bits from a byte stream, LSB first.
pub struct BitReader<R> where R: Reader{
r: R,
bits: u8,
buf: u64,
}
impl<R: Reader> BitReader<R> {
/// Creates a new bit reader
pub fn new(reader: R) -> BitReader<R> {
B... | true |
f9edceeeabbd4fdeb29196f8afece5f7d1b6d120 | Rust | bopohaa/log_loki | /src/scrape.rs | UTF-8 | 3,829 | 2.734375 | 3 | [] | no_license | use crate::models::{LogMetricConf};
use crate::log::{LogContainer,LogMetric,Log};
use crate::errors::*;
use std::collections::{HashMap};
use std::sync::{Mutex, Arc, atomic::AtomicBool};
use std::time::{Duration, Instant};
use std::thread::JoinHandle;
use std::sync::atomic::Ordering;
use std::cell::Cell;
type Contain... | true |
eb934fd0f6c79bb22a582a7e8451a0bfebe3f327 | Rust | qdrant/qdrant | /lib/api/build.rs | UTF-8 | 12,243 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use tonic_build::Builder;
fn main() -> std::io::Result<()> {
// Build gRPC bits from proto file
tonic_build::configure()
// Because we want to attach all validation rules to the generated gRPC types, we must do
// so by extending the builder. This is ugly, but better than manually implementing
... | true |
5c0e75cef27cb7f5c6e7986f3f9861d1b6c49caf | Rust | kenrick95/adventofcode2017 | /src/day20part2.rs | UTF-8 | 2,869 | 3.1875 | 3 | [] | no_license | use std::fs::File;
use std::io::Read;
use regex::Regex;
use std::collections::HashMap;
struct Coord {
x: i32,
y: i32,
z: i32,
}
struct Particle {
p: Coord,
v: Coord,
a: Coord,
exists: bool,
}
pub fn main() {
let mut input = String::new();
let mut f = File::open("day20.in.txt").unwrap();
f.read_t... | true |
035e5a5349ae580a634b7335416427d3c3353470 | Rust | developers-algorithm-study/mjy9088 | /acmicpc.net/10866/src/main.rs | UTF-8 | 1,079 | 3.109375 | 3 | [] | no_license | use std::{io, collections::VecDeque};
fn main() {
let mut line = String::new();
io::stdin().read_line(&mut line).unwrap();
let command_count = line.trim().parse::<usize>().unwrap();
let mut queue = VecDeque::<i32>::new();
for _ in 0..command_count {
let mut line = String::new();
i... | true |
20c1179f1b5e5647b5adee3d903f720c1ec84c7f | Rust | 7wf/noxell | /src/main.rs | UTF-8 | 1,159 | 2.90625 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate colour;
use std::process;
mod commander;
mod commands;
mod ui;
/**
* Runs a command.
*/
fn run_command(command_name: &str, command_arguments: Vec<&str>) -> Result<bool, String> {
match command_name {
"exit" => process::exit(0),
"cd" => match commands::change_directory:... | true |
af364d0d4a07679209cc5dc00b4d4e0de4e82794 | Rust | erkan80898/rust_sort_visualizer | /src/lib.rs | UTF-8 | 4,667 | 2.953125 | 3 | [] | no_license | use piston_window::{PistonWindow, Event};
use plotters::prelude::{draw_piston_window, WHITE, IntoDrawingArea, ChartBuilder, IntoFont, Histogram, BLUE};
use plotters::style::Color;
/// This file contains varies sort implementations
/// All sorts written here take a lambda that will define
/// it's sorting order
/// Dr... | true |
09695d6c127bdab08ec015980c90d26a0cf8f736 | Rust | maciek-rr/repo_racoon | /src/main.rs | UTF-8 | 3,047 | 2.703125 | 3 | [
"MIT"
] | permissive | mod app_error;
mod cli;
mod formatter;
mod github_repo;
mod github_repos;
mod recognizer;
mod repo_path;
mod repos_info;
extern crate base64;
extern crate clap;
extern crate github_rs;
extern crate regex;
extern crate serde;
extern crate serde_json;
use github_repo::GithubRepo;
use repo_path::RepoPath;
use std::sync:... | true |
5281dec38669306e9385acd8315d73cecf3ff99d | Rust | stanley-fork/variant-go-server | /shared/src/game/clock.rs | UTF-8 | 4,645 | 3.40625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[derive(
Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, serde::Serialize, serde::Deserialize,
)]
#[repr(transparent)]
#[serde(transparent)]
pub struct Millisecond(pub i128);
impl Millisecond {
pub fn as_secs(self) -> f32 {
self.0 as f32 / 1000.
}
pub fn as_minutes(self) -> f32 {
... | true |
bfd0a2829ce49ee03fbb9efb9ee3fb6279de2938 | Rust | jcsirot/rust-pgn-parser | /examples/show-pgn.rs | UTF-8 | 2,329 | 3.03125 | 3 | [] | no_license | extern crate pgnparser;
use pgnparser::*;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
fn main() {
let path = Path::new("examples/game.pgn");
let mut file = match File::open(&path) {
Err(why) => panic!("couldn't open game.pgn: {}", Error::description(&why))... | true |
ab81cfc68f0884e2cb57393cb81ee4d56dea8828 | Rust | YuichiroSato/Blog | /DataScience/SaitoKouki/chapter-4/deep_learning/src/network.rs | UTF-8 | 3,865 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::calculus::*;
use crate::layer;
use crate::layer::*;
use crate::numpy;
use crate::numpy::*;
use rand::prelude::*;
pub struct Network {
pub w1: Box<NumpyArray>,
pub w2: Box<NumpyArray>,
pub b1: Box<NumpyArray>,
pub b2: Box<NumpyArray>,
}
impl Network {
pub fn new(input_size: usize, hidden... | true |
f33740d1897dfe97c109602a1bd0c86d5551e9ce | Rust | Tarv3/particle_filter | /src/tracker.rs | UTF-8 | 1,166 | 2.609375 | 3 | [] | no_license | use filter::Filter;
use glm::*;
use measurement::weighting;
use std::mem;
use std::ops::Range;
pub struct AnimalTracker {
pub est_pos: Vec2,
pub filter: Filter<Vec2>,
pub noise: f32,
}
impl AnimalTracker {
pub fn new(
particles: usize,
h_range: Range<f32>,
v_range: Range<f32>,
... | true |
78fc83ac87d826bc0143f7b53cb9a6d0e80e8066 | Rust | nsalesky/todolist-backend | /src/models/user_lists.rs | UTF-8 | 3,095 | 3.21875 | 3 | [
"MIT"
] | permissive | use diesel::prelude::*;
use diesel::result::Error;
use crate::models::list::{List, ListDTO};
use crate::models::user::{User, UserDTO};
use crate::schema::user_lists;
use crate::schema::user_lists::dsl;
/// Represents a single row in the user_lists table associating a user with a list that they
/// have access to.
#[d... | true |
4346a529a65ab2226b69b7dc592128c2cb23a0b8 | Rust | andyyu2004/l-lang | /src/lc-ir/src/def.rs | UTF-8 | 8,099 | 2.9375 | 3 | [] | no_license | use super::{DefId, ParamIdx};
use crate as ir;
use lc_ast::NodeId;
use lc_index::Idx;
use rustc_hash::FxHashMap;
use std::cell::Cell;
use std::fmt::{self, Display, Formatter};
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
pub enum Res<Id = ir::Id> {
Err,
Def(DefId, DefKind),
// type namespace
Pri... | true |
7b670521e7798b28720c680e2d6db2c57fc97e21 | Rust | thedodd/sqlx | /sqlx-core/src/mysql/types/json.rs | UTF-8 | 1,521 | 2.671875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::{Deserialize, Serialize};
use crate::decode::Decode;
use crate::encode::{Encode, IsNull};
use crate::error::BoxDynError;
use crate::mysql::protocol::text::ColumnType;
use crate::mysql::{MySql, MySqlTypeInfo, MySqlValueRef};
use crate::types::{Json, Type};
impl<T> Type<MySql> for Json<T> {
fn type_info(... | true |
323f1106273fe2b39ff197ce173e34a746e67adb | Rust | rustgd/rhusics | /rhusics-core/src/physics/simple.rs | UTF-8 | 3,730 | 2.828125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Simple force integration and impulse solver
use std::ops::Mul;
use cgmath::num_traits::Float;
use cgmath::{BaseFloat, EuclideanSpace, InnerSpace, Rotation, VectorSpace, Zero};
use super::{
ApplyAngular, ForceAccumulator, Inertia, Mass, PhysicalEntity, Velocity, WorldParameters,
};
use {NextFrame, Pose};
///... | true |
86fcbe9ed056559e714a47c16b7359431a676185 | Rust | joshuaclayton/math-equations-csv | /src/main.rs | UTF-8 | 2,236 | 3.609375 | 4 | [
"MIT"
] | permissive | use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(
name = "math",
about = "A command line tool to generate math",
setting = structopt::clap::AppSettings::ColoredHelp
)]
struct Flags {
/// Minimum value
#[structopt(long, default_value = "0")]
pub minimum: usize,
/// Maximum ... | true |
e7a3e28aa6ff00eec42482a44167ccde793db3f5 | Rust | Kybox/SpringBootProjectGenerator | /src/lib/share/input.rs | UTF-8 | 327 | 3.09375 | 3 | [] | no_license | use std::io::{stdin};
pub fn get_user_input() -> String {
let reader = stdin();
let mut buffer = String::new();
// Get user input
reader.read_line(&mut buffer).ok().expect("Input error");
// Remove line breaks
buffer.truncate(buffer.trim_end_matches(&['\r', '\n'][..]).len());
return buf... | true |
8661d2331964e34b572015061401ccb2abbeb1f3 | Rust | pigeonking17/login_system | /src/main.rs | UTF-8 | 2,677 | 3.84375 | 4 | [] | no_license | mod rot13;
use std::io::{self, prelude::*};
use rot13::rot13;
use std::fs::OpenOptions;
fn main() {
choice();
}
fn sign_up() {
println!("Enter username:");
let mut username = String::new();
io::stdin().read_line(&mut username)
.expect("Failed to read line.");
println!("Enter password:"... | true |
26513994daec8b0337a7a8a80bdd14d1cf105095 | Rust | bosgood/advent-of-code-2018 | /src/day3.rs | UTF-8 | 12,634 | 3.6875 | 4 | [
"MIT"
] | permissive | use regex::Regex;
use std::collections::HashMap;
/*
Each Elf has made a claim about which area of fabric would be ideal for Santa's suit. All claims have an ID and consist of a single rectangle with edges parallel to the edges of the fabric. Each claim's rectangle is defined as follows:
The number of inches betwe... | true |
1dfcb1cb918fd87ba62aa370e33ee87122d364ea | Rust | MMXVII/mmix | /src/machine/behavior/is/arithmetic/mului.rs | UTF-8 | 721 | 2.859375 | 3 | [
"MIT"
] | permissive | use machine::state::State;
use machine::state::sr::R;
pub fn mului(state: &mut State, x: u8, y: u8, z: u8) {
// Load operand
let op1: u64 = state.gpr[y].into();
/*
* Theory:
*
* See instruction MULU in machine::behavior::is::arithmetic::mulu!
*/
// Calculate the single parts
... | true |
1de159afa5ed8d1ff4164b493e0d26415ecde28e | Rust | Fenex/vangers-tool | /prm/src/mechos.rs | UTF-8 | 5,328 | 2.75 | 3 | [
"MIT"
] | permissive | use std::{path::Path, str::FromStr};
use ::enum_primitive_derive::Primitive;
use ::num_traits::FromPrimitive;
use crate::{PrmFile, PrmParseError};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Primitive)]
pub enum Type {
Raffa = 0,
Light = 1,
Microbus = 2,
Atw = 3,
Track = 4,
Special = 5,
}
pu... | true |
5d78341388bbd79e3a561e39451979c289010a50 | Rust | lll1412/secs | /src/lib.rs | UTF-8 | 2,359 | 3.296875 | 3 | [] | no_license | use std::any::Any;
use std::cell::{RefCell, RefMut};
type VO<T> = Vec<Option<T>>;
#[derive(Default)]
pub struct World {
entities_count: usize,
components_vec_list: Vec<Box<dyn ComponentVec>>,
}
impl World {
pub fn new() -> Self {
Self {
entities_count: 0,
components_vec_li... | true |
d81bd24d4141fdc5de66861c7f1e231621b2af76 | Rust | DaraGboyega/cryptofriends-rust | /src/set_2/challenge_15.rs | UTF-8 | 755 | 2.84375 | 3 | [] | no_license | #[cfg(test)]
mod tests {
use utils::crypto::strip_pkcs_padding;
#[test]
fn challenge_15() {
let valid = b"ICE ICE BABY\x04\x04\x04\x04";
assert_eq!(strip_pkcs_padding(valid), Ok(Vec::from("ICE ICE BABY")));
let valid2 = b"ICE \x04\x04\x04\x04";
assert_eq!(strip_pkcs_padding... | true |
59f92a41d470fb553675af357eb03d989bd2a315 | Rust | devinschulz/advent-of-code | /2015/src/day03/mod.rs | UTF-8 | 2,064 | 3.4375 | 3 | [] | no_license | use std::collections::HashSet;
fn input() -> &'static [u8] {
include_bytes!("input.txt")
}
fn calculate_unique_houses(input: &[u8], part2: bool) -> usize {
let mut x = 0;
let mut y = 0;
let mut x2 = 0;
let mut y2 = 0;
let mut locations: HashSet<String> = HashSet::from(["0x0".to_string()]);
... | true |
ea9176fac74a08ed828d3a35b4a1bd236d56f633 | Rust | AndrewGaspar/rust-plugin-example | /core/src/lib.rs | UTF-8 | 780 | 3.234375 | 3 | [
"MIT"
] | permissive | /// The `PluginRegistrar` is defined by the application and passed to `plugin_entry`. It's used
/// for a plugin module to register itself with the application.
pub trait PluginRegistrar {
fn register_plugin(&mut self, plugin: Box<dyn Plugin>);
}
/// `Plugin` is implemented by a plugin library for one or more type... | true |
555f9fb48e8b70cd8f58dd61aa2147fb04dea861 | Rust | gelisam/ludum-dare-37 | /src/game.rs | UTF-8 | 8,235 | 2.8125 | 3 | [] | no_license | use std::mem;
use graphics::math::*;
use corpse::*;
use levels::*;
use player::*;
use spiny::*;
use state::*;
use types::*;
use types::RawInputEvent::*;
use types::AnimatedPos::*;
fn should_die(player: &AnimatedPos, spinies: &Vec<MovingSpiny>, t0: Seconds, t: Seconds) -> Option<Action> {
let player_pos = compute_p... | true |
9bd05d5cb99eb14dcaec374d8530f24e325289d3 | Rust | fabianvdW/FabChess | /referee/src/async_communication.rs | UTF-8 | 2,004 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | use log::{info, warn};
use std::time::{Duration, Instant};
use tokio::prelude::*;
use tokio::time::timeout;
pub async fn write_all<T: AsyncWrite + Unpin>(stdin: &mut T, msg: &str) {
stdin.write_all(msg.as_bytes()).await.unwrap_or_else(|msg| warn!("Could not write: {:?}", msg));
stdin.flush().await.unwrap_or_el... | true |
2eb02f6ed16c2eb9b6663a4705238a803b694f1a | Rust | J-AugustoManzano/livro_Rust | /ExerciciosAprendizagem/Cap08/c08ex04/src/main.rs | UTF-8 | 1,392 | 3.171875 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
struct CadAluno {
nome: String,
notas: Vec<f32>,
media: f32,
}
fn main() {
let mut aluno = CadAluno {
nome: "".to_string(),
notas: Vec::new(),
media: 0.
};
let mut n... | true |
3067604513a94c7e5cafab6cbcbd341f86a4bc13 | Rust | AustinHaugerud/oxidsys | /src/language/operations/output_and_messages/set_show_messages.rs | UTF-8 | 725 | 2.53125 | 3 | [
"MIT"
] | permissive | use language::operations::{make_param_doc, Operation, ParamInfo};
pub struct SetShowMessagesOp;
const DOC : &str = "Suppresses (value = 0) or enables (value = 1) game messages, including those generated by the game engine.";
pub const OP_CODE: u32 = 1107;
pub const IDENT: &str = "set_show_messages";
impl Operation... | true |
eedc0d0eeb7f189b292f5ae38141b84d27417c44 | Rust | sore0159/rust_island | /src/ui/c_term/parts/selections/sel.rs | UTF-8 | 3,576 | 2.703125 | 3 | [] | no_license | use super::super::super::{
output::{new_rgb, Style},
parts::text::Text,
Key,
};
pub struct Selection {
pub text: Text,
pub base_style: [Style; 2],
pub hover_style: [Style; 2],
pub selected_style: [Style; 2],
pub h_and_s_style: [Style; 2],
pub selected: bool,
pub quick_select: O... | true |
ea65ff9bdb9107b225e9abb6300b7e755b18cbb3 | Rust | ncalibey/mini-projects | /rust/blog-actix/src/routes/users.rs | UTF-8 | 1,949 | 2.875 | 3 | [] | no_license | use crate::errors::AppError;
use crate::routes::convert;
use crate::{models, Pool};
use actix_web::{web, HttpResponse};
use futures::Future;
#[derive(Debug, Serialize, Deserialize)]
struct UserInput {
username: String,
}
// The return value is `impl Future` which means it is a type that will implement
// the `Fut... | true |
9cbf5e9056a199789304790434804e12e09e98b5 | Rust | margarita-v/optimization_methods_development | /src/functions/mod.rs | UTF-8 | 133 | 2.625 | 3 | [] | no_license | pub fn sample_func(x: f64) -> f64 {
(x - 3.0) * (x - 3.0)
}
pub fn sample_func_str() -> String {
String::from("(x - 3)^2")
} | true |
52f75d42ea96205be7f0ffa2483ef187f362cc31 | Rust | maddymakesgames/chain-bot | /src/database/tables/users.rs | UTF-8 | 2,547 | 2.625 | 3 | [] | no_license | use diesel::{pg::PgConnection, prelude::*, Queryable};
use serenity::model::id::UserId;
use crate::database::{schema::*, U64Wrapper};
pub fn create_user(conn: &PgConnection, id: UserId) -> UserData {
diesel::insert_into(users::table)
.values(&UserData {
id: id.0.into(),
points: 0,
... | true |
8c0713b73f688f9080443fe52b2f5339127e67f9 | Rust | SPERAXIO/ckb | /pow/src/lib.rs | UTF-8 | 2,087 | 2.890625 | 3 | [
"MIT"
] | permissive | use byteorder::{ByteOrder, LittleEndian};
use ckb_types::{
packed::{Byte32, Header},
prelude::*,
};
use serde::{Deserialize, Serialize};
use std::any::Any;
use std::fmt;
use std::sync::Arc;
mod dummy;
mod eaglesong;
pub use crate::dummy::DummyPowEngine;
pub use crate::eaglesong::EaglesongPowEngine;
#[derive(... | true |
76cc8cb7be539ed89c01bc199ae56982fd1a7186 | Rust | steveklabnik/rust-replace-map | /src/lib.rs | UTF-8 | 936 | 3.1875 | 3 | [] | no_license | #![license = "MIT"]
#![deny(missing_doc)]
#![deny(warnings)]
#![feature(unboxed_closures, overloaded_calls)]
//! Exposes `replace_map`, for replacing values at mutable memory locations.
use std::ptr;
/// Replace the value at a mutable memory location with the value
/// produced by the passed in closure.
///
/// Doe... | true |
cbcc947dd97dd2ef10947ad9ea86296532d19ab9 | Rust | stormtracks/rust-examples | /arrow/examples/structarray.rs | UTF-8 | 1,328 | 3.328125 | 3 | [
"MIT"
] | permissive | /// A nested array type where each child (called *field*)
/// is represented by a separate array
/// # Example: Create an array from a vector of fields
use arrow::array::{Array, ArrayRef, BooleanArray, Int32Array, StringArray, StructArray};
use arrow::datatypes::{DataType, Field};
use std::sync::Arc;
fn main() -> arr... | true |
a6dd5a030a417a212237ff0cf8faee26a4544f04 | Rust | CAD97/windex | /src/traits.rs | UTF-8 | 2,664 | 3.25 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::proof::{NonEmpty, Unknown};
use {
crate::{
particle::{perfect::*, IndexError},
Container,
},
core::ops,
};
/// Types that can back a trusted container: it can have particles that are
/// trusted to be in bounds. See also [`TrustedItem`], [`TrustedUnit`].
#[allow(clippy::len_witho... | true |
8f5e3128cece0bd09f1ae69569e6df8069f373d3 | Rust | r2gnl/xaynet | /rust/xaynet-mobile/src/ffi/participant.rs | UTF-8 | 17,849 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use std::{
convert::TryFrom,
os::raw::{c_int, c_uchar, c_uint, c_void},
ptr,
slice,
};
use ffi_support::{ByteBuffer, FfiStr};
use xaynet_core::mask::{DataType, FromPrimitives, IntoPrimitives, Model};
use super::{
LocalModelConfig,
ERR_GLOBALMODEL_CONVERT,
ERR_GLOBALMODEL_DATATYPE,
ERR_... | true |
8eb1e90fa1788286f2ab015c450dedcfb4e63f82 | Rust | ebobby/chip8-vm | /src/chip8/cpu.rs | UTF-8 | 6,331 | 2.71875 | 3 | [] | no_license | use chip8::ram;
use chip8::utils;
#[derive(Debug)]
pub struct Cpu {
regs: [u8; 16],
stack: [u16; 16],
pc: u16,
sp: u8,
i: u16,
}
#[derive(Debug)]
enum Reg {
V(u8),
}
#[derive(Debug)]
enum Opcode {
Clear, // 00E0 - CLS
Return, // ... | true |
295364ed0d8b7cdcc9f8094f93168822e7e3ba60 | Rust | d3lio/lexpar | /examples/ml_family/lexer/mod.rs | UTF-8 | 2,957 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | pub mod token;
use lexpar::lexer::{Lexer, Span};
use self::token::Token;
pub type Term = (Span, Token);
pub fn lexer() -> Lexer<(Span, Token)> {
use self::Token::*;
Lexer::new(lex_rules![
r"[ \t\n]+" => |span, text, _| (span, Whitespace(text.to_owned())),
r"/\*[^(?:*/)]*\*/" ... | true |
3ba6971812b44eb89785e7aaf35dc465ad09a74a | Rust | eeff/bevy_chess | /src/board.rs | UTF-8 | 10,722 | 2.828125 | 3 | [
"MIT"
] | permissive | use bevy::app::AppExit;
use bevy::prelude::*;
use bevy_mod_picking::{MeshButtonMaterials, PickableBundle, PickingEvent, SelectionEvent};
use crate::pieces::*;
use std::fmt;
pub struct Square {
pub x: u8,
pub y: u8,
}
#[derive(Default)]
pub struct SelectedSquare {
entity: Option<Entity>,
}
#[derive(Defa... | true |
d205be6909c60eba94bfa9aa302b4b37237bd29c | Rust | mohanson/brainfuck | /src/main_jit.rs | UTF-8 | 3,190 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::io::prelude::*;
use dynasm::dynasm;
use dynasmrt::{DynasmApi, DynasmLabelApi};
use brainfuck::ir;
use brainfuck::opcode;
unsafe extern "sysv64" fn putchar(char: u8) {
std::io::stdout().write_all(&[char]).unwrap()
}
#[derive(Default)]
struct Interpreter {}
impl Interpreter {
fn run(&mut self, data:... | true |
91e4d7affe84897dcbf1a379f649383af4ebd402 | Rust | davidaq/rust-babeljs | /src/syntax/tokenize/tokenizer.rs | UTF-8 | 4,597 | 2.796875 | 3 | [] | no_license | use std::str::Chars;
use util::Queue;
use syntax::basic_types::{ SourceLoc };
use syntax::tokenize::*;
use syntax::context::Context;
pub struct State {
pub expr_allowed: bool,
pub brace_stack: Vec<bool>,
}
impl State {
fn new () -> Self {
State {
expr_allowed: true,
brace_stack: vec![],
}
... | true |
5578db8ebb8d591bbb48ed8dba9830bd11ef18cf | Rust | SwapnilGaikwad/lsp-asm | /crates/base/src/filetype.rs | UTF-8 | 595 | 2.71875 | 3 | [
"MIT"
] | permissive | #[derive(Clone, PartialEq, Debug)]
pub enum FileType {
Assembly,
ObjDump,
}
impl Default for FileType {
fn default() -> Self {
Self::Assembly
}
}
impl FileType {
pub fn from_contents(filedata: &str) -> Self {
use regex::Regex;
lazy_static! {
static ref OBJDUMP_... | true |
26faf2322bfc546bbeecdebb4a42c194883456fe | Rust | wusyong/advent-of-code | /2020/01/rust/src/main.rs | UTF-8 | 1,056 | 3.375 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs::File;
use std::io::{prelude::*, BufReader};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn main() -> Result<()> {
let file = File::open("../../input/01.txt")?;
let buf = BufReader::new(file);
let mut list: HashSet<usize> = HashSet::new()... | true |
82cc1a36244bd96f0f5fc1122a7e8e7d8815a763 | Rust | adeoku/chimera_evolve | /src/ealgorithm.rs | UTF-8 | 12,609 | 3.28125 | 3 | [] | no_license | use rand::seq::IteratorRandom;
use rand::{thread_rng, Rng};
use std::collections::HashMap;
use std::f64;
use suffix::SuffixTable;
use crate::rayon::iter::IntoParallelRefMutIterator;
use crate::rayon::iter::ParallelIterator;
#[allow(dead_code)]
fn calculate_ars(string: &str, suffix_table: &suffix::SuffixTable) -> f64 ... | true |
bcaaa95534249421e3344a3853bc3f032c8335fa | Rust | maghoff/pixu.rs | /src/site/index.rs | UTF-8 | 5,155 | 2.546875 | 3 | [] | no_license | use diesel;
use diesel::prelude::*;
use diesel::sqlite::SqliteConnection;
use r2d2::Pool;
use r2d2_diesel::ConnectionManager;
use web::{Error, MediaType, RepresentationBox, Resource, Response};
use super::auth;
use super::handling_error::HandlingError;
use crate::db::schema::*;
use crate::id30::Id30;
pub struct Index... | true |
aabb9eafc82ba48723e61f19b88c9d860a42d355 | Rust | KenSuenobu/rust-pushrod | /src/image_widget.rs | UTF-8 | 2,609 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | // Image Widget
// Pushrod
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing... | true |
7fdfb4c0a845deddd9c86fc3481e399e56b339f4 | Rust | zaeleus/noodles | /noodles-cram/src/data_container/compression_header/encoding/codec/byte_array.rs | UTF-8 | 6,758 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::{
collections::HashMap,
io::{self, Write},
};
use byteorder::WriteBytesExt;
use bytes::Buf;
use crate::{
container::block,
data_container::compression_header::{
encoding::{
codec::{Byte, Integer},
Decode, Encode,
},
Encoding,
},
io::{Bit... | true |
6d80567b05e98e7d6215304f0c34ccc3b60654a8 | Rust | yufengwng/loxscript | /src/tree/ast/token.rs | UTF-8 | 6,404 | 3.703125 | 4 | [] | no_license | //! Module for source-level syntactic elements.
use std::fmt;
/// The fundamental units of the language.
///
/// Each token represents an atomic element of the language grammar. A few of the literal tokens
/// also contains the value it represents.
#[derive(Clone, Debug, PartialEq)]
pub enum Token {
// Punctuatio... | true |
5e102dbd62143de3557f4977aba65b45be8cb5fe | Rust | supython-coder/leetcode-rust | /S0128-longest-consecutive-sequence/src/main.rs | UTF-8 | 2,953 | 3.65625 | 4 | [] | no_license | struct Solution;
use std::collections::HashMap;
use std::collections::HashSet;
#[derive(Clone, Debug)]
struct Bounds {
pub lower_bound: i32,
pub upper_bound: i32,
}
impl Solution {
pub fn longest_consecutive(nums: Vec<i32>) -> i32 {
// 记录每个元素对应的上界、下界
// 如果两个元素相连的话,那么这两个元素对应的上下界一定能连起来
... | true |
f4224870857ae7f15bf7ff9bfbc608b0e6277e8f | Rust | lucab/rust-crdt | /src/mvreg.rs | UTF-8 | 6,640 | 3.078125 | 3 | [] | no_license | use serde::de::DeserializeOwned;
use serde::Serialize;
use std::fmt::{self, Debug, Display};
use vclock::{VClock, Actor};
use ctx::{ReadCtx, AddCtx};
use traits::{Causal, CmRDT, CvRDT};
/// A Trait alias for the possible values MVReg's may hold
pub trait Val: Debug + Clone + Send + Serialize + DeserializeOwned {}
im... | true |
b33a59c989aa7125dc1a2b83b2781b24179e98dc | Rust | Tejpbit/advent-of-code-2018 | /advent-of-code-2018-rust/src/main.rs | UTF-8 | 6,010 | 3.1875 | 3 | [] | no_license | use std::fs;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BTreeMap;
use std::ops::Range;
#[derive(PartialEq, Eq, Hash, Clone, Copy, Ord, PartialOrd)]
struct Point {
x: i32,
y: i32,
}
impl Point {
fn neighbours(&self) -> Vec<Point> {
let mut vec = Vec::new(... | true |
81e47fe2af9a73dc83ead78fac013e5d74cf3641 | Rust | aaronbruckner/rustPlayground | /implementations/src/bin/pig_latin.rs | UTF-8 | 1,548 | 3.671875 | 4 | [] | no_license | use std::io::{self, Read};
use std::str::Chars;
use std::iter::Peekable;
/*
* Converts standard in to pig-latin. Handles unicode characters. Leaves all other spacing and punctuation
* untouched.
*
* To run:
* cargo run --bin pig_latin
*/
fn main() {
let mut raw_string: String = String::new();
io:... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.