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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
1aa7ddd73e9072e574c8d73167fa5160a0cb53fb | Rust | ZcashFoundation/zebra | /zebra-consensus/src/block/check.rs | UTF-8 | 12,753 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! Consensus check functions
use std::{collections::HashSet, sync::Arc};
use chrono::{DateTime, Utc};
use zebra_chain::{
amount::{Amount, Error as AmountError, NonNegative},
block::{Block, Hash, Header, Height},
parameters::{Network, NetworkUpgrade},
transaction,
work::{difficulty::ExpandedDiffi... | true |
2e20dc24c87779a35e6edf68293e8b5b559c3be8 | Rust | pathakraul/ProjectEuler | /p3/src/p3.rs | UTF-8 | 559 | 3.3125 | 3 | [] | no_license | use std::env::args;
use std::str::FromStr;
fn isprime(num: u64) -> bool {
if num <=3 {
return (num > 1)
}
else if num%2 == 0 || num%3 == 0 {
return false
}
let mut k = 5;
while k <= (num as f64).sqrt() as u64 {
if num%k == 0 && num%(k+2) == 0 {
return fa... | true |
9df67b76e2439259a65ccfbeba3191bbaa7d35e0 | Rust | cottonguard/kyopro-rust | /src/libs/slice/permutation.rs | UTF-8 | 1,083 | 3.578125 | 4 | [] | no_license | pub fn next_permutation<T: Ord>(p: &mut [T]) -> bool {
for i in (0..p.len() - 1).rev() {
if p[i] < p[i + 1] {
for j in (0..p.len()).rev() {
if p[j] > p[i] {
p.swap(i, j);
p[i + 1..].reverse();
return true;
... | true |
d5cdc908367e97504e322793fbeee87e02f99b57 | Rust | lsimrsi/pg-rust | /src/models.rs | UTF-8 | 151 | 2.609375 | 3 | [] | no_license | #[derive(Queryable)]
pub struct User {
pub id: i32,
pub email: String,
pub first: String,
pub last: String,
pub password: String,
} | true |
caee7c6bc14a31d53f4782efcd2efdfd26e43420 | Rust | jtempest/advent_of_code_2019-rs | /day01/src/main.rs | UTF-8 | 1,427 | 3.265625 | 3 | [
"MIT"
] | permissive | //! Solution to Advent of Code 2019 [Day 1](https://adventofcode.com/2019/day/1).
use once_cell::sync::Lazy;
static DAY01_INPUT: Lazy<Vec<i32>> = Lazy::new(|| {
let input = include_str!("day01_input.txt");
input.lines().map(|s| s.parse::<i32>().unwrap()).collect()
});
fn fuel_required(mass: i32) -> i32 {
... | true |
c3aafe3dad09d3a5fe1f22aa292188d11f866721 | Rust | jmriesen/tower_defense | /src/enemy/death.rs | UTF-8 | 722 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use amethyst::{
derive::SystemDesc,
ecs::{Entities, Join, ReadStorage, System, SystemData, Write},
};
use super::{Enemy, Helth};
use crate::player::Player;
#[derive(SystemDesc)]
pub struct DeathSystem;
impl<'s> System<'s> for DeathSystem {
type SystemData = (
Entities<'s>,
ReadStorage<'s... | true |
3a37e1125de7b9f63d438cc0f6c45a2797979d52 | Rust | KeAiMianYang/work_repo_training | /Rust/book/19_01_advanced_features/advanced_types/src/lib.rs | UTF-8 | 1,846 | 4.09375 | 4 | [] | no_license | //========== Newtype Pattern for safety and abstraction ==========//
use std::collections::HashMap;
// Type Safety
struct Millimeters(u32);
struct Metters(u32);
// Abstraction
struct People(HashMap<i32, String>);
//========== Type Aliases ==========//
// same as a typedef, no type safety
type Kilometers = i32;
fn use... | true |
0038e9b5d134841a79e473d949728911138a4745 | Rust | burcadoruciprian/aoc-2020 | /day05/src/main.rs | UTF-8 | 1,337 | 3.078125 | 3 | [] | no_license | use itertools::Itertools;
fn decode_id(borading_pass: &str) -> i32 {
let (row, col) = borading_pass.split_at(7);
decode_row(row) * 8 + decode_col(col)
}
fn decode_row(s: &str) -> i32 {
s.chars()
.fold(0..=127, |range, c| {
let mid = (range.start() + range.end()) / 2;
match ... | true |
4d13f55f60829e0d20e484b607387909db070226 | Rust | lucasavila00/thop | /src/local_search.rs | UTF-8 | 8,521 | 3 | 3 | [] | no_license | use evaluate;
use instance;
use std::collections::HashMap;
use utils;
#[derive(Debug)]
struct BestImprov {
pub profit: u32,
pub city: u32,
pub items: Vec<u32>,
}
pub fn two_opt(
instance: &instance::Instance,
mut route: Vec<u32>,
mut hash: HashMap<u32, bool>,
first_improvement: bool,
) -> (... | true |
16bcb38b9136cde999d9241d0c3ffc0f12e187f5 | Rust | AliAryanTech/rust-tg-bot | /src/methods/answer_shipping_query.rs | UTF-8 | 2,187 | 3.390625 | 3 | [
"MIT"
] | permissive | use crate::types::{ShippingOption, ShippingQuery};
use crate::{bot::Bot, error::Result};
use serde::Serialize;
use serde_json;
#[must_use = "AnswerShippingQuery does nothing until you `send` it"]
#[derive(Serialize)]
pub struct AnswerShippingQuery<'a> {
#[serde(skip)]
bot: &'a Bot,
/// Unique identifier fo... | true |
2fc71d65ef0f2ffb63502e9d3c1d001c2ac5a053 | Rust | ahungrynoob/rust-queue-stack | /src/main.rs | UTF-8 | 2,055 | 3.84375 | 4 | [] | no_license | use std::usize;
#[derive(Debug)]
struct StackNode<T> {
data: T,
next: Option<Box<StackNode<T>>>,
}
#[derive(Debug)]
struct Stack<T> {
top: Option<Box<StackNode<T>>>,
}
impl<T> Stack<T> {
fn new() -> Self {
Stack { top: None }
}
fn push(&mut self, data: T) {
let mut node = Sta... | true |
64264f3fce049865859a89def9a6cc6ca1f46e7c | Rust | pluehne/foliage | /src/format/terms.rs | UTF-8 | 32,477 | 3.390625 | 3 | [
"MIT"
] | permissive | impl std::fmt::Debug for crate::SpecialInteger
{
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
{
match &self
{
Self::Infimum => write!(formatter, "#inf"),
Self::Supremum => write!(formatter, "#sup"),
}
}
}
impl std::fmt::Display for crate::SpecialInteger
{
fn fmt(&self, formatt... | true |
926a9c29309339b1c2161423b6ac4e49bd6f3db3 | Rust | benjamin-fleischmann/keyboard_layout_lessons | /src/bone_app.rs | UTF-8 | 1,825 | 2.625 | 3 | [
"MIT"
] | permissive | use std::fs::OpenOptions;
use crate::app::selectable_session_list::SelectableLessonList;
use crate::app::trainer::TrainerApp;
use crate::core::lesson::Lesson;
use crate::core::weighting_strategy::WeightingStrategy;
mod app;
mod core;
mod wrapper;
fn create_bone_home_row_lessons() -> Vec<Lesson> {
let lesson_leng... | true |
10f926af604eddbbdaa73269d59cb493cb815d48 | Rust | MJKWoolnough/bytes | /src/buffer/mod.rs | UTF-8 | 4,007 | 3.671875 | 4 | [] | no_license | use std::io;
use std::ops;
/// The Buffer struct wraps a Vec<u8> to provide read and write
pub struct Buffer {
data: Vec<u8>,
}
impl Buffer {
pub fn new(data: Vec<u8>) -> Buffer {
Buffer { data: data }
}
}
impl io::Read for Buffer {
/// The read function moves bytes from the internal Vec<u8> ... | true |
3bc7f59a0a8d76dbb9c0c587717d40d58a1fbd3f | Rust | h4hany/leetcode | /python_solutions/436.find-right-interval.rs | UTF-8 | 6,026 | 3.109375 | 3 | [] | no_license | /*
* @lc app=leetcode id=436 lang=rust
*
* [436] Find Right Interval
*
* https://leetcode.com/problems/find-right-interval/description/
*
* algorithms
* Medium (44.55%)
* Total Accepted: 33.2K
* Total Submissions: 74.5K
* Testcase Example: '[[1,2]]'
*
* Given a set of intervals, for each of the interva... | true |
00fe12a5bfd7320df91d565fecde52b2208bb141 | Rust | PatiPavanSai/rust-cardano | /storage-units/src/utils/bloom.rs | UTF-8 | 1,155 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use utils::bitmap;
const FNV_PRIME : u64 = 0x100000001b3;
const FNV_OFFSET_BASIS : u64 = 0xcbf29ce484222325;
// calculate FNV1, FNV1a
pub fn hash(content: &[u8]) -> (u64, u64) {
let mut hash = FNV_OFFSET_BASIS;
let mut hash2 = FNV_OFFSET_BASIS;
for c in content {
// FNV1
hash = hash.wrappi... | true |
48d77230592411cd3d80616f866d2a765995dfbb | Rust | maxim-komar/learning-rust | /rust-by-example/generics/phantom/phantom.rs | UTF-8 | 1,231 | 3.46875 | 3 | [] | no_license | // a phantom type parameter is one that doesn't show up ar runtime, but
// is checked statically (and only) at compile time
//
// in the following example, we combine std::marker::PhantomData with the
// phantom type parameter concept to create tuples containing different
// data types
use std::marker::PhantomData;
... | true |
0ce770af92c9936fcbf9f847302ba7154bfd6312 | Rust | GrossBetruger/exercism | /rust/pythagorean-triplet/src/lib.rs | UTF-8 | 284 | 2.734375 | 3 | [] | no_license | const LIMIT: u32 = 1000;
pub fn find() -> Option<u32> {
for a in 1..LIMIT {
for b in 1..LIMIT-a {
let c = 1000 - (a + b);
if a.pow(2) + b.pow(2) == c.pow(2) {
return Some(a * b * c)
}
}
}
return None;
}
| true |
6dbf31204f0bb360a9715d408a825b1f78c027e1 | Rust | superfunc/benchviz | /src/cli.rs | UTF-8 | 2,758 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2018 superfunc, see license.txt for usage details.
//
// Module containing io functionality for printing info to users
// in the CLI environment
use clap;
// Honestly I'm probably just missing how to get clap to do this
// behavior naturally, but for now we'll just write a nice little function.
pub fn pa... | true |
f3e1e4072230c56d3fa12ad40519cec17990a14b | Rust | 0nkery/congenial-lamp | /src/web_api.rs | UTF-8 | 12,003 | 2.984375 | 3 | [
"MIT"
] | permissive | use actix::Recipient;
use actix_web::{error, http, middleware, App, FromRequest, HttpRequest, HttpResponse, Json, Path};
use chrono::{NaiveDate, ParseError};
use failure::Error;
use futures::Future;
use apis::{WeatherData, WeatherQuery};
/// Перечисление с ошибками API. `UnexpectedError` логируются
/// полностью, а н... | true |
703bafe5aa2476de72e6d373da8f7c1dce3f1d07 | Rust | crossterm-rs/crossterm-winapi | /src/handle.rs | UTF-8 | 6,628 | 3.203125 | 3 | [
"MIT"
] | permissive | //! This module contains some logic for working with the console handle.
use std::io::Result;
use std::ops::Deref;
use std::ptr::null_mut;
use std::sync::Arc;
use winapi::shared::minwindef::DWORD;
use winapi::um::{
fileapi::{CreateFileW, OPEN_EXISTING},
handleapi::{CloseHandle, INVALID_HANDLE_VALUE},
proc... | true |
d33263792f5ee1800f37db703396d3ed61ecec4b | Rust | samlet/alfin | /src/hash_set.rs | UTF-8 | 1,154 | 2.78125 | 3 | [] | no_license | use pyo3::prelude::*;
use pyo3::PyIterProtocol;
#[pyclass]
struct SetIterator {
iter: std::collections::hash_set::IntoIter<usize>
}
#[pyproto]
impl PyIterProtocol for SetIterator {
fn __iter__(slf: PyRef<Self>) -> Py<SetIterator> {
slf.into()
}
fn __next__(mut slf: PyRefMut<Self>) -> Option<u... | true |
65456fb4ccdf9ff48bcdc93de120fb4acd0ad6fd | Rust | webern/rs | /ezxml/build.rs | UTF-8 | 1,473 | 2.609375 | 3 | [
"MIT"
] | permissive | // Automatically generate README.md and xml parse tests.
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
generate_readme();
generate_tests();
}
fn generate_readme() {
// Check for environment variable "SKIP_README". If it is set, skip README generation.
if env... | true |
f110c95bbbbf860c57d12af8562af47c9f968287 | Rust | mechiru/iso-4217 | /src/macros.rs | UTF-8 | 2,315 | 2.875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[doc(hidden)]
#[macro_export]
macro_rules! impl_curr_code {
($(#[$attr:meta])* ($($vis:tt)*)
enum $name:ident {
$($var:ident { num: $num:expr, digit: $digit:expr, name: $currency:expr, },)*
}) => {
$(#[$attr])*
$($vis)* enum $name { $($var = $num),* }
impl $name {
... | true |
dcfe058cd65390d0a6a78af702b85903c655a57e | Rust | pimox/proxmox | /proxmox-api-macro/src/util.rs | UTF-8 | 23,588 | 3.078125 | 3 | [] | no_license | use std::borrow::Borrow;
use std::collections::HashMap;
use std::convert::TryFrom;
use proc_macro2::{Ident, Span, TokenStream};
use quote::ToTokens;
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::Token;
use anyhow::Error;
use crate::api::{self, Schema, Sche... | true |
3f59e1c4600c89659441be60bf367b9c8d81a5e5 | Rust | mantissaman/rust-basics | /003-master/m010-trait-inheritance/src/main.rs | UTF-8 | 589 | 3.65625 | 4 | [] | no_license | trait Vehicle {
fn get_price(&self) ->u64;
}
trait Car: Vehicle {
fn model(&self) -> String;
}
struct Audi{
model: String,
release_date: u16
}
impl Audi {
fn new(model: &str, release_date: u16) -> Self{
Self { model: model.to_string(), release_date}
}
}
impl Car for Audi{
fn mode... | true |
dac61a0bf0bc6e91d5129995e5ae48a10257928c | Rust | comp590-19s/590-material | /lecture/31-pipes/foe/src/main.rs | UTF-8 | 321 | 2.953125 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
fn main() -> std::io::Result<()> {
let mut file = File::create("foe.txt")?;
let mut i = 0u64;
loop {
i += 1;
file.write_all(format!("file : {}\n", i).as_bytes())?;
println!("stdout: {}", i);
eprintln!("stderr: {}", i);
}
}... | true |
fa61b925ea37e623e9cf31c5e76310efe72d7a96 | Rust | fossabot/wickdb | /src/mem/arena.rs | UTF-8 | 10,298 | 2.515625 | 3 | [
"Apache-2.0",
"BSD-3-Clause"
] | permissive | // Copyright 2019 Fullstop000 <fullstop1005@gmail.com>.
//
// 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 appli... | true |
959fe17c43d393fba685edf9efe3bdd064a26579 | Rust | wartyz/zengine | /zengine/src/math/matrix4x4.rs | UTF-8 | 7,330 | 2.96875 | 3 | [] | no_license | use crate::math::vector3::Vector3;
use auto_ops::*; // Tienen macros para hacer sobrecarga de operadores
pub struct Matrix4x4 {
pub data: [f32; 16]
}
// sobrecarga el operador * para poder multiplicar matriz_c = &matriz_a * &matriz_b
impl_op_ex!(* |a: &Matrix4x4, b: &Matrix4x4| -> Matrix4x4 {
let mut m = Matr... | true |
607e13afb3d7676594fd9bfcfb75c680dd34dc57 | Rust | py-162157/test_code | /DoublyLinklist/src/main.rs | UTF-8 | 1,824 | 3.421875 | 3 | [] | no_license | use std::rc::{Rc, Weak};
use std::cell::RefCell;
#[derive(Debug)]
struct Node<T> {
value: Option<T>,
pre: Option<RefCell<Weak<Node<T>>>>,
next: Option<RefCell<Rc<Node<T>>>>,
}
impl<T: std::fmt::Display> Node<T> {
fn new(key: T) -> Node<T> {
Node {
value: Some(key),
pre:... | true |
453a4cce69f1c12eacba652d32cc8a03a8de8994 | Rust | curtiseng/nng-rs | /examples/survey.rs | UTF-8 | 2,329 | 3.34375 | 3 | [
"MIT"
] | permissive | //! Survey (everybody votes) example.
//!
//! The surveyor pattern is used to send a timed survey out, with responses being individually
//! returned until the survey has expired. This pattern is useful for service discovery and voting
//! algorithms.
//!
//! This example was derived from [this NNG example][1].
//!
//!... | true |
8ae459bb4fb5d4236d5a7f54e5c3c8ab49246ae7 | Rust | dezajno/boolean_expression | /src/cubes.rs | UTF-8 | 13,193 | 3.3125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // boolean_expression: a Rust crate for Boolean expressions and BDDs.
//
// Copyright (c) 2016 Chris Fallin <cfallin@c1f.net>. Released under the MIT
// License.
//
use std::iter;
use std::slice;
use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use std::collections::VecDeque;
use smallvec::SmallVec;
/// A va... | true |
20b75d3ad77ef8e2d781c92a93a8fa5b3abe618f | Rust | lache-melvin/a-lil-rusty | /guessing_game/src/main.rs | UTF-8 | 920 | 3.875 | 4 | [] | no_license | use std::io;
use std::cmp::Ordering;
use rand::Rng;
fn main() {
println!("\nWe're guessing stuff! (Well, numbers, to be precise...)");
let secret_number = rand::thread_rng().gen_range(1, 101);
loop {
println!("\nGive me your best guess (between 1 and 100 my friend)");
let mut guess = Str... | true |
9079e75a7f128c152797d052421d5232e7574326 | Rust | wuggen/julia | /src/export.rs | UTF-8 | 5,616 | 2.53125 | 3 | [
"MIT"
] | permissive | use vulkano::buffer::{BufferUsage, CpuAccessibleBuffer, ImmutableBuffer};
use vulkano::command_buffer::{AutoCommandBuffer, AutoCommandBufferBuilder, CommandBuffer};
use vulkano::descriptor::descriptor_set::PersistentDescriptorSet;
use vulkano::format::Format;
use vulkano::image::{Dimensions, StorageImage};
use vulkano:... | true |
ebee3fd3f558eaa013b7fd1125307d7a974cfd89 | Rust | Alexander-Panin/packman | /src/alg.rs | UTF-8 | 2,273 | 3.046875 | 3 | [] | no_license | pub type Matrix<T> = Vec<Vec<T>>;
pub type Integral = usize;
fn get_in<T>(x: &Matrix<T>, i: usize, j: usize) -> &T {
unsafe { x.get_unchecked(i).get_unchecked(j) }
}
pub fn mmult<T, Add, Mult>(a: &Matrix<T>, b: &Matrix<T>, add: Add, mult: Mult) -> Matrix<T>
where T: Default+Clone,
Add: Fn(&T, &T) ->... | true |
326a2a0bc7581b4f3d56ea1c6302034eb3ade031 | Rust | eras/ClickMuteJack | /src/fader.rs | UTF-8 | 589 | 3.375 | 3 | [
"MIT"
] | permissive | pub struct Fader {
value: f32,
step_per_sample: f32,
}
impl Fader {
pub fn new(value: f32) -> Fader {
Fader {
value,
step_per_sample: 0.0,
}
}
pub fn fade_in(&mut self, samples: usize) {
self.step_per_sample = 1.0 / (samples as f32);
}
pub f... | true |
88b2006d71a4792a74afb11ecf1a504e5ef5189c | Rust | caser789/coreutils | /yes/yes.rs | UTF-8 | 769 | 3.09375 | 3 | [] | no_license | #[link(name="yes", vers="1.0.0", author="Xue Jiao")]
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
exec("y");
}
let option = &args[1];
match &option[..] {
"-h" => help(),
"--help" => help(),
"-V" => version(),
... | true |
62f0ee12a0f9da6baf226fd9c203124bc3f732ac | Rust | aGiant/robust_trading.icml2019 | /rstat/src/univariate/discrete/bernoulli.rs | UTF-8 | 3,120 | 2.890625 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | use crate::core::*;
use rand;
use spaces::{Vector, Matrix, discrete::Binary};
use std::fmt;
#[derive(Debug, Clone, Copy)]
pub struct Bernoulli {
pub p: Probability,
q: Probability,
variance: f64,
}
impl Bernoulli {
pub fn new<P: Into<Probability>>(p: P) -> Bernoulli {
let p = p.into();
... | true |
fa037d70d45665bb732406a1a72ecb686f4ffa0a | Rust | mxork/nats.rs | /src/lib.rs | UTF-8 | 30,574 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | //! A Rust client for the NATS.io ecosystem.
//!
//! <code>git clone https://github.com/nats-io/nats.rs</code>
//!
//! NATS.io is a simple, secure and high performance open source messaging system for cloud native applications,
//! IoT messaging, and microservices architectures.
//!
//! For more information see [https:... | true |
d97fc6537c798c9f5b6ac9f133587ee499437b22 | Rust | timglabisch/innodblockmon | /src/server.rs | UTF-8 | 2,585 | 2.765625 | 3 | [] | no_license | use mysql::Conn;
use mysql::Opts;
use mysql::Error;
pub struct Server {
conn: Conn
}
#[derive(Debug)]
pub struct TransactionResult {
pub waiting_trx_id : Option<String>,
pub waiting_thread : Option<u32>,
pub waiting_query : Option<String>,
pub waiting_for_lock : Option<String>,
pub blocking_tr... | true |
5f46716c1c7f8b12d972bacde36e1b5d9213f02a | Rust | alun/app-comparison | /quotes-exporter-rust/src/main.rs | UTF-8 | 1,300 | 2.875 | 3 | [] | no_license | use quotes_exporter::exchange::{create_exchange, PriceType};
use quotes_exporter::sheets::Doc;
use serde::Deserialize;
use std::collections::HashMap;
use std::{fs, thread, time};
#[derive(Deserialize, Debug)]
struct Config {
sheet: String,
timeout: u32,
data: HashMap<String, Vec<String>>,
}
fn export_quot... | true |
0219901f53a60a06a7e081c25c74b6a317d0514b | Rust | Saravanan-Jodavula/libra | /language/move-vm/types/src/chain_state.rs | UTF-8 | 2,469 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{loaded_data::types::FatStructType, values::GlobalValue};
use libra_types::{access_path::AccessPath, contract_event::ContractEvent};
use move_core_types::{
gas_schedule::{GasCarrier, GasUnits},
language_storage::Modu... | true |
c79d3669cc1ea5bb9899dfeb982b37e3af505953 | Rust | prangel-git/gts | /src/abstractions/play.rs | UTF-8 | 1,485 | 3 | 3 | [] | no_license | use super::agent::Agent;
use super::environment::Environment;
// TODO: Figure out how to play with a list of players.
// Note that players can have different types as far as they
// implement the Agent trait.
/// Plays a game in Envirnment 'env', and two agents.
pub fn play<Action, AgentId, T, R, S>(
env: &mut T,... | true |
229fa3c7a653e50604deb3a91f0e6b0b8e5790c3 | Rust | xhresko/lingebra | /src/lib.rs | UTF-8 | 2,875 | 3.65625 | 4 | [
"MIT"
] | permissive | //! # LinGebra
//!
//! `lingebra` is a library that provides simple implementation of objects and operations
//! that are used in linear algebra.
mod matrix;
pub use matrix::Matrix;
use std::f64::consts::E;
use std::f64::consts::PI;
///
/// Sigma = standard deviation
/// Mu = mean
/// # Examples
///
/// ```
/// let x... | true |
e924770f5c3da2f1ed2704b27e4118bcc340ebfc | Rust | torsv454/lined | /src/cmds/character.rs | UTF-8 | 7,952 | 3.625 | 4 | [
"Apache-2.0"
] | permissive | //! Character level functions.
//!
//!
use super::super::LineState;
use std::cmp;
use std::collections::HashMap;
/// Transposes the character at the cursor position with the preceeding character and moves forward.
/// Does nothing if the cursor is in the HOME position.
pub fn transpose_character(state: &mut LineState)... | true |
2facbc64981f41ea5bbd6790d22c8c89a79b69c0 | Rust | glacyr/giraffe | /src/receive_pack.rs | UTF-8 | 2,220 | 2.515625 | 3 | [] | no_license | use futures::{Stream, StreamExt};
use std::pin::Pin;
use warp::Filter;
use super::proto::packet;
use super::{InfoRefs, Multiplexed, Status};
pub trait ReceivePack: InfoRefs {
/// Should process an incoming packfile and stream the results.
fn receive<'a, S, B>(
&self,
stream: S,
) -> Pin<Bo... | true |
891cebe6254fb6c93a40a4826aca779ab40a793a | Rust | Geobert/aoc-2019 | /src/day2.rs | UTF-8 | 2,242 | 3.3125 | 3 | [] | no_license | use anyhow::{bail, Result};
use aoc_runner_derive::{aoc, aoc_generator};
#[aoc_generator(day2)]
pub fn str_to_vec(input: &str) -> Vec<u64> {
input
.split(',')
.map(|i| u64::from_str_radix(i, 10).expect("Invalid input, can't be converted to u64"))
.collect()
}
fn exec_opcode(instruction: &[... | true |
b0b1dc57b4bb641cd5156a805148a83da37e904e | Rust | amethyst/ludumdare42 | /amethyst/amethyst_assets/examples/hl.rs | UTF-8 | 5,530 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! High level example
#![allow(unused)]
extern crate amethyst_assets;
extern crate amethyst_core;
extern crate rayon;
extern crate ron;
#[macro_use]
extern crate serde;
use std::sync::Arc;
use amethyst_assets::*;
use amethyst_core::specs::common::Errors;
use amethyst_core::specs::prelude::{
Builder, Dispatcher... | true |
8ba197d64c7b45139688acb6d39920a20f7b0e07 | Rust | tornadocash/phase2-bn254 | /phase2/src/utils.rs | UTF-8 | 5,072 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | extern crate bellman_ce;
extern crate rand;
extern crate byteorder;
use byteorder::{
BigEndian,
ReadBytesExt,
};
use num_bigint::BigUint;
use num_traits::Num;
use std::sync::Arc;
use bellman_ce::pairing::{
ff::{
PrimeField,
},
CurveAffine,
CurveProjective,
Wnaf,
bn256::{
... | true |
82185cb661958cb97d5b283c455cea603938bc4e | Rust | MidasLamb/async-graphql | /tests/list.rs | UTF-8 | 1,634 | 2.984375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use async_graphql::*;
#[async_std::test]
pub async fn test_list_type() {
#[InputObject]
struct MyInput {
value: Vec<i32>,
}
struct Root {
value: Vec<i32>,
}
#[Object]
impl Root {
async fn value_vec(&self) -> Vec<i32> {
self.value.clone()
}
... | true |
0ef8a74002c33118f337cb10102388d2aa4a18a0 | Rust | MaxDesiatov/wasminspect | /crates/cli/src/commands/subroutine.rs | UTF-8 | 725 | 2.625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
pub struct Variable {
pub name: String,
pub type_name: String,
}
pub trait SubroutineMap {
fn variable_name_list(&self, code_offset: usize) -> Result<Vec<Variable>>;
fn display_variable(
&self,
code_offset: usize,
rbp: u32,
memory: &[u8],
nam... | true |
02d4f18ee720ebff21405b1246c71ba13fe42dfb | Rust | newpavlov/rustrush-crypto-workshop | /ciphers/src/cli.rs | UTF-8 | 4,021 | 2.859375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use structopt::StructOpt;
use std::path::PathBuf;
#[derive(StructOpt)]
#[structopt(
name = "rustrush-ciphers",
about = "Various cipher examples")]
pub(crate) enum Cli {
/// Encrypt file using AES128-CBC-PKCS7 (without any authentification!!!)
#[structopt(name = "cbc_encrypt")]
CbcEncrypt {
... | true |
30bdd5a30c3647e530786d60631a1a798fab239f | Rust | ROki1988/opentelemetry-rust | /opentelemetry-otlp/src/exporter/tonic.rs | UTF-8 | 5,135 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | use crate::ExportConfig;
use std::fmt::{Debug, Formatter};
use tonic::metadata::MetadataMap;
#[cfg(feature = "tls")]
use tonic::transport::ClientTlsConfig;
use super::default_headers;
/// Configuration for [tonic]
///
/// [tonic]: https://github.com/hyperium/tonic
#[derive(Debug, Default)]
#[non_exhaustive]
pub struc... | true |
92dbfd560d2615a3b9f3afd9f5f38af40bd16e15 | Rust | lagudomeze/flatten | /src/cons/fix.rs | UTF-8 | 2,186 | 3.125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Make `Cons` flat.
use cons::*;
/// Convert
///
/// [A, B, [C, Nil], [[D, Nil], Nil], Nil]
/// to [A, B, C, D, Nil]
///
///
/// Recursion trait for `Tail`.
pub trait Fix: Node + Sized {
// type Fixed: Fix<Fixed = <Self as Fix>::Fixed>;
type Fixed: ValidNode;
fn fix(self) -> Self::Fixed;
}
/// Fixe... | true |
930c30bce3dd33f505548e7701449d9df01d6e8f | Rust | stm32-rs/stm32f7xx-hal | /src/gpio/hal_02.rs | UTF-8 | 9,098 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use core::convert::Infallible;
use super::{
dynamic::PinModeError, DynamicPin, ErasedPin, Floating, Input, OpenDrain, Output,
PartiallyErasedPin, Pin, PinState, PullDown, PullUp, PushPull,
};
use embedded_hal::digital::v2::{
InputPin, IoPin, OutputPin, StatefulOutputPin, ToggleableOutputPin,
};
// Implem... | true |
2be3ac18ca267dc47f6157aeaa32ba147d79ae01 | Rust | nilehmann/liquid-rust | /liquid-rust-core/src/ast/pred.rs | UTF-8 | 3,233 | 3.28125 | 3 | [] | no_license | use std::fmt;
use super::BaseTy;
use crate::names::{Field, Location};
#[derive(Clone)]
pub enum Pred<S = usize> {
Constant(Constant),
Place(Place<S>),
BinaryOp(BinOp, Box<Pred<S>>, Box<Pred<S>>),
UnaryOp(UnOp, Box<Pred<S>>),
}
impl<S> Pred<S> {
pub fn tt() -> Self {
Self::Constant(Constan... | true |
cd188c01f8a4d61105d6184b0714aba109d9cd09 | Rust | KBone12/ray-tracing | /src/camera.rs | UTF-8 | 2,012 | 3.015625 | 3 | [
"MIT"
] | permissive | use cgmath::{InnerSpace, Point3, Vector3};
use rand::{distributions::Uniform, prelude::Distribution, Rng};
use crate::Ray;
pub struct Camera {
origin: Point3<f64>,
lower_left_corner: Point3<f64>,
horizontal: Vector3<f64>,
vertical: Vector3<f64>,
u: Vector3<f64>,
v: Vector3<f64>,
lens_radiu... | true |
cbe935fa33f31763363abf90c7e46d72b847586d | Rust | Canop/lapin | /src/win_db/win_file.rs | UTF-8 | 1,802 | 2.859375 | 3 | [
"MIT"
] | permissive |
use {
anyhow::Result,
dirs,
std::{
fs::{
self,
File,
},
io::{
self,
BufRead,
Write,
},
path::PathBuf,
},
super::{
Signature,
},
};
/// An implementation of the wins storage based
/// on ... | true |
6dee8479d7eabaff5c4290f719ce71d62375c788 | Rust | dbartussek/kernel | /src/disassemble.rs | UTF-8 | 822 | 2.90625 | 3 | [] | no_license | use std::path::Path;
pub fn disassemble<S, D>(source: S, destination: D)
where
S: AsRef<Path>,
D: AsRef<Path>,
{
let destination = destination.as_ref();
if let Some(parent) = destination.parent() {
std::fs::create_dir_all(parent).unwrap();
}
let result = std::process::Command::new("ob... | true |
1a26de522ac416c49aa89e662883c43269da0a6d | Rust | premjithb/cnet-homework-by-rust | /src/web_server/server.rs | UTF-8 | 1,305 | 2.875 | 3 | [] | no_license | use std::error::Error;
use std::fs;
use std::io::{Read, Write};
use std::net::{SocketAddr, TcpListener};
use std::str::FromStr;
pub fn start() -> Result<(), Box<dyn Error>> {
// server socket
let addr = SocketAddr::from_str("127.0.0.1:7878")?;
let listener = TcpListener::bind(addr)?;
println!("Web serv... | true |
bd4f0636728e7c219e386d3a6d14cf4cb22d0cc9 | Rust | goiw111/ex_rust | /proverb/src/lib.rs | UTF-8 | 508 | 2.546875 | 3 | [] | no_license | pub fn build_proverb(list: &[&str]) -> String {
match list.len() {
x if x > 0 => {
vec![list
.windows(2)
.map(|i|format!("For want of a {} the {} was lost.",i[0],i[1]))
.collect::<Vec<String>>().join("\n"),
format!("And all for the ... | true |
e3ca5214dd4d1afdf6215e4868808a8821131fed | Rust | devnought/gitplz | /src/main.rs | UTF-8 | 1,132 | 2.671875 | 3 | [
"MIT"
] | permissive | mod cli;
mod dispatcher;
use crate::dispatcher::Dispatcher;
use color_printer::ColorPrinter;
use command::WorkType;
use std::{
path::PathBuf,
sync::mpsc::{channel, Receiver},
};
use threadpool::ThreadPool;
use util::RepoIter;
fn main() {
let (command, working_path) = cli::handle_args().destructure();
... | true |
3e50ee666949a62b3d527cc1befa18e6e4984461 | Rust | shanithkk/RustExercism | /scale-generator/src/lib.rs | UTF-8 | 1,479 | 3.125 | 3 | [] | no_license | pub type Error = ();
const SHARPS: [&str; 12] = [
"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#",
];
const FLATS: [&str; 12] = [
"A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab",
];
const SHARP_MAP: [&str; 14] = [
"C", "G", "D", "A", "E", "B", "F#", "a", "e", "b", "f#", "c#"... | true |
3430e41c77ce5d6c8a77c49fea8de4b4ba1ae82c | Rust | joelarmstrong/aoc18 | /src/aoc7.rs | UTF-8 | 5,725 | 3.078125 | 3 | [] | no_license | use std::io;
use std::io::BufRead;
use std::collections::{HashMap, BinaryHeap};
use std::cmp::Reverse;
use regex::Regex;
use failure::Error;
pub fn aoc7(part2: bool) -> Result<(), Error> {
let dependencies = parse_dependency_graph(&mut io::stdin().lock())?;
if part2 {
println!("Seconds till completion:... | true |
305cf41e63aefdbf543a48799a2fa69bf3c51f6b | Rust | ZakaKen/nand2tetris | /projects/RustVMtranslator/src/CodeWriter.rs | UTF-8 | 14,152 | 2.953125 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufWriter, Write};
pub struct CodeWriter{
pub filename:String,
pub writer: BufWriter<File>,
pub comp_count: usize,
pub ret_count: usize,
}
impl CodeWriter{
pub fn new(out_file_path: String) -> CodeWriter{
//out_file_path = /dir/out_file_name.asm
let mut trimed:... | true |
59a98ac82adc3f8de89d2f3d40af434b4dac26f8 | Rust | coreylowman/projectEuler | /src/problems/problem046.rs | UTF-8 | 545 | 2.75 | 3 | [] | no_license | use util::prime_gen;
fn can_decompose(n: u64, primes: &Vec<u64>) -> bool {
let mut i = 1;
while 2 * i * i < n {
if primes.binary_search(&(n - 2 * i * i)).is_ok() {
return true;
}
i += 1;
}
false
}
fn go() -> String {
let primes = prime_gen::gen(1_000_000);
... | true |
be5bf181ca8dca57f7f38cfa0dc7289a242c7366 | Rust | digideskio/spectra | /src/gui.rs | UTF-8 | 2,111 | 3.09375 | 3 | [
"BSD-3-Clause"
] | permissive | use std::marker::PhantomData;
use std::rc::Rc;
use color::Color;
use linear::Vector2;
pub trait Widget {
fn get_rect(&self) -> Rect;
}
pub trait WidgetContainer: Widget {
fn get_widgets(&self) -> &[Rc<Widget>];
fn add_widget(&mut self, widget: Rc<Widget>);
}
type Px = u32;
type Pos = Vector2<Px>;
pub mod lay... | true |
e073056b396dccfa7e075f77fe40dd2ba4366752 | Rust | songlinshu/winsafe | /src/gui/native_controls/radio_group.rs | UTF-8 | 5,360 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::ops::Index;
use std::sync::Arc;
use crate::co;
use crate::funcs::PostQuitMessage;
use crate::gui::{RadioButton, RadioButtonOpts};
use crate::gui::events::RadioGroupEvents;
use crate::gui::traits::{baseref_from_parent, Child, Parent};
use crate::gui::very_unsafe_cell::VeryUnsafeCell;
/// A group of ... | true |
af574fd63efcab61f6cfdcd7c17f0578d8e8bb50 | Rust | naheedmk/apis-catalog | /server/src/dao/repo_domains/mod.rs | UTF-8 | 3,068 | 2.53125 | 3 | [] | no_license | extern crate failure;
extern crate rusqlite;
extern crate time;
extern crate uuid;
use uuid::Uuid;
use rusqlite::NO_PARAMS;
use rusqlite::{params, Connection, Result};
//use rustbreak::{FileDatabase, deser::Ron};
use log::debug;
pub struct DomainItem {
pub name: std::string::String,
pub id: Uuid,
pub de... | true |
74c99fa9adc58b54a1a07e4307b54f08237ed261 | Rust | 1HPorange/rays | /src/material.rs | UTF-8 | 3,521 | 3.453125 | 3 | [
"MIT"
] | permissive | use crate::color::*;
use crate::util;
use serde::Deserialize;
// TODO: Supply useful default values for all these things
#[derive(Debug, Copy, Clone, Default, Deserialize)]
#[serde(default)]
#[serde(deny_unknown_fields)]
pub struct Material {
pub color: RGBColor,
pub opacity: Opacity,
pub reflection: Ref... | true |
b40dc249ecf7311005909cabf94660b95e54ccca | Rust | mkamener/iron_sky | /src/tween.rs | UTF-8 | 4,365 | 3.5625 | 4 | [] | no_license | pub type KeyFrame = (f64, f64); // (frac, value)
#[allow(dead_code)]
pub enum Easing {
Linear,
EaseIn,
EaseOut,
EaseInOut,
}
type EasingFn = fn(f64) -> f64;
fn linear(x: f64) -> f64 {
x
}
fn ease_in(x: f64) -> f64 {
x.powi(3)
}
fn ease_out(x: f64) -> f64 {
(x - 1.0).powi(3) + 1.0
}
fn ... | true |
2bcaf7162707b9fe461c3198e0d3d8b3e0f71e52 | Rust | skariel/handlebars-rust | /src/render.rs | UTF-8 | 29,009 | 2.625 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, BTreeMap, VecDeque};
use std::error;
use std::fmt;
use std::rc::Rc;
use std::io::Write;
use std::io::Error as IOError;
#[cfg(all(feature = "rustc_ser_type", not(feature = "serde_type")))]
use serialize::json::{ToJson, Json};
#[cfg(feature = "serde_type")]
use serde_json::value::{Value a... | true |
82cee449573dcb6946dd8b7c4055c4fc3ef45325 | Rust | kaa-it/image_sl | /examples/use_lib/img/bindings.rs | UTF-8 | 2,747 | 3.203125 | 3 | [] | no_license | use std::error::Error;
use std::ffi::c_void;
use std::fmt::{Display, Formatter};
use std::os::raw::c_char;
use std::path::Path;
/// Statically known path to library.
#[cfg(target_os = "linux")]
pub fn lib_path() -> &'static Path {
Path::new("target/release/libimage_sl.so")
}
/// Statically known path to library.
... | true |
bfdc41c1addb347e97b96bab06c78b417f55f994 | Rust | songyzh/leetcode-rust | /src/solution/s0331_verify_preorder_serialization_of_a_binary_tree.rs | UTF-8 | 2,100 | 3.5625 | 4 | [
"Apache-2.0"
] | permissive | /**
* [331] Verify Preorder Serialization of a Binary Tree
*
* One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.
*
*
* _9_
* / \
* 3 2
* ... | true |
07652557f113f94aadb3195aed06114ebadca2c3 | Rust | high-moctane/anylang-rl | /rust/src/agent.rs | UTF-8 | 3,720 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::env;
use rand::prelude::random;
use std::f64;
use std::f64::consts::PI;
const ALPHA: f64 = 0.1; // 学習率
const GAMMA: f64 = 0.999; // 割引率
const EPSILON: f64 = 0.1; // ランダムに行動選択する割合
const INIT_QVALUE: f64 = 10000.0; // q-value の初期値
const ACTIONS: [f64; 2] = [-10.0, 10.0]; // 行動の候補
// 状態分割の下限と上限
const X_LIMI... | true |
5371558e0dfc995054542f5ab632845ec2abc114 | Rust | barafael/snarky-parrot | /examples/cli.rs | UTF-8 | 906 | 2.703125 | 3 | [
"MIT"
] | permissive | use std::env;
use std::fs;
use snarky_parrot::rule_trainer::generate_rule_from_data_vec;
use snarky_parrot::text_generator::generate_text;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = args.get(1).expect("Please provide input file name");
let key_size: usize = args
.get... | true |
e6f035c112a28b8598f3bed44a9b2401ecec866d | Rust | EFanZh/LeetCode | /src/problem_0336_palindrome_pairs/trie.rs | UTF-8 | 2,741 | 3.375 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
#[derive(Default)]
struct Node {
children: [Option<Box<Node>>; 26],
value: Option<i32>,
}
impl Solution {
fn is_palindrome(s: &[u8]) -> bool {
let mut iter... | true |
833e638df5bf4d01bb07c4b78d68abb51198c97d | Rust | TrustTheRust/rust-actix-realworld-example-app | /src/app/tags/mod.rs | UTF-8 | 1,013 | 2.75 | 3 | [] | no_license | mod list_tags;
use actix_web::{Json, State};
use self::list_tags::CanListTags;
use crate::app::res::TagListResponse;
use crate::hub::Store;
use crate::prelude::*;
pub fn list<S>(store: State<impl Store<Svc = S>>) -> Result<Json<TagListResponse>>
where
S: CanListTags,
{
let hub = store.service()?;
let tag... | true |
eb5a8e6c07d02f195b52cb7d6d95cc863f7aceca | Rust | sbrocket/serenity | /src/builder/edit_interaction_response.rs | UTF-8 | 2,743 | 2.828125 | 3 | [
"ISC"
] | permissive | use std::collections::HashMap;
use serde_json::Value;
use super::{CreateAllowedMentions, CreateEmbed};
use crate::builder::CreateComponents;
use crate::utils;
#[derive(Clone, Debug, Default)]
pub struct EditInteractionResponse(pub HashMap<&'static str, Value>);
impl EditInteractionResponse {
/// Sets the `Inter... | true |
028a7ee86cf36b655653ce44661f719271a2244e | Rust | gnoliyil/fuchsia | /src/sys/run_test_suite/directory/src/testing.rs | UTF-8 | 57,168 | 2.71875 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::{ArtifactMetadata, MaybeUnknown, Outcome, SuiteResult, TestCaseResult, TestRunResult};
use std::{
collections::{HashMap, HashSet},
ops::... | true |
152e75914da7bf212c502fdcb5fcadcdb5c0df3d | Rust | tommilligan/multiplicative-persistence | /src/combinations_wr.rs | UTF-8 | 3,897 | 4 | 4 | [] | no_license | /// An iterator for all the `n`-length combinations of a collection, with replacement.
#[derive(Debug, Clone)]
pub struct CombinationsWithReplacement<T: Copy> {
// Derived value, whether the iterator will have no values
empty: bool,
// Collection of (probably) unique elements
pool: Vec<T>,
// Vector... | true |
a7603f3aca4fccb9ac2396c38c42be42e56fb090 | Rust | jeffparsons/ncollide | /src/shape/convex_polygonal_feature2.rs | UTF-8 | 3,139 | 3.1875 | 3 | [
"BSD-2-Clause"
] | permissive | use na::{Real, Unit};
use math::{Isometry, Point, Vector};
use query::Contact;
use shape::FeatureId;
/// A feature (face or vertex) of a 2D convex polygon.
#[derive(Clone, Debug)]
pub struct ConvexPolygonalFeature<N: Real> {
// FIXME: don't keep all those public.
/// The vertices of this face.
pub vertice... | true |
9ce7c7533ffa82b99867a3cb4226b9d9ef81084b | Rust | arthurprs/rust-optimized-inttostr | /src/bench.rs | UTF-8 | 6,976 | 2.875 | 3 | [] | no_license | use Wrapper;
use std::str::FromStr;
use std::fmt::Write as fmtWrite;
use std::io::{self, Write};
use test;
use rand::{Rng, SeedableRng, StdRng};
const SEED: &'static [usize] = &[0, 1, 1, 2, 3, 5, 8, 13, 21, 34];
struct VoidWriter;
impl Write for VoidWriter {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::... | true |
33e1eecd5fd21ff7d3c4105f0a71cd548b59cce3 | Rust | jsimmons/lax | /src/main.rs | UTF-8 | 2,014 | 3.1875 | 3 | [] | no_license | // Crafting Interpreters.
use std::{
io::{BufRead, Read},
path::Path,
};
mod scanner;
use scanner::Scanner;
trait Reporter {
fn report(&mut self, chunk_name: &str, line: usize, r#where: &str, message: &str);
}
struct StderrReporter {}
impl StderrReporter {
fn new() -> Self {
Self {}
}
... | true |
27d83543f5eccfd266451b8c9ebfac3233723c01 | Rust | sria91-rlox/luxya | /src/interpreter/native_functions.rs | UTF-8 | 10,665 | 2.859375 | 3 | [
"BSD-3-Clause"
] | permissive | use super::{
env::InterpreterEnvironment,
helpers::unwrap_list,
types::{
InterpreterFunction,
InterpreterValue,
NativeFunctionSignature,
RuntimeError,
},
};
use crate::{
env::{DeclaredValue, EnvironmentWrapper},
token::Token,
try_exact_convert,
};
use std::{
cell::RefCell,
io::{self, Write},
rc::Rc,
... | true |
c5ca4ccda4b25f3a08fc6517236b29aba66508cb | Rust | ulysseB/telamon | /kernels/src/statistics.rs | UTF-8 | 1,868 | 3.421875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Statistical analysis for benchmarking.
use utils::*;
/// Estimates a mean within a confidence interval.
pub struct Estimate {
pub unit: &'static str,
pub value: f64,
pub interval: f64,
pub confidence: f64,
}
impl std::fmt::Display for Estimate {
fn fmt(&self, f: &mut std::fmt::Formatter) -> st... | true |
dd6610ec0d83e0c3c42f7cad4280320b827ef40d | Rust | J-Fields/nes-emulator | /src/instruction.rs | UTF-8 | 2,926 | 3.265625 | 3 | [
"MIT"
] | permissive | extern crate bit_vec;
use bit_vec::BitVec;
#[allow(dead_code)]
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug)]
pub enum Opcode {
ADC,
AND,
ASL,
BCC,
BCS,
BEQ,
BIT,
BMI,
BNE,
BPL,
BRK,
BVC,
BVS,
CLC,
CLD,
CLI,
CLV,
CMP,
CPX,
CPY,
... | true |
feb64f62edb03b718a8c376ffc45a183d7eb0629 | Rust | geekingfrog/advent-of-code-rust | /src/y2019/day09.rs | UTF-8 | 966 | 3.03125 | 3 | [] | no_license | use y2019::computer;
pub fn answer1() {
// let codes = vec![109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99];
// let codes = vec![1102,34915192,34915192,7,4,7,99,0];
let codes = computer::read_codes("data/2019/day09.txt");
let mut c = computer::Computer::new(codes);
c.with_input(vec![1]);... | true |
a5f1650facb1d182418e0258739f35ef338021e1 | Rust | probe-rs/probe-rs | /probe-rs/src/probe/cmsisdap/commands/swj/sequence.rs | UTF-8 | 1,784 | 3.15625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /// Implementation of the DAP_SWJ_SEQUENCE command
///
use super::super::{CmsisDapError, CommandId, Request, SendError, Status};
#[derive(Clone, Copy, Debug)]
pub struct SequenceRequest {
bit_count: u8,
data: [u8; 32],
}
impl Request for SequenceRequest {
const COMMAND_ID: CommandId = CommandId::SwjSequen... | true |
f95da28cd9134a22ea99b11ae6c88ca51c4fe465 | Rust | akolybelnikov/algorithmic-toolbox | /src/bin/collecting_signatures.rs | UTF-8 | 2,932 | 3.375 | 3 | [] | no_license | use std::io;
use std::io::BufRead;
fn optimal_points(mut slots: Vec<Slot>) -> Vec<i64> {
// order the segments by end
&slots.sort_by(|a, b| a.end
.partial_cmp(&b.end)
.unwrap());
// declare result array starting with the first slot's end
let mut points: Vec<i64> = vec![slots[0].end];
... | true |
88fa41b7c478250088a2644be8bf20acd13d8886 | Rust | Nemo157/bsx-rs | /src/decode.rs | UTF-8 | 5,808 | 3.328125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Functions for decoding arbitrary base encoded strings.
use core::fmt;
#[cfg(feature = "alloc")]
use alloc::{vec, vec::Vec};
use crate::{alphabet::Unspecified, Alphabet};
/// A builder for setting up the alphabet and output of a decode.
///
/// See the documentation for [`bsx::decode`](crate::decode()) for a mor... | true |
27867f6e369b1be91727ae8c9701a95e660a02bf | Rust | SidneyArmitage/png | /src/process/read.rs | UTF-8 | 179 | 2.546875 | 3 | [] | no_license | use std::io::Read;
pub fn int_u_32(buf_reader: &mut Read) -> std::io::Result<u32> {
let mut buffer = [0; 4];
buf_reader.read(&mut buffer)?;
Ok(u32::from_be_bytes(buffer))
} | true |
ec0c19b2c4f0cc7c6787aa886f082d38fa244597 | Rust | bjrnmrtns/xp-game-engine | /game/src/simulation.rs | UTF-8 | 1,523 | 2.59375 | 3 | [] | no_license | use crate::scene::Entity;
use crate::{physics, transformation};
use crate::{scene, window_input};
pub trait FrameInputHandler {
fn handle(
&mut self,
frame: u64,
command: &window_input::input_state::InputState,
player: &mut scene::Entity,
frame_time: f32,
);
}
pub struc... | true |
8dc8e63031444ab3bcbb8e690a1a015e82a412d4 | Rust | bensu/rust_intro_to_algo | /src/main.rs | UTF-8 | 7,332 | 3.359375 | 3 | [] | no_license | // binary tree
#![feature(box_patterns)]
use std::mem;
mod util;
struct Node {
key: usize,
val: u32,
n: u32,
left: BinaryTree,
right: BinaryTree,
}
impl Node {
fn new(key: usize, val: u32) -> Self {
Node {
key: key,
val: val,
n: 1,
left:... | true |
0262ff644df96c7667799977f15ea5d2a8e2352d | Rust | cyobero/serbia | /src/bin/create_user.rs | UTF-8 | 937 | 3 | 3 | [] | no_license | use blog_user::db::{create_user, establish_connection};
use blog_user::models::NewUser;
use clap::{App, Arg};
fn main() {
let conn = establish_connection().expect("Failed to establish connection.");
let matches = App::new("Create New User")
.author("Czar Yobero")
.arg(
Arg::with_na... | true |
e4ece2fe0f3ba414495446d46b5658617fb4bbec | Rust | PacktPublishing/Hands-On-Functional-Programming-in-Rust | /Chapter08/share5.rs | UTF-8 | 282 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::thread;
use std::sync::{Arc};
fn main() {
let a = Arc::new(vec![1, 2, 3]);
{
let a = Arc::clone(&a);
thread::spawn(move || {
a[1];
});
}
{
let a = Arc::clone(&a);
thread::spawn(move || {
a[1];
});
}
}
| true |
919286c22b832c6c070cb5c57d67e866d49c4a5a | Rust | ptorru/prometheus_exporter | /src/test.rs | UTF-8 | 1,815 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::prometheus::register_counter;
#[test]
fn wait_request() {
let binding_raw = "127.0.0.1:9185";
let metric_name = "test_wait_request";
let barrier = std::sync::Arc::new(std::sync::Barrier::new(2));
{
let barrier = barrier.clone();
std::thread::spawn(move || {
pri... | true |
a0c6bffe7c646d9daa27d05a7d952f74d332f5ad | Rust | fiji-flo/gtmpl-rust | /src/parse.rs | UTF-8 | 32,138 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet, VecDeque};
use crate::error::ParseError;
use crate::lexer::{Item, ItemType, Lexer};
use crate::node::*;
use crate::utils::*;
pub struct Parser {
name: String,
pub funcs: HashSet<String>,
lex: Option<Lexer>,
line: usize,
token: VecDeque<Item>,
peek_count... | true |
97e67dce5a967d567e0ee75372da324586033a52 | Rust | keiichiw/advent-of-code-2020 | /day15/src/main.rs | UTF-8 | 1,137 | 3.546875 | 4 | [
"MIT"
] | permissive | use std::collections::btree_map::Entry;
use std::collections::BTreeMap;
struct State {
turn: u32,
mp: BTreeMap<u32, u32>,
}
impl State {
fn new(init: &[u32]) -> (Self, u32) {
let mut s = State {
turn: 1,
mp: Default::default(),
};
let mut r = 0;
for ... | true |
677cc732bd44e6aa9775bae3d2239a1527cb2acb | Rust | ryanavella/hilbert16 | /src/lib.rs | UTF-8 | 7,049 | 3.625 | 4 | [
"MIT",
"Unlicense"
] | permissive | #![no_std]
//! Hilbert transforms between 1D and 2D space, optimized for u16 coordinates.
//!
//! # Examples
//!
//! ```
//! use hilbert16::{Curve, Point};
//!
//! let order = 9;
//! let curve = Curve::new(order).unwrap();
//!
//! let p = Point { x: 175, y: 295 };
//! println!("{:?} => {}", p, curve.dist_a... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.