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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8f52291035a654c2f0ae187dc1dd00fd2ac241d5 | Rust | rfaulhaber/pluv | /src/client/client.rs | UTF-8 | 1,016 | 3.0625 | 3 | [
"MIT"
] | permissive | use super::darksky::DarkSkyClient;
use std::error;
use std::fmt;
pub enum ClientType {
DarkSky { api_key: String },
}
pub enum ForecastClient {
DarkSkyClient(DarkSkyClient),
}
impl ForecastClient {
pub fn get_current_weather(&mut self, latitude: f64, longitude: f64) -> Forecast {
match self {
... | true |
3b09f48960952a66626c2e76e36030bec4f60658 | Rust | jkbstrmen/snark-tool | /src/service/component_analysis/vertex_pairs.rs | UTF-8 | 1,877 | 3.234375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::graph::graph::Graph;
use crate::graph::vertex::Vertex;
///
/// de-facto list of edges for simple graph with undirected edges
///
pub struct PairsOfAdjacentVertices<'a, V: Vertex, G: Graph> {
first_vertex_iterator: Box<dyn Iterator<Item = &'a V> + 'a>,
second_vertex_iterator: Box<dyn Iterator<Item = ... | true |
191f32d7f58094276529e2668f7c98a76fe22239 | Rust | zoosky/rust-yew-realworld-example-app | /crates/conduit-wasm/src/routes/editor.rs | UTF-8 | 10,942 | 2.765625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use yew::services::fetch::FetchTask;
use yew::{
agent::Bridged, html, Bridge, Callback, Component, ComponentLink, FocusEvent, Html, InputData,
KeyboardEvent, Properties, ShouldRender,
};
use yew_router::{agent::RouteRequest::ChangeRoute, prelude::*};
use crate::components::list_errors::ListErrors;
use crate::e... | true |
bbe7165cdffa742a7ded7f59623a6bfb5c38e092 | Rust | cowboy8625/ggezLife | /src/main.rs | UTF-8 | 5,199 | 2.515625 | 3 | [] | no_license | mod game;
mod grid;
mod commands;
mod game_event;
use ggez::{input::mouse::MouseButton, GameResult, Context, event, event::KeyCode, graphics};
use game::Game;
use commands::{key_mapper, Mapper};
use grid::Grid;
const WINDOW: CellPoint<i32> = CellPoint { x:1400, y:800 };
const GRID: i32 = 2;
const CELL: CellPoint<i32... | true |
451bf20341229e1ab0451b902b036f86a38346c2 | Rust | wookievx/advent-of-code-2020 | /rust/src/day2.rs | UTF-8 | 1,837 | 3.09375 | 3 | [] | no_license | extern crate nom;
use nom::{
IResult,
bytes::complete::tag,
combinator::map_res};
use nom::sequence::separated_pair;
use nom::bytes::complete::take_while;
use nom::sequence::preceded;
use nom::bytes::complete::take;
use nom::AsChar;
pub struct Password {
min_req: u16,
max_req: u16,
character: ... | true |
3a70d0024e940942d8ead84f8364222306c34b77 | Rust | javiercode/gb | /src/cpu.rs | UTF-8 | 55,647 | 2.703125 | 3 | [] | no_license | use crate::bus::Bus;
use anyhow::{bail, Result};
use bitfield::bitfield;
use bitmatch::bitmatch;
use rustyline::Editor;
bitfield! {
#[derive(Default)]
struct F(u8);
impl Debug;
c, set_c: 4;
h, set_h: 5;
n, set_n: 6;
z, set_z: 7;
}
pub struct Cpu {
a: u8,
f: F,
bc: u16,
de: u... | true |
d5a3f15c382c6226f8ffa55e735a03d5818ea559 | Rust | qqq-tech/braiins | /open/bosminer/bosminer-config/src/group.rs | UTF-8 | 3,219 | 2.578125 | 3 | [] | no_license | // Copyright (C) 2020 Braiins Systems s.r.o.
//
// This file is part of Braiins Open-Source Initiative (BOSI).
//
// BOSI is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
... | true |
be9000d0372156fcb6818a1a375039441f2f8bba | Rust | mucompilers/project | /pa2/tests/11-arr1.rs | UTF-8 | 147 | 2.71875 | 3 | [] | no_license | fn main() {
let a : [bool; 3] = [true, false, false];
let x = a[0];
a[0];
a[1 - 1];
a[if (a[0]) { 0 } else { 1 }];
}
| true |
90849c7e645d9b315d91f8149bd602624f8f993a | Rust | timokoesters/ruma-client-api | /src/r0/directory/get_public_rooms_filtered.rs | UTF-8 | 2,023 | 2.734375 | 3 | [
"MIT"
] | permissive | //! [POST /_matrix/client/r0/publicRooms](https://matrix.org/docs/spec/client_server/r0.6.0#post-matrix-client-r0-publicrooms)
use js_int::UInt;
use ruma_api::ruma_api;
use serde::{Deserialize, Serialize};
use super::PublicRoomsChunk;
ruma_api! {
metadata {
description: "Get the list of rooms in this hom... | true |
e8cd23f733925eb9029725a7760ff351fd7e699d | Rust | SINHASantos/configure_me | /configure_me_codegen/tests/custom_args.rs | UTF-8 | 2,246 | 2.59375 | 3 | [
"MITNFA"
] | permissive | macro_rules! test_name { () => { "single_optional_param" } }
include!("glue/boilerplate.rs");
use std::iter;
use std::path::PathBuf;
#[test]
fn custom_args() {
let (config, mut remaining, _metadata) = config::Config::custom_args_and_optional_files(&["custom_args", "--foo", "42"], iter::empty::<PathBuf>()).unwrap... | true |
f6f90824662c014c336129ee6677a60cec401fc1 | Rust | hextal/dolysis | /skipframe/src/cli.rs | UTF-8 | 5,343 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | #![allow(deprecated)]
use {
clap::{crate_authors, crate_version, App, Arg, SubCommand},
std::{
net::{IpAddr, SocketAddr},
path::{Path, PathBuf},
str::FromStr,
},
};
#[cfg(unix)]
pub fn generate_cli<'a, 'b>() -> App<'a, 'b> {
__generate_cli().subcommand(
SubCommand::with_... | true |
5a5cc97d9f206326b8cffccc3bb7c71e51d0775d | Rust | ceigey/textgame-rs-prototype | /cellexp/src/main.rs | UTF-8 | 1,151 | 3.546875 | 4 | [] | no_license | use std::cell::Cell;
use std::vec::Vec;
use std::fmt::Debug;
use std::clone::Clone;
use std::marker::Copy;
use std::rc::Rc;
use std::cell::RefCell;
#[derive(Debug, Clone)]
struct Room {
name: String,
doors: Vec<String>,
}
impl Room {
fn new(name: String) -> Room {
let doors = Vec::new();
... | true |
68a2ba263b50738191e70a82f2e702eb4688a14b | Rust | Lokathor/bytemuck | /tests/doc_tests.rs | UTF-8 | 3,155 | 3.125 | 3 | [
"Zlib",
"Apache-2.0",
"MIT"
] | permissive | #![allow(clippy::disallowed_names)]
//! Cargo miri doesn't run doctests yet, so we duplicate these here. It's
//! probably not that important to sweat keeping these perfectly up to date, but
//! we should try to catch the cases where the primary tests are doctests.
use bytemuck::*;
// Miri doesn't run on doctests, so... | true |
7cdc92d974da35120590486f6e1770fc35eca318 | Rust | ftxqxd/anagrams | /src/main.rs | UTF-8 | 6,578 | 3.25 | 3 | [] | no_license | extern crate argparse;
use std::collections::{HashMap, hash_map::DefaultHasher};
use std::hash::BuildHasherDefault;
use std::fs::File;
use std::path::Path;
use std::io::{self, prelude::*};
/// `Identifier` is used to denote a normalized (i.e., lowercased) and sorted string.
type Identifier = str;
type Dictionary = Ha... | true |
c2ec02fa579009d4feb89c49de89d2b5edab510f | Rust | Sherif-Abdou/basic-algebra | /src/main.rs | UTF-8 | 3,952 | 3.265625 | 3 | [] | no_license | extern crate regex;
mod equation;
mod equation_solver;
mod expression;
use crate::equation::*;
use crate::equation_solver::*;
use crate::expression::*;
use regex::Regex;
use std::env;
fn tokenize(argument: &str) -> Vec<String> {
let re = Regex::new(r"[0-9]+|\+|-|\*|/|=|[A-Za-z]").unwrap();
let mut values: Ve... | true |
95d73efbb6a1fe1fe4f03f9cb7d24ff531dd29ed | Rust | dgodd/adventofcode | /2022/src/day5.rs | UTF-8 | 2,714 | 3.359375 | 3 | [] | no_license | use regex::Regex;
#[derive(Debug)]
pub struct Input {
crates: Vec<Vec<char>>,
instructions: Vec<(u32, u8, u8)>,
}
#[aoc_generator(day5)]
pub fn input_generator(input: &str) -> Input {
let pos = input.find("\n\n").unwrap();
let (inp1, inp2) = input.split_at(pos);
let num: usize = ((inp1.lines().ne... | true |
2bb21fe7bae774174c23130347a3f75c315058ee | Rust | mvanbem/oot-explorer | /oot-explorer-vrom/src/borrowed.rs | UTF-8 | 1,427 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::fmt::{self, Debug, Formatter};
use std::ops::{Deref, Range};
use crate::{VromAddr, VromError};
/// A slice representing all of VROM.
#[derive(Clone, Copy)]
pub struct Vrom<'a>(pub &'a [u8]);
impl<'a> Vrom<'a> {
pub fn slice_from(self, from: VromAddr) -> Result<&'a [u8], VromError> {
self.0
... | true |
b61b4863dc4a0358fd34be9151cb6567790cbed4 | Rust | aonorin/immi | /src/animations/mod.rs | UTF-8 | 3,798 | 3.828125 | 4 | [] | no_license | //! Contains everything related to the animations that are supported by this library.
use Matrix;
/// Describes a way to modify an element during an animation.
pub trait Animation {
/// Takes an animation percentage between `0.0` and `1.0`. Returns the most-inner matrix to
/// multiply the element with.
f... | true |
8e28f0da86e9c205afb09e5468057c75215992b1 | Rust | zayenz/advent-of-code-2018 | /day18/src/main.rs | UTF-8 | 5,334 | 2.65625 | 3 | [
"MIT"
] | permissive | #![allow(
dead_code,
unused_imports,
clippy::needless_range_loop,
clippy::ptr_arg,
clippy::char_lit_as_u8
)]
use std::char;
use std::cmp::{max, min};
use std::fmt;
use std::io::BufRead;
use std::iter::*;
use std::ops::*;
use std::str;
use std::str::FromStr;
use std::{io, process};
use enum_map::*;... | true |
21eba04f0540bf545afe15c821faf897cb944533 | Rust | mnts26/aws-sdk-rust | /sdk/smithy-types/src/lib.rs | UTF-8 | 6,226 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
pub mod base64;
pub mod instant;
pub mod primitive;
pub mod retry;
use std::collections::HashMap;
pub use crate::instant::Instant;
#[derive(Debug, PartialEq, Clone)]
pub struct Blob {
inner: Vec<... | true |
ffed375083eded69ddb77547ad8070a37fd06536 | Rust | TGElder/rust | /frontier/src/simulation/settlement/extensions/update_current_population.rs | UTF-8 | 7,833 | 3.015625 | 3 | [
"CC-BY-4.0"
] | permissive | use crate::settlement::{Settlement, SettlementClass};
use crate::simulation::settlement::SettlementSimulation;
use crate::simulation::MaxAbsPopulationChange;
use crate::traits::has::HasParameters;
use crate::traits::Micros;
impl<T, D> SettlementSimulation<T, D>
where
T: HasParameters + Micros,
{
pub async fn u... | true |
22d690ee781fb5010868263ac774a7bbe68e5f2f | Rust | martinrlilja/foodtech-quiz | /src/main.rs | UTF-8 | 9,092 | 2.578125 | 3 | [] | no_license | use anyhow::{Error, Result};
use rand::prelude::*;
use ring::{digest, hmac};
use serde::{Deserialize, Serialize};
use std::{env, net::SocketAddr};
use tokio::fs;
use warp::{
http::{self, Response},
reject,
reply::{self, Reply},
Filter,
};
use controllers::{QuizController, UserWriter};
use models::{Conf... | true |
3a1c0f63b68ce54c3aa252e6c78eb6e8ac0f17c1 | Rust | julesartd/Exercices-Kattis | /nastyhacks/src/main.rs | UTF-8 | 708 | 3.046875 | 3 | [] | no_license | use std::io::{self, prelude::*};
fn main() {
let mut entree = String::new();
io::stdin().read_to_string(&mut entree).expect("lecture données");
let mut line = entree.lines();
line.next();
for l in line
{
let mut mot = l.split_whitespace();
let i = mot.next().expect("i").parse::<... | true |
858dc55d3e027a927ec2b981fb08af990c06cf7f | Rust | AndrewGaspar/fortknight | /fortknight/src/parser/classify/types.rs | UTF-8 | 14,506 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::parser::lex::{KeywordTokenKind, Token, TokenKind};
use super::statements::{
DeclarationTypeSpec, DerivedTypeSpec, IntegerTypeSpec, IntrinsicTypeSpec, KindSelector,
Spanned, TypeParamSpec, TypeParamValue,
};
use super::{Classifier, TakeUntil};
impl<'input, 'arena> Classifier<'input, 'arena> {
//... | true |
c8934e48e8c23ce1cfb902717be7a5202a071b05 | Rust | carrotflakes/kantera | /src/lerp.rs | UTF-8 | 239 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::ops::{Add, Mul};
pub trait Lerp: Copy + Add<Output = Self> + Mul<f64, Output = Self> {
#[inline(always)]
fn lerp(&self, other: &Self, v: f64) -> Self {
*self * (1.0 - v) + *other * v
}
}
impl Lerp for f64 {}
| true |
7b740592a56d90bacc7d1d6a89e4a1443086f3be | Rust | atuinsh/atuin | /atuin-common/src/utils.rs | UTF-8 | 5,899 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::env;
use std::path::PathBuf;
use chrono::{Months, NaiveDate};
use rand::RngCore;
use uuid::Uuid;
pub fn random_bytes<const N: usize>() -> [u8; N] {
let mut ret = [0u8; N];
rand::thread_rng().fill_bytes(&mut ret);
ret
}
// basically just ripped from the uuid crate. they have it as unstable, but... | true |
f4d73e0cd363e5687b334485e696c188c8904e6a | Rust | Txuritan/stry | /stry-frontend-user/src/controllers/edit.rs | UTF-8 | 4,068 | 2.75 | 3 | [
"MIT"
] | permissive | use {
crate::{
models::ChapterForm,
pages,
utils::{self, wrap},
},
chrono::Utc,
std::borrow::Cow,
stry_backend::DataBackend,
warp::{
http::{
header::{HeaderValue, LOCATION},
Response, StatusCode,
},
hyper::Body,
repl... | true |
6ef5b7e00a85ca50511ced48d6d6201a0e323602 | Rust | TLmaK0/rustneat | /src/organism.rs | UTF-8 | 7,422 | 2.90625 | 3 | [
"MIT"
] | permissive | use ctrnn::{Ctrnn, CtrnnNeuralNetwork};
use genome::Genome;
use std::cmp;
use std::cmp::Ordering;
/// An organism is a Genome with fitness.
/// Also maitain a fitenss measure of the organism
#[allow(missing_docs)]
#[derive(Debug, Clone)]
pub struct Organism {
pub genome: Genome,
pub fitness: f64,
}
impl Ord f... | true |
c50851b5f1d207b2fba4d7d9ab7306efb3da975e | Rust | fstiffo/scale-rust-old | /src/scale.rs | UTF-8 | 4,697 | 2.609375 | 3 | [] | no_license | #![warn(clippy::all)]
extern crate chrono;
use chrono::NaiveDate;
extern crate serde;
use serde::{Deserialize, Serialize};
// use serde::Serialize;
extern crate serde_json;
use serde_json::Result;
use std::io::prelude::*;
use std::fs::{File, OpenOptions};
use std::path::Path;
#[derive(Serialize, Deserialize)]
pub ... | true |
ab27d207e116acf7fb1eb7347752b901a7395af5 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/idna/src/punycode.rs | UTF-8 | 7,801 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive |
use std::char;
use std::u32;
static BASE: u32 = 36;
static T_MIN: u32 = 1;
static T_MAX: u32 = 26;
static SKEW: u32 = 38;
static DAMP: u32 = 700;
static INITIAL_BIAS: u32 = 72;
static INITIAL_N: u32 = 0x80;
static DELIMITER: char = '-';
#[inline]
fn adapt(mut delta: u32, num_points: u32, first_time: b... | true |
57da01c94bd7722078f773045cbfd6fcfe437a67 | Rust | KanoczTomas/bitcoin_playground | /src/types/points.rs | UTF-8 | 590 | 3.421875 | 3 | [] | no_license | use crate::types::{Point, ECpoint};
#[derive(Debug, PartialEq,Clone,Copy)]
/// Represents all possible points (even those not on curve!).
pub enum Points{
/// Infinity.
Infinity,
/// A point with a coordinate.
FinitePoint(Point)
}
impl std::convert::From<ECpoint> for Points {
fn from(p: ECpoint)-... | true |
40bb350022275dd29ccd0685d13fa13fb3ba2dd6 | Rust | jimblandy/fxsnapshot | /src/query/stream.rs | UTF-8 | 1,430 | 3.390625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use fallible_iterator::FallibleIterator;
use std::rc::Rc;
#[derive(Clone)]
pub struct Stream<'a, T, E>(Rc<dyn CloneableStream<'a, T, E> + 'a>);
impl<'a, T: 'a, E> Stream<'a, T, E>
{
pub fn new<I>(iter: I) -> Stream<'a, I::Item, I::Error>
where I: 'a + FallibleIterator<Item=T, Error=E> + Clone
{
... | true |
cc544cc120513f4f1cbf4afdd4b3e72754553b8d | Rust | heyacherry/Team4 | /projects/lesson-2/runtime/src/substrateKitties.rs | UTF-8 | 7,232 | 2.78125 | 3 | [
"Unlicense"
] | permissive | /// A runtime module template with necessary imports
/// Feel free to remove or edit this file as needed.
/// If you change the name of this file, make sure to update its references in runtime/src/lib.rs
/// If you remove this file, you can remove those references
/// For more guidance on Substrate modules, see the ... | true |
bd29949b8dd7485b7069f9bf03a2cb7aaa44b066 | Rust | alibaba/GraphScope | /interactive_engine/executor/store/groot/src/db/graph/bench/data.rs | UTF-8 | 1,125 | 3.109375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-proprietary-license",
"FSFAP",
"BSD-3-Clause-Clear",
"GPL-1.0-or-later",
"BSD-2-Clause-Views",
"Bitstream-Vera",
"MPL-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"OFL-1.1",
"BSD-3-Clause",
"APAFML",
"0BSD",
"LicenseRef-scancode-free-unknown",
"CC-B... | permissive | use std::collections::HashMap;
use crate::db::api::*;
pub fn gen_properties(type_def: &TypeDef) -> HashMap<PropertyId, Value> {
let mut ret = HashMap::new();
for prop_def in type_def.get_prop_defs() {
let v = gen_property(prop_def.r#type);
ret.insert(prop_def.id, v);
}
ret
}
fn gen_pr... | true |
b7ea20408e26d99bc93be4e86561f0d33f51e57a | Rust | cszczepaniak/cribbage-scorer | /impl-rust/src/cards.rs | UTF-8 | 5,795 | 3.609375 | 4 | [] | no_license | use core::fmt::Display;
use std::error::Error;
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub enum Suit {
Clubs,
Diamonds,
Hearts,
Spades,
Unknown,
}
impl From<usize> for Suit {
fn from(n: usize) -> Self {
match n {
0 => Suit::Clubs,
1 => Suit::Diamonds,... | true |
aeae4a31d395ac21ca140a4751f86cfd0cac77a6 | Rust | Patryk27/avr-tester | /avr-tester/tests/tests/timeout.rs | UTF-8 | 846 | 3.328125 | 3 | [
"MIT"
] | permissive | //! # Scenario
//!
//! We're given an AVR that does nothing, while we think it should toggle a pin
//! on-and-off.
//!
//! By carefully constructing the test, using timeout, we prevent it from
//! running forever, waiting for a toggle that will never happen.
//!
//! # Firmware
//!
//! See: [../../../avr-tester-tests/ti... | true |
806b640130d2b9034f736694300e43b657abab7f | Rust | emmanuelantony2000/deta-rust | /src/update.rs | UTF-8 | 2,982 | 3.5625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::string;
use serde::{Deserialize, Serialize};
/// Only used for update requests.
///
/// # Examples
///
/// ```
/// use deta::Update;
///
/// let update = Update::new()
/// .set("profile.age", 33)
/// .set("profile.active", true)
/// .set("profile.email", "jimmy@deta... | true |
02ea0022aed030f22d38c1becc62fada79891e71 | Rust | mattclement/nanoblog | /nanoblog/src/posts.rs | UTF-8 | 3,058 | 2.65625 | 3 | [
"MIT"
] | permissive | use tera::Tera;
use tide::http;
use tide::{Context, EndpointResult, Error, error::ResultExt};
use crate::db;
use http::status::StatusCode;
use pulldown_cmark::{Parser, Options, html};
const INDEX: &str = "index.html";
const POST: &str = "post.html";
const NOT_FOUND: &str = "404.html";
lazy_static! {
pub static r... | true |
4cd1bc26c00f4652b1eef574b062877f98d18e61 | Rust | potatosalad/exercism | /rust/palindrome-products/src/lib.rs | UTF-8 | 1,933 | 3.21875 | 3 | [] | no_license | extern crate num_cpus;
use std::collections::HashSet;
use std::sync::mpsc;
use std::thread;
pub type Palindrome = u64;
pub fn get_palindrome_products(min: u64, max: u64) -> Vec<Palindrome> {
let cpus = num_cpus::get();
if cpus == 1 {
let mut products: HashSet<Palindrome> = HashSet::new();
pal... | true |
cb7d3d9270e2d93014a85492397cee825681aa3d | Rust | extrawurst/gitui | /src/components/cred.rs | UTF-8 | 3,714 | 2.625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, Frame};
use asyncgit::sync::cred::BasicAuthCredential;
use crate::components::{EventState, InputType, TextInputComponent};
use crate::keys::key_match;
use crate::{
components::{
visibility_blocking, CommandBlocking, Comm... | true |
4b3635f2e8796d9695bc7c45819d5e173086aa58 | Rust | Dipendra-creator/RustyChef | /Easy Problem to Get Started/Add Natural Numbers/main.rs | UTF-8 | 333 | 3.28125 | 3 | [] | no_license | fn int_input() -> i64 {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let n: i64 = line.trim().parse().expect("invalid input");
return n;
}
fn main() {
let num = int_input();
let mut sum: i64 = 0;
for i in 1..num+1 {
sum = sum + i;
}
println!(... | true |
0fd015990658c9204fafca68f432f0d6351d50df | Rust | Devolutions/IronRDP | /crates/ironrdp-pdu/src/input/mouse.rs | UTF-8 | 2,295 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::io;
use bitflags::bitflags;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use super::InputEventError;
use crate::PduParsing;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MousePdu {
pub flags: PointerFlags,
pub number_of_wheel_rotation_units: i16,
pub x_position: u16,
pub y... | true |
9b875c28998412ac06b03d27bfedbc8575deb5e2 | Rust | mewhhaha/wasm-example | /wasm/src/lib.rs | UTF-8 | 43,581 | 3.0625 | 3 | [] | no_license | #![feature(or_patterns)]
#![feature(str_split_once)]
#![feature(iterator_fold_self)]
#![feature(array_map)]
extern crate wasm_bindgen;
use std::{
collections::{HashMap, HashSet},
hash::Hash,
ops::{Add, Mul},
};
use fxhash::{FxHashMap, FxHashSet};
use parse_display::{Display, FromStr};
use wasm_bindgen::p... | true |
ca0a40b3e7206b0948895a069041fa7deb82e48a | Rust | digitlimit/cargo-user-app | /src/app/models/user.rs | UTF-8 | 330 | 3.125 | 3 | [] | no_license | #[allow(dead_code)]
pub struct User {
id: u32,
email: String
}
impl User {
#[allow(dead_code)]
pub fn new(id: u32, email: &str) -> User {
User {
id: id,
email: email.to_string()
}
}
#[allow(dead_code)]
pub fn get_id(&self) -> u32 {
self.i... | true |
2fe93e3605e5b8d14d27db842972773fd50161c9 | Rust | LeLeMoe/CGToy | /src/render/_render_context.rs | UTF-8 | 7,191 | 2.640625 | 3 | [
"Unlicense"
] | permissive | use std::sync::Arc;
use wgpu::util::DeviceExt;
use winit::{dpi::PhysicalSize, window::Window};
///
pub struct RenderContext {
size: PhysicalSize<u32>,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
accessor: ContextAccessor,
}
impl RenderContext {
///
pub async fn new(desc: R... | true |
5c3f33a218c2a6639ac47434dd668796c2a73216 | Rust | learn-you-a-rust/basic_types | /src/main.rs | UTF-8 | 411 | 3.5625 | 4 | [] | no_license | fn main() {
//an array is specified by [type, num_elements]
let typed_array: [i32; 5] = [1, 2, 3, 4, 5];
//instead of specifying the type explicitly,
//the array can also be initialized to a particular value
let _initialized_array = [3; 5];
//array indexing
let three = typed_array[2];
... | true |
8ba8e2176c9c76e02ee062b41cb5969e3eec87af | Rust | Xinkai/Minesweeper | /src/main.rs | UTF-8 | 9,015 | 2.84375 | 3 | [] | no_license |
extern crate rand;
extern crate ansi_term;
mod map;
#[macro_use]extern crate conrod;
extern crate piston;
extern crate piston_window;
use conrod::{
color,
Canvas,
Color,
Colorable,
Frameable,
Labelable,
Positionable,
Sizeable,
Text,
Theme,
Toggle,
Widget,
WidgetM... | true |
7b08e7e78a3013b1e6645fbaa0f5834336abad9c | Rust | pchiwan/rustbridge | /src/main1.rs | UTF-8 | 2,269 | 3.96875 | 4 | [] | no_license | fn add (a: i32, b: i32) -> i32 {
a + b
}
enum GameType {
SinglePlayer,
MultiPlayer(u32),
}
fn choose_game (game: GameType) {
match game {
GameType::SinglePlayer => println!("How about solitaire?"),
GameType::MultiPlayer(2) => println!("How about checkers?"),
GameType::MultiPlay... | true |
7509ea97d20e70adeb020c6e18d0d11ea19696f0 | Rust | georgegerdin/guitest | /src/layout.rs | UTF-8 | 18,325 | 3.109375 | 3 | [] | no_license |
use cassowary;
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::collections::HashMap;
type WidgetHandle = i32;
#[derive(Eq, PartialEq, Clone)]
struct LayoutPosition(u32, u32);
fn new_term (variable: cassowary::Variable, coefficient: f64) -> cassowary::Term {
cassowary::Term {
variable: v... | true |
ce895d00229c459d749f96fbfe8b6fa9ae3468da | Rust | chenyangzhi88/datafuse | /common/datavalues/src/data_array_comparison_test.rs | UTF-8 | 12,102 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
#[test]
fn test_array_comparison() {
use std::sync::Arc;
use pretty_assertions::assert_eq;
use super::*;
#[allow(dead_code)]
struct ArrayTest {
name: &'static str,
args: Vec<Vec<DataArrayRef>>... | true |
8ffca43213766ba2dd9f492f0405aa281e41baec | Rust | paulkirkwood/rs.parcoursdb | /src/col/col.rs | UTF-8 | 1,805 | 3.328125 | 3 | [] | no_license | use crate::location::Location;
use std::fmt;
#[derive(Copy,Clone,PartialEq, Debug)]
pub enum ColCategory {
HC,
C1,
C2,
C3,
C4,
UC,
}
impl fmt::Display for ColCategory {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
ColCategory::HC => write!(f, "HC"... | true |
64e446c7dae09d5d111ffe82acd88454eba83b14 | Rust | carrotflakes/kakapo | /src/parse.rs | UTF-8 | 6,916 | 3.15625 | 3 | [] | no_license | use crate::Ast;
use std::iter::Peekable;
#[derive(Debug, Clone)]
pub enum Error {
UnexpectedChar(char),
UnexpectedParenClose,
UnexpectedEOS,
}
pub fn parse(str: &str) -> Result<Ast, Error> {
let mut cs = str.chars().peekable();
let res = parse_or(&mut cs);
if let Some(c) = cs.peek() {
... | true |
27db0b6e932065a53a03abd489ea93e0f6e5f1ff | Rust | danigm/rust-euler | /euler/src/p6.rs | UTF-8 | 977 | 4.25 | 4 | [] | no_license | //! Problem 6
//! Sum square difference
//!
//! The sum of the squares of the first ten natural numbers is,
//! 1^2 + 2^2 + ... + 10^2 = 385
//!
//! The square of the sum of the first ten natural numbers is,
//! (1 + 2 + ... + 10)^2 = 55^2 = 3025
//!
//! Hence the difference between the sum of the squares of the first ... | true |
14909f5c2344c6688d2588a4c97cac5c6b92e24b | Rust | mbarbero/koukku | /src/error.rs | UTF-8 | 2,872 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::{fmt, result, io};
use std::error::Error as StdError;
use std::str::Utf8Error;
use std::sync::mpsc::{SendError, RecvError};
use std::sync::PoisonError;
use hyper::error::Error as HyperError;
use ini::ini::Error as IniError;
use rustc_serialize::hex::FromHexError;
use serde_json::error::Error as JsonError;
use... | true |
56ad81b9d3dc287e15aa6d62eaaf9a359ac850a3 | Rust | langestefan/atsamd | /pac/atsamd51j19a/src/sdhc0/hc2r.rs | UTF-8 | 24,260 | 2.828125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u16,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u16,
}
impl super::HC2R {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
eb067e5344071d6aa08de796946db91c1d6decca | Rust | vain0x/languages | /lambda-calc-rs/lc-v1/src/syntax/syntax_token.rs | UTF-8 | 657 | 3 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::token::token_kind::TokenKind;
use std::fmt::{self, Debug, Formatter};
#[derive(Copy, Clone)]
pub(crate) struct SyntaxToken<'a> {
#[allow(unused)]
pub(crate) index: usize,
pub(crate) kind: TokenKind,
pub(crate) text: &'a str,
}
impl Debug for SyntaxToken<'_> {
fn fmt(&self, f: &mut Forma... | true |
a6c4bbcb34cdf3391fcd3cc809792d675f1b09f3 | Rust | zubivan/games50-rust | /pong/src/states/gamestate.rs | UTF-8 | 6,046 | 2.546875 | 3 | [
"MIT"
] | permissive | use ggez::graphics::Rect;
use ggez::input::keyboard::KeyCode;
use ggez::nalgebra::Point2;
use ggez::Context;
use std::time::Duration;
use rand::{thread_rng, Rng, RngCore};
use super::gameoverstate::{GameOverState, Winner};
use super::shapes::{Ball, GameObject, Paddle};
use super::utils;
use crate::constants::{FONT... | true |
ab865bb1b599b1328d115c901f81b99c16c58e0d | Rust | dongcarl/script_descriptor | /src/descriptor.rs | UTF-8 | 21,314 | 2.859375 | 3 | [] | no_license | // Script Descriptor Language
// Written in 2018 by
// Andrew Poelstra <apoelstra@wpsoftware.net>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any w... | true |
31eae8952b6e362e3ad826025901b82e7ff94ba2 | Rust | timokae/data-node | /src/heartbeat_service.rs | UTF-8 | 2,666 | 2.859375 | 3 | [] | no_license | use crate::storage;
use crate::{logger, models};
use models::{DataNode, Heartbeat, HeartbeatResponse};
use std::error::Error;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use storage::Storage;
/// The Heartbeat Service starts a thread which send periodic messages over a http connection to the name se... | true |
36559c5356ce5cd78f9ffb3db5fee89016024955 | Rust | m4b/scroll | /src/ctx.rs | UTF-8 | 29,175 | 3.5 | 4 | [
"MIT"
] | permissive | //! Generic context-aware conversion traits, for automatic _downstream_ extension of `Pread`, et. al
//!
//! The context traits are arguably the center piece of the scroll crate. In simple terms they
//! define how to actually read and write, respectively, a data type from a container, being able to
//! take context in... | true |
a837f8c5f4daf0933baaf22533c7037d94fac3ab | Rust | rust-lang/rust | /tests/ui/issues/issue-35976.rs | UTF-8 | 544 | 2.78125 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // revisions: imported unimported
//[imported] check-pass
mod private {
pub trait Future {
//[unimported]~^^ HELP perhaps add a `use` for it
fn wait(&self) where Self: Sized;
}
impl Future for Box<dyn Future> {
fn wait(&self) { }
}
}
#[cfg(imported)]
use private::Future;
fn b... | true |
0c410a380f11a7f883132b71410e1b64d7218bdc | Rust | mkhan45/slang-v2 | /src/parser/while_parse.rs | UTF-8 | 458 | 2.859375 | 3 | [] | no_license | use crate::{parse_block, parse_expr, statement::While, Lexer, TokenType};
pub fn parse_while(lexer: &mut Lexer) -> While {
lexer.next();
assert_eq!(lexer.next().ty, TokenType::LParen);
let cond = parse_expr(lexer);
assert_eq!(lexer.next().ty, TokenType::RParen);
assert_eq!(lexer.next().ty, TokenTyp... | true |
afb7e9b0a286f5dd2973b7ba9a743b23996f826a | Rust | tmzt/isymtope | /isymtope-ast-common/src/ast/nodes/content/mod.rs | UTF-8 | 3,927 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::marker::PhantomData;
use error::*;
use traits::*;
use expressions::*;
pub mod bindings;
pub mod attr;
pub mod element;
pub mod extern_;
pub mod visitor;
pub use self::bindings::*;
pub use self::attr::*;
pub use self::element::*;
pub use self::extern_::*;
pub use self::visitor::*;
#[derive(Debug, Clone, Par... | true |
e4af0dd2ef165f2d6774dc6c6a66870f6b0938a3 | Rust | Dyr-El/advent_of_code_2020 | /mantono-rust/src/days/day2.rs | UTF-8 | 4,056 | 3.609375 | 4 | [] | no_license | use regex::Regex;
/// To try to debug the problem, they have created a list (your puzzle input) of passwords
/// (according to the corrupted database) and the corporate policy when that password was set.
///
/// For example, suppose you have the following list:
///
/// 1-3 a: abcde
/// 1-3 b: cdefg
/// 2-9 c: cccccccc... | true |
6cc66bcaeb44cb54031e6927a5d3aed7457380dd | Rust | vavrusa/edgedns | /crates/sandbox/examples/memcache/src/memcache.rs | UTF-8 | 1,772 | 2.90625 | 3 | [
"ISC"
] | permissive | /// This is a simplified implementation of [rust-memcache](https://github.com/aisk/rust-memcache)
/// ported for AsyncRead + AsyncWrite.
use core::fmt::Display;
use futures::prelude::*;
use guest::BufferedStream;
use std::io::{Error, ErrorKind};
pub struct AsciiProtocol {
io: BufferedStream,
}
impl AsciiProtocol... | true |
4b7b2b8c03367402be9004b64ad93e7cbdd228d1 | Rust | JamieSK/connect-4 | /src/main.rs | UTF-8 | 1,207 | 3.28125 | 3 | [] | no_license | extern crate connect_4;
use connect_4::*;
use std::io;
fn main() {
let mut game = Connect4::new();
let mut player = Player::Red;
while game.state() != State::Won {
print!("{}", game.to_string());
match take_input(player) {
column @ 1...7 => {
match game.play(pl... | true |
0f3a0b8bececf5073440ce02527f06d3c7c88b8f | Rust | TsvetelinKostadinv/Programming-With-Rust-2020 | /zz. Homework-3/solution/tests/iter.rs | UTF-8 | 948 | 3.015625 | 3 | [] | no_license | use solution::*;
use std::io::BufReader;
#[test]
fn iter_test() {
let reader = BufReader::new(
r#"
name, age, birth date
"Douglas Adams", "42", "1952-03-11"
"Gen Z. Person", "20", "2000-01-01"
"Ada Lovelace", "36", "1815-12-10"
"#
.trim()
.as_bytes(),
);
// Конструи... | true |
b6ceb45d94ab9e35de949b2e71d64072415527c2 | Rust | hamidr/rmafia | /src/scenario.rs | UTF-8 | 2,899 | 2.671875 | 3 | [] | no_license | use std::{collections::{BTreeMap, BTreeSet}, vec};
use btreemultimap::BTreeMultiMap;
use crate::waiting::PlayerId;
pub type Error = String;
pub enum ShootingResult {
Killed(PlayerId),
EmptyGun(PlayerId),
NotAllowed
}
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord)]
pub enum Power {
Guard,
... | true |
e58432561814aa3e975e82adeb8fb849bd3577fd | Rust | agerasev/hypertrace | /kernel/build.rs | UTF-8 | 2,442 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
collections::BTreeMap,
env, fs,
path::{Path, PathBuf},
};
use walkdir::WalkDir;
fn str_text(value: &str) -> String {
format!("r##\"{}\"##", value)
}
fn dict_text(name: &str, dict: &BTreeMap<String, String>) -> String {
[
format!("pub const {}: [(&str, &str); {}] = [\n", name, di... | true |
491095ae3cba42812705377425cf29fd13a734be | Rust | marco-c/gecko-dev-wordified | /third_party/rust/weedle2/src/namespace.rs | UTF-8 | 1,547 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use
crate
:
:
argument
:
:
ArgumentList
;
use
crate
:
:
attribute
:
:
ExtendedAttributeList
;
use
crate
:
:
common
:
:
{
Identifier
Parenthesized
}
;
use
crate
:
:
types
:
:
{
AttributedType
ReturnType
}
;
/
/
/
Parses
namespace
members
declaration
pub
type
NamespaceMembers
<
'
a
>
=
Vec
<
NamespaceMember
<
'
a
>
>
;
a... | true |
79741a73e3434ef7b0b8b36c3300b6c4243d11c8 | Rust | scritchley/orcrs | /src/columnreader.rs | UTF-8 | 744 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::io::{Read, Bytes};
pub trait ColumnReader<T> {
fn next(&self) -> Result<T, ReaderError>;
}
pub struct RunLengthByteReader<R: Read> {
i: Bytes<R>,
}
impl<R: Read> RunLengthByteReader<R> {
pub fn new(r: R) -> RunLengthByteReader<R> {
RunLengthByteReader{
i: r.bytes(),
}... | true |
556196293b52987ba2de60a4f4a75bd46ea74c77 | Rust | timurista/rust-examples | /enums-demo/src/main.rs | UTF-8 | 1,238 | 3.515625 | 4 | [] | no_license | // enums stored in lowest bytes necessary
// min for actual type and contents
use std::collections::HashMap;
use std::env::args;
#[derive(Debug)]
pub struct Bed{
size:i32,
count:u32,
}
#[derive(Debug)]
pub enum Room{
Kitchen(i32),
Bedroom(Bed),
Lounge(i32, String)
}
fn main() {
use self::Roo... | true |
228c33579c3777ba520a7e8daf45e440fadf5264 | Rust | TDHGroupWork/northwind-rs | /components/user/src/services/jwt_processor_impl.rs | UTF-8 | 1,505 | 2.609375 | 3 | [
"MIT"
] | permissive | use async_trait::async_trait;
use chrono::Utc;
use color_eyre::Result;
use jsonwebtoken::{Algorithm, decode, DecodingKey, encode, EncodingKey, Header, Validation};
use crate::domain::jwt_processor::JwtProcessor;
use crate::domain::auth::Claims;
pub struct JwtProcessorImpl {}
#[async_trait]
impl JwtProcessor for JwtP... | true |
7b22711b6e4ee7fa48e46fdb61decaf8b3d39af3 | Rust | toyama1710/rs_library | /src/tests/segtree_test.rs | UTF-8 | 1,412 | 3.203125 | 3 | [
"CC0-1.0"
] | permissive | use crate::algebra::Monoid;
#[allow(unused_imports)]
use crate::data_structures::segment_tree::SegmentTree;
#[allow(dead_code)]
struct Min();
impl Monoid for Min {
type T = i64;
fn identity() -> i64 {
return i64::max_value();
}
fn op(a: &i64, b: &i64) -> i64 {
return std::cmp::min(*a, *... | true |
75e0be5697db150f7d662398311c21a13676ebb6 | Rust | mdcg/a-tour-of-rust | /codewars/dia-2/will-there-be-enough-space.rs | UTF-8 | 526 | 2.96875 | 3 | [
"MIT"
] | permissive | // https://www.codewars.com/kata/5875b200d520904a04000003/train/rust
// Minha solução
fn enough(cap: i32, on: i32, wait: i32) -> i32 {
let fit = cap - on - wait;
if fit < 0i32 {
return fit.abs()
} else {
return 0i32;
}
}
// Melhor solução
fn enough(cap: i32, on: i32, wait: i32) -> ... | true |
2074d8e767e1cd2fe952e1ef16f52322b96274e2 | Rust | avranju/iotedge-k8s | /edgelet/systemd/src/error.rs | UTF-8 | 2,623 | 2.734375 | 3 | [
"MIT"
] | permissive | // Copyright (c) Microsoft. All rights reserved.
use std::fmt;
use std::fmt::Display;
use failure::{Backtrace, Context, Fail};
#[cfg(target_os = "linux")]
use nix::unistd::Pid;
use Fd;
#[derive(Debug)]
pub struct Error {
inner: Context<ErrorKind>,
}
#[derive(Debug, Fail)]
pub enum ErrorKind {
#[cfg(target_... | true |
13032587e7bb93353a6e77e605876f67ba97caa6 | Rust | briarpatch1337/fast-and-feudalist | /src/hardware.rs | UTF-8 | 5,901 | 3.21875 | 3 | [] | no_license |
// NOTE: Prefixing these fields with an underscore is necessary to avoid an unused variable warning.
pub struct HardwareResources
{
pub sdl: sdl2::Sdl,
_video_subsystem: sdl2::VideoSubsystem,
pub window: sdl2::video::Window,
pub drawable_size: (u32, u32),
pub display_dpi: (f32, f32, f32),
_gl_c... | true |
ae8019dfe5a15c1609409e7480a7705730bbcbfd | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/issues/issue-46553.rs | UTF-8 | 356 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
#![feature(const_fn)]
#![deny(const_err)]
pub struct Data<T> {
function: fn() -> T,
}
impl<T> Data<T> {
pub const fn new(function: fn() -> T) -> Data<T> {
Data {
function: function,
}
}
}
pub static DATA: Data<i32> = Data::new(|| {
413i32
});
fn main() {
p... | true |
9d86430cf2aabc07e597f495f36c4d91fdc72631 | Rust | kuviman/trans-gen | /src/gens/rust/trans.rs | UTF-8 | 4,487 | 3.296875 | 3 | [
"MIT"
] | permissive | use byteorder::{ReadBytesExt, WriteBytesExt};
pub trait Trans: Sized + 'static {
fn write_to(&self, writer: &mut dyn std::io::Write) -> std::io::Result<()>;
fn read_from(reader: &mut dyn std::io::Read) -> std::io::Result<Self>;
}
impl Trans for bool {
fn read_from(reader: &mut dyn std::io::Read) -> std::i... | true |
227859398c5486391d6aff0ece7dbfb8f4b9293e | Rust | wangyingsm/advent-of-code-2020 | /day20/day20-rust/src/lib.rs | UTF-8 | 12,377 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use ndarray::{concatenate, s, Array1, Array2, Axis};
#[macro_use]
extern crate lazy_static;
peg::parser!(grammar parse_tile() for str {
pub rule parse_tile_id() -> usize
= "Tile " id:$(['0'..='9']+) ":" { id.parse().unwrap() }
pub rule parse_border() -> (u32, u32)
= line:$(['#' | '.']+) {
... | true |
08942663e7d7108894e82425fe1534e30dddb72b | Rust | mtak-/swym | /src/internal/alloc/dyn_vec.rs | UTF-8 | 16,802 | 2.96875 | 3 | [
"MIT"
] | permissive | //! An contiguous container of Dynamically Sized Types.
use core::{
borrow::{Borrow, BorrowMut},
marker::PhantomData,
mem::{self, ManuallyDrop},
ops::{Deref, DerefMut},
ptr::{self, NonNull},
};
#[repr(C)]
#[derive(Copy, Clone)]
pub struct TraitObject {
pub data: *mut (),
pub vtable: *mut... | true |
36705f0db2eb3ea61b33848f7a77fee4e34d2931 | Rust | usagi/vec-dimension-shift | /examples/d2_and_d3.rs | UTF-8 | 840 | 2.859375 | 3 | [
"MIT"
] | permissive | use vec_dimension_shift::{
VecDimensionShift2D,
VecDimensionShift2DFlatten,
VecDimensionShift3D,
VecDimensionShift3DFlatten
};
fn d2_and_d3()
{
let original = vec![0.0, 1.1, 2.2, 3.3, 4.4, 5.5];
dbg!(&original);
let mut d2_shifted = original.as_2d_array().unwrap();
dbg!(&d2_shifted);
assert_eq!(d2_shifted[0]... | true |
1ee8829702da7ee9a3024e7e32d614167e15fd3c | Rust | jo12bar/weekend-tracer-rs | /src/pdf/mod.rs | UTF-8 | 2,318 | 3.53125 | 4 | [
"Unlicense"
] | permissive | //! Probability Density Functions (PDFs), and their associated structs and methods.
pub mod cosine_pdf;
pub mod hittable_pdf;
pub mod mixture_pdf;
use crate::{hittable::Hittable, vec3::Vec3};
use rand::prelude::*;
use std::sync::Arc;
/// A probability density function. Supports generating either floats or vectors.
#... | true |
57ea5dd72de15361d7c63b03d32e651764319de9 | Rust | RusPiRo/ruspiro-mailbox | /src/propertytags/mod.rs | UTF-8 | 20,083 | 3.03125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /***********************************************************************************************************************
* Copyright (c) 2020 by the authors
*
* Author: André Borrmann <pspwizard@gmx.de>
* License: Apache License 2.0 / MIT
****************************************************************************... | true |
6610b015b7a371ac8d908d1a8325b7de776586c1 | Rust | MDoerner/AdventOfCode2020 | /Rust/adventOfCode2020/src/day/day15.rs | UTF-8 | 5,759 | 3.40625 | 3 | [] | no_license | use std::collections::HashMap;
use std::convert::TryFrom;
pub struct Day15 {}
impl super::Day for Day15{
type PuzzleInput = Vec<u128>;
fn parse_input(&self, text: std::string::String) -> Self::PuzzleInput {
text.split(',')
.filter_map(|number| number.parse::<u128>().ok())
... | true |
44286119538a7c64b63bbac8cb66ab7d6079685d | Rust | yjh0502/ch | /src/bin/osm-tools.rs | UTF-8 | 3,537 | 2.75 | 3 | [] | no_license | use std::fs::File;
use anyhow::Error;
use clap::{Arg, Command};
use memmap::MmapOptions;
use osmpbf::*;
use rayon::prelude::*;
type Result<T> = std::result::Result<T, Error>;
// const FILENAME: &'static str = "data/planet-latest.osm.pbf";
const FILENAME: &'static str = "data/seoul.osm.pbf";
use std::f64;
#[derive(C... | true |
da036c0579b449952fefb110b7b2db97a3990664 | Rust | ralvescosta/rust_exercism | /triangle/src/lib.rs | UTF-8 | 699 | 3.515625 | 4 | [] | no_license | use std::ops::Add;
pub struct Triangle<T>(T, T, T);
impl<T: Copy + PartialOrd + Add<Output = T>> Triangle<T> {
pub fn build(sides: [T; 3]) -> Option<Triangle<T>> {
let a = sides[0];
let b = sides[1];
let c = sides[2];
if a + b > c && b + c > a && a + c > b {
return Some... | true |
4bb909bb49e875c064facb6ed4fc09ef605153e7 | Rust | phial3/hakutaku | /kern/src/device/pci/class.rs | UTF-8 | 5,490 | 2.625 | 3 | [] | no_license | use super::class::HeaderType::*;
use cpuio::UnsafePort;
#[derive(Debug, Clone, Copy)]
pub enum HeaderType {
RegularDevice(u8),
PCIBridge(u8),
OtherHeaderType(u8)
}
impl HeaderType {
pub fn is_multi_function(&self) -> bool {
match self {
RegularDevice(a) => {
a & 0x8... | true |
7302cbba49b62a534f46f3d3f2666cdb8566900f | Rust | JonasRSV/Friday | /friday/friday-vad/src/vad_energy.rs | UTF-8 | 2,511 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::core::{SpeakDetector, VADResponse};
use serde_derive::{Deserialize, Serialize};
use friday_storage;
use friday_logging;
use friday_error::{FridayError, propagate};
#[derive(Deserialize, Serialize)]
struct Config {
threshold: f64,
// Will print the energy if provided and is true
verbose: Option... | true |
e2fee85e8d739b3370a107ee801e50699a522a47 | Rust | imlyzh/riscv-process-rs | /src/parser.rs | UTF-8 | 6,148 | 2.5625 | 3 | [
"MIT"
] | permissive | use pest::iterators::{Pair, Pairs};
use pest::{error::Error, Parser};
use pest_derive::*;
use crate::node::*;
#[derive(Parser)]
#[grammar = "./grammar.pest"]
struct RiscVAsm {}
pub trait ParseFrom<T>
where
Self: std::marker::Sized,
{
fn parse_from(pair: Pair<T>) -> Self;
}
impl ParseFrom<Rule> for Register ... | true |
b48ef9ec1d8678f0bac3b8beee3e6cd0381365b8 | Rust | teloxide/teloxide | /crates/teloxide-core/src/types/inline_query_result_venue.rs | UTF-8 | 4,724 | 3.0625 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::types::{InlineKeyboardMarkup, InputMessageContent};
/// Represents a venue.
///
/// By default, the venue will be sent by the user. Alternatively, you can use
/// `input_message_content` to send a message with the specified content instead
/// of the venue.
///
/// [The... | true |
e55276cd160497784f6d0142f592aee5baaa4975 | Rust | aleixjf/onetagger | /src/playlist/mod.rs | UTF-8 | 2,090 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use serde::{Serialize, Deserialize};
use crate::tag::EXTENSIONS;
use crate::ui::OTError;
pub const PLAYLIST_EXTENSIONS: [&str; 2] = [".m3u", ".m3u8"];
// Playlist info from UI
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UIPlaylist {
... | true |
00b97baa529682d7054c5bbc7395515ed7e5a13d | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0122.best-time-to-buy-and-sell-stock-ii/best-time-to-buy-and-sell-stock-ii.go | UTF-8 | 190 | 2.65625 | 3 | [
"MIT"
] | permissive | package problem0122
func maxProfit(prices []int) int {
res := 0
for i := 1; i < len(prices); i++ {
if prices[i] > prices[i-1] {
res += prices[i] - prices[i-1]
}
}
return res
}
| true |
8d71733460759451cd9147f32362bba27971320d | Rust | museun/shaken | /shaken/src/registry.rs | UTF-8 | 4,915 | 2.921875 | 3 | [
"Unlicense"
] | permissive | use crate::prelude::*;
use rusqlite::{Connection, NO_PARAMS};
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Error {
AlreadyExists,
}
#[derive(Debug, PartialEq, PartialOrd)]
pub struct Command {
name: String,
help: String,
namespace: String,
}
impl Command {
pub fn replace_name(&mut self, nam... | true |
b3c83e0f19baead4d1557fa17bc23d66d37118bf | Rust | Timidger/awesome-wayland | /src/object/class.rs | UTF-8 | 1,924 | 2.8125 | 3 | [] | no_license | //! These methods set up a interface to be a class for Lua.
use libc;
use lua_sys::*;
use std::cell::Cell;
use super::signal::Signal;
use super::property::Property;
/// Method that allocates new objects for the class.
pub type AllocatorF = unsafe extern fn(*mut lua_State) -> *mut Object;
/// Method that is called whe... | true |
1d3c9992ea20a77d3539ab8314a916f5c65a1263 | Rust | winksaville/fuchsia | /src/lib/cobalt/rust/src/cobalt_event_builder.rs | UTF-8 | 10,720 | 3.265625 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Helper builder for constructing a `CobaltEvent`.
use {
crate::traits::AsEventCodes,
fidl_fuchsia_cobalt::{CobaltEvent, CountEvent, EventPayloa... | true |
aa9bd61e45a7eacd307d4c6c5bda34c1016b6dc0 | Rust | exit91/miniserve | /tests/upload_files.rs | UTF-8 | 1,973 | 2.71875 | 3 | [
"MIT"
] | permissive | mod fixtures;
use assert_cmd::prelude::*;
use assert_fs::fixture::TempDir;
use fixtures::{port, tmpdir, Error};
use reqwest::multipart;
use rstest::rstest;
use select::document::Document;
use select::predicate::{Attr, Text};
use std::process::{Command, Stdio};
use std::thread::sleep;
use std::time::Duration;
#[rstest... | true |
83c7c81b6f1e4f60d7d8f4ff920221f8cd2f0a30 | Rust | i2p/i2p-rs | /src/net/addr.rs | UTF-8 | 9,179 | 3.34375 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::io;
use std::iter;
use std::option;
use std::slice;
use std::vec;
use serde_derive::{Deserialize, Serialize};
use crate::net::i2p::I2pAddr;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Hash)]
pub struct I2pSocketAddr {
port: u16,
dest: I2pAddr,
}
impl I2pSo... | true |
373f66f5c6b544f7efdf3ef63d79eb08e538ff07 | Rust | zhengrenzhe/nand2tetris | /compiler/utils/tests/io.rs | UTF-8 | 1,030 | 2.953125 | 3 | [] | no_license | extern crate utils;
use utils::io::{read_lines, write_lines};
const TEST_FILE_PATH: &str = "tests/test.txt";
fn get_lines() -> Vec<String> {
vec![
String::from("a"),
String::from("b"),
String::from("c"),
String::from("1"),
String::from("2"),
String::from("3"),
... | true |
ff1313a8dc1d50062ad9d387e2e2f1432497b01f | Rust | rehwinkel/OliveScript | /oliveparser/src/ast.rs | UTF-8 | 2,172 | 3.125 | 3 | [
"GPL-3.0-only"
] | permissive | #[derive(Debug)]
pub enum Statement<'a> {
Break,
Continue,
Return {
value: Located<Expression<'a>>,
},
Block {
statements: Vec<Located<Statement<'a>>>,
},
While {
condition: Located<Expression<'a>>,
block: Vec<Located<Statement<'a>>>,
},
If {
c... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.