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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
e382dd1d01bebff13cfadf807c13dce64d41da26 | Rust | stm32-rs/stm32f1xx-hal | /src/gpio/erased.rs | UTF-8 | 4,282 | 2.9375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use super::*;
pub type EPin<MODE> = ErasedPin<MODE>;
macro_rules! impl_pxx {
($(($port_id:literal :: $pin:ident)),*) => {
/// Erased pin
///
/// `MODE` is one of the pin modes (see [Modes](crate::gpio#modes) section).
pub enum ErasedPin<MODE> {
$(
$pin(P... | true |
794cb7032f57c754356840fca9a9002ea85f97e4 | Rust | stanislavkozlovski/Rusty-Exercises | /Hackerrank/Algorithms/Sorting/insertion_sort_part_II/src/main.rs | UTF-8 | 968 | 3.4375 | 3 | [] | no_license | use std::io;
fn print_vector(numbers: &Vec<i32>) {
for num in numbers {
print!("{} ", num);
}
println!("");
}
fn num_is_sorted(numbers: &Vec<i32>, index: usize) -> bool {
if (index == 0) {
return true
} else {
return numbers[index-1] <= numbers[index];
}
}
... | true |
7e1eaac82c04969fbc4b23eba5b4e29602279aff | Rust | Sevaarcen/rustpython-complexintegration | /src/plugin_handlers/mod.rs | UTF-8 | 1,942 | 2.75 | 3 | [] | no_license | use std::path::PathBuf;
use std::fs;
use log::{debug, info, warn, error};
use crate::model::{DataObject, PluginResults};
const PLUGIN_PATH: &str = "./plugins/";
mod python_handler;
// A "Plugin" object is the necessary structure to run arbitrary code
pub trait Plugin: std::fmt::Display + Sync + Clone {... | true |
0257ceef696bd756acca399962d68055038f91df | Rust | killercup/rune | /crates/rune/src/macros.rs | UTF-8 | 2,888 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Macro compiler.
use crate::error::CompileResult;
use crate::{
ast, CompileError, MacroContext, Options, Parse, ParseError, Parser, Storage, TokenStream,
UnitBuilder,
};
use runestick::{Context, Hash, Item, Source, Span};
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::Arc;
pub(crate) struct MacroC... | true |
114751999fffa14ff13ed9b0c94dd7864c07f0c5 | Rust | open-telemetry/opentelemetry-rust | /opentelemetry-otlp/examples/external-otlp-grpcio-async-std/src/main.rs | UTF-8 | 3,152 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | //! This shows how to connect to a third party collector like
//! honeycomb or lightstep using grpcio with tls and using async-std as reactor.
//! To run this specify a few environment variables like in the example:
//! ```shell
//! OTLP_GRPCIO_ENDPOINT=https://api.honeycomb.io:443 \
//! OTLP_GRPCIO_X_HONEYCOMB_TEAM=to... | true |
13caf8f31402321da436b7d64d91b33c671240fc | Rust | agausmann/discriminord | /src/lib.rs | UTF-8 | 5,504 | 2.9375 | 3 | [
"0BSD"
] | permissive | use image::{DynamicImage, GenericImageView, Pixel, Rgb, Rgba, RgbaImage};
use std::str::FromStr;
pub type Error = Box<dyn std::error::Error>;
pub struct Color(pub Rgb<u8>);
impl FromStr for Color {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some(rem) = s.strip_prefix(... | true |
d0e50fcca737eaafc064c1cb161563ced6a49e54 | Rust | Geal/syn | /synom/src/tokens.rs | UTF-8 | 23,965 | 3.1875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Discrete tokens that can be parsed out by synom.
//!
//! This module contains a number of useful tokens like `+=` and `/` along with
//! keywords like `crate` and such. These structures are used to track the spans
//! of these tokens and all implment the `ToTokens` and `Synom` traits when the
//! corresponding feat... | true |
4e34c08e7eca7402e49bf7fe15bc0748a32f7151 | Rust | GeorgeKT/menhir-lang | /src/bytecode/compiler.rs | UTF-8 | 44,398 | 2.65625 | 3 | [
"MIT"
] | permissive | use super::consteval::expr_to_const;
use super::function::*;
use super::instruction::*;
use crate::ast::*;
use crate::bytecode::{ByteCodeFunction, ByteCodeModule};
use crate::compileerror::{type_error_result, CompileResult};
use crate::package::Package;
use crate::target::Target;
use std::collections::HashMap;
fn stac... | true |
46b2d6c35d99cde8797156b61d9b8ae2bfa8f634 | Rust | Becavalier/rust-by-example-cases | /expressions/src/main.rs | UTF-8 | 6,435 | 3.96875 | 4 | [
"MIT"
] | permissive | fn main() {
let x = 5;
x; // no effect.
let y = { 1 }; // block with return value.
println!("{}", y);
/* if/else */
if (x == 5) {
println!("{}", x);
}
if x == 5 {
println!("{}", x);
}
/* loop */
let mut count = 0u32;
loop {
count += 1;
if... | true |
4b7d65fb76f01114dea56f700d7d17280feb5162 | Rust | stanislav-omelchenko/rupnp | /src/scpd/state_variable.rs | UTF-8 | 5,548 | 3.015625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::{find_in_xml, utils, Error, Result};
use roxmltree::Node;
use std::{fmt, ops::RangeInclusive};
/// A `StateVariable` is the type of every [Argument](struct.Argument.html) in UPnP Actions.
/// It is either a single value, an enumeration of strings or an integer range: see
/// [StateVariableKind](enum.StateVa... | true |
620bacaa22818b522e40d2c1f82f1bb01a4a51cf | Rust | duncanrhamill/msl | /src/lexer.rs | UTF-8 | 9,633 | 3.390625 | 3 | [] | no_license | //! # Lexing for MSL strings.
//!
//! This module uses [`logos`] to lex MSL strings.
// ---------------------------------------------------------------------------
// IMPORTS
// ---------------------------------------------------------------------------
use logos::{Logos, Lexer};
use rson_rs;
use crate::interpreter:... | true |
7dd827d139ba5ee826ea4a5a4fcf35e24f0afdf4 | Rust | frugalos/libfrugalos | /src/schema/config.rs | UTF-8 | 6,706 | 2.546875 | 3 | [
"MIT"
] | permissive | //! 構成管理系RPCのスキーマ定義。
use bytecodec::bincode_codec::{BincodeDecoder, BincodeEncoder};
use fibers_rpc::{Call, ProcedureId};
use std::net::SocketAddr;
use crate::entity::bucket::{Bucket, BucketId, BucketSummary};
use crate::entity::device::{Device, DeviceId, DeviceSummary};
use crate::entity::server::{Server, ServerId, S... | true |
298d9179cc71080aafbf27b6387e323b46fca662 | Rust | nolanderc/gpukit | /crates/gpukit_egui/src/renderer.rs | UTF-8 | 11,877 | 2.828125 | 3 | [] | no_license | use gpukit::wgpu;
use std::sync::Arc;
pub struct Renderer {
context: Arc<gpukit::Context>,
pipeline: wgpu::RenderPipeline,
vertex_buffer: gpukit::Buffer<Vertex>,
index_buffer: gpukit::Buffer<u32>,
bind_group: gpukit::BindGroup,
screen_uniforms: UniformBuffer<ScreenUniforms>,
texture_bind... | true |
2cb8f1b00f0430c975c07fb1ed9512c358bb5fdd | Rust | isgasho/fmm | /fmm/src/ir/if_.rs | UTF-8 | 972 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use super::{block::Block, expression::Expression};
use crate::types::Type;
use std::sync::Arc;
#[derive(Clone, Debug, PartialEq)]
pub struct If {
type_: Type,
condition: Expression,
then: Arc<Block>,
else_: Arc<Block>,
name: String,
}
impl If {
pub fn new(
type_: impl Into<Type>,
... | true |
06696af8e72963a77e9946cdfa296963bd7c8a73 | Rust | younghyunjo/rust-string-calculator | /src/input.rs | UTF-8 | 2,119 | 3.828125 | 4 | [] | no_license | use crate::operand::Operand;
use crate::operators::Operators;
use crate::operands::Operands;
use crate::operator::Operator;
pub struct Input {
operands: Operands,
operators: Operators,
}
impl Input {
pub fn new(input: &str) -> Self {
let splitted = split(input);
let operands = Operands:... | true |
7ec032c499f0ea9b2fe9ad3295ec17b998fe9c5f | Rust | oliversno/molecular_biology | /recursive_rabbits/src/main.rs | UTF-8 | 524 | 3.296875 | 3 | [] | no_license | use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let n = args[1].parse::<u64>().unwrap();
let k = args[2].parse::<u64>().unwrap();
println!("After {} months there are {} pairs", n, iterative_rabbits(n, k));
}
fn iterative_rabbits(n: u64, k: u64) -> u64{
let mut fn_1 = 1;
... | true |
e888a2887ab10b220821fe70e76356eb76d2e88c | Rust | lelandhwu/rusty-8 | /src/chip8.rs | UTF-8 | 1,108 | 2.90625 | 3 | [] | no_license | use ram::Ram;
use sdl2::VideoSubsystem;
use sdl2::keyboard::Keycode;
use cpu::Cpu;
use cpu;
pub struct Chip8 {
ram: Ram,
cpu: Cpu
}
impl Chip8 {
pub fn new(vid_context: &VideoSubsystem) -> Chip8 {
Chip8 {
ram: Ram::new(),
cpu: Cpu... | true |
057115f84360d768e2b4c2b557954fceedb34284 | Rust | deagahelio/vm | /vm/src/disk_controller.rs | UTF-8 | 3,955 | 3.09375 | 3 | [] | no_license | use crate::device::{Class, DeviceRecord, Device, WriteResult};
use crate::memory::Bytes;
pub struct DiskController {
record: DeviceRecord,
address: u32,
data_address: u32,
disks: [Option<Vec<u8>>; 8],
input: [u8; 4],
selected_disk: usize,
update_disk_register: Option<u8>,
}
impl DiskContro... | true |
b1e4e26ed5773c06130e1c024124f76506314380 | Rust | 223kazuki/rust-exercise | /rust-book/15/workspace/src/main.rs | UTF-8 | 2,183 | 3.578125 | 4 | [] | no_license | use std::cell::RefCell;
use std::mem::drop;
use std::ops::Deref;
use std::rc::Rc;
use List::{Cons, Nil};
enum List {
Cons(Rc<RefCell<i32>>, Rc<List>),
Nil,
}
struct MyBox<T>(T);
impl<T> MyBox<T> {
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
impl<T> Deref for MyBox<T> {
type Target = T;
f... | true |
051c387b6b218a9f2e8e72ea3a66b00358ffaf7f | Rust | rupansh/grammers | /lib/grammers-mtsender/src/errors.rs | UTF-8 | 5,206 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2020 - developers of the `grammers` project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distr... | true |
69d8233caa91b7c57f6eaf6e2d6aa8c46df50808 | Rust | optozorax/confidence | /src/lib.rs | UTF-8 | 9,441 | 3.5625 | 4 | [] | no_license | use std::convert::TryFrom;
use std::ops::Mul;
/// Value from `-1` to `1` inclusively
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
pub struct Confidence(Option<f64>);
impl Confidence {
pub fn none() -> Self {
Confidence(None)
}
pub fn get(&self) -> Option<f64> {
self.0
}
}
impl Default for Confidence... | true |
c469c028e8c73089caafdd4f0100fa8949df982d | Rust | AntonZelenin/rust-physics-engine | /src/rigid_body/mod.rs | UTF-8 | 7,565 | 3.1875 | 3 | [] | no_license | use crate::matrix::{Matrix3, Matrix4};
use crate::quaternion::Quaternion;
use crate::types::Real;
use crate::vector::Vec3;
pub struct RigidBody {
inverse_mass: Real,
linear_dumping: Real,
angular_damping: Real,
position: Vec3,
orientation: Quaternion,
velocity: Vec3,
acceleration: Vec3,
... | true |
8c3c731f60d4221710b37f69a8cadd64bc7a9d69 | Rust | tsheinen/advent-of-code-2020 | /src/day6.rs | UTF-8 | 1,639 | 3.40625 | 3 | [] | no_license | use itertools::Itertools;
use reduce::Reduce;
use std::collections::HashSet;
/// https://adventofcode.com/2020/day/6
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Group {
pub people: Vec<Vec<char>>,
}
impl Group {
pub fn count_unique(&self) -> usize {
self.people.iter().flat_map(|x| x.iter()).uni... | true |
339394a2d52c11ff42e2544ed93cf25081b9d0b5 | Rust | Happy-Ferret/combustion | /combustion_game/src/components/isometry.rs | UTF-8 | 565 | 2.5625 | 3 | [] | no_license | //! Isometry transform component
use specs;
use nalgebra::Isometry3;
use num_traits::One;
use super::effector::Effector;
#[derive(Clone, Debug)]
pub struct Component(pub Isometry3<f32>);
impl specs::Component for Component {
type Storage = specs::VecStorage<Component>;
}
impl Component {
#[inline(always)]
... | true |
138652e5259b70a5afd57b860dd502277c167f75 | Rust | Phibonacci/adventofcode2020 | /day01/src/main.rs | UTF-8 | 2,137 | 3.53125 | 4 | [] | no_license | fn main() {
let before = std::time::Instant::now();
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
panic!("Not enough arguments");
}
let filename = &args[1];
println!("Loading file {}", filename);
let data = parse_file(filename);
part1(&data);
part2(&data);
println!("Tot... | true |
c9abd28ca261ac4686ab1889159c1a44d5c7cd6e | Rust | dapr/rust-sdk | /examples/pubsub/publisher.rs | UTF-8 | 1,472 | 2.8125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | use std::{collections::HashMap, thread, time::Duration};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// TODO: Handle this issue in the sdk
// Introduce delay so that dapr grpc port is assigned before app tries to connect
thread::sleep(Duration::from_secs(2));
// Get the ... | true |
0751c14e775975eae2be3b54d1603555c326f3bd | Rust | timakro/rust-unsorted | /aoc16/src/main.rs | UTF-8 | 2,575 | 2.953125 | 3 | [] | no_license | use std::fs;
use std::collections::HashSet;
use regex::Regex;
fn main() {
let rule_re = Regex::new(r"^([\w ]+): (\d+)-(\d+) or (\d+)-(\d+)$").unwrap();
let input = fs::read_to_string("input").unwrap();
let mut blocks = input.split("\n\n");
let mut rules: Vec<(String, u32, u32, u32, u32)> = Vec::new()... | true |
a55d7cc76fa32c0e04c553a72e063312bdf0242f | Rust | sanpii/todo-txt | /src/errors.rs | UTF-8 | 435 | 2.59375 | 3 | [
"MIT"
] | permissive | pub type Result<T = ()> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Launch this program via todo.sh")]
Env,
#[error("Invalid period: {0}")]
InvalidPeriod(String),
#[error("Invalid priority: {0}")]
InvalidPriority(char),
#[error("Invalid recu... | true |
26edd8467882ec9cf78154b20737e0d165903f28 | Rust | wadachi-ware/wadachi-os | /src/tests/test.rs | UTF-8 | 2,112 | 3.1875 | 3 | [
"MIT"
] | permissive | use custom_test::custom_test;
#[allow(unused)]
#[derive(PartialEq)]
pub enum TestCondition {
FirstTest,
ModeMachine,
ModeSupervisor,
IntegrationMachineToSupervisor,
IntegrationVirtualMemory,
}
pub trait Testable {
fn run(&self) -> bool;
}
impl<T> Testable for (TestCondition, T, &'static str)
w... | true |
c83fafba7034c3b94089c8a05bf176b0d11ff11c | Rust | kamu-data/kamu-cli-rust | /kamu-core/src/infra/dataset_layout.rs | UTF-8 | 1,164 | 2.796875 | 3 | [] | no_license | use super::VolumeLayout;
use crate::domain::DatasetID;
use std::path::PathBuf;
/// Describes the layout of the dataset on disk
#[derive(Debug, Clone)]
pub struct DatasetLayout {
/// Path to the directory containing actual data
pub data_dir: PathBuf,
/// Path to the checkpoints directory
pub checkpoints... | true |
45385505d7d32a3eb1a8781f138fbaaf630816fc | Rust | regendo/advent-of-code-2020 | /src/day08/compile.rs | UTF-8 | 1,375 | 3.765625 | 4 | [] | no_license | use std::convert::TryFrom;
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub(crate) enum Instruction {
Accumulate(i32),
Jump(i32),
Noop(i32),
}
impl TryFrom<(&str, i32)> for Instruction {
type Error = String;
fn try_from(value: (&str, i32)) -> Result<Self, Self::Error> {
Ok(match value {
("acc", val) => Ins... | true |
84c7ee88f39c1d586a3ecdac6b44c8cad534a1b3 | Rust | eyeplum/rust-unic | /gen/src/source/ucd/unihan/mod.rs | UTF-8 | 1,904 | 2.625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2017 The UNIC Project Developers.
//
// See the COPYRIGHT file at the top-level directory of this distribution.
//
// 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 http://opensource.org/licenses/MIT>, a... | true |
4fb9114001db8b212730719cc46c7ed300db7f71 | Rust | toybox-rs/toybox-rs | /tb_pong/src/types.rs | UTF-8 | 1,707 | 3.15625 | 3 | [] | no_license | use crate::Body2D;
use toybox_core::graphics::Color;
/// This represents the setup needed for a game of Pong.
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct Pong {
/// What is the background color of the board? Brownish by default.
pub bg_color: Color,
/// The gray area at the top/b... | true |
3d13cea2523f2a6c2b399810f6a9b37487e6e369 | Rust | yeethawe/PokemonRust | /pokemon_rust/src/overworld/events/repeated_event.rs | UTF-8 | 1,723 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | //! Generic event. Repeats an event for a given number of times sequentially.
use amethyst::ecs::World;
use super::{BoxedGameEvent, ChainedEvents, ExecutionConditions, GameEvent};
use std::marker::PhantomData;
pub struct RepeatedEvent<T>
where
T: 'static + GameEvent + Sync + Send,
{
chain: ChainedEvents,
... | true |
c5c97306bc89598fee361e248884394a13a4128c | Rust | DyrellC/bee-p | /bee-network/src/events.rs | UTF-8 | 5,332 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 IOTA Stiftung
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in w... | true |
79628975e90f668f303cb9f12a21017290801325 | Rust | ignatenkobrain/jwalk | /src/core/read_dir.rs | UTF-8 | 1,127 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::io::Result;
use super::{ClientState, DirEntry, IndexPath, Ordered, ReadDirSpec};
/// Results of successfully reading a directory.
#[derive(Debug)]
pub struct ReadDir<C: ClientState> {
pub(crate) parent_client_state: C,
pub(crate) dir_entry_results: Vec<Result<DirEntry<C>>>,
}
impl<C: ClientState> Re... | true |
ec99b64069b9c802602708b0ab07fd218c239d8f | Rust | lxdlam/CP-Answers | /Codeforces/RandomProblems/1287A.rs | UTF-8 | 1,768 | 3.5 | 4 | [
"MIT"
] | permissive | use std::cmp::max;
use std::collections::LinkedList;
use std::io::stdin;
use std::str::FromStr;
struct Reader {
tokens: LinkedList<String>,
line: String,
}
impl Reader {
pub fn new() -> Reader {
Reader {
tokens: LinkedList::new(),
line: String::new(),
}
}
f... | true |
8cda7a0bc9335da945569907c19662004bc70d87 | Rust | evq/atsaml11xxx | /src/wdt/ewctrl/mod.rs | UTF-8 | 9,047 | 2.734375 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::EWCTRL {
#[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 |
f8aa0c50dbe7e3117ce594a08a5237a8e41aef79 | Rust | Boyquotes/zeldalike-rs | /game2d/tests/collide.rs | UTF-8 | 16,095 | 2.625 | 3 | [
"MIT"
] | permissive | use game2d::{
self,
collide::*,
geom::{P2, V2},
};
use std::time::Duration;
mod test_support;
use crate::test_support::*;
const GROUP_WALL: u32 = GROUP_0;
const GROUP_ACTOR: u32 = GROUP_1;
const GROUP_PASSTHRU: u32 = GROUP_2;
fn new_default_world() -> CollisionWorld {
CollisionWorld::new(CollisionWo... | true |
ec719c3cf4e50020342ee632830db0dddb643295 | Rust | Stebalien/horrorshow-rs | /tests/utf8.rs | UTF-8 | 528 | 2.8125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[macro_use]
extern crate horrorshow;
use horrorshow::Template;
#[test]
fn test_utf8() {
let data = "м, о";
// Test fmt::Write
assert_eq!(format!("{}", html! {: data}), data);
// Test String
#[cfg(feature = "alloc")]
assert_eq!(html! {: data}.into_string().unwrap(), data);
// Test io::Wri... | true |
af116012aaa14b74de88997b9cb9972f004160a9 | Rust | cypressf/learning-rust | /rectangles/src/main.rs | UTF-8 | 942 | 4.09375 | 4 | [] | no_license | #[derive(Debug)]
struct Rectangle {
width: u32,
height: u32
}
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height
}
fn fits_in(&self, rectangle: &Rectangle) -> bool {
self.width < rectangle.width && self.height < rectangle.height
}
fn square(size: u32) -> Rec... | true |
65f64b11b051f14e80c3a8b9ce855a6ce24d2554 | Rust | cryptopossum/gp-v2-services | /orderbook/src/api/create_order.rs | UTF-8 | 4,998 | 2.796875 | 3 | [] | no_license | use crate::api::extract_payload;
use crate::orderbook::{AddOrderResult, Orderbook};
use anyhow::Result;
use model::order::OrderCreationPayload;
use std::{convert::Infallible, sync::Arc};
use warp::{hyper::StatusCode, Filter, Rejection, Reply};
pub fn create_order_request(
) -> impl Filter<Extract = (OrderCreationPaylo... | true |
1fa86e014d56611c25696a55cc6f8d92004ddfeb | Rust | villor/rustia | /crates/game/src/map.rs | UTF-8 | 4,554 | 3.125 | 3 | [] | no_license | use std::{fmt::{self, Display, Formatter}, sync::Arc};
use parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard};
use ahash::AHashMap;
use smallvec::{SmallVec};
use base::Position;
const MAX_LAYERS: usize = 16;
const CHUNK_BITS: u16 = 3;
const CHUNK_SIZE: u16 = 1 << CHUNK_BITS;
const CHUNK_MASK: u16 = CHUNK_SIZE... | true |
624cc862cba4cea6fa0b492a6293d6ef498a8dcf | Rust | fewensa/rtdlib | /src/types/passport_suitable_element.rs | UTF-8 | 3,049 | 2.90625 | 3 | [
"MIT"
] | permissive |
use crate::types::*;
use crate::errors::*;
use uuid::Uuid;
/// Contains information about a Telegram Passport element that was requested by a service
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct PassportSuitableElement {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@... | true |
28d70769eb117c6e327dd2b94dc18c767dcee207 | Rust | bisforboman/RayTracingInOneWeekend | /src/vec3.rs | UTF-8 | 3,282 | 3.4375 | 3 | [] | no_license | use std::ops;
// Mostly stolen från adamse
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Vec3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
pub fn color(x: f64, y: f64, z: f64) -> Vec3 {
Vec3 { x, y, z }
}
pub fn point(x: f64, y: f64, z: f64) -> Vec3 {
Vec3 { x, y, z }
}
pub fn vec(x: f64, y: f... | true |
e255236e82c0ffb12d57cf0683a50994aff62660 | Rust | M3L6H/Data-Structures | /Lists/Rust/skip_list/src/lib.rs | UTF-8 | 529 | 3.34375 | 3 | [
"MIT"
] | permissive | //! An implementation of a skip list in Rust.
//! Supports O(log n) insertion and search while maintaining a list-like structure.
pub mod skip_list;
#[cfg(test)]
mod tests {
use super::skip_list::SkipList;
#[test]
fn it_constructs() {
let comp = |a: &i32, b: &i32| -> i32 {
if a < b {
return... | true |
e9be02dec86ed969439ed8b535ee22447e14e5ae | Rust | dunnock/wabench | /crates/web/src/data/mod.rs | UTF-8 | 2,131 | 2.578125 | 3 | [] | no_license | pub mod views;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use wabench::tests::Tests;
#[derive(Serialize, Deserialize, Debug, PartialEq, Hash, Eq, Clone, Copy)]
pub enum RunnerImpl {
Wasi,
Stdweb,
Embedded,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum Request {
RunTest(... | true |
335b5c5efb763b89c91c1c3b65f71a4a9530c911 | Rust | treetertot/raytracer | /src/camera.rs | UTF-8 | 1,918 | 2.640625 | 3 | [] | no_license | use crate::ray::Ray;
use crate::rtweekend::{degrees_to_radians, random_double_between};
use crate::scene_loader::StartEndPair;
use crate::vec3::{random_in_unit_disk, unit_vector, Point3, Vec3};
pub(crate) struct Camera {
origin: Point3,
lower_left_corner: Point3,
horizontal: Vec3,
vertical: Vec3,
u... | true |
e2a66c7e5c6e6987f7f98163d92a56f08b5b7953 | Rust | rust-vmm/event-manager | /tests/multi_threaded.rs | UTF-8 | 6,908 | 3.078125 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
use std::sync::{Arc, Mutex};
use std::thread;
use event_manager::utilities::subscribers::{
CounterInnerMutSubscriber, CounterSubscriber, CounterSubscriberWithData,
};
use event_manager... | true |
ea05bb1f3bf0a25437d37d4c330e9ab4c7b78f36 | Rust | alisyahidin/learn-rust | /src/main.rs | UTF-8 | 4,405 | 3.515625 | 4 | [] | no_license | use rand::Rng;
use regex::Regex;
use std::cmp::Ordering;
use std::io;
mod get_collections;
mod holla;
mod routes;
fn fib(num: i32) -> i32 {
match num {
0 => 0,
1 => 1,
2 => 1,
_ => fib(num - 1) + fib(num - 2),
}
}
fn get_loop() {
let mut y: u32 = 1;
let max_loop: u32 =... | true |
1e3bf3e63ccc852db585931fd234bfc60ba51eec | Rust | PeterUlb/rust-user-service | /src/api/session.rs | UTF-8 | 2,925 | 2.515625 | 3 | [] | no_license | use crate::auth::AccessClaims;
use crate::configuration::Configuration;
use crate::configuration::Jwt;
use crate::db;
use crate::db::PgPool;
use crate::error::ApiError;
use crate::model::sessions::{LoginDto, Session};
use crate::service;
use actix_web::web::Json;
use actix_web::{get, http, post, web, HttpMessage, HttpR... | true |
df559ef42dab5560bb2d223198d32048f0f856f6 | Rust | uddp/eph | /src/fs.rs | UTF-8 | 629 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::fs;
use crate::config;
use crate::cli::is_init;
pub fn init(is_standalone: bool) {
let init = is_init("benl");
match init {
Ok(()) => {
if is_standalone {
println!("Creating eph data directory in: {}", config::EPH_DATA_DIR);
match fs::create_dir(con... | true |
0ccf09aa4536388bc6ef27dbe6dc6ca79f463a01 | Rust | nn1ks/rwarden | /rwarden/src/settings/request.rs | UTF-8 | 2,940 | 2.53125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::settings::{Domains, EquivalentDomains, GlobalEquivalentDomainsType};
use crate::{cache::Cache, util::ResponseExt, Client, Error, Request};
use futures_core::future::BoxFuture;
use reqwest::Method;
use serde::Serialize;
use typed_builder::TypedBuilder;
/// A [`Request`] for retrieving domain settings.
#[deri... | true |
42e831077e1bd0564074b2b38c7a74b4bcb36fb9 | Rust | clucompany/cluLockFile | /src/file_system/flock/mod.rs | UTF-8 | 4,371 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive |
use crate::file_system::flock::element::DontAutoRemovePath;
use crate::file_system::flock::err::FlRecoveryErr;
use crate::file_system::flock::err::FlReadFileErr;
use crate::err::LockFileErr;
use crate::file_system::flock::err::FlCreateFileErr;
use std::io::ErrorKind::AlreadyExists;
use crate::file_system::flock::eleme... | true |
f4f797eb482d9d229d50f8689972350e111ae114 | Rust | joelong01/rust_cribbage_core | /api/src/game_handlers.rs | UTF-8 | 27,559 | 2.90625 | 3 | [] | no_license | use crate::client_structs::{
ClientCard, CountedCardResponse, CutCardResponse, CutCards, ParsedHand, RandomHandResponse,
ScoreResponse,
};
use actix_web::{web::Path, HttpRequest, HttpResponse, Responder};
use cribbage_library::{
cards::Card,
counting::score_counting_cards_played,
cribbage_errors::{C... | true |
d9a0831a8c73db8c431e008c97ffb74dbd426c79 | Rust | isgasho/arithmetic-parser | /eval/src/values/variable_map.rs | UTF-8 | 5,210 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! `VariableMap` trait and implementations.
#![allow(renamed_and_removed_lints, clippy::unknown_clippy_lints)]
// ^ `missing_panics_doc` is newer than MSRV, and `clippy::unknown_clippy_lints` is removed
// since Rust 1.51.
use arithmetic_parser::{grammars::Grammar, Block};
use core::{cmp::Ordering, fmt};
use crate... | true |
e73f5366e35dc199b05fba9d77416a4bd6a636c1 | Rust | zaeleus/noodles | /noodles-vcf/src/header/builder.rs | UTF-8 | 13,117 | 2.8125 | 3 | [
"MIT"
] | permissive | use super::{
record::{
self,
value::{
map::{AlternativeAllele, Contig, Filter, Format, Info, Meta},
Map,
},
},
AlternativeAlleles, Contigs, FileFormat, Filters, Formats, Header, Infos, OtherRecords,
SampleNames,
};
use indexmap::IndexMap;
/// A VCF heade... | true |
6efefde01130df1aa459e97dbc3d85396ae10451 | Rust | alexcrichton/wasmtime | /cranelift/codegen/src/value_label.rs | UTF-8 | 1,812 | 2.703125 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::ir::{SourceLoc, ValueLabel};
use crate::machinst::Reg;
use crate::HashMap;
use alloc::vec::Vec;
use core::cmp::Ordering;
use core::convert::From;
use core::ops::Deref;
#[cfg(feature = "enable-serde")]
use serde::{Deserialize, Serialize};
/// Value location range.
#[derive(Debug, Clone, Copy, PartialEq, Eq)... | true |
52e3f8d37219c7a11a4af4b8e8a8555b6cbceb6a | Rust | rust-bitcoin/rust-bitcoin | /hashes/src/sha512_256.rs | UTF-8 | 6,551 | 2.625 | 3 | [
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-public-domain"
] | permissive | // SPDX-License-Identifier: CC0-1.0
//! SHA512_256 implementation.
//!
//! SHA512/256 is a hash function that uses the sha512 alogrithm but it truncates
//! the output to 256 bits. It has different initial constants than sha512 so it
//! produces an entirely different hash compared to sha512. More information at
//! <... | true |
16a3e6cf68cd3e580abe4e17bebe03e63185e9e2 | Rust | rust-lang/libm | /src/math/sincosf.rs | UTF-8 | 5,261 | 2.765625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /* origin: FreeBSD /usr/src/lib/msun/src/s_sinf.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
* Optimized by Bruce D. Evans.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPr... | true |
fede86e3d58dcb085f5df523de8015472e05b6f7 | Rust | stanbar/mini-whirlpool | /src/bipoly.rs | UTF-8 | 8,436 | 3.515625 | 4 | [] | no_license | use std::ops::{Add, Mul};
/// Binary Ring Polynomial element
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct BiPoly(pub u8);
impl std::fmt::Display for BiPoly {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
impl BiPoly {
fn to_array(&self) -> ... | true |
36c34136fb070c2475fbbe52204390ef84ba468d | Rust | crunchbang/lang-adventures | /rust/rust101/src/main.rs | UTF-8 | 2,226 | 3.671875 | 4 | [
"BSD-2-Clause"
] | permissive | use self::SomethingOrNothing::{Nothing, Something};
fn main() {
let v = read_numbers();
let result = vec_min(v);
result.print();
let v2 = read_numbers();
let sum = vec_sum(v2);
sum.print();
let v3 = read_numbers();
vec_print(v3);
let r4 = vec_min(vec![11.0, 1.2, 2.3, 3.4, 4.5]);
... | true |
c056228272805ca4daa1bc58aa4f0007ba837fb1 | Rust | pavlus/rt-one-week-rust | /src/material/dielectric.rs | UTF-8 | 2,006 | 3 | 3 | [
"MIT"
] | permissive | use crate::random;
use super::{Hit, Material, Ray, V3};
#[derive(PartialEq, Copy, Clone, Debug)]
pub struct Dielectric {
albedo: V3,
ref_idx: f64,
}
impl Dielectric {
pub fn new(ref_idx: f64) -> Dielectric { Dielectric { albedo: V3::ones(), ref_idx } }
pub fn new_colored(albedo: V3, ref_idx: f64) -> ... | true |
215b47db139f856a9ba4018a0461f2e81400ff55 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/bytes/benches/buf.rs | UTF-8 | 4,546 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #
!
[
feature
(
test
)
]
#
!
[
warn
(
rust_2018_idioms
)
]
extern
crate
test
;
use
bytes
:
:
Buf
;
use
test
:
:
Bencher
;
/
/
/
Dummy
Buf
implementation
struct
TestBuf
{
buf
:
&
'
static
[
u8
]
readlens
:
&
'
static
[
usize
]
init_pos
:
usize
pos
:
usize
readlen_pos
:
usize
readlen
:
usize
}
impl
TestBuf
{
fn
new
(
buf... | true |
f74c53e68e15cb2c6fc4a79470825d74f3ec91f0 | Rust | awski/ntcp | /src/ntcp.rs | UTF-8 | 5,694 | 2.625 | 3 | [
"MIT"
] | permissive | use std::{cmp::Ordering, io::prelude::*, unimplemented};
use std::io;
const MTU_SIZE: usize = 1500;
const IP_HDR_TIMEOUT: u8 = 123;
pub struct TCB {
state: State,
send: SendSequence,
recv: RecvSequence,
ip: etherparse::Ipv4Header,
tcp: etherparse::TcpHeader,
}
pub enum State {
Closed,
Lis... | true |
8dceabd819793edd04d8cbe924bbcbd5f406b4a7 | Rust | Riari/aoc-2020 | /src/bin/08.rs | UTF-8 | 2,779 | 3.328125 | 3 | [] | no_license | #![feature(map_first_last)]
use std::collections::BTreeSet;
use util;
#[derive(Clone)]
struct Line {
op: String,
arg: i32,
}
#[derive(Clone)]
struct Program {
lines: Vec<Line>,
visited: BTreeSet<i32>,
i: i32,
acc: i32,
}
struct Result {
completed: bool,
acc: i32,
}
impl Program {
... | true |
7b27ea8dcf12043c6a05976eb2ff50c82c9ec64c | Rust | Technolution/rustig | /lib/panic_analysis/tests/libcalls.rs | UTF-8 | 6,077 | 2.515625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // (C) COPYRIGHT 2018 TECHNOLUTION BV, GOUDA NL
// 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// exce... | true |
a0ec527ec1ef64f8dcc5e88c6f8a9523c626c868 | Rust | CarlOsterberg/D7050E | /d7050e_2020/src/tests/random_tests/sum.rs | UTF-8 | 137 | 2.5625 | 3 | [] | no_license | fn main() -> i32 {
sum(9)
};
fn sum(var:i32) -> i32 {
if var==0 {
var
}; else {
sum(var - 1) + var
};
}; | true |
1767a75ac27809cba01f0e3c2eaf9db9f50efc5a | Rust | yk-amarly-20/rust-line-bot-sdk | /src/event/message.rs | UTF-8 | 6,901 | 3.203125 | 3 | [] | no_license | use serde_json::Number;
#[derive(Deserialize, Debug, PartialEq)]
#[serde(tag = "type")]
pub enum Message {
#[serde(rename = "text")]
Text {
id: String,
text: String,
},
#[serde(rename = "image", rename_all = "camelCase")]
Image {
id: String,
content_provider: Content... | true |
375c35cd20fe39547661b4b4e400f84305986e4e | Rust | gwenn/rustyline | /src/test/history.rs | UTF-8 | 5,245 | 2.671875 | 3 | [
"MIT"
] | permissive | //! History related commands tests
use super::assert_history;
use config::EditMode;
use keys::KeyPress;
#[test]
fn down_key() {
for mode in &[EditMode::Emacs, EditMode::Vi] {
assert_history(
*mode,
&["line1"],
&[KeyPress::Down, KeyPress::Enter],
("", ""),
... | true |
d728c82a2c85d32a0f69c718555f3a5d25b09572 | Rust | remexre/evaltrees | /src/cst/display/mod.rs | UTF-8 | 3,772 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[cfg(test)]
mod tests;
use std::fmt::{Display, Formatter, Result as FmtResult};
use crate::ast::Op;
use crate::cst::{Decl, Expr};
impl Display for Decl {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
write!(fmt, "{}", self.name)?;
for arg in &self.args {
write!(fmt, " {}", arg)?;... | true |
361f0363bacaa504c5fc16fe92787b9fa93b8e80 | Rust | lovasoa/gapdecoder-rs | /src/decryption.rs | UTF-8 | 3,258 | 2.71875 | 3 | [] | no_license | use std::io::{Cursor, Read, Seek, SeekFrom, Write};
use aes::Aes128;
use aes::block_cipher_trait::generic_array::{arr, arr_impl};
use block_modes::{BlockMode, BlockModeError, Cbc};
use block_modes::block_padding::ZeroPadding;
use custom_error::custom_error;
// create an alias for convenience
type Aes128Cbc = Cbc<Aes... | true |
f6db0d714548c0245c25dcc70217463cce418975 | Rust | sapotero/microJVM | /src/main.rs | UTF-8 | 13,113 | 2.546875 | 3 | [] | no_license | use byteorder::{ReadBytesExt, BigEndian};
use std::{
path::Path,
fs::File,
io::{self, Read},
};
/*
MD5 checksum 5bea216f2a8c3eef7e5998435f01a067
Compiled from "Main.java"
public class Main
minor version: 0
major version: 55
flags: (0x0021) ACC_PUBLIC, ACC_SUPER
this_c... | true |
6b0a75cf6cddea6aefb954c124fcf47dd1e19d99 | Rust | wdv4758h/fib_bench | /src/fib-recursive.rs | UTF-8 | 252 | 3.484375 | 3 | [] | no_license | use std::env;
fn fib(number: usize) -> usize {
if number < 2 {
return number;
}
fib(number-1) + fib(number-2)
}
fn main() {
let number: usize = env::args().nth(1).unwrap().parse().unwrap();
println!("{}", fib(number));
}
| true |
506a11466fe5574b42a1fa9344e46cb9c8038aaf | Rust | SachinMaharana/rust-dynamodb-mailing-list | /src/dynamo.rs | UTF-8 | 4,095 | 2.9375 | 3 | [] | no_license | use chrono::Utc;
use std::collections::HashMap;
use anyhow::{anyhow, bail, Result};
use rusoto_core::Region;
use rusoto_dynamodb::{
AttributeValue, DeleteItemInput, DynamoDb, DynamoDbClient, PutItemInput, QueryInput,
};
// #[derive(Debug)]
// struct Item {
// newsletter: String,
// email: String,
// c... | true |
164961aab76ffedfaa42c4b1152433bc0af54714 | Rust | ajiahamed/icefoss | /code2/session1/enum2.rs | UTF-8 | 175 | 2.890625 | 3 | [] | no_license | #[derive(Debug)]
enum Shape {
Circle(i32),
Square(i32),
Rectangle(i32, i32),
}
use Shape::*;
fn main() {
let s = Rectangle(10, 20);
println!("{:?}", s);
}
| true |
daba1b68c67e70fecaa1f02098b9fba5e070f2c3 | Rust | TerminalWitchcraft/actix-ratelimit | /src/errors.rs | UTF-8 | 1,128 | 3.03125 | 3 | [
"MIT"
] | permissive | //! Errors that can occur during middleware processing stage
use actix_web::error::Error as AWError;
use actix_web::web::HttpResponse;
use failure::{self, Fail};
use log::*;
/// Custom error type. Useful for logging and debugging different kinds of errors.
/// This type can be converted to Actix Error, which defaults ... | true |
9fd0830ab26e22abc698584e84ef069739c824bd | Rust | truchi/lay | /src/layer/cell/cell/layer.rs | UTF-8 | 2,106 | 3.03125 | 3 | [] | no_license | use crate::*;
use std::iter::{once, Map, Once, Skip, Take};
impl LayerSize for Cell {
fn size(&self) -> Coord {
(1, 1)
}
}
impl<'a> Layer<'a> for Cell {
type Cells = Take<Skip<Once<Cell>>>;
type Row = Take<Skip<Once<Cell>>>;
type Rows = Map<Take<Skip<Once<(Cell, u16, u16)>>>, fn((Cell, u16... | true |
aac038bb125eb806ff9691df0699cbf48fb19042 | Rust | Lapz/rust-analyzer | /crates/ra_lsp_server/build.rs | UTF-8 | 431 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Just embed git-hash to `--version`
use std::process::Command;
fn main() {
let rev = rev().unwrap_or_else(|| "???????".to_string());
println!("cargo:rustc-env=REV={}", rev)
}
fn rev() -> Option<String> {
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().ok()?;
let stdout = Str... | true |
54989d531e8454aad709f6aaf3b3bd3878294a7c | Rust | PIAIC-IOT/Quarter-1_6.45-9.45 | /mini-hackathon/copying-strings/src/main.rs | UTF-8 | 777 | 3.71875 | 4 | [] | no_license | use std::io;
fn main(){
println!("Enter String:");
let mut element = String::new();
io::stdin().read_line(&mut element).expect("Failed to read lines");
println!("How many copies of String you need:");
let mut number = String::new();
io::stdin().read_line(&mut number);
let mut num :... | true |
1056b40b346275cb1248864327d5e3f7a07a2033 | Rust | 0xflotus/wambo | /src/parse/unit.rs | UTF-8 | 4,741 | 3.140625 | 3 | [
"MIT"
] | permissive | /*
MIT License
Copyright (c) 2020 Philipp Schuster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publis... | true |
4d47e247280a39dd4be751e7b26b9f0c018a2785 | Rust | haileys/go_parser | /src/lex/mod.rs | UTF-8 | 2,884 | 2.953125 | 3 | [] | no_license | use std::path::PathBuf;
use std::rc::Rc;
use loc::Loc;
mod scan;
use self::scan::Lexeme;
#[derive(Debug)]
pub enum LexError {
UnexpectedChar(Loc),
UnterminatedComment,
UnterminatedString,
UnterminatedRune,
BadEscape(Loc),
IllegalNewline(Loc),
IllegalHexDigit(Loc),
IllegalOctalValue(L... | true |
d0f40515409a28d41570ac4c3f76a33d1a05b02d | Rust | krooken/AdventOfCode2020 | /day_09/src/main.rs | UTF-8 | 241 | 2.59375 | 3 | [] | no_license | fn main() {
let filename = "data/code.txt";
let row = day_09::find_invalid(filename, 25);
println!("First invalid number is: {}", row);
let sum = day_09::get_min_max_sum(filename, 25);
println!("Weakness is: {}", sum);
} | true |
339c94213ade6ae5c50aba2bef5fe345b8ea89c5 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc238/src/bin/c.rs | UTF-8 | 638 | 2.625 | 3 | [] | no_license | use proconio::input;
fn f(a_1: u128, a_n: u128) -> u128 {
let n = a_n - a_1 + 1;
let a_n = a_1 + (n - 1);
(a_1 + a_n) * n / 2
}
fn main() {
input! {
n: u128,
};
let mod_p = 998_244_353_u128;
let mut sum = 0_u128;
for i in 0..n.to_string().len() - 1 {
let l = 10_u128.po... | true |
05a200ff1ec21637ea0c2f7623b6e4a58d402425 | Rust | webrtc-rs/rtc | /sdp/src/lexer/mod.rs | UTF-8 | 1,760 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use super::description::session::SessionDescription;
use super::error::{Error, Result};
use std::io;
use std::io::SeekFrom;
pub(crate) const END_LINE: &str = "\r\n";
pub struct Lexer<'a, R: io::BufRead + io::Seek> {
pub desc: SessionDescription,
pub reader: &'a mut R,
}
pub type StateFnType<'a, R> = fn(&mut... | true |
b527bd4039113040cdbba67c86a3609e23e91903 | Rust | rust-mbedtls/mbedtls | /src/error.rs | UTF-8 | 19,039 | 2.734375 | 3 | [
"Apache-2.0",
"GPL-2.0-or-later",
"GPL-3.0-or-later",
"GPL-2.0-only",
"LicenseRef-scancode-unknown-license-reference",
"GPL-1.0-or-later",
"LicenseRef-scancode-dco-1.1"
] | permissive | /* Copyright (c) Fortanix, Inc.
*
* Licensed under the GNU General Public License, version 2 <LICENSE-GPL or
* https://www.gnu.org/licenses/gpl-2.0.html> or the Apache License, Version
* 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>, at your
* option. This file may not be copied, modified, or ... | true |
7eb88b6aa1286f48ee768c4eacceb1c89fee6b70 | Rust | edison-moreland/chip-8 | /src/chip8/mod.rs | UTF-8 | 757 | 2.84375 | 3 | [] | no_license | mod chip8;
pub use self::chip8::*;
mod instructions;
use self::instructions::Instruction;
pub mod traits;
use std::fmt;
pub enum Chip8Error {
RomTooBig(usize),
InvalidInstruction(u16, u16),
InstructionNotImplemented(Instruction),
}
impl fmt::Display for Chip8Error {
fn fmt(&self, f: &mut fmt::Forma... | true |
aded8b2ffe8533cfe23ab5b144321ec5ac676174 | Rust | luminalang/lumina | /lumina-compiler/src/verifier/type/enum.rs | UTF-8 | 2,924 | 2.6875 | 3 | [] | no_license | use super::*;
pub struct Builder<'ast> {
base: &'ast collector::DefinedType,
enum_: &'ast lumina_parser::Enum,
variants: VariantsBuilder,
}
impl<'ast> UniqueHandler for &mut Builder<'ast> {
type Root = hir::Type;
type Tree = Tp<hir::Type>;
fn combinator(root: Self::Root, params: Vec<Tr<Self:... | true |
7b9b9a76201ed0056904db0d111336eed150f39c | Rust | Daohub-io/cap9 | /kernel-ewasm/validator/src/modules.rs | UTF-8 | 18,255 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use super::func;
use super::import_entry;
use super::parse_varuint_32;
use super::Cursor;
use super::ImportEntry;
use crate::instructions;
use crate::primitives::CountedList;
use crate::serialization::{WASMDeserialize};
#[cfg(not(feature = "std"))]
use pwasm_std::String;
#[cfg(not(feature = "std"))]
use pwasm_std::Vec;... | true |
4b655ede420f60f19e65dc5e511774a899e85336 | Rust | sebastien-mariaux/AdventOfCode2020 | /day13/part1/src/main.rs | UTF-8 | 1,061 | 3.25 | 3 | [] | no_license | use std::fs;
fn main() {
let result = solve_puzzle("input");
println!("And the result is {}", result);
}
fn solve_puzzle(file_name: &str) -> u32 {
let file = read_data(file_name);
let mut data = file.lines();
let earliest = data.next().unwrap().parse::<u32>().unwrap();
let bus_ids = data
... | true |
4d958f132c8f950aadca9f1d8e0b75b11c506bb8 | Rust | apognu/kvlogger | /src/builder.rs | UTF-8 | 2,280 | 3.140625 | 3 | [
"MIT"
] | permissive | use crate::kvlogger::KvLogger;
use env_logger::filter::{Builder as FilterBuilder, Filter};
use log::{Level, SetLoggerError};
/// A builder to create and register `kvlogger`
///
/// # Examples
///
/// ```no_run
/// use std::error::Error;
/// use log::Level;
/// use kvlogger::*;
///
/// fn main() -> Result<(), Box<dyn E... | true |
432957f39d0e8b81ab851cc03a6f548adbc34ba0 | Rust | rserpent/yet_another_hashmap | /src/hash_map.rs | UTF-8 | 2,313 | 3.484375 | 3 | [] | no_license | use crate::hash_table::{Entry, HashTable};
use std::sync::Mutex;
use std::sync::RwLock;
#[derive(Debug)]
pub struct HashMap<T>
where
T: Clone,
{
data: RwLock<HashTable<T>>,
count: Mutex<usize>,
capacity: Mutex<usize>,
}
impl<T> HashMap<T>
where
T: Clone,
{
// Creates new HashMap with default(3... | true |
f8c96eac186371d4c821e029bac8a0d08eb2f122 | Rust | raymondsiu/rust101 | /serde_example/src/main.rs | UTF-8 | 503 | 2.890625 | 3 | [] | no_license | extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[derive(Serialize, Deserialize)]
struct MSG {
from: String,
to: String,
message: String,
}
fn main() {
let new = MSG {
from: "me".to_string(),
to: "you".to_string(),
message: "hello".to_strin... | true |
c89e2f26cb4085be9418b508ca48856f70dfdbed | Rust | jihchi/gpkg | /gpkg/src/directory_portal.rs | UTF-8 | 1,778 | 3.40625 | 3 | [] | no_license | use log::*;
use std::path::Path;
use tempdir::TempDir;
pub struct DirectoryPortal<P: AsRef<Path>> {
temp_dir: TempDir,
target: P,
}
impl<P: AsRef<Path>> DirectoryPortal<P> {
#[must_use]
pub fn new(target: P) -> Self {
let temp_dir = TempDir::new("directory_portal").expect("Can't generate a tem... | true |
2cc6a445f61d014de388a8abede9e843aa7ec859 | Rust | shashankhacker730/feroxbuster | /src/statistics/macros.rs | UTF-8 | 1,061 | 3.078125 | 3 | [
"MIT"
] | permissive | #![macro_use]
/// Wrapper `Atomic*.fetch_add` to save me from writing Ordering::Relaxed a bajillion times
///
/// default is to increment by 1, second arg can be used to increment by a different value
#[macro_export]
macro_rules! atomic_increment {
($metric:expr) => {
$metric.fetch_add(1, Ordering::Relaxed... | true |
7de166da202a4e4d8225630c615e3ee757c3b22e | Rust | nozaq/csa-rs | /src/parser/mod.rs | UTF-8 | 1,502 | 3.015625 | 3 | [
"MIT"
] | permissive | mod game;
mod time;
use std::error::Error;
use std::fmt;
use self::game::game_record;
use crate::value::GameRecord;
#[derive(Debug)]
pub enum CsaError {
ParseError(),
}
impl fmt::Display for CsaError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
CsaError::ParseEr... | true |
65abfeca2892859752775feeb730124ee83918b9 | Rust | blasrodri/matecito | /src/cache.rs | UTF-8 | 3,239 | 2.765625 | 3 | [] | no_license | use crate::bloom_filter::BloomFilter;
use crate::matecito_internal::MatecitoInternal;
use parking_lot::Mutex;
use std::hash::{BuildHasher, Hasher};
use std::sync::Arc;
const NUM_SHARDS: usize = 256;
pub(crate) struct Cache<K, T> {
hash_builder: twox_hash::RandomXxHashBuilder64,
sharded_matecitos: Arc<Vec<Arc<... | true |
980282b1e6e1b80d4649b5a1641d60a56b6b7c15 | Rust | metarational/typesense-rust | /typesense/src/document.rs | UTF-8 | 565 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | //! # Document
//!
//! In Typesense, documents are each one of the JSON elements that are stored in the collections.
//! A document to be indexed in a given collection must conform to the schema of the collection.
//!
use crate::collection::CollectionSchema;
use serde::{de::DeserializeOwned, Serialize};
/// Trait that... | true |
25d1bdf5c0129f77b6fa39a8ef14d0dbf350d209 | Rust | crackcomm/wtf-rlsr | /src/cmd/mod.rs | UTF-8 | 1,249 | 2.578125 | 3 | [] | no_license | pub(crate) mod exec;
pub(crate) mod release;
pub(crate) mod update_paths;
use std::path::PathBuf;
use structopt::StructOpt;
use crate::util::init::setup_opt;
/// Command line application options.
#[derive(Debug, StructOpt)]
#[structopt(name = "wtf-rlrsr", about = "WTF Releaser.")]
pub struct Opt {
/// Workspace... | true |
1240bde5db80058f739600afbdbd957f4b1bb439 | Rust | willemv/rust-mastermind | /www/src/js_utils.rs | UTF-8 | 918 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::{console, EventTarget};
#[allow(unused_unsafe)]
//this is for the benefit or rust-analyzer, who marks all usages of the regular log_1 as unsafe
pub fn log_1(data_1: &::wasm_bindgen::JsValue) {
unsafe {
console::log_1(data_1);
}
}
#[m... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.