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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25192e1f913866955aa50b963163dab6934cf28a | Rust | kyleoneill/adventofcode | /2019/1/1.rs | UTF-8 | 794 | 3.34375 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, prelude::*, BufReader};
fn main() -> io::Result<()> {
let file = File::open("input.txt")?;
let reader = BufReader::new(file);
let mut required_fuel: i64 = 0;
for line in reader.lines() {
let mass: i32 = line?.parse().unwrap();
required_fuel += get_... | true |
a377564effa28fefa764b2cc4acdbe37143f460a | Rust | KillingSpark/rustysd | /src/runtime_info.rs | UTF-8 | 2,126 | 2.953125 | 3 | [
"MIT"
] | permissive | //! The RuntimeInfo encapsulates all information rustysd needs to do its job. The units, the pid and filedescriptors and the rustysd config.
//! In the lifetime of ruytsd there will only ever be one RuntimeInfo which is passed wrapped inside the ArcMutRuntimeInfo.
//!
//! The idea here is to make as much as possible co... | true |
8d7bd163850da5f729d87b547b9a6cecd716b92f | Rust | cmnord/learning-rust | /src/08-flow-of-control/loop.rs | UTF-8 | 1,027 | 3.625 | 4 | [
"MIT"
] | permissive | #![allow(unreachable_code)]
fn main() {
let mut count = 0u32;
println!("let's count until infinity!");
loop {
count += 1;
if count == 3 {
println!("three");
continue;
}
println!("{}", count);
if count == 5 {
println!("ok, tha... | true |
590fff15e401966be5324bcb88ab5c3042a952f6 | Rust | yjhmelody/learn-rust | /image/src/main.rs | UTF-8 | 2,618 | 3.4375 | 3 | [] | no_license | extern crate lodepng;
use lodepng::RGB;
fn main() {
let bitmap = lodepng::decode24_file("0.png").unwrap();
let (width, height) = (bitmap.width, bitmap.height);
println!("width={},height={}", width, height);
let buffer = edge_detection(&bitmap.buffer, width, height, 127.0);
lodepng::encode24_f... | true |
2a88f0304263fbfc9a7f92a5b232a54838c3ad2b | Rust | bububa/jos-rs | /src/request/account/get_account_info.rs | UTF-8 | 3,759 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use crate::client::{APIError, Error, Request, Response, ResponseError};
use num::Zero;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Default, Debug)]
pub struct GetAccountInfoRequest {
#[serde(rename = "accountType")]
account_type: u16,
#[serde(rename = "accountCode")]
account_c... | true |
d45b411e2489f8ffbbfc7f04749ea0c73f0df8de | Rust | npmccallum/cbor | /src/codec.rs | UTF-8 | 2,202 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Encoding and decoding for tokio
use crate::error::Category;
use crate::Error;
use std::marker::PhantomData;
use bytes::{buf::ext::BufMutExt, buf::Buf, BytesMut};
use serde::de::DeserializeOwned;
use serde::Serialize;
use tokio_util::codec;
/// A `tokio_util::codec::Encoder` for CBOR frames
pub struct Encoder<T:... | true |
0c6695fb48f8518f632e28f411d79382f6db3863 | Rust | yazgoo/bema | /examples/basic.rs | UTF-8 | 5,506 | 2.8125 | 3 | [] | no_license | extern crate bema;
use plotters::prelude::*;
use bema::*;
use indoc::indoc;
use compile_time_run::run_command;
use image::ImageBuffer;
use image::DynamicImage;
fn image_from_plot(width: usize, height: usize, f: &dyn Fn(BitMapBackend) -> Result<(), Box<dyn std::error::Error>>) -> Result<Vec<u8>, Box<dyn std::error::Er... | true |
566a9bec67a0849de00c245e76e5e657e2c42c55 | Rust | gridbugs/apocalypse-post | /src/game/renderer_buffers.rs | UTF-8 | 624 | 2.875 | 3 | [
"MIT"
] | permissive | use game::*;
pub struct RendererBuffers {
pub tiles: TileBuffer,
pub message_log: Vec<Message>,
}
impl RendererBuffers {
pub fn new(width: usize, height: usize, num_lines: usize) -> Self {
let mut message_log = Vec::new();
for _ in 0..num_lines {
message_log.push(Message::new()... | true |
1edbf1098c4cc4aa830eced7501fae13c30af9d7 | Rust | carped99/mago3d-converter | /tiles3d/tests/bounding_volume_test.rs | UTF-8 | 467 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use serde_json::{Result, Value};
use tiles3d::types::bounding_volume::BoundingVolume;
#[test]
fn it_adds_two() -> Result<()> {
let data = r#"
{
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
}
"#;
let v: BoundingVolume = serde_json::from_s... | true |
78ae59f8de53f5e4e0c958457d668a6dc8059d07 | Rust | lperson/spotifytops | /src/lib/throttling_future.rs | UTF-8 | 3,952 | 2.890625 | 3 | [] | no_license | use futures::{task, Async, Future, Poll};
use std::boxed::Box;
use std::collections::VecDeque;
use std::sync::{
atomic::{AtomicUsize, Ordering},
RwLock,
};
#[derive(Debug)]
pub struct ThrottlingFutureQueue {
sequences_in_progress: Vec<usize>,
waiting_sequences: VecDeque<usize>,
}
impl ThrottlingFuture... | true |
aaf61ff77434dca7e322947a5aa7390d82de108e | Rust | Rustops/dwarf_seeks_fortune | /dsf_core/src/resources/adventure.rs | UTF-8 | 6,404 | 2.75 | 3 | [
"BlueOak-1.0.0"
] | permissive | use std::collections::HashMap;
use std::fs;
use std::path::Path;
use amethyst::config::ConfigError;
use amethyst::prelude::*;
use amethyst::renderer::palette::Srgba;
use amethyst::renderer::resources::Tint;
use serde::{Deserialize, Serialize};
use crate::components::{MapCursor, Pos};
use crate::levels::{load_asset_fr... | true |
f851572e5a892ae53242ec53a743faf04e73dbdd | Rust | simensgreen/bevy | /crates/bevy_render/src/draw.rs | UTF-8 | 12,158 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use crate::{
pipeline::{
IndexFormat, PipelineCompiler, PipelineDescriptor, PipelineLayout, PipelineSpecialization,
},
renderer::{
AssetRenderResourceBindings, BindGroup, BindGroupId, BufferId, RenderResource,
RenderResourceBinding, RenderResourceBindings, RenderResourceContext, Shar... | true |
1b2630f5bb80ce605cb4a0eaf55763e4b58c6187 | Rust | pnkfelix/euca | /src/diff.rs | UTF-8 | 34,971 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Tools to get the difference between two virtual dom trees.
use std::fmt;
use std::iter;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::hash::Hash;
use crate::patch::PatchSet;
use crate::patch::Patch;
use crate::vdom::DomItem;
use crate::vdom::WebItem;
/// Return the series of steps... | true |
dc80fa7856c08bf12de4e80708e3bc43615fdb01 | Rust | dtolnay-contrib/shipyard | /src/erased_serde/macros.rs | UTF-8 | 4,224 | 2.78125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // This file was modified and is not the same as the one present in erased_serde.
/// Implement `serde::Serialize` for a trait object that has
/// `erased_serde::Serialize` as a supertrait.
macro_rules! serialize_trait_object {
($($path:tt)+) => {
__internal_serialize_trait_object!(begin $($path)+);
};... | true |
f3684b0dca09a038a9834d988503faec5a16c9e3 | Rust | DimChtz/rust-fstream | /src/lib.rs | UTF-8 | 3,929 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::fs::OpenOptions;
use std::io::{Read, Write};
use std::path::Path;
use std::convert::AsRef;
use std::option::Option;
use std::fmt::Arguments;
pub fn read<P: AsRef<Path>>(src:P) -> Option<Vec<u8>> {
return match File::open(src) {
Ok(mut file) => {
... | true |
61cd5ec01dec0a113235f8eb4657a887d33a527e | Rust | justinpombrio/synless | /frontends/src/terminal/screen_buf.rs | UTF-8 | 18,901 | 3.5 | 4 | [] | no_license | use super::TermError;
use partial_pretty_printer::{pane::PrettyWindow, Pos, ShadedStyle, Size, Width};
/// Represents a screen full of characters. It buffers changes to the
/// characters, and can produce a set of instructions for efficiently updating
/// the screen to reflect those changes.
#[derive(Debug)]
pub struc... | true |
a9c3289736256380465d4151dcd7d994ec9f7c21 | Rust | willcrichton/rapier | /src/geometry/z_order.rs | UTF-8 | 1,651 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | use num_traits::float::FloatCore;
use std::cmp::Ordering;
#[allow(dead_code)] // We don't use this currently, but migth in the future.
pub fn z_cmp_ints(lhs: &[usize], rhs: &[usize]) -> Ordering {
assert_eq!(
lhs.len(),
rhs.len(),
"Cannot compare array with different lengths."
);
l... | true |
f8e22217f2e01e625370158dd43a961f490e6c82 | Rust | OragonEfreet/sage_mqtt | /src/packet_type.rs | UTF-8 | 1,150 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::QoS;
/// The control packet type is present as the first element of the fixed header
/// in an MQTT paquet. It is encoded in a 8bit flag set where the 4 most
/// significant bits represent the type of the paquet and the 4 least are flags
/// where values depend on the type.
#[derive(Debug, Clone, Copy)]
pub... | true |
687018e7c5301457548705bdc8a5e53cb7578705 | Rust | willfindlay/aoc2020 | /will-cargo-aoc/src/day17.rs | UTF-8 | 4,548 | 2.890625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use std::collections::HashMap;
#[aoc_generator(day17, part1)]
pub fn input_generator_part1(input: &str) -> Result<HashMap<(i64, i64, i64), bool>> {
let mut state = HashMap::new();
for (i, line) in input.lines().enumerate() {
for (j, c) in line.chars().enumerate() {
state... | true |
d289f91d9ea25836de1dfa41b833aa74fb0d9f1e | Rust | Toyotomius/Rust-Tinkering | /LotteryRust/src/lottoexample.rs | UTF-8 | 1,808 | 3.0625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::time::Instant;
#[derive(Serialize, Deserialize, Debug)]
struct Lotto {
#[serde(alias = "Lotto649")]
lotto649: Vec<LottoData>,
}
#[derive(Serialize, Deserialize, Debug)... | true |
2d2a213915ef34c7a061fbe7c4011e0aee70ea7f | Rust | shenzhongshan/solana | /runtime/src/in_mem_accounts_index.rs | UTF-8 | 4,374 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use crate::accounts_index::{AccountMapEntry, IsCached, WriteAccountMapEntry};
use crate::accounts_index_storage::AccountsIndexStorage;
use crate::bucket_map_holder::BucketMapHolder;
use crate::bucket_map_holder_stats::BucketMapHolderStats;
use solana_measure::measure::Measure;
use solana_sdk::pubkey::Pubkey;
use std::c... | true |
0b4379f64e9d3c500da1baa5ae0fc06a14f81723 | Rust | Henning-K/exercism-tasks | /atbash-cipher/src/lib.rs | UTF-8 | 1,191 | 3.3125 | 3 | [] | no_license | use std::char;
pub fn encode(inp: &str) -> String {
let inp: Vec<_> = inp.replace(" ", "")
.to_lowercase()
.split(|c| !char::is_alphanumeric(c))
.collect::<Vec<&str>>()
.concat()
.bytes()
// .chars()
.collect();
let mut result = String::new();
let mut... | true |
a506c871db45cd5ad19c468f884b537627bd4098 | Rust | twe4ked/aoc2020 | /day_25/src/main.rs | UTF-8 | 3,746 | 3.765625 | 4 | [] | no_license | const HANDSHAKE_SUBJECT: u64 = 7;
const SECRET: u64 = 20201227;
use std::ops::Range;
fn main() {
// Input:
let card_pub_key = 2069194;
let door_pub_key = 16426071;
let part_1 = part_1(card_pub_key, door_pub_key);
assert_eq!(part_1, 11576351);
println!("Part 1: {}", part_1);
}
fn part_1(card_... | true |
0de9442571a30667220c091f4c4e132959adfcaf | Rust | doytsujin/rhai | /src/tests.rs | UTF-8 | 1,183 | 2.515625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Module containing unit tests.
#![cfg(test)]
/// This test is to make sure no code changes increase the sizes of critical data structures.
#[test]
fn check_struct_sizes() {
use crate::*;
use std::mem::size_of;
const PACKED: bool = cfg!(all(
target_pointer_width = "32",
feature = "only_i... | true |
042b8f681517311c5b4ecf7462ec5a065e1d7a83 | Rust | sendilkumarn/AdventOfCode2017 | /day15/aocd15s1.rs | UTF-8 | 373 | 3.53125 | 4 | [] | no_license | fn main() {
let mut a = 873;
let mut b = 583;
let mut count = 0;
for i in 0..40000000 {
a = get_next(a, 16807);
b = get_next(b, 48271);
if a&0xFFFF == b&0xFFFF {
count +=1;
}
}
println!("{}",count);
}
fn get_next(mut gen: i64, factor: i64) -> i64 ... | true |
ccc3fc7caf62283894d3c17dec8503c7ff43460c | Rust | hayatoito/icfp2020 | /src/main.rs | UTF-8 | 965 | 2.953125 | 3 | [] | no_license | use reqwest::StatusCode;
type Result<T> = anyhow::Result<T>;
// https://icfpc2020-api.testkontur.ru/swagger/index.html
fn first_post(server_url: &str, player_key: &str) -> Result<()> {
let client = reqwest::blocking::Client::new();
let response = client
.post(server_url)
.body(player_key.to_s... | true |
608db24bf2fdda0c8c5ba79278724fff7a83a4d4 | Rust | JeyRathnam/synth | /core/src/graph/string/truncated.rs | UTF-8 | 1,347 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use crate::graph::prelude::*;
use crate::graph::{RandomString, StringNode};
use anyhow::Result;
pub struct Truncated {
len: usize,
inner: Box<RandomString>,
}
impl Truncated {
pub(crate) fn new(len: usize, graph: Graph) -> Result<Self> {
match graph {
Graph::String(StringNode::String(r... | true |
5e42dfab5640347a6b023097501f282841b7ef40 | Rust | ggriffiniii/parse-logs | /src/bin/create_dhcp_table.rs | UTF-8 | 2,372 | 2.84375 | 3 | [] | no_license | extern crate parse_logs;
#[macro_use]
extern crate structopt;
extern crate rusqlite;
use structopt::StructOpt;
use std::error::Error;
use std::path::PathBuf;
use std::io::BufReader;
use std::fs::File;
use std::io::BufRead;
use parse_logs::dhcp::{LogEntry, DhcpMsg};
#[derive(StructOpt, Debug)]
struct Opt {
#[struc... | true |
d350b492c4ced9ed2e4c098c7162b34683621807 | Rust | HadrienG2/coursera-crypto | /src/hexfile.rs | UTF-8 | 2,457 | 3.859375 | 4 | [] | no_license | //! Facilities for manipulating hexadecimal data stored in files
//!
//! As part of the week 1 assignment of Coursera's Cryptography 1 course, one
//! must manipulate hex-encoded ciphertext. This module is dedicated to loading
//! such ciphertext from a file, into a more convenient array of bytes.
use std::fs::File;
u... | true |
df4bb7cfd5fcb4356064d54b5e87e0dad86102f1 | Rust | Limeth/cubeb-rs | /src/sample_format.rs | UTF-8 | 1,212 | 2.8125 | 3 | [
"MIT"
] | permissive | use ffi;
use std::mem;
/// You most likely want to use the `signed_16_native_endian` and `float_32_native_endian`
/// functions to retrieve the correct value for your system.
#[repr(u32)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum SampleFormat {
Signed16LittleEndian,
Signed16BigEndian,
Flo... | true |
2697e80315da885741735ee94701d9adeb38c21e | Rust | SKTT1Ryze/zCore-riscv | /os/src/zircon_object/ipc/channel.rs | UTF-8 | 6,512 | 2.75 | 3 | [] | no_license | use {
crate::zircon_object::object::*,
alloc::collections::VecDeque,
alloc::sync::{Arc, Weak},
alloc::vec::Vec,
core::convert::TryInto,
core::sync::atomic::{AtomicU32, Ordering},
futures::channel::oneshot::{self, Sender},
hashbrown::HashMap,
spin::Mutex,
};
/// Bidirectional interpr... | true |
72d7bf351bff284181d1931f56a43e4e73c0a5c2 | Rust | k0pernicus/orbtk | /src/text_box.rs | UTF-8 | 13,521 | 3.03125 | 3 | [
"MIT"
] | permissive | use super::{CloneCell, Color, CopyCell, Event, Place, Point, Rect, Renderer, Widget, Window};
use super::callback::{Click, Enter};
use std::cmp::min;
use std::sync::Arc;
pub struct TextBox {
pub rect: CopyCell<Rect>,
pub text: CloneCell<String>,
pub text_i: CopyCell<usize>,
pub bg: Color,
pub fg: ... | true |
065ae67b93206caffe1aa46df340c0de718fefff | Rust | sparkle-os/sparkle | /src/arch/x86_64/device/pit.rs | UTF-8 | 795 | 2.9375 | 3 | [
"BSD-3-Clause"
] | permissive | //! Driver for the Programmable Interrupt Timer (Intel 8253/8254).
use x86_64::instructions::port::Port;
pub static mut PIT: Pit = Pit {
chan0: Port::new(0x40),
mode: Port::new(0x43),
};
const SELECT_CHAN0: u8 = 0;
const ACCESS_LOHI: u8 = 0x30;
const MODE_2: u8 = 1 << 2;
/// Base frequency of the PIT, in _H... | true |
5f2783eb7cd2acdf5d2d52ddc869354be2ec9909 | Rust | mark-schultz/latticecrypto | /src/matrices.rs | UTF-8 | 3,281 | 3 | 3 | [] | no_license | //! Matrix-Matrix and Matrix-Vector products, where matrices are defined over finite-rank
//! commutative rings
use crate::rings::FinRankCRing;
use alga::general::*;
use num_traits::identities::{One, Zero};
use std::convert::From;
use std::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
#[derive(Clone, Pa... | true |
a5f892ae0cf6dc6ee0ff14117f570d6f2bd015f3 | Rust | Lemon-main/reception | /src/plonk/transparent_engine/mod.rs | UTF-8 | 19,444 | 2.65625 | 3 | [] | no_license | use crate::ff::*;
use crate::pairing::Engine;
#[macro_use]
mod impl_macro;
#[derive(PrimeField)]
#[PrimeFieldModulus = "3618502788666131213697322783095070105623107215331596699973092056135872020481"]
#[PrimeFieldGenerator = "3"]
pub struct Fr(FrRepr);
pub trait TransparentEngine: Engine {}
pub trait PartialReductio... | true |
0e26123cb28b3a2c616292a6545cf6e4f13e50ce | Rust | wycats/rust-experiments | /src/reporter/json.rs | UTF-8 | 3,622 | 2.75 | 3 | [
"MIT"
] | permissive | use derive_new::new;
use serde::{Deserialize, Serialize};
use std::{fmt::Write, time::Duration};
use crate::{
spec_result::{SpecInfo, SpecStatus},
suite::described::SuiteDetails,
suite::DurationWithPrecision,
suite_result::SuiteFinished,
};
use super::{output::SuiteOutput, ReportResult, Reporter, Star... | true |
72c84cd8327e8922826a6608acc814a330677afd | Rust | bingyanglin/bee | /bee-common/bee-common/src/worker.rs | UTF-8 | 1,155 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 IOTA Stiftung
//
// 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 w... | true |
d0c274b0ceefcb6c8e86f68aa24060e8136d2508 | Rust | TimDiekmann/TagGame | /examples/tag/config.rs | UTF-8 | 1,921 | 2.984375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
fs::{File, OpenOptions},
io::{self, BufReader, BufWriter},
ops::Range,
};
use serde::{Deserialize, Serialize};
use crate::Board;
/// Configuration for player properties and behaviors
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct AgentConfig {
pub untagged_deciding: ... | true |
96b9a4434abfcb4c85e7cf0366a16e800f9a4bb6 | Rust | PSeitz/tantivy | /columnar/src/columnar/column_type.rs | UTF-8 | 4,508 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::fmt::Debug;
use std::net::Ipv6Addr;
use serde::{Deserialize, Serialize};
use crate::value::NumericalType;
use crate::InvalidData;
/// The column type represents the column type.
/// Any changes need to be propagated to `COLUMN_TYPES`.
#[derive(Hash, Eq, PartialEq, Debug, Clone, Copy, Ord, Part... | true |
5d26d91eb3d9a763b4e4686ce9fc591124641a3c | Rust | TimelikeClosure/wasm-game-of-life | /src/patterns/glider.rs | UTF-8 | 411 | 2.890625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::pattern::Pattern;
use crate::Cell;
pub struct Glider {}
impl Glider {
pub fn new() -> Pattern {
let mut pattern = Pattern::rect(7, 7);
pattern.set_cell(2, 2, Cell::Alive);
pattern.set_cell(3, 2, Cell::Alive);
pattern.set_cell(4, 2, Cell::Alive);
pattern.set_cell... | true |
d8523de4e73d6bffd22d59785af4ea8e1b31d96a | Rust | allthatjazzleo/ibc-solo-machine | /solo-machine/build.rs | UTF-8 | 851 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
error::Error,
fs::{read_dir, DirEntry},
path::PathBuf,
};
use prost_build::Config;
fn main() -> Result<(), Box<dyn Error>> {
let mut files = Vec::new();
let paths = read_dir("./proto")?;
for path in paths {
files.extend(get_files(path?)?);
}
let mut config = Confi... | true |
4a12290bf3fa31bccb68b69f55c111c72411925d | Rust | originbenntou/mark_as_read | /src/main.rs | UTF-8 | 2,898 | 2.59375 | 3 | [] | no_license | mod config;
mod request;
mod message;
mod events;
mod app;
use config::Config;
use request::{
client::GClient,
};
use message::{MessageClient};
use events::events::{Event, Events};
use app::App;
use crate::events::EventState;
use tui::{
backend::CrosstermBackend,
Terminal,
};
use crossterm::{
terminal... | true |
2983809e092e02c1e8e3973c4064db5f6f8a1525 | Rust | mephesto1337/pe-parser | /src/structures/data_directory/import_descriptor.rs | UTF-8 | 2,703 | 2.625 | 3 | [] | no_license | use nom::bytes::complete::take_while1;
use nom::combinator::{map, map_opt};
use nom::error::context;
use nom::number::complete::{le_u16, le_u32};
use nom::sequence::tuple;
use crate::structures::Name;
use crate::{NomError, Parse};
use std::fmt;
#[derive(Debug)]
pub struct ImportDescriptor<'a> {
pub original_firs... | true |
1783544917683da963bd0b3ff802cb9dd592b274 | Rust | Happy-Ferret/wasm-bindgen | /tests/simple.rs | UTF-8 | 3,320 | 3.28125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate test_support;
#[test]
fn add() {
test_support::project()
.file("src/lib.rs", r#"
#![feature(proc_macro)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
wasm_bindgen! {
pub fn add(a: u32, b: u32) -> u32 {
... | true |
1369fe651420a30128302b63ff3a35ac0b98bdcc | Rust | seb-m/crypto.rs | /src/hash.rs | UTF-8 | 2,264 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Hash traits
use std::c_str::CString;
use std::io::{IoResult, Writer};
use common::sbuf::{Allocator, SBuf};
use curve41417::bytes::{Bytes, B416, B512, B832, Scalar, MontPoint, EdPoint};
/// Trait for hashable types
pub trait Hash<S> {
fn hash(&self, state: &mut S) -> IoResult<()>;
}
impl<'a, S: Writer> Hash<... | true |
2ea889c8d1f8417ef0542599afef6c2a07916155 | Rust | krlosMata/rust-hw | /hw01/src/problem2.rs | UTF-8 | 630 | 3.234375 | 3 | [] | no_license | /// Represents a matrix in row-major order
pub type Matrix = Vec<Vec<f32>>;
/// Computes the product of the inputs `mat1` and `mat2`.
pub fn mat_mult(mat1: &Matrix, mat2: &Matrix) -> Matrix {
// Check Matrix are compatible to perform multiplication
let columns = mat1[0].len();
let rows = mat2.len();
as... | true |
e4d51debc98f778621b5a4e2f920277c17b67582 | Rust | alichtman/lsd | /src/meta/symlink.rs | UTF-8 | 4,013 | 3.25 | 3 | [
"Apache-2.0"
] | permissive | use crate::color::{ColoredString, Colors, Elem};
use crate::flags::Flags;
use std::fs::read_link;
use std::path::Path;
#[derive(Clone, Debug)]
pub struct SymLink {
target: Option<String>,
valid: bool,
}
impl From<&Path> for SymLink {
fn from(path: &Path) -> Self {
if let Ok(target) = read_link(pat... | true |
fdbc4d7e546bb8a7a26e561b3719ef8b10612d0c | Rust | mrtnzlml-archive/abacus-test | /src/arangodb/mod.rs | UTF-8 | 6,349 | 2.796875 | 3 | [] | no_license | use crate::arangodb::pool::ConnectionManager;
use arangors::{ArangoError, ClientError, Connection};
#[cfg(test)]
use deadpool::managed::Object;
use deadpool::managed::Pool;
use serde::Deserialize;
use serde_json::Value;
use std::collections::HashMap;
mod pool;
#[derive(Clone)]
pub struct ConnectionPool {
pub pool... | true |
3e6a8243c1fa2502a0c888ed468815115b2c3e04 | Rust | Whipshout/WebAssemblyTest | /tests/node.rs | UTF-8 | 2,366 | 3.078125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Test suite for node.
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen_test;
use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
use web_assembly_whipshout::{
convert_to_provider, parse_string, parse_string_option, send_array, send_vector, Provider,
};
/// Test if function can parse with js values
... | true |
c8d6b6e7dbe1f31ffe0105a1c2b902c19bf42ed3 | Rust | doy/rbw | /src/bin/rbw/sock.rs | UTF-8 | 1,282 | 2.671875 | 3 | [
"MIT"
] | permissive | use anyhow::Context as _;
use std::io::{BufRead as _, Write as _};
pub struct Sock(std::os::unix::net::UnixStream);
impl Sock {
// not returning anyhow::Result here because we want to be able to handle
// specific kinds of std::io::Results differently
pub fn connect() -> std::io::Result<Self> {
Ok... | true |
d9687d59e484e02afed3f2b247e3c6cd77e427d9 | Rust | lo48576/fbxcel-dom | /src/v7400/object/property/loaders/binstr.rs | UTF-8 | 3,755 | 2.96875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Property loaders for binary, and string.
use crate::v7400::object::property::{loaders::check_attrs_len, LoadProperty, PropertyHandle};
/// Binary property loader that loads owned data.
///
/// This does minimal checks about `data_type` and `label`.
/// If you want to check property type precisely, you should make... | true |
f700ed5085bd3ec31c8ba0c26e59b8dcf0c21c54 | Rust | fanatid/schnorrkel-node-perf | /schnorrkel-bench/schnorrkel.rs | UTF-8 | 4,584 | 2.796875 | 3 | [] | no_license | use criterion::{criterion_group, criterion_main, Criterion};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use schnorrkel::{
context::SigningContext, signing_context, ExpansionMode, MiniSecretKey, PublicKey, SecretKey,
Signature, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH, SIGNATURE_LENGTH,
};
use sha2::{... | true |
d0d163eb2eecfdee3bd8f0d192b32343c9cdcd1a | Rust | Devolutions/siquery-rs | /siquery/src/linux/processes.rs | UTF-8 | 15,709 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use regex::Regex;
use std::io::Read;
use std::fs::{read_dir, File, canonicalize, read_link};
use crate::tables::{
ProcessesRow,
ProcessEnvsRow,
ProcessMemoryMapRow,
};
pub struct SimpleProcStat {
name: String,
real_uid: String,
real_gid: String,
effective_uid: String,
effective_gid: S... | true |
787841dbd36fa78db5130049b17b8b87501d4726 | Rust | lilith645/chance-is-meaningless | /src/modules/board.rs | UTF-8 | 1,513 | 3.015625 | 3 | [
"MIT"
] | permissive | pub use crate::modules::cards::Deck;
use maat_graphics::cgmath::{Vector2, Vector4};
use maat_graphics::DrawCall;
const BOARD_HEIGHT: f32 = 0.20;
const BOARD_WIDTH: f32 = 0.60;
pub enum BoardPosition {
Top,
Bottom,
Left,
Right,
}
pub struct Board {
deck: Deck,
position: BoardPosition,
}
impl Board {
p... | true |
0502fdd20afd7c069a469c7d2542b0744eb03d8b | Rust | ChainSafe/serde-bin-prot | /src/value/visitor.rs | UTF-8 | 2,993 | 3 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::loose_deserializer::EnumData;
use crate::value::Value;
use serde::de::MapAccess;
use serde::de::SeqAccess;
use serde::de::Visitor;
use serde::de::{EnumAccess, VariantAccess};
use serde::Deserialize;
use std::collections::HashMap;
pub struct ValueVisitor;
impl<'de> Visitor<'de> for ValueVisitor {
type V... | true |
b368660a6f52a573ab5ca71d5b6e93b432ac3719 | Rust | nettan20/rust_sexpr | /sexpr.rs | UTF-8 | 5,252 | 3.546875 | 4 | [
"MIT"
] | permissive | extern mod std;
#[deriving(Eq)]
#[deriving(Clone)]
pub enum Value {
List(~[Value]),
Atom(~str),
Str(~str),
Num(f64)
}
#[inline]
fn isws(c: char) -> bool {
c == ' ' || c == '\t' || c == '\n'
}
/// Determines if the input begins a number
#[inline]
fn beginning_is_num(input: &str, i: uint) -> bool {
let c = input... | true |
17a5d2df440d29e44df61f4f58747c12ef37f366 | Rust | manarimo/ICFPC2021 | /kenkoooo/brute-force/src/bin/two-three-forces.rs | UTF-8 | 3,437 | 2.59375 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use brute_force::{
amylase_bruteforce, extract_valid_best_solutions, load_all_problems, load_solutions, PathRefExt,
};
use manarimo_lib::types::{Pose, Problem};
use rayon::prelude::*;
use std::collections::HashMap;
use std::env;
use std::fs::{read_dir, File};
use std::io::BufWriter;
use std::pat... | true |
8f9b1ade97ec3a7dab3114c6ac511d5c0472e692 | Rust | kroeckx/ruma | /crates/ruma-client-api/src/r0/backup/delete_backup_keys.rs | UTF-8 | 1,252 | 2.75 | 3 | [
"MIT"
] | permissive | //! [DELETE /_matrix/client/r0/room_keys/keys](https://matrix.org/docs/spec/client_server/unstable#delete-matrix-client-r0-room-keys-keys)
use js_int::UInt;
use ruma_api::ruma_api;
ruma_api! {
metadata: {
description: "Delete all keys in a backup.",
method: PUT,
name: "delete_backup_keys",... | true |
ce8f15fc926756ae6dd3744f201cbf6110f3a95c | Rust | robohouse-delft/show-image-rs | /src/backend/window.rs | UTF-8 | 23,771 | 3.0625 | 3 | [
"BSD-2-Clause"
] | permissive | use crate::Color;
use crate::ContextHandle;
use crate::ImageInfo;
use crate::ImageView;
use crate::WindowId;
use crate::WindowProxy;
use crate::backend::Context;
use crate::backend::util::GpuImage;
use crate::backend::util::UniformsBuffer;
use crate::error;
use crate::event::EventHandlerControlFlow;
use crate::event::W... | true |
f07a68d08a188e53caf010d1dfb15d8eefa36588 | Rust | SINHASantos/zbox | /src/volume/storage/mem/mem.rs | UTF-8 | 7,969 | 2.65625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use std::collections::HashMap;
use std::fmt::{self, Debug};
use std::sync::Mutex;
use lazy_static::lazy_static;
use log::warn;
use crate::base::crypto::{Crypto, Key};
use crate::base::IntoRef;
use crate::error::{Error, Result};
use crate::trans::Eid;
use crate::volume::address::Span;
use crate::volume::storage::Stora... | true |
b220fc51ad15c41edf3135390a4859104c95938a | Rust | ngtkana/aribook | /crates/chap4_2/coin_game_2/src/main.rs | UTF-8 | 1,153 | 2.65625 | 3 | [] | no_license | #![allow(clippy::many_single_char_names)]
use proconio::input;
fn main() {
input!(n: usize, k: usize, a: [usize; k], b: [usize; n]);
let b_max = *b.iter().max().unwrap();
let mut grundy = vec![0; b_max + 1];
for i in 1..=b_max {
let mut ckd = vec![false; k + 1];
for &x in a.iter().filte... | true |
5c5e1c74c8578e0daf4c1dce10f397576d6ca0a7 | Rust | isgasho/linux-aio-tokio | /tests/helpers.rs | UTF-8 | 1,288 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::io::Write;
use std::path::PathBuf;
use tempfile::{tempdir, TempDir};
pub fn fill_temp_file(file_size: usize, file: &mut std::fs::File) {
let mut data = vec![0u8; file_size];
for index in 0..data.len() {
data[index] = index as u8;
}
file.write(&data).unwrap();
file.sync_all().unwr... | true |
0f6dc81920b9fb44a5de96dd4e9e21485243b99c | Rust | francisco-perez-sorrosal/yarner | /src/util.rs | UTF-8 | 2,246 | 3.59375 | 4 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt::{Display, Write};
pub type Fallible<T = ()> = Result<T, Box<dyn Error>>;
pub trait TryCollectExt<T, E>
where
Self: Iterator<Item = Result<T, E>> + Sized,
{
fn try_collect(self) -> Result<Vec<T>, Vec<E>> {
let vals = Vec::with_capacity(self.size_hint().0);
... | true |
349ed2b5dd10e2a8edf67afd9b138affcc06861f | Rust | karkigrishmin/Rust | /control_flow/src/main.rs | UTF-8 | 913 | 4.34375 | 4 | [] | no_license | fn main() {
//-----if expression-------
let x = 10;
if x > 15 {
println!("X is greater");
}
println!("X is smaller");
let number = 5;
if number != 0 {
println!("Number is not zero");
}
//we have to always provide boolean value in the if condition, the following c... | true |
51d5d82702f281095e227846533938885603a0f3 | Rust | iCodeIN/mlc | /src/cli.rs | UTF-8 | 4,703 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::logger;
use crate::markup::MarkupType;
use crate::Config;
use clap::{App, Arg};
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use std::path::MAIN_SEPARATOR;
use wildmatch::WildMatch;
pub fn parse_args() -> Config {
let matches = App::new(crate_name!())
.arg(
Arg::with_nam... | true |
486cd63056b1aa536912ff71c27dcdc4534b640b | Rust | ebobby/simple-pathtracer | /src/bvh.rs | UTF-8 | 3,243 | 3.421875 | 3 | [
"MIT"
] | permissive | //! Bounding volume hierarchy.
use crate::aabb::AABB;
use crate::intersectable::{Intersectable, Intersection};
use crate::ray::Ray;
use crate::Hitable;
use rand::Rng;
#[derive(Debug)]
pub struct BVH {
left: Option<Hitable>,
right: Option<Hitable>,
bounding_box: AABB,
}
impl BVH {
pub fn from_vec(mut... | true |
62db58dcfbb4ac4e921601896e52a83dbcda54b8 | Rust | kazumatsudo/react-native-rust-test | /rust/src/string.rs | UTF-8 | 507 | 2.90625 | 3 | [] | no_license | use libc::size_t;
#[repr(C)]
pub struct StringPtr {
pub ptr: *const u8,
pub len: size_t,
}
impl<'a> From<&'a str> for StringPtr {
fn from(s: &'a str) -> Self {
StringPtr {
ptr: s.as_ptr(),
len: s.len() as size_t,
}
}
}
impl StringPtr {
pub fn as_str(&self) ... | true |
9c4bcbfe7789858622172fc50d0cf440ff8e8bbf | Rust | dkushner/chopper | /src/system/entity.rs | UTF-8 | 2,117 | 3.546875 | 4 | [
"MIT"
] | permissive | use std::collections::VecDeque;
const INDEX_REUSE_THRESHOLD: usize = 2048;
const INDEX_MASK: u32 = (1 << 24) - 1;
const GENERATION_MASK: u32 = (1 << 8) - 1;
pub type Entity = u32;
pub type Generation = u8;
pub struct EntityManager {
generations: Vec<Generation>,
pool: VecDeque<Entity>,
}
impl EntityManager ... | true |
1d4d43fe9c4b432528f1d592b074a1d7987884e9 | Rust | Jacobamv/Rust_File_io | /src/utils.rs | UTF-8 | 1,815 | 2.8125 | 3 | [] | no_license | extern crate rustc_serialize;
use rustc_serialize::json::Json;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::fs::OpenOptions;
pub enum Result<T, E> {
Ok(T),
Err(E),
}
impl <T, E> Result<T, E> {
fn unwrap(self) -> T{
match self {
Result::Ok(v) => return v,
... | true |
d23bcaeeed3879ad4e82b4e6a6e1e064ae5c102f | Rust | rej696/finleys-foods | /rust_test/src/routes/recipes.rs | UTF-8 | 4,269 | 2.890625 | 3 | [] | no_license | use std::collections::HashMap;
use std::vec::Vec;
use crate::records::{Recipe, PartialRecipe};
use crate::templates::recipes::*;
use crate::utils;
use sqlx::prelude::*;
pub async fn index(request: crate::Request) -> tide::Result {
let recipes = Recipe::all().fetch_all(&request.state().db).await?;
Ok(IndexTempl... | true |
e5cae3b5e4d6f16dcda596841c532ac1e113d58f | Rust | maco/unused | /crates/cli/src/flags.rs | UTF-8 | 2,866 | 2.734375 | 3 | [
"MIT"
] | permissive | use read_ctags::Language;
use std::str::FromStr;
use structopt::StructOpt;
use token_analysis::{OrderField, UsageLikelihoodStatus};
#[derive(Debug, StructOpt)]
pub enum Command {
/// Run diagnostics to identify any potential issues running unused
Doctor,
/// Write the default YAML configuration to STDOUT
... | true |
8fa6f11a38dbc77e004641a91e57c6f52375c591 | Rust | ederst/exercism-rust | /leap/src/lib.rs | UTF-8 | 934 | 3.5625 | 4 | [
"Unlicense"
] | permissive | pub fn is_leap_year(year: u64) -> bool {
// Note:
// This does not account for "-" (BC) years,
// but it is not designed to do so anyways (using u64)
year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
// Note(sprietl): learned about "switch cases"
// is_leap_year_using_match(year)
//... | true |
7601a41d40e13fde968f534b54b4855714e1b5fa | Rust | tempbottle/ws-rs | /src/handshake.rs | UTF-8 | 14,880 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::default::Default;
use std::io::{Cursor, Write};
use std::mem::transmute;
use std::str::from_utf8;
use log::LogLevel::Trace as TraceLevel;
use sha1;
use rand;
use url;
use httparse;
use result::{Result, Error, Kind};
static WS_GUID: &'static str = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
static BASE64: &'sta... | true |
478805da23735719b51901d2c652ea1236b8a12f | Rust | JulianKnodt/mat-fst | /benches/par_benchmarks.rs | UTF-8 | 1,713 | 2.609375 | 3 | [] | no_license | use criterion::{black_box, criterion_group, criterion_main, Criterion};
use sparse_mat::{matrix::Matrix, output::FiniteFloat};
use std::{
fs::File,
io::{BufRead, BufReader},
path::Path,
time::Duration,
};
// 0.005 works p well
// 0.05 hits a lot of edge cases
const TEN_P_THRESH: f32 = 0.031094962;
fn file() -... | true |
88d31cb95da7665e130923a30755ad89658e017c | Rust | lighter/Leetcode-Rust | /n1007. Minimum Domino Rotations For Equal Row/main.rs | UTF-8 | 790 | 2.6875 | 3 | [
"MIT"
] | permissive | // Author: Netcan @ https://github.com/netcan/Leetcode-Rust
// Zhihu: https://www.zhihu.com/people/netcan
use std::mem::swap;
impl Solution {
pub fn min_domino_rotations(mut a: Vec<i32>, mut b: Vec<i32>) -> i32 {
let mut ans = -1;
for point in (1..=6) {
for _ in 0..2 {
l... | true |
c219692f4e2cd1c4188a142808ef06fd227638c4 | Rust | martinhath/advent-of-code | /2015/src/days/day11.rs | UTF-8 | 2,237 | 3.328125 | 3 | [] | no_license | fn next_char(c: u8) -> u8 {
let cval = c;
match cval + 1 {
105 => 106, // skip i
111 => 112, // skip o
108 => 109, // skip l
123 => 97, // wrap z to a
v => v
}
}
fn next_password(input: Vec<u8>) -> Vec<u8> {
let mut inp = input;
let mut i = inp.len() - 1;
... | true |
abd074839726e0f5e61b7231ad321e0928aed5a7 | Rust | fatmatto/hoglog | /src/main.rs | UTF-8 | 4,128 | 2.84375 | 3 | [] | no_license | extern crate logwatcher;
use clap::{App, Arg};
use logwatcher::{LogWatcher, LogWatcherAction};
use serde::Deserialize;
use std::fs;
use std::path::Path;
mod server;
mod storage;
#[derive(Deserialize)]
struct ReceiverConfig {
ip: String,
port: String,
}
#[derive(Deserialize)]
struct ForwarderConfig {
receiv... | true |
0fd56e844ef15e6f7940a228c9f437cf13e86b5a | Rust | Phala-Network/phala-blockchain | /pallets/phala/src/utils/balance_convert.rs | UTF-8 | 1,308 | 3 | 3 | [
"Apache-2.0"
] | permissive | use fixed::types::{U64F64 as FixedPoint, U80F48};
pub trait FixedPointConvert {
fn from_bits(bits: u128) -> Self;
fn from_fixed(v: &FixedPoint) -> Self;
fn to_fixed(&self) -> FixedPoint;
}
const PHA: u128 = 1_000_000_000_000;
// 12 decimals u128 conversion
impl FixedPointConvert for u128 {
fn from_bits(bits: u12... | true |
fe8c1df341db01555194156ee7df92e5c77d3db4 | Rust | terminar/rusty-maschine | /tools/src/font-gen.rs | UTF-8 | 3,050 | 3.328125 | 3 | [] | no_license | ///
/// Simple tool to parse a 160x24 pixel grid into a font glyph lookup table
///
/// All Glyphs are formatted for easy insertion into a data table
///
use clap::{AppSettings, Clap};
use std::fs::File;
use std::io::Read;
pub mod bitmap;
const WHITE: bitmap::Colour = bitmap::Colour {
red: 0xFF,
green: 0xFF,
... | true |
6a0b63336d2d820fdd8c566c9080a594b2144402 | Rust | dragonrider7225/advent_of_code_rust | /src/year_2020/day_3/mod.rs | UTF-8 | 2,154 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::parse::NomParse;
use std::{fs, io, iter};
use nom::{branch, character::complete as character, combinator as comb, multi, sequence, IResult};
#[derive(Clone, Copy, Debug)]
enum Tile {
Snow,
Tree,
}
impl<'s> NomParse<'s> for Tile {
fn nom_parse(s: &'s str) -> IResult<&'s str, Self> {
br... | true |
4674ba4ce7c7d13dc02a7c295e096671aea676f4 | Rust | hGrigol/wavelet-fp5 | /src/wavelet_tree_pointer.rs | UTF-8 | 13,233 | 3.296875 | 3 | [] | no_license | use bio::data_structures::rank_select::RankSelect;
use bv::BitVec;
use bv::BitsMut;
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use snafu::{ensure, Snafu};
use std::fmt::Debug;
use std::hash::Hash;
use std::ops::Index;
///custom errors for the tree with pointer
#[derive(Debug, Snafu)]
pub enum Error... | true |
494f2fe0dae8097c797a8c6ba3c17bfd5a5c6da0 | Rust | anykao/openlimits | /src/binance/client/websocket.rs | UTF-8 | 4,798 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | use crate::{
binance::model::websocket::{
AccountUpdate, BinanceWebsocketMessage, Subscription, UserOrderUpdate,
},
shared::Result,
};
use std::{collections::HashMap, pin::Pin, task::Poll};
use futures::{
stream::{SplitStream, Stream},
StreamExt,
};
use serde::{Deserialize, Serialize};
use... | true |
96e81cebd13f3f53d5b51cc481af3e506cf88d0e | Rust | zhiwei-w-luo/zeitgeist | /zrml/swaps/src/check_arithm_rslt.rs | UTF-8 | 1,890 | 2.640625 | 3 | [] | no_license | use crate::ARITHM_OF;
use frame_support::dispatch::DispatchError;
use sp_runtime::traits::{CheckedAdd, CheckedDiv, CheckedMul, CheckedSub};
/// Check Arithmetic - Result
///
/// Checked arithmetic operations returning `Result<_, DispatchError>`.
pub trait CheckArithmRslt: CheckedAdd + CheckedDiv + CheckedMul + Checked... | true |
033b5c05e6a0d8ea1c8f83c6ad91069b470737fc | Rust | wozgonon/dumbsum | /src/main.rs | UTF-8 | 989 | 3.5 | 4 | [] | no_license |
use std::io;
use std::io::BufRead;
fn main () {
let mut sum = 0.0;
let mut compensation = 0.0;
let reader = io::stdin();
let buffer = io::BufReader::new(reader);
for line in buffer.lines () {
let string = line.unwrap ();
match string.parse::<f64>() {
Ok(input) =>... | true |
54062adf10c24de90102db232cfe91b9047a16c3 | Rust | yssource/rxRust | /src/test_scheduler.rs | UTF-8 | 7,761 | 2.671875 | 3 | [
"MIT"
] | permissive | #![cfg(test)]
use crate::prelude::{LocalScheduler, SpawnHandle, SubscriptionLike};
use crate::scheduler::Instant;
use futures::future::AbortHandle;
use std::future::Future;
use std::ops::{Add, Sub};
use std::sync::{Arc, Mutex, RwLock};
use std::time::Duration;
#[derive(Clone)]
pub struct ManualScheduler {
clock: Arc... | true |
292bb286613076a188bea98bf220c9d3e94a2e17 | Rust | SkyMomentum/merklet | /src/lib.rs | UTF-8 | 12,301 | 3.578125 | 4 | [] | no_license |
pub mod merklet {
///! A Toy Merkle Tree Type.
///!
///! Create Merkle trees from arbitrary types which impliment Hash2(Temporary).
use std::rc::Rc;
extern crate openssl;
use self::openssl::hash::{DigestBytes, MessageDigest, hash2};
/// Temporary trait to hash with sha256 from Openssl.
... | true |
e0324d026be1651afa8688de210f7a0c5bf0d39c | Rust | cmisenas/aoc2020 | /src/day20.rs | UTF-8 | 12,202 | 3.234375 | 3 | [] | no_license | extern crate itertools;
extern crate regex;
use self::itertools::Itertools;
use self::regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
#[derive(Clone, PartialEq, Eq)]
struct Tile {
id: String,
conten... | true |
fca3fee1c99f15fd6b72f5bb51dbc44ebaf36ff4 | Rust | yancouto/competitive-programming | /ojs/cf/1718B.rs | UTF-8 | 2,265 | 3.1875 | 3 | [] | no_license | use std::io::BufRead;
use std::collections::BTreeMap;
fn do_partit_impl(fibs: &Vec<usize>, mut val: usize) -> Option<Vec<usize>> {
let mut ans = vec![];
for j in (1..fibs.len()).rev() {
if fibs[j] <= val {
val -= fibs[j];
if let Some(prev) = ans.last() {
if *prev... | true |
adad5e4cabc1e8f820910416f4ddcbb532cd15d6 | Rust | rust-windowing/raw-window-handle | /src/redox.rs | UTF-8 | 976 | 2.625 | 3 | [
"Apache-2.0",
"Zlib",
"MIT"
] | permissive | use core::ffi::c_void;
use core::ptr;
/// Raw display handle for the Redox operating system.
///
/// ## Construction
/// ```
/// # use raw_window_handle::OrbitalDisplayHandle;
/// let mut display_handle = OrbitalDisplayHandle::empty();
/// /* set fields */
/// ```
#[non_exhaustive]
#[derive(Debug, Clone, Copy, Partial... | true |
9a9d55fcf950ab19b474449924b5ef9fb6795607 | Rust | ajunlonglive/suruga | /src/crypto/p256.rs | UTF-8 | 23,376 | 2.890625 | 3 | [
"MIT"
] | permissive | // constantly slow implementation of NIST P-256
// http://www.nsa.gov/ia/_files/nist-routines.pdf
// http://point-at-infinity.org/ecc/nisttv
use crypto::wrapping::*;
use crypto::wrapping::Wrapping as W;
use self::int256::{Int256, ZERO, ONE};
// Point on Y^2 = X^3 - 3 * X + B mod P256 where B is some obscure big numbe... | true |
c40a9edc519c31ae48558ca0ee9e87b166ae5062 | Rust | simeg/programming-exercises | /rust/counting-chars_2/src/main.rs | UTF-8 | 319 | 3.46875 | 3 | [] | no_license | use std::io;
fn main() {
println!("What is the input string?");
let mut input: String = String::new();
io::stdin().read_line(&mut input)
.expect("Failed to read line");
let char_count: usize = input.trim().chars().count();
println!("{} has {} characters.", input.trim(), char_count);
}
| true |
a192f9102c78849daaf3b4d202d80677c13d6a2f | Rust | dfschwabe/hellorust | /test/it.rs | UTF-8 | 621 | 3.078125 | 3 | [] | no_license | #[cfg(test)]
mod test {
use std::collections::HashMap;
use std::net::{TcpStream};
extern crate serde;
extern crate serde_json;
#[derive(serde::Deserialize, Debug)]
struct ShapeResult {
spec: HashMap<String, u8>,
area: u16,
}
#[test]
fn writes_square_on_connection() ... | true |
109afa2c489cc20e5b9ad05e460db375459484ca | Rust | ahbali/adventofcode2020 | /day03/src/main.rs | UTF-8 | 1,004 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::io::{self, prelude::*};
use std::{error::Error, writeln};
fn main() -> Result<(), Box<dyn Error>> {
let (stdin, stdout) = (io::stdin(), io::stdout());
let mut out = io::BufWriter::new(stdout.lock());
let reader = io::BufReader::new(stdin.lock());
let input = reader.lines().filter_map(Result::... | true |
61a2890d62b0feaa6a95d13f4cdb5ab798395171 | Rust | MediocreBoris/gitgud | /fibonacci/main.rs | UTF-8 | 472 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::io;
fn main(){
let mut g = String::new();
io::stdin().read_line(&mut g).expect("Failed to read line");
loop{
let g: u128 = match g.trim().parse() {
Ok(num) => num,
Err(_) => continue,
};
let mut f: Vec<u128> = vec![0, 1];
for i in ... | true |
5ce989106f1b064e7b9b142ee69342d5564c9ab4 | Rust | jakobneufeld/lorry-cli | /src/main.rs | UTF-8 | 1,746 | 2.984375 | 3 | [] | no_license | use clap::*;
use git2::*;
use ansi_term::*;
use std::env::*;
use std::process::exit;
use std::path::*;
use indicatif::ProgressBar;
fn main() {
let mut matches = App::new("lorry-cli")
.about("Helps tasks with lorry lib")
.setting(AppSettings::SubcommandRequired)
.version("1.0.0")
.subcommand(clap::Su... | true |
f433cac057a3b770af1b1c3ae08820ccdaa00e25 | Rust | hydrostaticcog/serenity-rs_boilerplate | /bot_commands/src/cmd_dropdowns.rs | UTF-8 | 2,162 | 2.6875 | 3 | [] | no_license | use serenity::collector::CollectComponentInteraction;
use serenity::model::interactions::InteractionResponseType;
use serenity::{
client::Context,
framework::standard::{macros::command, CommandResult},
model::prelude::Message,
};
#[command("dropdowns")]
#[description = "dropdowns"]
async fn cmd_dropdowns(c... | true |
4a353c9594fb20679630e8ba773d75e1fc5193ab | Rust | dcastelltort/fractal | /src/mandelbrot.rs | UTF-8 | 387 | 2.828125 | 3 | [
"MIT"
] | permissive |
use num::complex::Complex;
use num::traits::Zero;
pub const MAX_ITERATIONS: u32 = 1000;
pub fn get_iterations(x: f64, y: f64) -> u32 {
let mut z : Complex<f64> = Zero::zero();
let c : Complex<f64> = Complex::new(x, y);
let mut iterations : u32 = 0;
while iterations < MAX_ITERATIONS {
z = z*z + c;
if z.... | true |
d438237c1bfaf7b98484bae97680cd511c321361 | Rust | Twey/mkRustCrate | /libnix/src/parse.rs | UTF-8 | 5,881 | 2.703125 | 3 | [] | no_license | use combine::*;
use combine::stream::Stream;
use combine::parser::char::*;
use crate::expr::*;
parser! {
pub fn id_cont[I]()(I) -> char where [
I: Stream<Item=char>,
] {
char('\'').or(alpha_num())
}
}
parser! {
pub fn id[I]()(I) -> String where [
I: Stream<Item=char>,
] {
... | true |
4cdcff1be8ce4b9277683472e209f91ffda4838f | Rust | odarbelaeze/vegas-lattice-rs | /src/error.rs | UTF-8 | 1,617 | 2.875 | 3 | [
"MIT"
] | permissive | use serde_json::Error as SerdeError;
use std::error::Error as StdError;
use std::fmt;
use std::io::Error as IoError;
#[derive(Debug)]
pub enum LatticeError {
IoError(IoError),
JsonParseError(SerdeError),
InconsistentVertices,
NegativeSize,
}
impl StdError for LatticeError {
fn description(&self) -... | true |
cf5c89f0aebc230c1581ca2a9a0457a9ce7e8f1e | Rust | vlmonk/advent2019 | /day07/src/vm.rs | UTF-8 | 6,558 | 3.359375 | 3 | [] | no_license | #[derive(Debug, PartialEq)]
enum Mode {
Position,
Immediate,
}
impl Mode {
fn from_i32(input: i32) -> Self {
match input {
0 => Mode::Position,
1 => Mode::Immediate,
n => panic!("invalid mode: {}", n),
}
}
}
type ModeSet = (Mode, Mode, Mode);
#[deri... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.