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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
583f94d52d69d748673a24edd1bfec7ba0d9de94 | Rust | noc7c9/ray-tracing-in-one-weekend | /src/vec3.rs | UTF-8 | 5,353 | 3.15625 | 3 | [] | no_license | use super::utils;
pub type Point3 = Vec3;
pub type Color = Vec3;
/***
* struct definition
*/
#[derive(Clone, Copy)]
pub struct Vec3(f64, f64, f64);
/***
* methods
*/
impl Vec3 {
pub const BLACK: Color = Vec3(0., 0., 0.);
pub const WHITE: Color = Vec3(1., 1., 1.);
pub fn new(a: f64, b: f64, c: f64)... | true |
21485bc71b47d4f8190a9266dc590c30120ec143 | Rust | XANi/toolbox | /project-templates/rust-arm/src/main.rs | UTF-8 | 2,026 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive |
#![deny(unsafe_code)]
#![no_std]
#![no_main]
use panic_halt as _;
use nb::block;
use stm32f1xx_hal::{
prelude::*,
pac,
timer::Timer,
};
//use cortex_m_semihosting::hprintln;
use cortex_m_rt::entry;
use embedded_hal::digital::v2::OutputPin;
#[entry]
fn main() -> ! {
// Access to peripherals common t... | true |
81b8b29f85017a810673bcba2c9319181da961e4 | Rust | NoamDev/rust-tvm | /src/executor/gas/gas_state.rs | UTF-8 | 6,898 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASI... | true |
1a25233ba799c816f04c5aba499a9c4027499462 | Rust | cleanunicorn/rust-learn | /ch03-data_types/src/main2.rs | UTF-8 | 934 | 3.671875 | 4 | [] | no_license | // use std::io;
// fn parse_number() {
// let mut number = String::new();
// println!("Enter number:");
// io::stdin()
// .read_line(&mut number)
// .expect("Failed to read line");
// let number: u8 = number
// .trim()
// .parse()
// .expect("Could not transfo... | true |
53c206da022a760df0b1b33bb14c20895b66c6cc | Rust | emmanuelantony2000/valerie | /src/state/state_vec.rs | UTF-8 | 15,748 | 3.25 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use alloc::sync::Arc;
use alloc::vec::Vec;
use core::fmt::Display;
use core::iter::FromIterator;
// use core::ops::{Index, IndexMut};
use futures_intrusive::channel::shared::{unbuffered_channel, Sender};
use parking_lot::RwLock;
use super::{StateAtomic, StateMutex, StateTrait};
use crate::component;
use crate::html;
... | true |
6d24bd6ce85717b9fc76c6a082d8c1dedb8947ba | Rust | mersinvald/primitive-map-rs | /src/lib.rs | UTF-8 | 4,143 | 2.84375 | 3 | [
"MIT"
] | permissive | extern crate smallvec;
pub mod bucket;
pub mod hash;
pub mod kv;
use std::marker::PhantomData;
pub use bucket::{ArrayBucket, ArrayBucketList, Bucket, BucketList, SmallVecBucket,
SmallVecBucketList};
pub use hash::{DefaultHasher, Hash, Hasher};
pub use kv::{Key, Value};
pub struct PrimitiveMap<
... | true |
da56b31c22c53c4b98c165ea62301578a1e2902e | Rust | sessamekesh/advent-of-code-2018 | /02-inventory-management-system/main.rs | UTF-8 | 2,645 | 3.625 | 4 | [
"MIT"
] | permissive | fn part_two(input: &str) {
use std::collections::HashSet;
// I happen to know that the input consists of all 26-length things, soooo that's nice
let id_len = 26;
let mut tokens = input.split("\n").collect::<Vec<_>>();
// Also, the prompt gives a pretty huge hint into a potential solution of this ... | true |
bccc786acf1025f4c6e856d85079c1ab0c91b209 | Rust | tekjar/numbers | /collections/src/lib.rs | UTF-8 | 3,017 | 2.703125 | 3 | [] | no_license | #![feature(test)]
extern crate test;
use std::collections::HashMap;
use indexmap::IndexMap;
use fasthash::RandomState;
use fasthash::sea::Hash64;
fn iterate_vec(v: &Vec<Option<u64>>) -> u64 {
let mut out = 0;
for i in v {
out += i.unwrap();
}
out
}
fn iterate_map(v: &HashMap<String, u64>) ->... | true |
1ea0b859f73a3a192af17fdffc411c5cdc8f9f5b | Rust | lucifer1004/AtCoder | /abc242/src/bin/a.rs | UTF-8 | 282 | 2.859375 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
a: usize,
b: usize,
c: usize,
x: usize,
}
if x <= a {
println!("1");
} else if x > b {
println!("0");
} else {
println!("{}", c as f64 / (b - a) as f64);
}
}
| true |
92f74bc637477c69906f0ac178958f3fa8769824 | Rust | Robbepop/type-metadata | /src/type_def.rs | UTF-8 | 12,157 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019
// by Centrality Investments Ltd.
// and Parity Technologies (UK) Ltd.
//
// 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/... | true |
cdd9ff0e11889037e6dfe4bb1b8d3bc828e0d22a | Rust | jedisct1/rust-openssl | /openssl/src/x509/extension.rs | UTF-8 | 7,348 | 3.234375 | 3 | [
"OpenSSL",
"MIT",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"Apache-2.0"
] | permissive | use std::fmt;
use nid::Nid;
/// Type-only version of the `Extension` enum.
///
/// See the `Extension` documentation for more information on the different
/// variants.
#[derive(Clone,Hash,PartialEq,Eq)]
pub enum ExtensionType {
KeyUsage,
ExtKeyUsage,
SubjectAltName,
IssuerAltName,
OtherNid(Nid),
... | true |
02c1db9f273c283bc48e96dfe0024327e4cd76c7 | Rust | diggyk/sshcerts | /src/yubikey/management.rs | UTF-8 | 5,687 | 2.640625 | 3 | [
"MIT"
] | permissive | use ring::digest;
use yubikey_piv::{MgmKey, YubiKey};
use yubikey_piv::policy::{PinPolicy, TouchPolicy};
use yubikey_piv::key::{attest, AlgorithmId, sign_data as yk_sign_data, SlotId};
use yubikey_piv::certificate::{Certificate, PublicKeyInfo};
/// Errors when interacting with the Yubikey.
#[derive(Debug)]
pub enum ... | true |
0b9bc289b0c556f733162356d64b8b014860e872 | Rust | Advaith3600/amfoss-tasks | /task-05/src/main.rs | UTF-8 | 1,692 | 3.09375 | 3 | [] | no_license | use reqwest;
use scraper::{Selector, Html};
use csv::Writer;
use std::fs;
use std::fs::File;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// fetching data from url
let resp = reqwest::get("https://www.worldometers.info/coronavirus/#countries").await?;
assert!(resp.status().is_... | true |
cce375db19e151a949534fa64bf25a6bddd5fcfc | Rust | mEEksIsu/rust-aoc-2018 | /src/days/day7.rs | UTF-8 | 5,859 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use crate::days::Day;
use regex::Regex;
use std::collections::BTreeMap;
use std::fs;
type Step = char;
pub struct Day7 {
input: String,
}
impl Day7 {
pub fn new() -> Day7 {
let input = fs::read_to_string("res/day7.txt").unwrap();
Day7 { input }
}
}
impl Day for Day7 {
fn part1(&self... | true |
c120e5415bc5f6a5896a558a2324fc9ff2fb15f7 | Rust | shadowng/rust-protobuf | /protobuf/src/reflect/dynamic.rs | UTF-8 | 1,645 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::arc_or_static::ArcOrStatic;
use crate::cached_size::CachedSize;
use crate::reflect::MessageDescriptor;
use crate::reflect::ProtobufValue;
use crate::Clear;
use crate::CodedInputStream;
use crate::CodedOutputStream;
use crate::Message;
use crate::ProtobufResult;
use crate::UnknownFields;
#[derive(Debug)]
pub... | true |
3da8b707cf52f1158f0b543a7d132a34fe497e34 | Rust | UARTman/chip8 | /src/main.rs | UTF-8 | 3,625 | 2.515625 | 3 | [
"Unlicense"
] | permissive | #![deny(clippy::all)]
#![forbid(unsafe_code)]
#![windows_subsystem = "windows"]
use crate::gui::Gui;
use crate::world::World;
use log::error;
use pixels::{Error, Pixels, SurfaceTexture};
use simple_logger::SimpleLogger;
use winit::dpi::LogicalSize;
use winit::event::{Event, VirtualKeyCode};
use winit::event_loop::{Con... | true |
31f10200209429e5896cd6edef02b66fc98e10f1 | Rust | plaflamme/advent-2018 | /src/puzzle9/mod.rs | UTF-8 | 6,558 | 3.203125 | 3 | [] | no_license | use regex::Regex;
use std::str::FromStr;
use std::collections::BinaryHeap;
use std::cmp::Reverse;
use std::fmt::{Display, Formatter, Error};
use termion::color;
#[derive(PartialEq)]
enum Turn {
GameOver,
NoPoints,
Points(u32)
}
#[derive(Clone, Debug)]
struct Marble {
value: u32, // the marble's value
... | true |
c3766ef733a0862e9d23d8e333711ad06a14b7e9 | Rust | j-haj/dist-si | /pso/src/pso/position.rs | UTF-8 | 1,396 | 3.234375 | 3 | [] | no_license | use ndarray::Array1;
use rand::{Rng, thread_rng};
use rand::distributions::Uniform;
///! Represents the position of a particle. A position does not necessarily
///! need to be a numeric value. A position object has a current coordinate,
///! represented by `coords`, a restriction on the min and max values allowed
///!... | true |
3fd41c6d00d627fba6f6d6aca6b679a2203e9d49 | Rust | ivfranco/baby-rgit | /src/bin/show_diff.rs | UTF-8 | 2,929 | 2.578125 | 3 | [] | no_license | use std::{convert::TryFrom, fs::File, io::Read, str::from_utf8};
use anyhow::Context;
use argh::FromArgs;
use baby_rgit::{
cache::{sha256_to_hex, DirCache, FileStats},
cmd::{db_environment, error_exit},
};
use bitflags::bitflags;
use difference::{Changeset, Difference::*};
bitflags! {
struct Diff: u32 {
... | true |
c484cdb95394535fb68f532ebfeffb6fe5df81c8 | Rust | iampawan/flutter-rs | /flutter-engine/src/builder.rs | UTF-8 | 1,118 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::{CreateError, FlutterEngine, FlutterEngineHandler};
use std::path::PathBuf;
use std::sync::Weak;
pub struct FlutterEngineBuilder {
pub(crate) handler: Option<Weak<dyn FlutterEngineHandler>>,
pub(crate) assets: PathBuf,
pub(crate) args: Vec<String>,
}
impl FlutterEngineBuilder {
#[allow(clip... | true |
47b18b8f7ab92f2f933fef66ea782a0377460aba | Rust | masonwr/huffman-encoding | /src/ioutils.rs | UTF-8 | 6,051 | 2.96875 | 3 | [] | no_license | use std::collections::BTreeMap;
use std::convert::TryInto;
use std::io::prelude::*;
use std::mem::size_of;
use crate::encoding::{Direction, EncodingNode};
#[derive(Debug)]
pub struct HuffmanPathWriter {
bit_count: u8,
buffer: u8,
}
impl HuffmanPathWriter {
pub fn new() -> Self {
HuffmanPathWriter... | true |
74d35b91c66f82c99d06f5efbcbeb3e3ddc4c96d | Rust | veltzer/demos-rust | /src/types/simple.rs | UTF-8 | 428 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | // this example prints out various simple types of rust
use std::io::stdout;
use std::io::*;
use std::fs::File;
fn print_type_of<T>(_: &T) {
println!("{}", std::any::type_name::<T>())
}
fn main() {
let x: i32=7;
print_type_of(&x);
print_type_of(&stdout());
let file = File::open("/etc/passwd").unwr... | true |
c555a6a4c39282b476d60c53a0c0dcd0592d8d23 | Rust | rnleach/bufkit-data | /src/archive/query.rs | UTF-8 | 30,891 | 2.796875 | 3 | [
"MIT"
] | permissive | use rusqlite::OptionalExtension;
use std::{collections::HashSet, io::Read, iter::FromIterator, str::FromStr};
use crate::{
errors::BufkitDataErr,
models::Model,
site::{SiteInfo, StateProv, StationNumber},
};
mod station_summary;
pub use station_summary::StationSummary;
impl crate::Archive {
/// Retri... | true |
211cea598b1210b92d8ee758c2395b8da6769692 | Rust | greyshaman/pas | /src/models/client.rs | UTF-8 | 2,190 | 3.25 | 3 | [
"MIT"
] | permissive | use super::human_names::{HumanNamed, HumanNames};
pub struct Client {
human_name: HumanNames,
}
impl HumanNamed for Client {
fn first_name(&self) -> String {
self.human_name.first_name()
}
fn set_first_name(&mut self, value: &str) -> &Client {
self.human_name.set_first_name(value);
self
}
fn... | true |
8865050b88cebdff8f1c85cc5d8b49792ee95ead | Rust | tremor-rs/tremor-runtime | /src/postprocessor/compress.rs | UTF-8 | 10,996 | 2.8125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2020-2021, The Tremor Team
//
// 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 agr... | true |
201bc7f8952f19405139eca151a96a456d3d0be1 | Rust | zhuoyw/timely-dataflow | /src/progress/nested/pointstamp_counter.rs | UTF-8 | 1,714 | 2.84375 | 3 | [
"MIT"
] | permissive | //! Manages pointstamp counts (timestamp, location) within a sub operator.
use progress::Timestamp;
use progress::nested::{Source, Target};
use progress::ChangeBatch;
/// Represents changes to pointstamps before and after transmission along a scope's topology.
#[derive(Default)]
pub struct PointstampCounter<T:Timesta... | true |
b9c4c28d6629c51c306fd5b23e61fc99ce83a10e | Rust | nareshganduri/Cache | /src/lib.rs | UTF-8 | 4,586 | 3.9375 | 4 | [] | no_license | //! Thread-safe and non-thread-safe variants of lazily evaluated caches.
#![deny(missing_docs)]
use std::cell::{Ref, RefCell};
use std::ops::Deref;
use std::sync::{RwLock, RwLockReadGuard};
/// a non-thread-safe implementation of a lazily evaluated expression. For a
/// thread-safe variant, use [`AtomicCache`].
/// ... | true |
c9deba5baaac922163f07760f7a56fccb12f5f77 | Rust | IgorBoyarshin/vffm | /src/direntry.rs | UTF-8 | 4,775 | 3.171875 | 3 | [] | no_license | use crate::filesystem::*;
use crate::coloring::*;
use crate::input::*;
use std::path::PathBuf;
#[derive(Clone)]
pub struct DirEntry {
pub entrytype: EntryType,
pub name: String,
pub size: u64,
pub time_modified: u64,
pub permissions: Permissions,
pub paint: Paint,
pub is_selected: bool,
}
... | true |
360fe81a4aa91dc71fed806f377250b9f6a5aeba | Rust | brownian-motion/lisp_compiler_rust | /src/parser/tree.rs | UTF-8 | 11,262 | 3 | 3 | [
"MIT"
] | permissive | use crate::lexer::Lexable;
use crate::memory::*;
use crate::text::CharLocation;
use crate::text::*;
use std::clone::Clone;
use std::fmt;
use std::fmt::Debug;
use std::ops::Range;
use super::elems::*;
use super::traits::*;
pub struct ParseTree {
pub exprs: MemoryArena<Expr>,
pub es: MemoryArena<Es>,
pub... | true |
b7caf5f586174cd5896b6dd1edd382f215e29212 | Rust | keringar/assembler | /src/sys/physics.rs | UTF-8 | 536 | 2.765625 | 3 | [] | no_license | use cgmath::Vector3;
use components;
use specs::{Join, ReadStorage, System, WriteStorage};
// Translates physical forces into transforms
pub struct PhysicsSys;
impl<'a> System<'a> for PhysicsSys {
type SystemData = (ReadStorage<'a, components::Physics>, WriteStorage<'a, components::Transform>);
fn ... | true |
e47e50adaa8b2e7e7066a8810c0b5c0f1352bdc7 | Rust | doitian/ckb | /pow/src/lib.rs | UTF-8 | 2,002 | 2.640625 | 3 | [
"MIT"
] | permissive | //! TODO(doc): @quake
use byteorder::{ByteOrder, LittleEndian};
use ckb_types::{
packed::{Byte32, Header},
prelude::*,
};
use serde::{Deserialize, Serialize};
use std::any::Any;
use std::fmt;
use std::sync::Arc;
mod dummy;
mod eaglesong;
mod eaglesong_blake2b;
#[cfg(test)]
mod tests;
pub use crate::dummy::Du... | true |
5965effd1dc662df5c41d92078ab7c09228bb7f7 | Rust | abonander/imgurian | /src/auth.rs | UTF-8 | 1,618 | 2.96875 | 3 | [] | no_license | use anterofit::{Adapter, JsonAdapter};
use std::fmt::{self, Display, Formatter, Write};
pub struct AuthUrl<'i, S> {
resp_type: ResponseType,
client_id: &'i str,
state: Option<S>,
}
impl<'i, S: Display> Display for AuthUrl<'i, S> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
if let Some(... | true |
d7a35e6f1c258023e20fe86c67b131ff8eaa5ec7 | Rust | dzobbe/rust-perfcnt-reader | /src/perf_counters/cpucounters/consumer.rs | UTF-8 | 3,268 | 2.796875 | 3 | [
"MIT"
] | permissive | use perf_counters::cpucounters::PCM_Counters;
use super::producer::CountersProducer;
// Maximum Instruction per cycles of Intel Skylake CPU architecture
static max_ipc: u8 = 4;
#[derive(Debug, Clone)]
pub struct CntMeasurement {
inst_retired_any: u64,
cpu_clk_unhalted_thread: u64,
cpu_clk_unhalted_ref: u6... | true |
3601a51b11816d6d6f6ea2a65a54e697c93ebdba | Rust | manojkumarmc/serde-example | /src/main.rs | UTF-8 | 983 | 2.84375 | 3 | [] | no_license | extern crate serde_json;
extern crate serde_yaml;
#[macro_use]
extern crate serde_derive;
use std::fs::File;
pub type Provider = Vec<ProviderElement>;
#[derive(Debug, Serialize, Deserialize)]
pub struct ProviderElement {
category: Category,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Category {
... | true |
b182e24b7547dc96b0cec8d73f95be27ad90e238 | Rust | svmk/fund-watch-bot | /src/telegram/model/chat.rs | UTF-8 | 1,290 | 2.765625 | 3 | [] | no_license | use crate::market::fund_report::model::fund_id::FundId;
use crate::telegram::model::chat_id::ChatId;
use crate::repository::model::entity::Entity;
#[derive(Debug, Serialize, Deserialize)]
pub struct Chat {
#[serde(rename="id")]
id: ChatId,
#[serde(rename="fund_subscriptions")]
fund_subscriptions: Vec<F... | true |
7d39440fdacecb515597ec3662dfcc28d4600af1 | Rust | timothyjrogers/tjr-chip8 | /src/application.rs | UTF-8 | 9,062 | 2.5625 | 3 | [] | no_license | use iced::{button, executor, keyboard, slider, time,
Application,Clipboard, Command, Element, Subscription};
use rodio::{
source::{SineWave, Source},
Sink,
};
use std::time::Duration;
use nfd2::Response;
use crate::gui;
use crate::chip8;
use crate::keypad;
//CONSTANTS
const DEFAULT_CLOCK_SPEED: u32... | true |
5d6f499c31f9fbfd850d5fb3728e2128571f86b9 | Rust | bwasty/gltf-rs | /gltf-importer/tests/import_examples.rs | UTF-8 | 2,294 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate gltf_importer;
use std::{fs, path};
use gltf_importer::{import, Error as ImportError};
use std::boxed::Box;
use std::error::Error as StdError;
fn import_from_path(path: &path::Path) -> Result<(), ImportError> {
match import(path) {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
#[al... | true |
93eb92d480a65a4f85ff99b19c80e7e0784fd0f0 | Rust | gfx-rs/naga | /src/front/type_gen.rs | UTF-8 | 17,724 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /*!
Type generators.
*/
use crate::{arena::Handle, span::Span};
impl crate::Module {
/// Populate this module's [`SpecialTypes::ray_desc`] type.
///
/// [`SpecialTypes::ray_desc`] is the type of the [`descriptor`] operand of
/// an [`Initialize`] [`RayQuery`] statement. In WGSL, it is a struct type
... | true |
a329546b7d81d0832c2a45e443c770d8101443e8 | Rust | hgallagher1993/discrete_transforms | /tests/haar_1d_tests.rs | UTF-8 | 777 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate discrete_transforms;
use discrete_transforms::haar_1d::*;
use discrete_transforms::util::TransformDirections;
#[test]
fn haar_1d_forward_test() {
let input = vec![6.0, 12.0, 15.0, 15.0, 14.0, 12.0, 120.0, 116.0];
let expected = vec![38.75, -26.75, -3.0, -52.5, -3.0, 0.0, 1.0, 2.0];
let mut h... | true |
afc9fd921e08678d03ddc737e1adc2d7277d4e4e | Rust | doraneko94/RustAntBook | /atcoder/examples/abc012b.rs | UTF-8 | 315 | 3.015625 | 3 | [] | no_license | pub fn read1<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn main() {
let n = read1::<usize>();
let h = n / 3600;
let m = n % 3600 / 60;
let s = n % 60;
println!("{:02}:{:02}:{:02}", h, m, s);
} | true |
0e77d75eaa5d6dd7a559b72527312bde6882b734 | Rust | ice1000/agda-mode | /src/resp/mod.rs | UTF-8 | 2,323 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use serde::Deserialize;
use crate::base::TokenBased;
use crate::pos::InteractionPoint;
pub use self::di::*;
pub use self::give::*;
pub use self::goal::*;
pub use self::hl::*;
pub use self::oc::*;
/// Display info.
mod di;
/// About the "Give" action.
mod give;
/// Goal information.
mod goal;
/// Highlighting.
mod hl... | true |
da9c4328963268de3a9f5227d8460e9f91043c35 | Rust | sweb/learn-rs | /src/main.rs | UTF-8 | 3,357 | 2.796875 | 3 | [] | no_license | use ndarray::{Array1, Array2, Axis, Slice};
use serde::Deserialize;
use std::error::Error;
use std::fs::File;
use std::time::SystemTime;
use learn_rs::Tree;
#[derive(Debug, Deserialize)]
struct BostonRecord {
crim: f64,
zn: f64,
indus: f64,
chas: f64,
nox: f64,
rm: f64,
age: f64,
dis: ... | true |
09c481de457c8e3c2bc2ae219f82e0a89be66084 | Rust | Danue1/namumark | /namumark_parser/src/span/command_span/image.rs | UTF-8 | 4,919 | 3.0625 | 3 | [] | no_license | use crate::{pipeline, CommandSpan, ImageOption, Result, EMPTY};
use nom::bytes::complete::{tag, take_till};
// TODO(Danuel): [[:파일:]] 문법 추가 필요
pub(crate) fn image(input: &str) -> Result<CommandSpan> {
let (input, _) = identifier(input)?;
let (input, url) = url(input)?;
let option = option(input);
let span = Co... | true |
dcddaa45402ea53fe3fa46fb92cce84dd70d7ad3 | Rust | charlieflowers/awarecs | /src/lex.rs | UTF-8 | 25,348 | 3.0625 | 3 | [] | no_license | use chomp::*;
use TokenTag::*;
// use collections::string::String;
// mod chomp; // If some other crate tries to use lex, then this won't work! That crate will have to say "mod chomp;" and "mod lex;"
// macro_rules! crf {
// ($e:expr) => {
// println!("{} is {}", stringify!($e), $e);
// };
// ($e... | true |
7b2a762ed61083aa5db5102043bb55239ccdf20d | Rust | mm318/ray-tracing | /src/hittable_box.rs | UTF-8 | 8,257 | 2.765625 | 3 | [
"MIT"
] | permissive | use super::aabb;
use super::hittable;
use super::material;
use super::ray;
use super::utils::RayTracingFloat;
//
// XY Rect
//
pub struct XY_Rect {
mp: std::rc::Rc<dyn material::Material>,
x0: RayTracingFloat,
x1: RayTracingFloat,
y0: RayTracingFloat,
y1: RayTracingFloat,
k: RayTracingFloat,
}
... | true |
81a4d85fea6a48e953c2a057ab5547b2d5d435c1 | Rust | wayofthepie/evee | /src/execution.rs | UTF-8 | 1,236 | 2.90625 | 3 | [] | no_license | use rocket::State;
use rocket_contrib::JSON;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use uuid::Uuid;
#[derive(Clone, Deserialize, Serialize)]
pub struct Execution {
repo: String,
init: String,
}
#[derive(Deserialize, Serialize)]
pub struct ExecutionCreated {
id: Uuid,
execution: Ex... | true |
ca24ad4fd9168f7b91c5b51f0688cb576198d4f4 | Rust | BenCrulis/GeneticTestbed | /src/algorithm/simple_adaptive.rs | UTF-8 | 5,058 | 2.625 | 3 | [] | no_license | use std::rc::Rc;
use crate::organism::Organism;
use crate::algorithm::config::ProblemConfig;
use crate::algorithm::selection::Elitism;
use crate::problems::DiscreteHyperparameters;
use crate::algorithm::mutation::Mutator;
use rand::{thread_rng, Rng};
use crate::scoring::Scorer;
use crate::common::{Named, Parametrized};... | true |
abc0b217effe0b9382c801cd94e146ceffc8921c | Rust | rymndhng/advent-of-code-2020 | /src/day16.rs | UTF-8 | 6,746 | 2.875 | 3 | [] | no_license | use crate::utils::ParseError;
use itertools::Itertools;
use std::collections::HashMap;
use std::collections::HashSet;
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::iter::FromIterator;
use std::str::FromStr;
#[allow(dead_code)]
pub fn main() -> std::io::Result<()> {
let ... | true |
f3fe9cf63c91e83add3b9803f59a31d7aa6f6268 | Rust | louiidev/math_utils_rs | /src/lib.rs | UTF-8 | 362 | 3.359375 | 3 | [] | no_license |
fn lerp(a: f32, b: f32, t: f32) -> f32 {
(1. - t) * a + b * t
}
fn inverse_lerp(a: f32, b: f32, v: f32) -> f32 {
(v - a) / (b - a)
}
fn remap(i: (f32, f32), o: (f32, f32), v: f32) -> f32 {
let t = inverse_lerp(i.0, i.1, v);
lerp(o.0, o.1, t)
}
#[cfg(test)]
mod tests {
#[test]
fn it_works(... | true |
85282e46125bf1746fbfbff3125f961642c283c2 | Rust | afprusin/leetcode-rust | /src/bin/112_path_sum.rs | UTF-8 | 1,489 | 3.328125 | 3 | [] | no_license | use std::rc::Rc;
use std::cell::{RefCell};
pub struct Solution {}
// Definition for a binary tree node.
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn new(val: i32)... | true |
78ac25a334afbcb6688e49d190a746eae2dfc877 | Rust | luccasmmg/noodles | /noodles-sam/src/reader.rs | UTF-8 | 6,888 | 3.484375 | 3 | [
"MIT"
] | permissive | //! SAM reader and iterators.
mod records;
pub use self::records::Records;
use std::io::{self, BufRead, Read, Seek};
use noodles_bgzf as bgzf;
const HEADER_PREFIX: u8 = b'@';
const LINE_FEED: u8 = b'\n';
/// A SAM reader.
///
/// The SAM format is comprised of two parts: 1) a header and 2) a list of records.
///
... | true |
46fe5798f1d2f0e3e8b9329d3893bb6dd3bf54b7 | Rust | snjax/near-sdk-pure-rs | /near-sdk-pure/src/collections/lookup_set.rs | UTF-8 | 3,067 | 3.4375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! A persistent set without iterators. Unlike `near_sdk_pure::collections::LookupSet` this set
//! doesn't store values separately in a vector, so it can't iterate over the values. But it
//! makes this implementation more efficient in the number of reads and writes.
use core::marker::PhantomData;
use borsh::{BorshDe... | true |
0335862073e732e8a53dd12addc97f0c73a27091 | Rust | cwenck/stock-sim | /src/pricing/expense_ratio.rs | UTF-8 | 699 | 3 | 3 | [] | no_license | use crate::number::Percent;
use super::Period;
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct ExpenseRatio {
amount: Percent,
}
#[allow(dead_code)]
impl ExpenseRatio {
pub fn new(amount: Percent, period: Period) -> Self {
let amount_per_period =
-Percent::from_decimal(amo... | true |
8d63860b5e6384a686787c66f06f2858f5e4594d | Rust | LinAGKar/advent-of-code-2017-rust | /day3b/src/main.rs | UTF-8 | 1,774 | 3.484375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::io;
struct CoordinateMap {
x: i64,
y: i64,
values: HashMap<(i64, i64), u64>,
}
impl CoordinateMap {
fn new() -> CoordinateMap {
CoordinateMap { x: 0, y: 0, values: [((0, 0), 1)].iter().cloned().collect() }
}
fn move_by(&mut self, x: i64, y: i64)... | true |
9995463a5899abe95da037efcb714115a5d0b61d | Rust | mockersf/Komarowii | /game_data/src/data.rs | UTF-8 | 3,866 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::sync::Arc;
use gdnative::{FromVariant, ToVariant};
use helpers::max;
/// An outfit
#[derive(Debug, Clone)]
pub struct Outfit {
/// it's name
pub name: String,
/// it's mass
pub mass: f32,
/// it's category
pub category: OutfitCategory,
/// does this outfit has engine properties
... | true |
ea6fba7e8a27bd2ff18191812aa76d74beb59912 | Rust | breezykermo/1-maze-rs | /src/bin/solver.rs | UTF-8 | 1,242 | 2.53125 | 3 | [] | no_license | use rust_1_maze::common::{EncodedMazeRoom, MazeRoom};
use rust_1_maze::read_encoded_maze_from_file;
use std::fs::File;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() != 4 {
println!("Incorrect number of arguments.");
println!("./generator <output file> ... | true |
42526405e835144c5e3d9569e2737e91c99a9c5c | Rust | risboo6909/NxM-puzzle-solver | /src/board.rs | UTF-8 | 4,517 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::cmp::{Ord, Ordering, PartialOrd};
use std::collections::HashSet;
use std::convert::From;
const HOLE: usize = 0;
#[derive(Debug, Clone, Copy)]
pub(crate) enum Dir {
Left,
Right,
Up,
Down,
}
#[derive(Hash, PartialOrd, Eq, PartialEq, Clone, Copy, Debug)]
pub(crate) struct RowCol(usize, usize);
... | true |
8e532d21267ba856bb5252616334460601372442 | Rust | g2wang/test | /leetcode20/valid_parentheses.rs | UTF-8 | 1,209 | 3.859375 | 4 | [] | no_license | pub fn main() {
let s = String::from("(5+1) * ((x-1)*[a + b]-{c * (d -e)})");
let ans = is_valid(s);
assert_eq!(ans, true);
}
///
/// Runtime: 0 ms, faster than 100.00% of Rust online submissions for Valid Parentheses.
/// Memory Usage: 2 MB, less than 100.00% of Rust online submissions for Valid Parenthes... | true |
e50d3120affaaa9a59a5b434f97148e139298994 | Rust | YanivBir/stremio-core | /src/models/common/compare_with_priorities.rs | UTF-8 | 750 | 3.09375 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::collections::HashMap;
use std::hash::Hash;
pub fn compare_with_priorities<T: Ord + Hash + Eq + ?Sized>(
a: &T,
b: &T,
priorities: &HashMap<&T, i32>,
) -> Ordering {
match (priorities.get(a), priorities.get(b)) {
(Some(a_priority), Some(b_priority)) => a_priority... | true |
556c03841e3f1771d87b7d5876c3b07f2389d093 | Rust | isgasho/galangua | /src/sdl/resource_manager.rs | UTF-8 | 1,407 | 3.515625 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::path::Path;
pub struct ResourceManager<T> {
map: HashMap<String, T>,
}
impl<T> ResourceManager<T> {
pub fn new() -> Self {
Self {
map: HashMap::new(),
}
}
pub fn load<F: Fn(&str) -> Result<T, String>>(
&mut self, base_path: &... | true |
5714f65d828fbd7bce7860864b27a88beb3f4a29 | Rust | benjaminhirsch/raytracer | /src/canvas/ppm_writer.rs | UTF-8 | 827 | 2.75 | 3 | [] | no_license | use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use crate::canvas::canvas::Canvas;
use std::fs::{create_dir, File};
use std::io::{Error, Write};
use std::path::Path;
#[allow(dead_code, unused_must_use)]
pub fn write_ppm(canvas: Canvas) -> Result<Box<String>, Error> {
let mut rand_string: Strin... | true |
145178cdb5276b1e92361567af6537e17a9acdc5 | Rust | Tenjin0/beginning-rust | /chap10/src/main.rs | UTF-8 | 947 | 3.734375 | 4 | [] | no_license | fn largest<T: PartialOrd + Copy>(list: &[T]) -> T {
let mut found = list[0];
for &item in list {
if item > found {
found = item;
}
}
return found;
}
#[derive(Debug)]
#[derive(Clone)]
#[derive(Copy)]
struct Point<T, U> {
x: T,
y: U
}
#[allow(dead_code)]
impl <T, U>Po... | true |
1a971560de704a1a43ff5489b1aac61227b61c03 | Rust | lpxxn/rust_example | /vector_demo/src/main.rs | UTF-8 | 4,406 | 3.75 | 4 | [] | no_license | fn main() {
let mut v: Vec<i32> = Vec::new();
v.push(1);
v.push(2);
println!("v = {:?}", v);
let v2 = vec![1, 2, 3];
let one: i32 = v[0];
println!("one: {}", one);
let one2: &i32 = &v[0];
println!("one: {}", *one2);
v.push(5);
match v.get(2) {
Some(x) => println!("x ... | true |
9f3f424e5bdc56c2c0902a18275468f1b50b84fb | Rust | andrewhickman/lang | /src/typeck/ops.rs | UTF-8 | 1,421 | 3.359375 | 3 | [] | no_license | use ast;
pub fn ty_of(op: ast::BinaryOp, left: ast::Ty, right: ast::Ty) -> Result<ast::Ty, String> {
use ast::BinaryOp::*;
match op {
// int . int -> int
Mul | Div | Rem | Add | Sub | AssignMul | AssignDiv | AssignRem | AssignAdd | AssignSub => {
if left == ast::Ty::Int && right ==... | true |
735d3799ed82466a73989d8749cfc542bf6a2100 | Rust | mcobzarenco/rust-doom | /wad/src/errors.rs | UTF-8 | 3,811 | 2.859375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-proprietary-license"
] | permissive | use failchain::{BoxedError, ChainErrorKind};
use failure::Fail;
use std::fmt;
use std::result::Result as StdResult;
pub type Error = BoxedError<ErrorKind>;
pub type Result<T> = StdResult<T, Error>;
#[derive(Clone, Eq, PartialEq, Debug, Fail)]
pub enum ErrorKind {
#[fail(display = "Corrupt metadata file: {}", 0)]
... | true |
fd354ad250cc7dc37f9a0ee0efcb9d22d238fd17 | Rust | yrong/24daysofrust | /vol2/src/bin/day18.rs | UTF-8 | 2,859 | 2.75 | 3 | [
"MIT"
] | permissive | #![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate tempfile;
use std::fmt;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::process::Command;
mod errors {
error_chain!{}
}
use errors::*;
#[derive(... | true |
b0a08bf6be293c52743563a798cdda7b51839cfa | Rust | rust-lang/rustc-hash | /src/lib.rs | UTF-8 | 4,506 | 2.859375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
b98439f5e0568c288d1317ac39729cf4429b8b83 | Rust | chrissimpkins/recurse | /src/config.rs | UTF-8 | 2,479 | 3.203125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::Recurse;
#[derive(Debug)]
pub(crate) struct Config {
pub(crate) subcmd: Recurse,
}
impl Config {
pub(crate) fn new(opt: Recurse) -> Self {
Self { subcmd: opt }
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
#[test]
fn test_config_instantiation_defau... | true |
6f8b598f7a3b6d2f677e60d5ffbf20f9c7157336 | Rust | Sousa99/AdventOfCode2020 | /day_06/src/main.rs | UTF-8 | 2,659 | 3.5625 | 4 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashSet;
struct Group {
at_least_one_yes : HashSet<char>,
all_yes : HashSet<char>
}
impl Group {
pub fn new() -> Group {
Group {
at_least_one_yes : HashSet::new(),
all_yes : HashSet::new(),
... | true |
cb6ed7340cf6081832c621d65b6538b970320fcc | Rust | swc-project/swc | /crates/swc_ecma_quote/src/clone.rs | UTF-8 | 193 | 2.5625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Module for implicitly copyable types.
/// Noop
pub trait ImplicitClone: Clone {
fn clone_quote_var(&self) -> Self {
self.clone()
}
}
impl<T: Clone> ImplicitClone for T {}
| true |
da0ff0d1b731baa4f7765174261b458b88d1159f | Rust | Robotics-BUT/DCMotor-firmware | /src/controller.rs | UTF-8 | 760 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::bridge::{fmaxf, fminf};
const MAX_ACTION: f32 = 1.0;
pub struct Controller {
p: f32,
s: f32,
sum: f32,
dt: f32,
target: f32,
}
impl Controller {
pub fn new(p: f32, s: f32, dt: f32) -> Self {
Self {
p,
s,
sum: 0.0,
dt,
... | true |
56cc95b12ca1edbb15dba4dd68e0556cec86848c | Rust | Veratil/rust-rosetta | /src/penneys_game.rs | UTF-8 | 2,991 | 3.3125 | 3 | [
"Unlicense"
] | permissive | // http://rosettacode.org/wiki/Penney's_game
extern crate rand;
use std::io::{stdout, stdin, Write};
use std::thread;
use std::time::Duration;
use rand::{Rng, thread_rng};
fn toss_coin(print: bool) -> char {
let c: char;
if thread_rng().gen::<bool>() {
c = 'H'
} else {
c = 'T'
}
i... | true |
85e1f25b50f16dc451f42a96f051ac6feeff6696 | Rust | mkeeter/advent-of-code | /2018/day20/src/main.rs | UTF-8 | 3,074 | 3.296875 | 3 | [] | no_license | use std::collections::{HashMap, HashSet, VecDeque};
use std::io::{self, Read};
type Pt = (i32, i32);
#[derive(Debug)]
struct Map {
graph: HashMap<Pt, HashSet<Pt>>,
}
impl Map {
fn from_str(s: &str, start: Pt) -> Map {
let mut out = Map {
graph: HashMap::new(),
};
out.walk(... | true |
345cde3cae2de6ac322d536c4de66c44ab1f9ae8 | Rust | Sousa99/AdventOfCode2020 | /day_25/src/main.rs | UTF-8 | 3,626 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{BufRead, BufReader};
// ------------------ Device ------------------
struct Device {
loop_size : u64,
subject_number : u64,
current_value : u64,
remainder_value : u64,
}
impl Device {
pub fn new(subject_number : u64, remainder_used : u64) -> Device {
Device... | true |
f04575b3e354e6e5507a6ae61d1427d7020835e0 | Rust | lambdaxymox/fuchsia | /src/developer/ffx/plugins/component/doctor/src/args.rs | UTF-8 | 1,329 | 2.515625 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {argh::FromArgs, ffx_core::ffx_command};
#[ffx_command()]
#[derive(FromArgs, Debug, PartialEq)]
#[argh(
subcommand,
name = "doctor",
descr... | true |
0d6f39c31a372513b5ae09b2b853be35c26a79d7 | Rust | aab11bcc2233/leetcode_test- | /src/two_sum.rs | UTF-8 | 927 | 3.625 | 4 | [] | no_license | use std::collections::HashMap;
fn main() {
let nums = vec![2, 11, 7, 15];
let target = 9;
// let result = two_sum(nums, target);
let result = two_sum_hash(nums, target);
println!("{:?}", result);
}
fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let length = nums.len();
for i in 0.... | true |
c855110391275070593dffe64f275f53c2eadd5e | Rust | KonishchevDmitry/investments | /src/formats/xls/sheet.rs | UTF-8 | 2,711 | 2.921875 | 3 | [] | no_license | use std::ops::Index;
use calamine::{Range, Reader, open_workbook_auto};
use crate::core::GenericResult;
use super::{Cell, is_empty_row};
pub struct SheetReader {
sheet: Range<Cell>,
parser: Box<dyn SheetParser>,
prev_row_id: Option<usize>,
next_row_id: usize,
eof_reached: bool,
}
impl SheetRea... | true |
b4194d3160206f34cf0d3963fb34afc7e49f66b1 | Rust | rklaehn/rust-multihash | /src/arb.rs | UTF-8 | 1,359 | 2.875 | 3 | [
"MIT"
] | permissive | use quickcheck::{Arbitrary, Gen};
use rand::{
distributions::{weighted::WeightedIndex, Distribution},
Rng,
};
use crate::{MultihashGeneric, U64};
/// Generates a random valid multihash.
impl Arbitrary for MultihashGeneric<U64> {
fn arbitrary<G: Gen>(g: &mut G) -> Self {
// In real world lower mult... | true |
decb603dbdcf03fcbad0d80c93c72662448e2cd4 | Rust | paulcacheux/hai | /src/ast/visitor.rs | UTF-8 | 2,393 | 2.90625 | 3 | [
"MIT"
] | permissive | use super::*;
pub trait Visitor: Sized {
type ProgramItem;
type DeclarationItem;
type StatementItem;
type ExpressionItem;
fn visit_program(
&mut self,
program: &Program,
declarations: &[Declaration],
) -> Option<Self::ProgramItem> {
for decl in declarations {
... | true |
9bb13073dfdbcb3dd9bbdd94409a8f5fc2643391 | Rust | MichaelAquilina/adventofcode2018 | /day14/src/main.rs | UTF-8 | 4,258 | 3.21875 | 3 | [] | no_license | // https://adventofcode.com/2018/day/14
fn main() {
let n = 286051;
let result = improve_recipes(n, false);
println!("{}", result);
let result = find_recipes(&n.to_string(), false);
println!("{}", result);
}
fn split_decimal(value: usize) -> (usize, usize) {
(value / 10, value % 10)
}
fn pr... | true |
80c8ebcd6c6e027dea2db317bd42944c41ac7e1d | Rust | PotatoTaco/Programming-Crappy-Solutions | /1_Programming Languages/Rust/Armstrong Number Detector/main.rs | UTF-8 | 721 | 3.625 | 4 | [] | no_license | fn main() {
print!("Please enter a number to check: ");
use std::io::{stdin,stdout,Write};
let mut input=String::new();
let _=stdout().flush();
stdin().read_line(&mut input).expect("Did not enter a correct string");
input = input.trim().to_string();
let val: u32 = input.parse().unwrap();
pr... | true |
b7c190187168e3ffff0e72f072844583a0bc917f | Rust | ttys3/risso | /risso_api/src/context.rs | UTF-8 | 3,146 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #![allow(dead_code, deprecated)]
// Republish diesel's manager so that server impls don't have to add it to their deps.
pub use diesel::r2d2::ConnectionManager;
use diesel::r2d2::Pool;
use serde_derive::Deserialize;
use futures::future::Future;
use crate::logs::macros::*;
#[derive(Deserialize)]
struct ContextConfig... | true |
142a2d932f970a53a4dd94da78da2c960a94cd6c | Rust | kompics/kompact | /core/src/serialisation/protobuf_serialisers.rs | UTF-8 | 1,786 | 3.078125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Provides serialisation support for protocol buffers
use super::*;
use protobuf::Message;
/// Kompact serialisation marker for protobuf messages
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct ProtobufSer;
impl<M: Message + Any + Debug> Serialiser<M> for ProtobufSer {
fn ser_id(&self) -> SerId {
... | true |
14ffac72dc5f19186d246f764f4ea5479ce68d69 | Rust | MiyamonY/atcoder | /abc/065/d/02/src/main.rs | UTF-8 | 2,714 | 2.953125 | 3 | [] | no_license | use std::collections::BinaryHeap;
#[allow(unused_macros)]
macro_rules! scan {
() => {
{
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim().to_string()
}
};
(;;$n:expr) => {
(0..$n).map(|_| scan!()).co... | true |
98998a9e9dd8f9effa0cdbc7e51be0526372db64 | Rust | colingavin/kd-forest | /src/metric.rs | UTF-8 | 15,425 | 3.53125 | 4 | [
"0BSD"
] | permissive | //! [Metric spaces](https://en.wikipedia.org/wiki/Metric_space).
pub mod approx;
pub mod forest;
pub mod kd;
pub mod soft;
pub mod vp;
use ordered_float::OrderedFloat;
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::iter::FromIterator;
/// An [order embedding](https://en.wikipedia.org/wiki/Order_... | true |
f6aaab1eb68193633ee9bc757d98d71ed44c608e | Rust | eholk/adventofcode2020 | /src/day2.rs | UTF-8 | 2,950 | 3.578125 | 4 | [
"Apache-2.0"
] | permissive | use regex::Regex;
struct Constraint {
min_count: usize,
max_count: usize,
character: char,
}
impl Constraint {
fn matches(&self, password: &str) -> bool {
let mut count = 0;
for c in password.chars() {
if c == self.character {
count += 1;
}
... | true |
a27fc634b86c5873ab2baebeac088d5df7fbba9c | Rust | paytonrules/godot-rust | /test/src/test_derive.rs | UTF-8 | 3,261 | 2.84375 | 3 | [
"MIT"
] | permissive | use gdnative::*;
pub(crate) fn run_tests() -> bool {
let mut status = true;
status &= test_derive_to_variant();
status
}
pub(crate) fn register(_handle: &init::InitHandle) {}
fn test_derive_to_variant() -> bool {
println!(" -- test_derive_to_variant");
#[derive(Clone, Eq, PartialEq, Debug, ToV... | true |
73220da454e4fb643d3ffe8b8f717d6b958d91c7 | Rust | hessifer/Rust | /quiz/src/main.rs | UTF-8 | 767 | 3.546875 | 4 | [] | no_license | use std::io;
/*
Program: quiz
Author: unknown
Date: 1/19/19
Purpose: Ask a user a question and give them three chances to
get the correct answer.
*/
fn main() {
let mut answer = String::new();
println!("What is the capital of Virginia?");
for n in 1..4 {
answer.cl... | true |
ed4387cbb0da84a83d537ffdcd2788b6e2d7c4bc | Rust | floatingmountain/assetmanage-rs | /src/manager.rs | UTF-8 | 10,259 | 3.125 | 3 | [
"MIT"
] | permissive | use crate::{
asset::{Asset, AssetHandle},
loaders::{LoadStatus, Loader},
sources::Source,
};
use std::path::{Path, PathBuf};
use std::sync::mpsc::{Receiver, Sender};
use std::{collections::HashMap, io::ErrorKind, sync::Arc};
/// Manages the loading and unloading of one struct that implements the Asset trai... | true |
0ff6da2617df12a5f9298f4a558495c8643f6cc3 | Rust | caiomcg/ccommit-analyser | /src/validator/check_line_length/mod.rs | UTF-8 | 2,742 | 3.625 | 4 | [] | no_license | use regex::Regex;
use crate::validator::{Validator, LineError, ValidatorError};
pub struct CheckLineLength {
size: usize,
re: Regex,
}
impl CheckLineLength {
pub fn new(size: usize) -> Self {
let regex_string = format!(r"^.{{1,{}}}\w$", size);
Self {
size,
re: Rege... | true |
efb9b2ecdee0356136b3935839b58e2fa7b6201a | Rust | chom-parser/chom | /src/lexing/nd_table.rs | UTF-8 | 3,979 | 2.9375 | 3 | [] | no_license | use super::{regexp, Automaton, RegExp, State};
use crate::poly::{terminal, Grammar};
/// Non deterministic lexing table.
pub struct NDTable {
/// Used to generate unique state ids.
next_state: u32,
/// Inner automaton.
automaton: Automaton,
}
impl NDTable {
/// Creates a new non deterministic lexing table from ... | true |
baed6f0dceef307b056c044db382b1503d1c630c | Rust | diversario/raytracing-in-one-weekend | /src/sphere.rs | UTF-8 | 1,629 | 3.1875 | 3 | [
"MIT"
] | permissive | use crate::hittable::HitRecord;
use crate::hittable::Hittable;
use crate::point3::Point3;
use crate::ray::Ray;
use crate::vec3::Vec3;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Sphere {
center: Point3,
radius: f64,
}
impl Sphere {
pub fn new(ctr: Point3, r: f64) -> Sphere {
Sphere {
center: c... | true |
f92293eb79d01c0666bc9ca5dafb339f5e39cf5c | Rust | fossabot/crossbow | /crates/creator-tools/src/commands/apple/gen_app_folder.rs | UTF-8 | 1,347 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use crate::error::*;
use fs_extra::dir::{copy as copy_dir, CopyOptions};
use std::fs::{create_dir_all, remove_dir_all};
use std::path::{Path, PathBuf};
/// Generates an apple app folder.
pub fn gen_apple_app_folder(
target_dir: &Path,
project_name: &str,
resources_dir: Option<PathBuf>,
assets_dir: Opti... | true |
9a50f3e27713002836a87c1232390b70770da5b1 | Rust | Dante-Broggi/swift-bindgen | /swift-sys/src/ctx_desc/ty/enum_.rs | UTF-8 | 1,208 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use crate::ctx_desc::TypeContextDescriptor;
/// Context descriptor for an enum type.
#[repr(C)]
#[derive(Clone, Debug)]
pub struct EnumDescriptor {
/// The base nominal type descriptor.
pub base: TypeContextDescriptor,
/// The number of non-empty cases in the enum are in the low 24 bits; the
/// offse... | true |
1ee4acca8c45ab6561dbfa0a0cbdc36e98ad35fd | Rust | evanparizot/wordclock | /firmware/src/config/default.rs | UTF-8 | 3,869 | 2.859375 | 3 | [] | no_license | use crate::times::{EMPTY, Phrase};
pub struct DefaultMode {}
impl DefaultMode {
pub const ONE: Phrase = [EMPTY, [0, 0, 0, 0, 0, 0, 0, 0b00000111], EMPTY, EMPTY];
pub const TWO: Phrase = [EMPTY, [0, 0, 0, 0, 0, 0, 0, 0b11100000], EMPTY, EMPTY];
pub const THREE: Phrase = [[0, 0, 0, 0, 0, 0, 0, 0b11111000],... | true |
9733cfc02bfc27c3e609c72d4c7c49b388324856 | Rust | jaxwilko/paddle | /src/input/pointer_tracker.rs | UTF-8 | 2,342 | 3.46875 | 3 | [] | no_license | use crate::{PointerEvent, PointerEventType, Vector};
/// Helper struct that can be added to a frame to track advanced cursor updates.
///
/// This can be useful to make the cursor position available to the draw function, for example to draw hover effects.
/// Drag gestures are also supported, to perform e.g. scrolling... | true |
1e06f1cbf785c686f1cebb977745bfebc67a7e25 | Rust | str4d/ire | /src/crypto/elgamal.rs | UTF-8 | 15,270 | 3.03125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Implementation of I2P's ElGamal public-key encryption scheme over the
//! 2048-bit MODP DH group.
//!
//! This implementation is not constant-time.
//!
//! Original implementation in Java I2P was based on algorithms 8.17 and 8.18
//! specified in section 8.4.1 of the Handbook of Applied Cryptography.
use num_bigin... | true |
5790c31435edd3e6cb74d405290555900df927a2 | Rust | udoprog/rune | /crates/rune/src/workspace/error.rs | UTF-8 | 1,505 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::path::Path;
use thiserror::Error;
use crate::{SourceId};
use crate::ast::Span;
error! {
/// An error raised when interacting with workspaces.
#[derive(Debug)]
pub struct WorkspaceError {
kind: WorkspaceErrorKind,
}
}
impl WorkspaceError {
pub(crate) fn missing_field(span: Span, fi... | true |
e081efe96efdf6f81739ecf6405c5dafb9a1a45b | Rust | thea0032/old-language-attempt | /src/format.rs | UTF-8 | 13,534 | 3.296875 | 3 | [] | no_license | use crate::string;
pub fn handle(input:Vec<String>) -> Vec<Vec<String>>{
clean(into_blocks(input))
}
pub fn into_blocks(mut input:Vec<String>) -> Vec<Vec<String>>{
let mut result:Vec<String> = vec![];
let mut buffer = "".to_string();
let mut level = 0;
let mut brace_level = 0;
input.push(";".to_... | true |
0bba0422964efa0f5b917db63202a3d8269072f1 | Rust | aq1018/rpi0wcar | /src/error.rs | UTF-8 | 1,581 | 2.6875 | 3 | [
"MIT"
] | permissive | use std::{error, fmt};
pub type PwmError = rppal::pwm::Error;
pub type I2cError = rppal::i2c::Error;
pub type Pca9685Error = pwm_pca9685::Error<I2cError>;
#[derive(Debug)]
pub enum MotionError {
PwmError(PwmError),
I2cError(I2cError),
Pca9685Error(Pca9685Error),
InvalidInput(String),
}
impl fmt::Dis... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.