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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7de9312760a11f86b7493f46845681f0dc744c03 | Rust | joechrisellis/parsec | /src/back/backend_handler.rs | UTF-8 | 11,554 | 2.75 | 3 | [
"BSD-3-Clause",
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
//! Convert requests to calls to the underlying provider
//!
//! The backend handler embodies the last processing step from external request
//! to internal function call - parsing of the request body and conversion to a
//! na... | true |
86cf53ca7fb2c0dc696ed258b116b931f17035ae | Rust | stm32-rs/stm32l0xx-hal | /src/lptim.rs | UTF-8 | 19,360 | 3.015625 | 3 | [
"BSD-3-Clause",
"0BSD",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Low-Power Timer (LPTIM) support.
use crate::gpio::{self, gpiob};
use crate::hal;
use crate::pac::LPTIM;
use crate::pwr::PWR;
use crate::rcc::{Enable, Rcc, Reset};
use cast::{u32, u64};
use core::convert::TryFrom;
use core::marker::PhantomData;
use embedded_time::duration::Microseconds;
use embedded_time::rate::Her... | true |
baee8164af26163a45b8a3c4ed0ac3748e546fda | Rust | AndrewChupin/rust-edu | /src/impl.rs | UTF-8 | 1,239 | 3.6875 | 4 | [] | no_license |
struct Rect {
width: i32,
height: i32
}
impl Rect {
// instance method
fn improve(&self, w: i32, h: i32) -> Rect {
Rect { width: self.height + w, height: self.height + h }
}
// instance method
fn area(&self) -> i64 {
(self.width + self.height) as i64
}
// static ... | true |
45303423ea75939063b02c4a1f4a948977658367 | Rust | obaranni/amsspf | /src/storage/hash_tree/build_tree.rs | UTF-8 | 4,834 | 2.5625 | 3 | [] | no_license | use rocksdb::{Options, DB};
use sha2::{Digest, Sha256};
use sha2;
use std::fs;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::path::Path;
use std::str;
use crate::storage::files_list::{DataV1, FileStruct, Version};
use crate::Settings;
fn generate_lvl(db: &DB, start_from: u64, hash_count: u64) -> ... | true |
926a2ebc992b4b600072c5126304e6e57b231eb3 | Rust | ScoreUnder/adventofcode-solutions | /2020/15/numbers_game.rs | UTF-8 | 735 | 3.359375 | 3 | [] | no_license | use std::vec::Vec;
fn play_game(initial: Vec<i32>, max_turns: i32) -> i32 {
let mut acc = Vec::new();
acc.resize_with(max_turns as usize, || -1);
let max_turns = max_turns - 1;
let mut turn = 0;
for value in initial.iter() {
acc[*value as usize] = turn;
turn += 1;
}
let mu... | true |
2c8a1bfc8a8d128c0b24c6ee1f6301b481ade194 | Rust | agungdwiprasetyo/cart-demo.rs | /src/lib.rs | UTF-8 | 1,137 | 2.84375 | 3 | [] | no_license | pub mod product;
pub mod cart;
pub mod order;
#[cfg(test)]
mod tests {
use std::collections::HashMap;
use super::*;
use super::cart::item;
#[test]
fn create_order() {
let mut iphone_name = String::from("iphone v");
let mut iphone = product::Product::new(1, &mut iphone_na... | true |
d0caf04130e00f03459f2a85b6b3e553c923c42f | Rust | marco-sundsk/NCD-GroupA-Demo | /contract/dice/src/lib.rs | UTF-8 | 13,195 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | /*
* This is NearDice contract:
*
*
*
*/
// To conserve gas, efficient serialization is achieved through Borsh (http://borsh.io/)
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::wee_alloc;
use near_sdk::json_types::{U64, U128};
use near_sdk::serde::{Deserialize, Serialize};
use near... | true |
a0484918e814ebd33f4749743c5122090e06b948 | Rust | rust-rocksdb/rust-rocksdb | /src/ffi_util.rs | UTF-8 | 8,509 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2016 Alex Regueiro
//
// 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 wr... | true |
59fa77c35179820fc9bb239562c664d7619b290b | Rust | mverleg/prover | /src/lib.rs | UTF-8 | 1,249 | 2.640625 | 3 | [] | no_license | pub mod logic;
pub mod num;
pub mod notation;
pub mod util;
pub mod test_util;
#[cfg(test)]
#[allow(unreachable_code)]
mod tests {
use super::logic::*;
use super::notation::*;
use super::num::*;
use super::util::f32eq;
use super::test_util::assert_provable;
#[test]
fn test_pure_logic() {
... | true |
33cd466fb04bef73d1647cf5a2fc570b0b82b33f | Rust | doytsujin/yew | /examples/nested_list/src/main.rs | UTF-8 | 1,490 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod app;
mod header;
mod item;
mod list;
use std::cell::RefCell;
use std::fmt;
use std::ops::Deref;
use std::rc::Rc;
use yew::html::{Component, ImplicitClone, Scope};
pub struct WeakComponentLink<COMP: Component>(Rc<RefCell<Option<Scope<COMP>>>>);
impl<COMP: Component> Clone for WeakComponentLink<COMP> {
fn clo... | true |
00d7bace94edaf8631e349ad3776b0ce78e62641 | Rust | AKST/rs-ts-webgl-example | /runtime/src/render/constants.rs | UTF-8 | 5,757 | 2.6875 | 3 | [] | no_license | use web_sys::{WebGl2RenderingContext};
#[derive(Clone, Copy, Debug)]
pub enum DrawKind {
StaticDraw,
DynamicDraw,
StreamDraw,
}
pub trait HasDrawKind {
fn draw_kind_constant(&self) -> u32;
}
impl HasDrawKind for DrawKind {
fn draw_kind_constant(&self) -> u32 {
match self {
DrawKind::StaticDraw =>... | true |
7ae04042182107140d3ff651b0189492be9127d6 | Rust | Connicpu/TransCrossroadsBot | /src/state/challenge.rs | UTF-8 | 1,046 | 2.890625 | 3 | [] | no_license | use std::sync::RwLock;
use rand::{thread_rng, Rng};
use serenity::model::id::{ChannelId, MessageId};
#[derive(Default, Serialize, Deserialize)]
pub struct Code {
#[serde(skip)]
code: RwLock<Option<String>>,
#[serde(skip)]
purge_data: RwLock<Option<(ChannelId, Vec<MessageId>)>>,
}
impl Code {
pub ... | true |
bddf6a197d1ab23ad6078f0f5dae2bdb2fa54c37 | Rust | yunfengsay/learn_rust | /note/src/main.rs | UTF-8 | 2,809 | 3.25 | 3 | [] | no_license | extern crate chrono;
use chrono::prelude::*;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::fs::OpenOptions;
struct InputContent {
command: String,
content: String,
}
static FILE_PATH:&str = ".content.note";
fn main() -> io::Result<()> {
if ... | true |
fa928458ba2c5b1603b16833b2585850fed0ad62 | Rust | jonlil/AoC18 | /dec03/src/lib.rs | UTF-8 | 3,114 | 3.28125 | 3 | [
"MIT"
] | permissive | extern crate regex;
use std::fs;
use std::ops::{Add, Range};
use std::process;
use regex::Regex;
use std::str::FromStr;
pub struct Config {
pub filename: String,
}
impl Config {
pub fn new(args: &[String]) -> Result<Config, &'static str> {
let filename = args[0].clone();
Ok(Config { filename ... | true |
fbde75f2ae3522cd9d75f35b13e6b18723ee26f3 | Rust | feather-rs/feather | /feather/server/src/systems/block.rs | UTF-8 | 2,841 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | //! Implements block change broadcasting.
//!
//! # Bulk updates
//! The protocol provides three methods to change blocks
//! on the client:
//! * The `BlockChange` packet to update a single block.
//! * The `MultiBlockChange` packet to update multiple blocks
//! within a single chunk section.
//! * The `ChunkData` pac... | true |
6e4b0d09d00626e368d51a7520c7d79cf4c816dd | Rust | ndgndg91/rust-practice | /src/builtin/map_combinatior_practice.rs | UTF-8 | 557 | 3.46875 | 3 | [] | no_license | #[derive(Debug)]
struct User {
user_id: i64,
name: String
}
fn find_user(name: &str) -> Option<i64> {
let name = name.to_lowercase();
match name.as_str() {
"sam" => Some(1),
"matt" => Some(3),
"katie" => Some(9),
_ => None
}
}
pub fn practice() {
let user_name =... | true |
5af2b30b15c364d59d568e33fb7b54609a313b04 | Rust | lamnot/TPS-API-Reference-Implementations | /rs_cddl/src/cddl/ast.rs | UTF-8 | 3,447 | 2.546875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /***************************************************************************************************
* Copyright (c) 2020-2021 Jeremy O'Donoghue. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software... | true |
8fbc7c39b233b0b8993d1b7d3c04d54960949bd6 | Rust | 0ncorhynchus/tapl | /untyped/src/bin/untyped.rs | UTF-8 | 4,750 | 2.984375 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::{self, Write};
use untyped::*;
fn print(term: &Term, ctx: &Context) -> String {
match term {
Term::Var(idx) => ctx.get_name(*idx).expect("Invalid Index"),
Term::Abs(name, t) => format!("λ{}. {}", name, print(t, &ctx.add(name.clone()))),
Term::App(... | true |
3188211fd1ef476094379cc1b95748c9b0571576 | Rust | khalid-dev/aoc2020 | /day7_handy_haversacks/src/main.rs | UTF-8 | 4,818 | 3.203125 | 3 | [] | no_license | // Could have done better today; TODO: read more about Ownership in Rust
use std::fs;
use std::path::Path;
use regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
use queues::*;
fn parse_rules(rule_str: &str, value_re: &Regex, adjacencies_re: &Regex) -> (String, Vec<String>) {
// two scena... | true |
9d5ce7c85c0ca36fd5af9ba63f137f13c63b788e | Rust | jobdeng/rucene | /src/core/store/mod.rs | UTF-8 | 3,459 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Zhizhesihai (Beijing) Technology Limited.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by a... | true |
e3f8359bc512b73b49c1f723dcd58d4b77255851 | Rust | tokio-rs/tokio | /tokio/src/io/util/async_seek_ext.rs | UTF-8 | 2,792 | 3.390625 | 3 | [
"MIT"
] | permissive | use crate::io::seek::{seek, Seek};
use crate::io::AsyncSeek;
use std::io::SeekFrom;
cfg_io_util! {
/// An extension trait that adds utility methods to [`AsyncSeek`] types.
///
/// # Examples
///
/// ```
/// use std::io::{self, Cursor, SeekFrom};
/// use tokio::io::{AsyncSeekExt, AsyncReadEx... | true |
2e4be6b38f6bcec775d1cedb32a6e30abeb8b0f8 | Rust | tirust/msp432e4 | /src/hib/ris.rs | UTF-8 | 12,012 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | #[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::RIS {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | true |
6a197b937da7f7bccbcc687cb217a6eed7b40300 | Rust | gwierzchowski/GPW_Challenge | /src/main.rs | UTF-8 | 5,512 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::env;
use std::io;
use std::collections::VecDeque;
mod dijkstra_speed;
mod dijkstra_mem;
fn solver_factory(rows: DimType, cols: DimType) -> Result<impl Solver, &'static str> {
dijkstra_speed::Solver1::new_rc(rows, cols)
//dijkstra_mem::Solver1::new_rc(rows, cols)
}
fn main() -> Result<(), isize> {
... | true |
d0898d194b69e73fafc44df0d3f47a5bb48b1b8c | Rust | ThrudPrimrose/cyrillic | /src/main.rs | UTF-8 | 3,320 | 2.984375 | 3 | [
"MIT"
] | permissive | mod map;
extern crate clap;
use crate::map::map::FinalStates;
use clap::{Arg,App};
use std::fs;
use std::path::Path;
fn ends_with(s: &str, typename: &str) -> bool {
let size = s.len();
let chars = s.get(size-3..size);
match chars {
Some(s) => if s.eq(typename) {
return true
}e... | true |
db7b719598d95aab46f94fc10ef353d6c651cbb1 | Rust | ontio/ontio-wasm-build | /src/main.rs | UTF-8 | 2,665 | 2.703125 | 3 | [
"MIT"
] | permissive | use clap::{App, Arg};
use std::io::Write;
use std::path::{Path, PathBuf};
use anyhow::{bail, Context, Result};
mod build;
mod constants;
fn main() -> Result<()> {
let version = format!(
"{}.{}.{}{}",
env!("CARGO_PKG_VERSION_MAJOR"),
env!("CARGO_PKG_VERSION_MINOR"),
env!("CARGO_PKG... | true |
22b0bc489c66ef4040c03a176facdc4b126ae677 | Rust | schmidtuzar/bee-p | /bee-ternary/src/t4b1.rs | UTF-8 | 2,269 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use std::ops::Range;
use crate::{Trit, RawEncoding, RawEncodingBuf};
#[repr(transparent)]
pub struct T4B1([()]);
impl T4B1 {
unsafe fn make(ptr: *const u8, offset: usize, len: usize) -> *const Self {
let len = (len << 2) | (offset % 4);
std::mem::transmute((ptr.offset((offset / 4) as isize), len))... | true |
3ec05aa6e7317c95eec1c1c95ddb30ff41853557 | Rust | david0u0/adams-leaf | /src/util/dijkstra.rs | UTF-8 | 3,841 | 3.09375 | 3 | [] | no_license | use std::cell::Cell;
use std::collections::HashMap;
use std::hash::Hash;
use super::MyMinHeap;
use crate::graph_util::Graph;
pub struct Dijkstra<K: Hash + Eq + Copy, G: Graph<K>> {
pub(super) g: G,
final_dist_map: HashMap<(K, K), (f64, Cell<K>)>,
routed_node_table: HashMap<K, bool>,
}
impl<K: Hash + Eq +... | true |
cb6eeed83b681c67ed08c7f8c855e628f79d773a | Rust | GaloisInc/mir-verifier | /lib/liballoc/collections/btree/search.rs | UTF-8 | 2,961 | 3.296875 | 3 | [] | permissive | use core::borrow::Borrow;
use core::cmp::Ordering;
use super::node::{marker, ForceResult::*, Handle, NodeRef};
use SearchResult::*;
pub enum SearchResult<BorrowType, K, V, FoundType, GoDownType> {
Found(Handle<NodeRef<BorrowType, K, V, FoundType>, marker::KV>),
GoDown(Handle<NodeRef<BorrowType, K, V, GoDownT... | true |
dd74371deee7bcb8ecffbb62deedf18c8f3866ea | Rust | netzzitrone/aoc2019 | /src/day3.rs | UTF-8 | 12,724 | 3 | 3 | [] | no_license | #[allow(dead_code)]
pub mod part1 {
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Eq, Hash)]
struct Point {
x: i16,
y: i16
}
/* #[derive(PartialEq, Eq, Hash)]
enum CellState {
Em... | true |
bd74d671e000508889cf864f52ddbabf70013742 | Rust | cesarila/portal2-cm-boards-v2 | /server/src/main.rs | UTF-8 | 2,196 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use]
extern crate serde_derive;
use actix_web::{web, App, HttpServer, middleware::Logger};
use actix_cors::Cors;
use sqlx::PgPool;
use anyhow::{Result, Error};
use env_logger::Env;
use dotenv::dotenv;
/// Configuration module that handles extracting information from the environment for setup.
mod config;
/// ... | true |
f78fbf83030bfbeccd104c26197fc3ff31750324 | Rust | Raul6469/rs-neural-network | /src/neural_network/layer.rs | UTF-8 | 1,593 | 3.265625 | 3 | [] | no_license | use std::rc::Rc;
use std::cell::RefCell;
use super::neuron::Neuron;
pub struct Layer {
neurons: Vec<Rc<RefCell<Neuron>>>,
}
impl Layer {
pub fn new(nb_neurons: u32, previous_layer: Option<&Layer>) -> Layer {
let mut neurons = Vec::with_capacity(nb_neurons as usize);
let predecessors: Option<... | true |
b76312b57e5ea117a1f054823077bec6d153c255 | Rust | Pslydhh/futures-rs | /futures-util/src/future/into_stream.rs | UTF-8 | 1,286 | 3 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::mem::PinMut;
use futures_core::{Poll, Future, Stream};
use futures_core::task;
/// A type which converts a `Future` into a `Stream`
/// containing a single element.
#[must_use = "futures do nothing unless polled"]
#[derive(Debug)]
pub struct IntoStream<F: Future> {
future: Option<F>
}
pub fn new<F: Fut... | true |
ba6fdd8d8c683a18a026db318d0e162477c3a546 | Rust | inspier/stevia | /ast/src/terms/cast/concat.rs | UTF-8 | 2,904 | 3.046875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{
P,
ExprResult,
AnyExpr,
ExprError,
HasKind,
ExprKind,
HasArity,
ty::{
expect_bitvec_ty,
BitvecTy,
HasType,
Type,
},
expr::utils::BinaryChildren,
iter::{
Children,
ChildrenMut,
IntoChildren,
},
};
/// Bi... | true |
b9ca5c9918fc9f6d9bbdf681081c1bdff20479a6 | Rust | nushell/nushell | /crates/nu-command/tests/commands/every.rs | UTF-8 | 4,939 | 2.703125 | 3 | [
"MIT"
] | permissive | use nu_test_support::fs::Stub::EmptyFile;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn gets_all_rows_by_every_zero() {
Playground::setup("every_test_1", |dirs, sandbox| {
sandbox.with_files(vec![
EmptyFile("amigos.txt"),
EmptyFile("are... | true |
83a7000540b6d6b8d66ce5f3998b94b94b400681 | Rust | mindbeam/mindbase | /crates/mbql/src/search/context.rs | UTF-8 | 4,608 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::ast;
/// Context object for low level search operations
pub struct SearchContext<'a> {
scan_min: [u8; 64],
scan_max: [u8; 64],
gs_agents: Vec<AgentId>,
pub mb: &'a MindBase,
}
impl<'a> SearchContext<'a> {
pub fn new(mb: &'a MindBase) -> Self {
let gs_agents = mb.ground_symbol_ag... | true |
7c96992d9182f886b477dedced8e53a50a4c3cec | Rust | Clematrics/penGui | /src/widget/center.rs | UTF-8 | 3,721 | 2.890625 | 3 | [] | no_license | use nalgebra::*;
use crate::core::*;
use crate::loc;
/// A widget that can contain another one, but adjusting its layout with a small padding
/// on each side. An outline is displayed to show it
pub struct CenterLayout<T: WidgetBuilder> {
content: Option<T>,
}
impl<T: WidgetBuilder> CenterLayout<T> {
pub fn ... | true |
2453a27099073d431eef09e6c23917d15acac081 | Rust | lpil/exercism | /rust/sieve/src/lib.rs | UTF-8 | 384 | 3.109375 | 3 | [] | no_license | type Primes = Vec<usize>;
pub fn primes_up_to(max: usize) -> Vec<usize> {
let bound = (max as f64).sqrt().ceil() as usize;
let mut primes: Primes = vec![];
'outer: for prime in 2..(max + 1) {
for n in 2..bound {
if prime != n && prime % n == 0 {
continue 'outer;
... | true |
a39d6aad949f93e90f01b43df989474a4dff02cb | Rust | aspen-lang/aspen | /aspen/src/generation/jit.rs | UTF-8 | 2,438 | 2.546875 | 3 | [] | no_license | use crate::generation::{GenResult, Generator};
use crate::semantics::{Host, Module};
use crate::Context;
use inkwell::execution_engine::ExecutionEngine;
use inkwell::OptimizationLevel;
use std::sync::Arc;
use std::sync::Mutex;
lazy_static! {
static ref LOCK: Mutex<()> = Mutex::new(());
}
static mut CONTEXT: Optio... | true |
7a3c4d2f98280bf79be2db7180eed43f3e13f25b | Rust | iCodeIN/ybc | /src/components/menu.rs | UTF-8 | 3,515 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use yew::prelude::*;
use yewtil::NeqAssign;
#[derive(Clone, Debug, Properties, PartialEq)]
pub struct MenuProps {
#[prop_or_default]
pub children: Children,
#[prop_or_default]
pub classes: Option<Classes>,
}
/// A simple menu, for any type of vertical navigation.
///
/// [https://bulma.io/documentatio... | true |
50f250eda696e5d9af9a5556500feebf75120290 | Rust | utkarshkukreti/escodegen.rs | /src/walk.rs | UTF-8 | 3,203 | 2.6875 | 3 | [] | no_license | use {Expr, Stmt};
macro_rules! walk {
($stmt:ident, $expr:ident, $stmt_ty:ty, $expr_ty:ty) => {
pub fn $stmt(
stmt: $stmt_ty,
pre_stmt: &mut impl FnMut($stmt_ty),
post_stmt: &mut impl FnMut($stmt_ty),
pre_expr: &mut impl FnMut($expr_ty),
post_expr... | true |
4eaab0c9399435392607150fef825f60892a630e | Rust | Takashiidobe/minus | /examples/msg-tokio.rs | UTF-8 | 749 | 2.53125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use futures::join;
use std::time::Duration;
use tokio::time::sleep;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let output = minus::Pager::new().unwrap().finish();
let increment = async {
for i in 0..=10_u32 {
let mut output = output.lock().await;
... | true |
832663fa7b2b284cc013a6a650936323c4d7cb37 | Rust | TheCowKingmoo/gridlock | /src/input.rs | UTF-8 | 1,140 | 2.546875 | 3 | [] | no_license |
use sdl2::event::Event;
use sdl2::mouse::MouseButton;
use crate::Grid;
use crate::Constants;
use crate::Grid::Tile;
use sdl2::render::WindowCanvas;
use sdl2::event::EventType;
use sdl2::EventPump;
pub fn on_mouse_release( canvas: &mut WindowCanvas, tile_grid: &mut Vec<Tile>, width: u32, height: u32, last_idx: usize,... | true |
efe74e21f94ca77ef90e3cc790a1096ec8c9b412 | Rust | lfdominguez/elastic | /src/queries/src/lib.rs | UTF-8 | 15,094 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![feature(custom_attribute)]
#![feature(iterator_for_each)]
#![recursion_limit = "256"]
#[macro_use]
extern crate derive_builder;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[marco_use]
extern crate serde_json;
//extern crate error_chain;
mod aggregations;
mod filters;
pub mod prelude;
use aggregat... | true |
dc446f3f6a5491cac1e3b73bfb1da9112c0975c8 | Rust | MichaelSheely/succinct-scheduling | /src/repl.rs | UTF-8 | 727 | 2.59375 | 3 | [] | no_license | // Michael Sheely <msheely@hmc.edu>
// The Read Eval Print Loop for testing the parser
#[macro_use]
extern crate nom;
mod ir;
use std::io;
use nom::IResult;
fn main() {
let mut line = String::new();
while io::stdin().read_line(&mut line).map(|l| l > 0).unwrap_or(false) {
match ir::parse_txt(line.as_... | true |
d209aa73bb035b57fa508e454080a08fd3518692 | Rust | SweTailor94/AdventOfCode2020 | /day6/src/main.rs | UTF-8 | 1,992 | 3.515625 | 4 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead};
use std::collections::HashSet;
fn main() {
let data = get_decl_from_file("src/day6_input.txt");
// let mut count = 0;
println!("Data length {}" , data.len());
let val = data.iter().fold(0, | acc, set| acc + set.len() as i32 );
println!("Sum {}",... | true |
1eceaaca8fd0179487b756a521dd2d023b4d3637 | Rust | Goodjooy/msg_chain | /src/impls/mod.rs | UTF-8 | 3,922 | 3 | 3 | [] | no_license | use std::collections::HashMap;
use crate::{ChainMeta, IntoChainMeta, LoadFormMap, Number};
use crate::{FromChainMeta, MessageChain};
use serde::{ser::SerializeStruct, Serialize};
mod collection;
mod json;
mod number;
impl<T> IntoChainMeta for Option<T>
where
T: IntoChainMeta,
{
fn into_chain(&self) -> ChainM... | true |
acfcce07d5e9d86b74596d554663a1c94375e2f5 | Rust | jbayardo/rust-skiplist | /tests/iter.rs | UTF-8 | 1,807 | 3.234375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate skiplist;
use skiplist::*;
extern crate rand;
#[test]
fn iter_empty() {
let list: SkipListMap<i32, i32> = Default::default();
let mut iter = list.iter();
assert!(iter.next().is_none());
}
#[test]
fn iter_single() {
let key = 55;
let value = 231;
let mut list: SkipListMap<i32, i32... | true |
ac427b341916e76a06a34b8dcffc61ede3ed4b6a | Rust | authereum/zksync | /core/server/src/utils/current_zksync_info.rs | UTF-8 | 1,256 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use models::node::BlockNumber;
use std::sync::{
atomic::{AtomicU32, Ordering},
Arc,
};
use storage::ConnectionPool;
/// This struct knows current verified block number.
/// It's like storage, but in memory.
/// In the future, more fields might be added.
#[derive(Debug, Clone)]
pub struct CurrentZksyncInfo {
... | true |
ff1a4a24e6e18f20a268da3e6995f46f7303f3c5 | Rust | pact-foundation/pact-reference | /rust/pact_models/src/query_strings.rs | UTF-8 | 7,684 | 3.046875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::collections::HashMap;
use std::str::from_utf8;
use hex::FromHex;
use itertools::Itertools;
use serde_json::Value;
use tracing::{error, trace, warn};
use crate::PactSpecification;
/// Decodes a query string using a percent-encoding scheme
pub fn decode_query(query: &str) -> Result<String, String> {
let mut... | true |
17d4c6d00f4627eda452c963ebe30034087fde10 | Rust | mateusfreira/nun-db | /benches/nundb_benchmark.rs | UTF-8 | 22,483 | 2.578125 | 3 | [
"MIT"
] | permissive | use nundb::process_request::process_request;
use criterion::{criterion_group, criterion_main, Criterion};
use futures::channel::mpsc::{channel, Receiver, Sender};
use nundb::bo::*;
use std::collections::HashMap;
use std::sync::atomic::Ordering;
use std::sync::Arc;
fn criterion_benchmark(c: &mut Criterion) {
c.ben... | true |
496b09b0fc0e9990e970c7dd756bf654930db1e9 | Rust | TheZoq2/rc-protocols | /src/sbus.rs | UTF-8 | 15,104 | 2.84375 | 3 | [] | no_license | use heapless::{Vec, spsc::{Producer, Consumer}};
use heapless::consts::*;
const HEADER_BYTE: u8 = 0x0f;
const FOOTER_BYTE: u8 = 0x00;
const CHANNEL_AMOUNT: u8 = 16;
const CHANNEL_BYTE_COUNT: usize = 22;
#[derive(Debug, PartialEq)]
pub enum Error<E> {
MissingFooter,
Failsafe(SbusFrame),
MissingHeader,
... | true |
b5e57a6f71009ccba51dbebc729111cad211ef4e | Rust | dropbox/ruba | /src/mem_store/integers.rs | UTF-8 | 7,056 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use std::convert::From;
use std::{u8, u16, u32};
use bit_vec::BitVec;
use engine::typed_vec::TypedVec;
use engine::types::*;
use engine::vector_op::types::IntVecType;
use heapsize::HeapSizeOf;
use ingest::raw_val::RawVal;
use mem_store::column::{ColumnData, ColumnCodec};
use mem_store::point_codec::PointCodec;
use num... | true |
f9db6133fe71b624c49acbc3dd8cbe298062655c | Rust | pola-rs/polars | /py-polars/src/expr/string.rs | UTF-8 | 8,347 | 2.578125 | 3 | [
"MIT"
] | permissive | use polars::prelude::*;
use pyo3::prelude::*;
use crate::conversion::Wrap;
use crate::error::PyPolarsErr;
use crate::PyExpr;
#[pymethods]
impl PyExpr {
fn str_concat(&self, delimiter: &str) -> Self {
self.inner.clone().str().concat(delimiter).into()
}
#[pyo3(signature = (format, strict, exact, ca... | true |
2cedf3bcc878e03d251725dff70376c56b1ad632 | Rust | lk29/braiins-open | /utils-rs/logging/tests/panic.rs | UTF-8 | 1,593 | 2.515625 | 3 | [] | no_license | // Copyright (C) 2019 Braiins Systems s.r.o.
//
// This file is part of Braiins Open-Source Initiative (BOSI).
//
// BOSI is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
... | true |
189c0797ac42628f8c0fce0e0bdf220d54fd9660 | Rust | brace-rs/brace-rs | /crates/brace-theme/src/lib/template.rs | UTF-8 | 563 | 2.96875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::path::PathBuf;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum TemplateInfo {
Static { name: String, path: PathBuf },
Tera { name: String, path: PathBuf },
Text { name: String, text: String },
}
impl Template... | true |
7a93221991e6203c8ca5392602dfe925b49756ba | Rust | insanebits/gir | /src/analysis/out_parameters.rs | UTF-8 | 1,652 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::slice::Iter;
use std::vec::Vec;
use env::Env;
use library::*;
use super::type_kind::TypeKind;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Mode {
None,
Normal,
Optional,
}
impl Default for Mode {
fn default() -> Mode {
Mode::None
}
}
#[derive(Default)]
pub struct Info {... | true |
73d09f5d075ccae9b458b87d8dd444c343a203e7 | Rust | richardanaya/watson | /examples/simulator/src/lib.rs | UTF-8 | 3,114 | 2.859375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate alloc;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use watson::*;
extern "C" {
fn _log(msg: *const u8);
}
fn log(msg: &str) {
let mut s = msg.to_string();
s.push_str("\0");
unsafe { _log(s.as_ptr()) }
}
#[no_mangle]
fn malloc(size: usize) -> *mut u8 {
let mut buf = Ve... | true |
851ee6c5fcf49b616adca0f9d314f7aa27ff06bc | Rust | brunoczim/lockfree | /benchmark/src/mpsc.rs | UTF-8 | 5,217 | 2.78125 | 3 | [
"MIT"
] | permissive | extern crate lockfree;
use lockfree::channel::mpsc;
use std::{
collections::VecDeque,
sync::{mpsc as std_mpsc, Arc, Mutex},
thread,
time::{Duration, Instant},
};
fn measure<C>(senders: usize, niter: u128) -> Duration
where
C: Channel,
{
let (sender, mut receiver) = C::create();
let then = ... | true |
2b1db28102c30ee7ae9a425fdc98e7d315f134b8 | Rust | guilhemSmith/computor_v2 | /src/lexer/token/matrix.rs | UTF-8 | 10,018 | 2.765625 | 3 | [] | no_license | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* matrix.rs :+: :+: :+: ... | true |
fff0b7195a3a0735138e4dbc702d14702c91eb45 | Rust | cen5bin/io_utils | /src/file/binary_file.rs | UTF-8 | 1,215 | 2.96875 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::mem::size_of;
pub struct BinaryFile {
f: File,
val_buf: Vec<u8>,
}
macro_rules! read_val_func {
($func:tt, $ty:ty) => {
#[inline]
pub fn $func(&mut self) -> Option<$ty> {
let size = self.... | true |
2c8406fffdca768694903ac0327678103af6e4be | Rust | TheLostLambda/dijkstra | /src/util/path.rs | UTF-8 | 2,648 | 4 | 4 | [] | no_license | //! Provides the Path type returned by the shortest_path() function and some methods for reading it
// Imports
use super::*;
use std::fmt;
/// The Path struct stores a series of vertices.
///
/// Each of these vertices is connected to the vertices before and after it and all the vertices are
/// ordered with the firs... | true |
08ba3a6fe2f367f6deb7c90ca7d68572b4f0200c | Rust | whitfin/efflux | /src/context/conf.rs | UTF-8 | 3,164 | 3.78125 | 4 | [
"MIT"
] | permissive | //! Module to provide representation of the Hadoop `Configuration` class.
use std::collections::HashMap;
use std::env;
/// Configuration struct to represent a Hadoop configuration.
///
/// Internally this is simply a `String` -> `String` map, as
/// we don't have enough information to parse with. The struct
/// implem... | true |
686a172bee4cb2ca8fdabbeb1dfb905ce07ed63f | Rust | crossterm-rs/crossterm | /src/terminal/sys/file_descriptor.rs | UTF-8 | 2,377 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::{
fs, io,
os::unix::{
io::{IntoRawFd, RawFd},
prelude::AsRawFd,
},
};
use libc::size_t;
/// A file descriptor wrapper.
///
/// It allows to retrieve raw file descriptor, write to the file descriptor and
/// mainly it closes the file descriptor once dropped.
#[derive(Debug)]
pub st... | true |
ce8adfeda1ce7b6d7a59cc84e0195878f7b5d2da | Rust | m-kann0/atcoder-rust | /examples/arc057_b.rs | UTF-8 | 2,661 | 3.3125 | 3 | [] | no_license | #![allow(non_snake_case)]
use std::io::Read;
use std::cmp::min;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).unwrap();
let answer = solve(&buf);
println!("{}", answer);
}
fn solve(input: &str) -> String {
let mut iterator = input.split_whitespace();
le... | true |
a0e9d2586308c1cc4c396121f9e2eb75a5d40ac2 | Rust | oloshe/rust-huffman | /src/main.rs | UTF-8 | 3,198 | 3.1875 | 3 | [] | no_license | use std::{fs::File, io::{Read, Write}, process::exit};
use crate::huffman::*;
mod huffman;
fn main() {
println!("【哈夫曼压缩】");
loop {
println!("1. 压缩文件\t2. 解压文件\t3. 退出");
match read().as_str() {
"1" => {
println!("待压缩文件路径名:");
let file = read();
... | true |
5cd1d4ccf419765ccdd1a3f5aa521d7491a2a4f9 | Rust | dobkeratops/thRustEngine | /r3d/vertex.rs | UTF-8 | 4,823 | 2.921875 | 3 | [] | no_license | use super::*;
// N normal
// C packed-color
// FC=Float Color.
// T texcoord
// P position
// D DiffuseColor
// W weights
// B bones
// S specularColor
// FC=FloatColor, the unusual attribute
// packed color vs float color
// blend weights
// Todo ..
// would we make Vertex<POS,Color=Vec4f, Tex=Vec2f, ()>
// .. a... | true |
ff44fe135bedc076b2fc13a45598f7271eff7d7f | Rust | wgwoods/atsamd | /pac/atsamd51j19a/src/sdhc0/aesr.rs | UTF-8 | 2,761 | 2.65625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = "Reader of register AESR"]
pub type R = crate::R<u8, super::AESR>;
#[doc = "ADMA Error State\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum ERRST_A {
#[doc = "0: ST_STOP (Stop DMA)"]
STOP,
#[doc = "1: ST_FDS (Fetch Descriptor)"]
FDS,
#[doc = "3: ST_TFR (Transfer Dat... | true |
55dd6d45a2db4fb4d3fa144a21efcba52619361e | Rust | dstaatz/parry | /src/query/nonlinear_time_of_impact/nonlinear_time_of_impact_support_map_support_map.rs | UTF-8 | 5,966 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use na::{ComplexField, Unit};
use crate::math::{Isometry, Point, Real, Vector};
use crate::motion::RigidMotion;
use crate::query::{self, ClosestPoints, TOIStatus, TOI};
use crate::shape::SupportMap;
use num::Bounded;
/// Time of impacts between two support-mapped shapes under a rigid motion.
pub fn nonlinear_time_of... | true |
c1a2ffbeaf842a5aa936e92981cf13b113901fc5 | Rust | m00p1ng/kattis-problem | /LV1/1.6/sumkindofproblem/sumkindofproblem.rs | UTF-8 | 501 | 3.109375 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let stdin = io::stdin();
let mut buff = String::new();
stdin.read_line(&mut buff).unwrap();
for line in stdin.lock().lines().map(|l| l.unwrap()) {
let num: Vec<i32> = line
.split_whitespace()
.map(|n| n.parse().unwrap())
... | true |
acdf1a9d688138854df88ff3432a8b77a0bf5ab1 | Rust | liljencrantz/crush | /src/lang/serialization/string_serializer.rs | UTF-8 | 2,265 | 3.0625 | 3 | [
"MIT"
] | permissive | use crate::lang::errors::{error, CrushResult};
use crate::lang::serialization::model::{element, Element, Strings};
use crate::lang::serialization::{DeserializationState, Serializable, SerializationState};
use crate::lang::value::Value;
use std::collections::hash_map::Entry;
impl Serializable<Vec<String>> for Vec<Strin... | true |
74a60699fd960c4f315fb7f9d33e69a31b1c0a3e | Rust | Pluriscient/rust-sudoku-solver | /src/sudokutwo/sudoku_get_indices.rs | UTF-8 | 1,245 | 2.96875 | 3 | [] | no_license | use crate::sudokutwo::Sudoku;
impl Sudoku {
/// Get all the indices of the given block (at the given block index)
pub(crate) fn get_block_indices_by_cell_index(cell_index: usize) -> Vec<usize> {
let box_col = (cell_index % 9) / 3;
let box_row = cell_index / 27;
return Sudoku::get_block_... | true |
db52e5c0074b4ae19800bb5d6383ef5774872802 | Rust | chaynabors/gear | /src/audio.rs | UTF-8 | 1,126 | 2.53125 | 3 | [] | no_license | // Copyright 2021 Chay Nabors.
use std::fmt::Debug;
use log::info;
use rodio::OutputStream;
use rodio::OutputStreamHandle;
use crate::Sound;
pub struct AudioSource {
pub(crate) sink: rodio::Sink,
}
impl AudioSource {
pub fn queue_sound(&self, sound: &Sound) -> &Self {
self.sink.append(sound.decoder... | true |
b314c359a194b5e753aad9c7207f0378c4f710a7 | Rust | camshaft/xsk-rs | /tests/setup/veth_setup.rs | UTF-8 | 3,069 | 2.90625 | 3 | [
"MIT"
] | permissive | use futures::stream::TryStreamExt;
use rtnetlink::Handle;
use std::sync::atomic::{AtomicUsize, Ordering};
use tokio::task;
static COUNTER: AtomicUsize = AtomicUsize::new(0);
struct VethLink {
handle: Handle,
dev1_index: u32,
}
async fn get_link_index(handle: &Handle, name: &str) -> anyhow::Result<u32> {
... | true |
585a147a89f7e7a2737d2b8946905669093cf558 | Rust | maobisheng/rust-fil-proofs | /storage-proofs/src/zigzag_graph.rs | UTF-8 | 21,909 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashMap;
use std::marker::PhantomData;
use std::sync::{Arc, RwLock};
use crate::crypto::feistel::{self, FeistelPrecomputed};
use crate::drgraph::{BucketGraph, Graph, BASE_DEGREE};
use crate::hasher::Hasher;
use crate::layered_drgporep::Layerable;
use crate::parameter_cache::ParameterSetMetadata;
... | true |
6693f977ef3ef66a3343e8d26ad926f023e60e7a | Rust | blueluna/psila | /psila-service/src/security/mod.rs | UTF-8 | 3,149 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::Error;
use psila_crypto::CryptoBackend;
use psila_data::{
application_service::commands::transport_key::NetworkKey,
network::NetworkHeader,
pack::Pack,
security::{CryptoProvider, KeyIdentifier, SecurityHeader, SecurityLevel},
ExtendedAddress, Key,
};
pub struct SecurityManager<CB> {
... | true |
06e51fe48e057ee8cec67e69684c45bcd4f554f3 | Rust | iPixelOldC/winsafe | /src/gui/events/events_en.rs | UTF-8 | 4,830 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::ptr::NonNull;
use crate::co;
use crate::gui::base::Base;
use crate::gui::events::WindowEvents;
ctrl_events_proxy! {
/// Exposes edit control
/// [notifications](https://docs.microsoft.com/en-us/windows/win32/controls/bumper-edit-control-reference-notifications).
///
/// These event methods are ... | true |
17c609b7894c00645bc8e719a5340d76a5599000 | Rust | N2D4/advent-of-code-2020 | /src/d17p1_conway_cubes.rs | UTF-8 | 2,854 | 3.078125 | 3 | [] | no_license | use crate::util;
use itertools::Itertools;
fn solve<T: AsRef<[bool]>>(input: impl AsRef<[T]>, steps: usize) -> i32 {
(0..steps)
.fold(
vec![input.as_ref().iter().map(|x| x.as_ref().to_vec()).collect()],
|i, _| step(i),
)
.iter()
.map(|x| {
x.iter(... | true |
33717741183f08de70f505777f247306e8b7de9f | Rust | truboxl/wapm-cli | /src/commands/install.rs | UTF-8 | 5,815 | 2.671875 | 3 | [
"MIT"
] | permissive | //! Code pertaining to the `install` subcommand
use crate::graphql::execute_query;
use graphql_client::*;
use crate::config::Config;
use crate::dataflow;
use crate::util;
use std::borrow::Cow;
use std::env;
use std::path::Path;
use structopt::StructOpt;
use thiserror::Error;
/// Options for the `install` subcommand... | true |
ce1143ff89b7e8fd8cfe372737411aa137e55986 | Rust | fewensa/rtdlib | /src/types/photo.rs | UTF-8 | 2,189 | 2.9375 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
/// Describes a photo
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Photo {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@extra", des... | true |
361c8d7d615657bbdbd59437d3c40e784d53d33e | Rust | msehnout/Advent-of-code | /d3/src/main.rs | UTF-8 | 2,384 | 3.21875 | 3 | [
"Unlicense"
] | permissive | extern crate regex;
use regex::Regex;
use std::str::FromStr;
use std::cmp;
use std::env;
use std::io::BufReader;
use std::io::BufRead;
use std::io::Read;
use std::fs::File;
fn is_triangle(sample: (u32, u32, u32)) -> u32 {
let mut v = vec![sample.0, sample.1, sample.2];
v.sort();
if v[2] < (v[1] + v[0]) {
... | true |
08525c77747c427ec08b1f6dd927334de635701e | Rust | cwenck/stock-sim | /src/pricing/period.rs | UTF-8 | 1,146 | 3.296875 | 3 | [] | no_license | use std::{cmp::Ordering, hash::Hash};
#[allow(dead_code)]
#[derive(Debug, Clone, Copy)]
pub enum Period {
Days(u64),
Years(u32),
}
impl Period {
pub const MARKET_DAYS_PER_YEAR: u64 = 253;
pub fn as_days(&self) -> u64 {
use Period::*;
match *self {
Days(val) => val,
... | true |
c60196bbf8553d8cc64e57badbd175f509910223 | Rust | Danue1/Danuel | /engine/src/character/player/mod.rs | UTF-8 | 708 | 2.8125 | 3 | [] | no_license | pub mod player_builder;
use crate::{ClassId, ItemCount, ItemId, Named, Stat};
pub use player_builder::*;
#[derive(Debug)]
pub enum PlayerError {
UnspecifiedName,
UnspecifiedClass,
UnspecifiedLevel,
UnspecifiedHealth,
UnspecifiedMana,
UnspecifiedStamina,
UnspecifiedStat,
UnspecifiedItem... | true |
860b7f5e462e4ee9f6550ee90d0a1a481718802d | Rust | roy-ganz/toql | /crates/core/src/table_mapper_registry.rs | UTF-8 | 2,084 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! A registry for all table mappers.
use crate::{
field_handler::FieldHandler, result::Result, table_mapper::mapped::Mapped,
table_mapper::TableMapper,
};
use heck::MixedCase;
use std::collections::HashMap;
/// The registry hold all table mappers togheter.
#[derive(Debug)]
pub struct TableMapperRegistry {
... | true |
c322189786fb33727b130f6c70d4e25a72e7629a | Rust | aimof/rust_sandbox | /escape/src/main.rs | UTF-8 | 789 | 2.890625 | 3 | [] | no_license | extern crate getch;
use getch::Getch;
use std::sync::mpsc::channel;
use std::thread::spawn;
use std::result::Result;
use std::io::Error;
fn main() {
println!("If you want to stop, please press x key!");
let (sender, receiver) = channel();
spawn(move || {
loop{
let g: Result<Getch, Err... | true |
b43fdf315d449ec08202582531995f7cc448f15f | Rust | afirago/ultrascale-plus | /firmware/zup-rtfm/macros/src/syntax.rs | UTF-8 | 30,318 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::{
collections::{BTreeMap, HashMap, HashSet},
iter, u8,
};
use proc_macro2::Span;
use syn::{
braced, bracketed, parenthesized,
parse::{self, Parse, ParseStream},
punctuated::Punctuated,
spanned::Spanned,
token::Brace,
ArgCaptured, AttrStyle, Attribute, Expr, FnArg, Ident, IntSuf... | true |
a64364d4df1c46cdf318bd214b146e548c78e4d6 | Rust | icechair/advent-of-code-2020 | /day1/src/main.rs | UTF-8 | 1,232 | 3.03125 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
where
P: AsRef<Path>,
{
let file = File::open(filename)?;
Ok(io::BufReader::new(file).lines())
}
fn main() {
let args: Vec<String> = env::args... | true |
f5f2925b4d8c943acfaf080299fd622d1886dd65 | Rust | kawashige/exercism | /rust/rna-transcription/src/lib.rs | UTF-8 | 1,210 | 3.375 | 3 | [] | no_license | #[derive(Debug, PartialEq)]
pub struct Dna {
nucleotides: Vec<char>,
}
#[derive(Debug, PartialEq)]
pub struct Rna {
nucleotides: Vec<char>,
}
impl Dna {
pub fn new(dna: &str) -> Result<Dna, usize> {
let mut nucleotides = Vec::with_capacity(dna.len());
for (i, c) in dna.chars().enumerate() ... | true |
4bc8c1f4450044c53363c18484e79c13d9384329 | Rust | GaloisInc/mir-verifier | /lib/libcore/num/flt2dec/estimator.rs | UTF-8 | 568 | 3.328125 | 3 | [] | permissive | //! The exponent estimator.
/// Finds `k_0` such that `10^(k_0-1) < mant * 2^exp <= 10^(k_0+1)`.
///
/// This is used to approximate `k = ceil(log_10 (mant * 2^exp))`;
/// the true `k` is either `k_0` or `k_0+1`.
#[doc(hidden)]
pub fn estimate_scaling_factor(mant: u64, exp: i16) -> i16 {
// 2^(nbits-1) < mant <= 2... | true |
8cd74bc481db24b00ab86d51f88af1e4a9868188 | Rust | cryscan/ceramic | /src/systems/animal/track.rs | UTF-8 | 3,784 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::f32::{consts::FRAC_PI_2, EPSILON};
use amethyst::{
assets::PrefabData,
core::{math::{UnitQuaternion, Vector3}, Time, Transform},
derive::SystemDesc,
ecs::{Component, prelude::*},
error::Error,
};
use serde::{Deserialize, Serialize};
use ceramic_derive::Redirect;
use redirect::Redirect;
u... | true |
f15b0ade478e7254d4973473c58dee48b46aa0f8 | Rust | reinterpretcat/vrp | /vrp-core/src/models/common/domain.rs | UTF-8 | 7,810 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(test)]
#[path = "../../../tests/unit/models/common/domain_test.rs"]
mod domain_test;
use crate::models::common::{Duration, Timestamp};
use hashbrown::HashMap;
use rosomaxa::prelude::compare_floats;
use rustc_hash::FxHasher;
use std::any::Any;
use std::cmp::Ordering;
use std::hash::{BuildHasherDefault, Hash, Hash... | true |
573862ecbf9f17105b27f172cc17cc4c047f5df5 | Rust | ia7ck/competitive-programming | /AtCoder/abc212/src/bin/e/main.rs | UTF-8 | 878 | 2.546875 | 3 | [] | no_license | use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: usize = rd.get();
let m: usize = rd.get();
let k: usize = rd.get();
let mut compl_g = vec![vec![]; n];
for _ in 0..m {
let u: usize = rd.get();
le... | true |
940f81469d3d02805af36abfc986128adce1d63d | Rust | zaksky7/Rust-project | /src/year2015/day21.rs | UTF-8 | 3,346 | 3.265625 | 3 | [] | no_license | use itertools::Itertools;
use std::cmp::max;
use std::ops::Add;
#[derive(Clone, Copy)]
struct Equip {
cost: i32,
damage: i32,
armor: i32,
}
impl Add<Equip> for Equip {
type Output = Equip;
fn add(self, rhs: Equip) -> Equip {
Equip {
cost: self.cost + rhs.cost,
dama... | true |
d8706cda26bbb9d1cf85b8b94eca8d2a5b4f728b | Rust | tahir-ali110/Assignment7 | /aly2020/src/main.rs | UTF-8 | 782 | 3.234375 | 3 | [] | no_license | mod printing {
pub mod math{
pub fn table(data:u32){
println!("Calcuations");
for count in 1..=3{
println!("{}*{}={}", data,count,data*count);
}
}
}
}
pub mod lib;
use std::io;
fn main() {
loop {
println!("Please input your number:... | true |
7739dbe6523d85b869bd5de54780d2403ddf58d8 | Rust | uuhan/yata | /src/methods/swma.rs | UTF-8 | 4,907 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use crate::core::{Error, Method, PeriodType, ValueType, Window};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Symmetrically Weighted Moving Average of specified `length` for timeseries of [`ValueType`].
///
/// F.e. if `length = 4`, then weights are: `[ 1.0, 2.0, 2.0, 1.0 ]`.
///
/// If `length ... | true |
9411664f1b2a32a675643e6b817a06d537c37cc4 | Rust | filosofis/advent-of-code-2020 | /src/dec_01.rs | UTF-8 | 611 | 3.234375 | 3 | [] | no_license | use std::fs;
pub fn run() {
let data = fs::read_to_string("input_01.txt").expect("Unable to read file");
for num_a in data.lines() {
for num_b in data.lines() {
for num_c in data.lines() {
let a: u32 = num_a.parse().unwrap();
let b: u32 = num_b.parse().unwra... | true |
1f003d416bf3f1b125f0307aebf9644aa4f29b81 | Rust | FuGangqiang/mdblog.rs | /src/theme.rs | UTF-8 | 5,111 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::path::{Path, PathBuf};
use log::{debug, info};
use tera::Tera;
use crate::error::{Error, Result};
use crate::utils::{read_file, write_file};
macro_rules! try_init_template {
($render:expr, $tpl_name:expr, $tpl_str:expr) => {
let template_content = match std::str::from_utf8(&$tpl_str) {
... | true |
4ab7deba18dc662f2fde57f06e35e0e4df8b3085 | Rust | cleonty/programming-rust | /input-and-output/src/main.rs | UTF-8 | 1,647 | 3.09375 | 3 | [] | no_license | #![allow(dead_code)]
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::{self, ErrorKind, Read, Write};
const DEFAULT_BUF_SIZE: usize = 8 * 1024;
pub fn copy_clone<R: ?Sized, W: ?Sized>(reader: &mut R, writer: &mut W) -> io::Result<u64>
where
R: Read,
W: Write,
{
let mut buf =... | true |
9d52e7044b9a8413c076dc29b0dc9c3170ad538e | Rust | plorefice/chip8-rs | /chip8/src/periph.rs | UTF-8 | 1,732 | 3.21875 | 3 | [] | no_license | #[derive(Default)]
pub struct Timer {
counter: u8,
}
impl Timer {
pub fn value(&self) -> u8 {
self.counter
}
pub fn reload(&mut self, v: u8) {
self.counter = v;
}
pub fn is_active(&self) -> bool {
self.counter != 0
}
pub fn tick(&mut self) {
if self.is... | true |
1936b3e9fab527b855670208cac020a743515336 | Rust | artichoke/ferrocarril | /mruby-bin/src/parser.rs | UTF-8 | 5,980 | 3.296875 | 3 | [
"MIT"
] | permissive | //! Parser for Ruby code that determines if it is fit to eval on an interpreter.
use mruby::sys;
use mruby::Mrb;
use std::convert::TryFrom;
use std::ffi::CStr;
/// State shows whether mruby can parse some code or why it cannot. This enum
/// only encapsulates whether mruby can parse the code. It may still have
/// sy... | true |
af21d8747a6d9b6bdf00e292e800c560b005e32e | Rust | irevoire/watchexec | /lib/src/watcher.rs | UTF-8 | 1,732 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use log::debug;
use notify::{raw_watcher, PollWatcher, RecommendedWatcher, RecursiveMode};
use std::convert::TryFrom;
use std::path::PathBuf;
use std::sync::mpsc::Sender;
use std::time::Duration;
/// Thin wrapper over the notify crate
///
/// `PollWatcher` and `RecommendedWatcher` are distinct types, but watchexec
///... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.