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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c7f8bd34e276190c7903e9fd3fd82573e7f71bc2 | Rust | Mcfloy/hexagonapp | /hexagonapp/src/student/repository/student_repository.rs | UTF-8 | 477 | 2.59375 | 3 | [] | no_license | use uuid::Uuid;
use crate::student::student::Student;
use async_trait::async_trait;
use crate::student::error::StudentError;
#[async_trait]
pub trait StudentRepository {
async fn find_by_id(&self, id: Uuid) -> Result<Option<Student>, StudentError>;
async fn delete_by_id(&self, id: Uuid) -> Result<(), StudentE... | true |
f5336c7138dd8879e0d90b70e7d538f74bd5294f | Rust | mat-h7/mw-btc-swap | /src/swap/slate.rs | UTF-8 | 5,467 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::swap::swap_types::BTCPriv;
use crate::swap::swap_types::MWPriv;
use crate::swap::swap_types::SwapSlatePriv;
use crate::swap::swap_types::SwapSlatePub;
use std::fs::File;
use std::fs;
use std::path::Path;
use crate::SwapSlate;
use sha2::{Sha256, Digest};
/// Write Atomic Swap slate into files on disk
///
//... | true |
36071f513741f0b95a456316a2c4235e372916b1 | Rust | benkay86/matlab-ndarray-tutorial | /rust/src/bin/clear.rs | UTF-8 | 5,619 | 3.9375 | 4 | [] | no_license | //! Clearing memory. In Rust this is referred to as "dropping" a variable.
extern crate blas_src;
use ndarray::{array, Array, Dim, Ix};
use std::mem::drop;
// Functions are covered in greater detail later.
// This function takes a reference to an array and computes a new array by
// adding 1 to each element of the f... | true |
0940d70e85bf1f856d1269e8a69f457de05df335 | Rust | drahnr/hongg-rs | /example/src/arbitrary_main.rs | UTF-8 | 747 | 3.15625 | 3 | [
"Apache-2.0",
"MIT",
"Unlicense",
"WTFPL"
] | permissive | use honggfuzz::fuzz;
fn main() {
// Here you can parse `std::env::args and
// setup / initialize your project
// You have full control over the loop but
// you're supposed to call `fuzz` ad vitam aeternam
loop {
// The fuzz macro gives an arbitrary object (see `arbitrary crate`)
//... | true |
d917f2277db402a77101531ada0541f2719b6c54 | Rust | cho0h5/stack-based-calculator | /src/converter.rs | UTF-8 | 1,732 | 3.0625 | 3 | [] | no_license | use std::collections::VecDeque;
use super::Operator;
use super::Token;
pub fn convert_to_postfix(tokenized: Vec<Token>) -> Vec<Token> {
let mut result = Vec::new();
let mut operator_temp = Vec::new();
let mut tokenized: VecDeque<Token> = tokenized.into_iter().collect();
loop {
match tokenized.... | true |
0253c642486b7c9ceb1cf4d64e51dafe18d9ae10 | Rust | pie-flavor/hexchat-rs | /src/msg.rs | UTF-8 | 12,489 | 2.75 | 3 | [
"MIT"
] | permissive | use std::ffi::CString;
use std::mem;
use std::ptr;
use chrono::{DateTime, TimeZone};
use crate::{c, from_cstring, to_cstring, ChannelRef, PrintEvent};
use std::cmp::Ordering;
/// Prints plain text to the current tab.
pub fn print_plain(text: &str) {
let text = to_cstring(text);
unsafe {
c!(hexchat_pr... | true |
86b90550a894552d6e011e4e683a9b61f6a8c8e2 | Rust | blueish/rlox | /src/ast/expr.rs | UTF-8 | 461 | 2.734375 | 3 | [] | no_license | use crate::token;
use crate::ast::{Visitor, Node};
use crate::value::Value;
#[derive(Debug, PartialEq)]
pub enum Expr {
Identifier(String),
Assignment(String, Box<Expr>),
ValueExpr(Value),
Grouping(Box<Expr>),
Unary(token::Token, Box<Expr>),
Binary(token::Token, Box<Expr>, Box<Expr>),
Call... | true |
575a50f853e143e5d1074ecf480be5f93ee84fd3 | Rust | saolsen/stee | /stee/src/parse.rs | UTF-8 | 14,586 | 3.1875 | 3 | [] | no_license | use super::types::*;
use super::lex::*;
fn parse_expr3(mut lexer: &mut Lexer) -> Result<Expression, CompileError> {
// @TODO: Maybe just always use patterns instead of those helpers.
match lexer.token.clone() {
Token::NOT => {
lexer.next_token()?;
let arg = parse_expr3(&mut lex... | true |
27e1680e0d2a99ec3f4ead1184cd8649b3866f3c | Rust | hw-standalonecomplex/appendix | /src/lib.rs | UTF-8 | 15,744 | 2.890625 | 3 | [] | no_license | #![deny(missing_docs)]
//! An append-only, on-disk key-value index with lockless reads
use std::cell::UnsafeCell;
use std::fs::OpenOptions;
use std::hash::{Hash, Hasher};
use std::io;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::path::{Path, PathBuf};
use arrayvec::ArrayVec;
u... | true |
7ee6e43d3bf24afe076fce4e8f6f4168a55c8b0b | Rust | yuparach99/open-location-code | /rust/tests/csv_reader.rs | UTF-8 | 937 | 3 | 3 | [
"Apache-2.0"
] | permissive | use std::env::current_dir;
use std::fs::File;
use std::io::{BufRead, BufReader, Lines};
pub struct CSVReader {
iter: Lines<BufReader<File>>,
}
impl CSVReader {
pub fn new(csv_name: &str) -> CSVReader {
// Assumes we're called from <open-location-code root>/rust
let project_root = current_dir()... | true |
ce5657082f7a89c41e1c68bff5e8c079c9661fe5 | Rust | DenSA-Inc/rustgameproject | /src/main.rs | UTF-8 | 211 | 2.75 | 3 | [] | no_license | extern crate engine;
fn main() {
// Create a new game and run it.
let mut game = engine::Game::new("Game Project");
game.add_sprite("othersprite.png", (400.0, 400.0), 0.0, 2.0);
game.run();
}
| true |
7288564cd2a4c68548fe72b2d4c0467317efa3e4 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass-valgrind/dst-dtor-1.rs | UTF-8 | 381 | 2.75 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | static mut DROP_RAN: bool = false;
struct Foo;
impl Drop for Foo {
fn drop(&mut self) {
unsafe { DROP_RAN = true; }
}
}
trait Trait { fn dummy(&self) { } }
impl Trait for Foo {}
struct Fat<T: ?Sized> {
f: T
}
pub fn main() {
{
let _x: Box<Fat<Trait>> = Box::<Fat<Foo>>::new(Fat { f: F... | true |
2945e7b42d7ecade9e61ed16bec1757b74f4e2dc | Rust | niofis/light | /bench/src/main.rs | UTF-8 | 2,314 | 2.6875 | 3 | [] | no_license | use clap::{App, Arg};
use light::{demos, Accelerator, RenderMethod, Renderer, Section};
use light::{Camera, Point};
fn main() {
let _matches = App::new("Bench")
.version("0.1")
.author("Enrique <niofis@gmail.com>")
.about("Benchmarks the light engine")
.arg(
Arg::with_na... | true |
602b021694ba0ab8cb9a5fa14a6a1ac87e6b9137 | Rust | seungha-kim/json-monkey-rs | /src/interpreter.rs | UTF-8 | 9,685 | 3.40625 | 3 | [] | no_license | use crate::ast::{AstNode, Ident};
use crate::environment::Environment;
use crate::value::Value;
pub struct Interpreter {
global_env: Environment,
}
impl Interpreter {
pub fn new() -> Self {
Self {
global_env: Environment::new(),
}
}
pub fn eval(&mut self, ast: &AstNode) ->... | true |
277c0fe004176cdac727ca38a51a9449a601ff7b | Rust | EFanZh/LeetCode | /src/problem_0599_minimum_index_sum_of_two_lists/index_map.rs | UTF-8 | 1,581 | 3.03125 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::collections::HashMap;
impl Solution {
pub fn find_restaurant(list1: Vec<String>, list2: Vec<String>) -> Vec<String> {
let (list1, mut list2) = if list2.le... | true |
202027cfeb98efacab514cf9e8d8ec0d405a3a08 | Rust | wujinderead/MyGoProjects | /gotest/leet_rust/tests/leet310_minimum_height_trees.rs | UTF-8 | 4,733 | 3.609375 | 4 | [] | no_license | // https://leetcode.com/problems/minimum-height-trees/
// A tree is an undirected graph in which any two vertices are connected by exactly one path.
// In other words, any connected graph without simple cycles is a tree.
// Given a tree of n nodes labelled from 0 to n - 1, and an array of n - 1 edges where edges[i] =
... | true |
5e1cf58b8aec5a3ef4e839c38298ab8401e26be8 | Rust | 196Ikuchil/nes_emulator | /src/nes/ppu/register/mod.rs | UTF-8 | 5,916 | 2.515625 | 3 | [
"MIT"
] | permissive | mod oam;
mod ppu_addr;
mod ppu_data;
mod ppu_scroll;
use self::oam::Oam;
use self::ppu_addr::PpuAddr;
use self::ppu_data::PpuData;
use self::ppu_scroll::PpuScroll;
use super::super::types::{Data, Addr};
use super::super::Ram;
use super::palette::*;
use super::PpuCtx;
use super::Mapper;
#[derive(Debug)]
pub struct Reg... | true |
717b4c34cfe3cd2326248c4e90efabb7f7eeb26a | Rust | ysavchenko1/spl-hmt-escrow | /token-lending/program/src/error.rs | UTF-8 | 678 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | //! Error types
use num_derive::FromPrimitive;
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
use thiserror::Error;
/// Errors that may be returned by the TokenLending program.
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum LendingError {
/// The account canno... | true |
89a8f7e44a19eedd8888d302c2794f534b2daa36 | Rust | steveyen/couchbase-shell | /src/cli/users.rs | UTF-8 | 2,467 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use crate::state::State;
use async_trait::async_trait;
use couchbase::GetAllUsersOptions;
use log::debug;
use nu_cli::{CommandArgs, OutputStream, TaggedDictBuilder};
use nu_errors::ShellError;
use nu_protocol::{Signature, Value};
use nu_source::Tag;
use std::sync::Arc;
pub struct Users {
state: Arc<State>,
}
impl... | true |
9293d0e5e6eb229eb4bf7dbf771e50e8f93cc888 | Rust | DallasC/ohship | /src/state.rs | UTF-8 | 1,898 | 2.734375 | 3 | [] | no_license | use quicksilver::{
lifecycle::{Event, Window},
Result,
};
use std::{cell::RefCell, rc::Rc};
// Import states
pub mod loading;
pub mod play;
use crate::{
map::Map,
state::{loading::LoadingState, play::PlayState},
GameAssets,
};
pub enum CurrentState {
Loading,
Playing,
}
#[allow(dead_code)... | true |
9907779379077c59e58c0cbe47fde25945ddc87a | Rust | fcard/MGL | /src/resources/instance.rs | UTF-8 | 706 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::ast::*;
use crate::error::*;
use crate::resources::resource_trait::*;
#[derive(Debug, Clone, PartialEq, Resource)]
pub struct Instance {
pub object: ResourceName,
pub id: u32,
pub x: i64,
pub y: i64,
pub scale: f64,
pub rotation: f64,
pub alpha: f64,
pub color: u32,
pub creation_code: Opti... | true |
a7aebf3732a73cc6754ccf2bfb27424f946a91f0 | Rust | paritytech/substrate | /primitives/trie/src/node_header.rs | UTF-8 | 4,928 | 2.515625 | 3 | [
"Apache-2.0",
"GPL-3.0-or-later",
"Classpath-exception-2.0",
"GPL-1.0-or-later",
"GPL-3.0-only"
] | permissive | // This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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.a... | true |
761f51fc8cd80cccff4a3332f844ebb806152147 | Rust | pkmn-api/pkmnapi | /pkmnapi-db/src/db/trades.rs | UTF-8 | 5,660 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::error::Result;
use crate::patch::*;
use crate::string::*;
use crate::PkmnapiDB;
use std::collections::HashMap;
impl PkmnapiDB {
pub fn get_trade_all(&self, trade_ids: &Vec<u8>) -> Result<HashMap<u8, Trade>> {
self.get_all(trade_ids, |id| self.get_trade(id))
}
/// Get trade by trade ID
... | true |
4924cbbce2f79db6e7091fe3fe086747c2269d28 | Rust | aphorisme/packs-rs | /packs/tests/derive_custom.rs | UTF-8 | 1,680 | 3.25 | 3 | [
"MIT"
] | permissive | use std::io::{Write, Read};
use packs::*;
#[derive(Debug, PartialEq)]
struct Part {
field_a: String,
field_b: Option<String>,
}
fn pack_part<T: Write>(part: &Part, writer: &mut T) -> Result<usize, EncodeError> {
Ok(&part.field_a.encode(writer)? + &part.field_b.encode(writer)?)
}
fn unpack_part<T: Read>(r... | true |
fe9b4c49a9a679c08f32a39e09c1cafc21efbd98 | Rust | fizyk20/numeric-algs | /src/symplectic/integration/suzuki.rs | UTF-8 | 1,973 | 2.921875 | 3 | [
"MIT"
] | permissive | use super::{super::State, Integrator, StepSize};
pub struct SuzukiIntegrator {
default_step: f64,
}
impl SuzukiIntegrator {
pub fn new(step_size: f64) -> Self {
Self {
default_step: step_size,
}
}
pub fn set_default_step(&mut self, step: f64) {
self.default_step = ... | true |
9ce2165b86f443d18cb94b8883fb920eb0852553 | Rust | BenoitZugmeyer/RustyAdventOfCode | /2018/src/bin/day02.rs | UTF-8 | 1,488 | 3.21875 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::HashMap;
use std::io::{stdin, BufRead};
fn main() {
let box_ids: Vec<String> = stdin().lock().lines().filter_map(|l| l.ok()).collect();
let mut two_letters = 0;
let mut three_letters = 0;
for box_id in &box_ids {
let mut letter_counts = HashMap::... | true |
ea34f9dd8f17ac4ff3d1423f0b65b37b27cdf503 | Rust | Kortekaasy/aoc2020 | /day08/src/main.rs | UTF-8 | 4,098 | 3.546875 | 4 | [] | no_license | use std::collections::HashSet;
// ========================= Challenge Logic ============================
#[derive(Clone, Debug)]
pub enum Instruction {
NOP(i64),
ACC(i64),
JMP(i64),
}
pub struct HandHeld {
pc: usize,
instructions: Vec<Instruction>,
accumulator: i64,
}
impl HandHeld {
#[al... | true |
8e86a7530fa0341cb662656e01317a69919b822e | Rust | FreddyWordingham/arc_fox | /src/util/pb/bar.rs | UTF-8 | 533 | 2.96875 | 3 | [] | no_license | //! Progress bar implementation.
use indicatif::{ProgressBar, ProgressStyle};
/// Create a simple progress bar with nice formatting.
#[inline]
#[must_use]
pub fn bar(title: &str, size: u64) -> ProgressBar {
let pb = ProgressBar::new(size);
pb.set_message(title);
pb.set_style(
ProgressStyle::defaul... | true |
cf8155cb70fa7c15871a0b234078280c578d0b37 | Rust | w4tson/advent-of-code-2018 | /rust-solutions/src/day12/mod.rs | UTF-8 | 5,752 | 3.09375 | 3 | [] | no_license | use core::result;
use std::error::Error;
use std::str::FromStr;
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::VecDeque;
type Result<T> = result::Result<T, Box<Error>>;
const TEST_INPUT : &str = "#..#.#..##......###...###";
const INPUT : &str = "##..#.#.#..##..#..##..##..#.#....#.....##.######... | true |
47eedd524eda26234b8cca8405e16a5f1fbdf856 | Rust | yeliknewo/pistol | /src/pistol/components/map3d_coords.rs | UTF-8 | 959 | 3.25 | 3 | [] | no_license | use std::hash::{Hash};
#[derive(Hash, Eq, Copy, Clone, PartialEq)]
pub struct Map3dCoords<T: Hash + Eq + Copy> {
x: T,
y: T,
z: T,
}
impl<T: Copy + Eq + Hash> super::Component for Map3dCoords<T> {
fn is_tick(&self) -> bool {
false
}
fn is_tick_mut(&self) -> bool {
false
}
... | true |
f8084aac7137b74c26417d0d57ccb1736122f7a2 | Rust | glium/glium | /examples/support/camera.rs | UTF-8 | 5,441 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | pub struct CameraState {
aspect_ratio: f32,
position: (f32, f32, f32),
direction: (f32, f32, f32),
moving_up: bool,
moving_left: bool,
moving_down: bool,
moving_right: bool,
moving_forward: bool,
moving_backward: bool,
}
impl CameraState {
pub fn new() -> CameraState {
... | true |
7e1bc437262e12feded5343229002a43b2c90df5 | Rust | ResidentMario/mini-cluster | /rust/mini-cluster-worker/src/err.rs | UTF-8 | 6,841 | 3.328125 | 3 | [] | no_license | use std::error::Error;
use std::fmt;
use std::result;
use std::io;
#[derive(Debug)]
pub enum WorkerError {
NetworkError(io::Error),
AWSError(io::Error),
DatabaseError(io::Error),
}
impl fmt::Display for WorkerError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// Because `&self` is ... | true |
564eaabda517f061df992c80e80a47b7890af80a | Rust | sundararajan93/rustlang | /src/variables.rs | UTF-8 | 642 | 4.03125 | 4 | [] | no_license | // Variables are references to the data
// Variables are immutable (cannot be reassigned)
// Rust is a block scoped language
pub fn run(){
println!("******* VARIABLES *******");
// Assigning a variable and value
let name = "Justin";
let age = 52;
println!("{} is {}", name, age);
// mutable ... | true |
05cdc2626593329c0019099d0c28b66cbd501c66 | Rust | ChaiTRex/advent-of-code-2019 | /rust/day2/src/main.rs | UTF-8 | 997 | 2.796875 | 3 | [
"MIT"
] | permissive | use intcode::machine::{Machine, MachinePause};
fn main() {
let original_machine = Machine::from_file("../2.txt").unwrap();
let mut machine = original_machine.clone();
let memory = machine.memory_mut();
memory[1] = 12;
memory[2] = 2;
match machine.execute() {
Ok(MachinePause::Halted(mac... | true |
2ab66542f92469438582bc2d41dd2107e864dd39 | Rust | yangzhe1990/conflux-rust | /util/solidity-abi/src/tests.rs | UTF-8 | 9,259 | 2.65625 | 3 | [
"GPL-3.0-only",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.0-or-later",
"GPL-3.0-or-later",
"GPL-1.0-or-later",
"LGPL-2.1-or-later",
"LicenseRef-scancode-other-copyleft"
] | permissive | // Copyright 2020 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/
use super::{ABIDecodable, ABIDecodeError, ABIEncodable};
use cfx_types::{Address, U256};
use lazy_static;
use rustc_hex::{FromHex, ToHex};
use std... | true |
8bfc1bab3875e88a3c54e6dfeafb369da2dffff1 | Rust | nylonblonde/wolf-gang | /wolf_gang/src/systems/character_animator.rs | UTF-8 | 2,547 | 2.515625 | 3 | [] | no_license | use legion::*;
use gdnative::prelude::*;
use gdnative::api::{
AnimationTree,
AnimationNodeStateMachinePlayback
};
use crate::{
node::NodeRef
};
pub struct AnimationControlCreator {}
pub struct AnimationControl {
animation_trees: Vec<Ref<AnimationTree>>
}
///passes the name of the state which will b... | true |
a575beeec1b79cc0865975b63dbd680b77b061d6 | Rust | JoachimBorup/kitty | /src/commands/get.rs | UTF-8 | 5,878 | 2.53125 | 3 | [
"MIT"
] | permissive | use crate::config::Config;
use crate::lang::Language;
use crate::problem::Problem;
use crate::StdErr;
use crate::CFG as cfg;
use clap::ArgMatches;
use colored::Colorize;
use std::env;
use std::fs;
use std::io::{self, Read, Write};
use std::path::Path;
use zip::ZipArchive;
pub async fn get(cmd: &ArgMatches<'_>) -> Resu... | true |
24610d8db5ed753c5663414e317a87a28a7a935b | Rust | wapm-packages/coreutils | /tests/test_unexpand.rs | UTF-8 | 3,048 | 3.109375 | 3 | [
"MIT"
] | permissive | use common::util::*;
#[test]
fn unexpand_init_0() {
new_ucmd!()
.args(&["-t4"]).pipe_in(" 1\n 2\n 3\n 4\n")
.run().stdout_is(" 1\n 2\n 3\n\t4\n");
}
#[test]
fn unexpand_init_1() {
new_ucmd!()
.args(&["-t4"]).pipe_in(" 5\n 6\n 7\n 8\n")
.run().std... | true |
b63828b760dfdc4ce612bacf2d92cec67214a212 | Rust | rawfalafel/rsa | /src/rsa_accumulator.rs | UTF-8 | 2,465 | 2.9375 | 3 | [] | no_license | extern crate rand;
extern crate num_bigint_dig;
extern crate sha2;
use crate::group_element::GroupElement;
use num_bigint_dig::{BigUint};
use num_bigint_dig::prime::probably_prime;
use sha2::{Sha256, Digest};
pub fn hash_transcript_to_prime(base: &GroupElement, exp: &BigUint, result: &GroupElement) -> BigUint {
l... | true |
fe7e96b0e3703fa4c4c6136c9f23b2e27c84e6d5 | Rust | theotherphil/kaleidoscope | /src/lexer.rs | UTF-8 | 1,764 | 3.28125 | 3 | [] | no_license |
use regex::Regex;
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
Def,
Extern,
Delimiter, // ';'
OpeningParenthesis,
ClosingParenthesis,
Comma,
Ident(String),
Number(f64),
Operator(String)
}
pub use self::Token::{
Def,
Extern,
Delimiter,
OpeningParenthesis,
... | true |
311ac829eba6c70ccb4ef1d5943e801a2aa19ff2 | Rust | 3for/signatures | /elliptic-curve-crate/src/weierstrass/curve.rs | UTF-8 | 770 | 2.796875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Registry of elliptic curves in short Weierstrass form
// Weierstrass curves
pub mod nistp256;
pub mod nistp384;
pub mod secp256k1;
pub use self::{nistp256::NistP256, nistp384::NistP384, secp256k1::Secp256k1};
use core::{fmt::Debug, ops::Add};
use generic_array::{
typenum::{Unsigned, U1},
ArrayLength, Gen... | true |
40dee2e833408ce7e78134f3050ce78629032b51 | Rust | rustwasm/walrus | /src/module/memories.rs | UTF-8 | 4,741 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Memories used in a wasm module.
use crate::emit::{Emit, EmitContext};
use crate::map::IdHashSet;
use crate::parse::IndicesToIds;
use crate::tombstone_arena::{Id, Tombstone, TombstoneArena};
use crate::{Data, ImportId, Module, Result};
use anyhow::bail;
/// The id of a memory.
pub type MemoryId = Id<Memory>;
/// ... | true |
a3eef6dbe0f73f3810cd35005ead9aeb1665a4c9 | Rust | GiantBlargg/python-patcher | /install_loader/src/installer_webview.rs | UTF-8 | 4,290 | 2.8125 | 3 | [] | no_license | use std::{fs, thread, sync::mpsc::{Sender, self}, path::{Path, PathBuf}};
use serde::{Deserialize, Serialize};
use anyhow::Result;
use wry::{application::{window::Window, dpi::{PhysicalSize, PhysicalPosition}, platform::windows::EventLoopExtWindows, event_loop::EventLoopProxy}, webview::WebContext};
use crate::{confi... | true |
ab6b3657fcc8ed112a3924891cb2463d5f79910b | Rust | habitat-sh/habitat | /components/core/src/os/net/windows.rs | UTF-8 | 554 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use std::io;
use winapi::um::winbase;
const MAX_LEN: usize = 15;
pub fn hostname() -> io::Result<String> {
let mut buf = [0; MAX_LEN + 1];
let mut len = buf.len() as u32;
unsafe {
if winbase::GetComputerNameA(buf.as_mut_ptr(), &mut len) == 0 {
return Err(io::Error::last_os_error());
... | true |
aedf3742d5e1ad9cebad4ff327c2716ad5a518fd | Rust | hedgar2017/dhcp | /server/src/storage.rs | UTF-8 | 3,596 | 3 | 3 | [] | no_license | //! The trait user must implement to provide a persistent lease storage for the DHCP server.
use std::net::Ipv4Addr;
use lease::Lease;
/// Errors generated by the `Storage` trait methods.
#[derive(Fail, Debug)]
pub enum Error {
#[fail(display = "Client getting error: {}", _0)]
GetClient(String),
#[fail(d... | true |
8674081cea4391650b99bd6be8f34b2c237da105 | Rust | brett-patterson/rice-servery | /src/monitor/config.rs | UTF-8 | 794 | 2.953125 | 3 | [] | no_license | /// The top-level configuration structure.
#[derive(Deserialize, Debug)]
pub struct Config {
pub rules: Vec<Rule>,
pub outgoing_email: Option<OutgoingEmail>,
}
/// A rule that describes what menu items to match, who to alert when found,
/// and how to alert them.
#[derive(Deserialize, PartialEq, Eq, Hash, Clon... | true |
0db0da3f0f9a1c339ee4de6e1a9c8a0381ecd7d9 | Rust | sindreij/advent-of-code-2020 | /template/src/main.rs | UTF-8 | 499 | 2.703125 | 3 | [] | no_license | use std::{
collections::{HashMap, HashSet, VecDeque},
fs::read_to_string,
};
use anyhow::{anyhow, bail, Result};
use maplit::{hashmap, hashset};
use utils::Vector;
fn main() -> Result<()> {
println!("part1: {}", part1(&read_input()?)?);
println!("part2: {}", part2(&read_input()?)?);
Ok(())
}
fn... | true |
1a95fad6e9973c416fea5fa5a33e2bcca667c267 | Rust | emabee/rust-hdbconnect | /hdbconnect_impl/src/protocol/parts/lob_flags.rs | UTF-8 | 1,300 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::protocol::parts::option_part::{OptionId, OptionPart};
use crate::protocol::parts::option_value::OptionValue;
// The part is sent from the client to signal whether the implicit LOB
// streaming is started so that the server does not commit the current
// transaction even with auto-commit on while LOB streami... | true |
99002e1af920cc89b9c0a383d97363bf4f9f7a6b | Rust | zinh/learn_rust | /w002/functions/borrow.rs | UTF-8 | 175 | 3.046875 | 3 | [] | no_license | fn foo(v1: &Vec<i32>) -> i32{
let v2 = v1;
println!("{}", v2[1]);
42
}
fn main(){
let mut v1 = vec![10,11];
foo(&v1);
println!("v[0] = {}", v1[0]);
}
| true |
61fd998f744f97b45cf421cefde5f1c4c8b0de21 | Rust | ar90n/lab | /sandbox/rust_wasm_game_dev/src/game.rs | UTF-8 | 11,526 | 2.796875 | 3 | [] | no_license | #[macro_use]
use crate::browser;
use crate::engine;
use crate::engine::{Game, KeyState, Point, Rect, Renderer};
use anyhow::Result;
use async_trait::async_trait;
use std::collections::HashMap;
use web_sys::HtmlImageElement;
use anyhow::anyhow;
use serde::Deserialize;
use self::red_hat_boyd_states::*;
#[derive(Deser... | true |
943d42c22986994e65d79dca33c6406e8159134a | Rust | iho/qdrant | /lib/segment/src/index/hnsw_index/config.rs | UTF-8 | 1,191 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::common::file_operations::{atomic_save_json, read_json};
use crate::entry::entry_point::OperationResult;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
pub const HNSW_INDEX_CONFIG_FILE: &str = "hnsw_config.json";
#[derive(Debug, Deserialize, Serialize, Copy, Clone, PartialEq)]
pub stru... | true |
0b5f76130b008d0b134d16dccd8f129f81c31905 | Rust | Myrannas/binary-tuples | /src/lib.rs | UTF-8 | 6,454 | 3.34375 | 3 | [
"MIT"
] | permissive | extern crate byteorder;
extern crate uuid;
pub mod segment;
mod constants;
mod utils;
mod errors;
use uuid::Uuid;
use segment::Segment;
use errors::TupleError;
#[derive(Clone)]
/// A builder for serialized tuples
pub struct Tuple {
buffer: Vec<u8>
}
impl Tuple {
/// Create a new tuple
pub fn new() -> Tu... | true |
2eb30323214c42f72d2da410e247a5c4afdcb49b | Rust | sugyan/atcoder | /diverta2019-2/src/bin/b.rs | UTF-8 | 517 | 2.53125 | 3 | [] | no_license | use proconio::{fastout, input};
use std::collections::HashMap;
#[fastout]
fn main() {
input! {
n: usize,
xy: [(i32, i32); n],
}
let mut hm = HashMap::new();
for i in 0..n {
for j in 0..n {
if i != j {
*hm.entry((xy[i].0 - xy[j].0, xy[i].1 - xy[j].1))
... | true |
f5a0b2ba70834d1236578bd8505ba40eefba94c4 | Rust | abdullahwaqar/leetcode | /169.Majority_Element/src/main.rs | UTF-8 | 449 | 3.1875 | 3 | [] | no_license | use std::collections::HashMap;
struct Solution {}
impl Solution {
pub fn majority_element(nums: Vec<i32>) -> i32 {
let mut num_entries = HashMap::new();
for num in &nums {
let count = num_entries.entry(num).or_insert(0);
*count += 1;
if *count > nums.len() / 2... | true |
5b3ec29dad6f9542827d55714d7dca8bf777ad3e | Rust | nushell/nushell | /crates/nu-command/src/platform/ansi/strip.rs | UTF-8 | 3,030 | 2.828125 | 3 | [
"MIT"
] | permissive | use nu_cmd_base::input_handler::{operate, CellPathOnlyArgs};
use nu_engine::CallExt;
use nu_protocol::{
ast::Call, ast::CellPath, engine::Command, engine::EngineState, engine::Stack, Category,
Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value,
};
#[derive(Clone)]
pub struct SubComman... | true |
270f55897d52c15935a25cdd42fd05b3820e770e | Rust | jduan/cosmos | /rust_sandbox/error_handling/src/bin/io-basic-error-string.rs | UTF-8 | 788 | 3.53125 | 4 | [
"MIT"
] | permissive | /// This program map all errors into their string representation.
use std::env;
use std::fs;
use std::path::Path;
/// The "io::Error" type in particular is pervasive throughout the standard library!
/// Read content of a file, parse it as a number, and double it.
fn file_double<P: AsRef<Path>>(file_path: P) -> Result... | true |
929396daaba0158851766940c992f96882990e6b | Rust | bittrance/vector | /src/sinks/util/retries.rs | UTF-8 | 3,074 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use super::Error;
use futures::{try_ready, Async, Future, Poll};
use std::time::{Duration, Instant};
use tokio::timer::Delay;
use tower::retry::Policy;
pub trait RetryLogic: Clone {
type Error: std::error::Error + Send + Sync + 'static;
type Response;
fn is_retriable_error(&self, error: &Self::Error) -> b... | true |
90e26784577b92e18d4b6fcf8a18d3f73c337b84 | Rust | sugyan/leetcode | /others/august-leetcoding-challenge/week-1/3415/lib.rs | UTF-8 | 1,994 | 3.421875 | 3 | [] | no_license | use std::cell::RefCell;
use std::cmp::Reverse;
use std::collections::{BTreeMap, BinaryHeap};
use std::rc::Rc;
use utils::TreeNode;
pub struct Solution {}
impl Solution {
pub fn vertical_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Vec<i32>> {
let mut btm: BTreeMap<i32, BinaryHeap<Reverse<(i32, i3... | true |
967a7d0642794d2c96c6b3fed74f2e427c93d13b | Rust | bobfang1992/rsqlite | /src/util.rs | UTF-8 | 344 | 2.546875 | 3 | [] | no_license | pub fn as_u16_be(array: &[u8; 2]) -> u16 {
((array[0] as u16) << 8) + (array[1] as u16)
}
pub fn as_u32_be(array: &[u8; 4]) -> u32 {
((array[0] as u32) << 24)
+ ((array[1] as u32) << 16)
+ ((array[2] as u32) << 8)
+ (array[3] as u32)
}
pub fn as_f64_be(array: [u8; 8]) -> f64 {
f64:... | true |
2bfd380733a66d4237f39b837d16b338b7a55935 | Rust | askanium/rustplotlib | /src/components/area.rs | UTF-8 | 1,474 | 3.03125 | 3 | [
"MIT"
] | permissive | use std::fmt::Display;
use svg::node::element::{Group, Path};
use svg::node::element::path::Data;
use svg::node::Node;
use crate::components::DatumRepresentation;
use crate::components::scatter::ScatterPoint;
/// Represents a point in a scatter plot.
#[derive(Debug)]
pub struct AreaSeries<T: Display + Clone, U: Displa... | true |
178bc556fc69c75f7fae5842901a88e52cfe95be | Rust | aiifabbf/leetcode-memo | /307.rust/src/main.rs | UTF-8 | 1,823 | 3.53125 | 4 | [] | no_license | /*
区间求和,原数组可变。
还是用了前缀和/积分。听说标准做法是线段树……我还没学,学会了再来改。
*/
struct NumArray {
integrals: Option<Vec<i32>>,
}
/**
* `&self` means the method takes an immutable reference.
* If you need a mutable reference, change it to `&mut self` instead.
*/
impl NumArray {
fn new(nums: Vec<i32>) -> Self {
if nums.is_em... | true |
123156a8c3b3aebeb55ddbfb3d4b8e097cf100a3 | Rust | dbartussek/kernel | /crates/kernel/pit/src/lib.rs | UTF-8 | 2,897 | 3.21875 | 3 | [] | no_license | //! X86 pic8259 pit configuration
//!
//! Based on https://en.wikibooks.org/wiki/X86_Assembly/Programmable_Interval_Timer
//! and https://wiki.osdev.org/Programmable_Interval_Timer
#![no_std]
use core::time::Duration;
use x86_64::instructions::port::*;
/// Programmable interrupt timer
///
///
pub struct Pit {
ch... | true |
f99164e130ea8547b6de3128c22080eafb5f0772 | Rust | zesterer/zte | /src/main.rs | UTF-8 | 2,096 | 2.59375 | 3 | [] | no_license | mod config;
mod display;
mod input;
mod event;
mod draw;
mod ui;
mod buffer;
mod state;
use std::{panic, env};
use backtrace::Backtrace;
use clap::{App, Arg};
use crate::{
config::Config,
display::{Display, Color},
event::{Dir, Event},
draw::Canvas,
ui::{MainUi, Theme},
buffer::{BufferId, Buffe... | true |
f6fae9e913dd3e16a5a91bd55990950669779dbd | Rust | karenhong/prusti-extern-spec-demo | /linear_search_iter.rs | UTF-8 | 939 | 3.140625 | 3 | [] | no_license | /// This version of linear search uses the following unsupported features
/// 1) The slice type is currently not supported with the external specs feature
/// therefore indexing into the array is not supported in specifications
/// 2) Loop invariants are temporarily broken due to the compiler upgrades
... | true |
4cf01b2b0aa34468e862353e5e08e1b90ff4c6d6 | Rust | guaifish/ezrs | /tests/rand.rs | UTF-8 | 770 | 3.125 | 3 | [] | no_license | use ezrs::rand::seq::SliceRandom;
use ezrs::rand::thread_rng;
use ezrs::*;
#[test]
fn test_rand_random() {
let _: bool = random();
let _: i32 = random();
let _: f64 = random();
let _: (char, u8) = random();
let _: [i32; 3] = random();
}
#[test]
fn test_rand_shuffle() {
let mut rng = thread_rng... | true |
887fe5f115406ff70c343b3c27c525fc5405d061 | Rust | ClementNerma/Comic-Encoder | /src/logger.rs | UTF-8 | 1,491 | 2.578125 | 3 | [] | no_license | use fern::colors::{Color, ColoredLevelConfig};
use log::{Level, LevelFilter};
use std::time::Instant;
/// Start the logger, hiding every message whose level is under the provided one
pub fn start(level: LevelFilter) {
// Create color scheme
let colors_line = ColoredLevelConfig::new()
.error(Col... | true |
334beb3f784528dfe9ae888e70c26e7974c53b85 | Rust | zaksky7/Rust-project | /src/year2020/day09.rs | UTF-8 | 1,026 | 3.171875 | 3 | [] | no_license | use itertools::Itertools;
use std::cmp::Ordering::*;
fn parse_nums(s: &str) -> Vec<i64> {
s.lines().map(|x| x.parse().unwrap()).collect()
}
fn find_first_invalid(ns: &[i64]) -> i64 {
let mut n = 25;
loop {
if !ns[n - 25..n]
.iter()
.combinations(2)
.any(|combo| ... | true |
c603b12df2fc73901d8510470cd326f9cdd1f0f8 | Rust | Sinono3/simple-roguelike | /src/creature/aggressive.rs | UTF-8 | 2,320 | 2.578125 | 3 | [
"MIT"
] | permissive | use specs::prelude::*;
use crossterm::style::{Color, style};
use crate::creature::{Playable, Combatant};
use crate::shared::*;
use crate::unanimate::Wieldable;
#[derive(Component, Debug, Default, Clone, Deserialize, Serialize)]
#[storage(NullStorage)]
pub struct AggressiveBehaviour;
pub struct AggressionSystem;
imp... | true |
3dea526a0b1398b75cbefba35fef7512021c3aa5 | Rust | suspend0/aws-sdk-rust | /sdk/iotevents/src/client.rs | UTF-8 | 121,490 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[derive(Debug)]
pub(crate) struct Handle<
C = aws_smithy_client::erase::DynConnector,
M = aws_hyper::AwsMiddleware,
R = aws_smithy_client::retry::Standard,
> {
client: aws_smithy_client::Client<C, M, R>,
conf: crate::C... | true |
ea863a48ab95775d909e9ad8a2c2f4756265c545 | Rust | lilith645/Maat-Sound | /src/lib.rs | UTF-8 | 2,486 | 3 | 3 | [
"MIT"
] | permissive | extern crate ears;
use std::collections::HashMap;
use ears::{Sound, AudioController};
use ears::State::{Stopped};
pub struct DukeBox {
music: HashMap<String, Sound>,
}
impl DukeBox {
pub fn new() -> DukeBox {
DukeBox {
music: HashMap::new(),
}
}
pub fn load(&mut self, name: String, locatio... | true |
4fabc241dccb92629a8ddd1d841004add8682ad4 | Rust | ipetr0v/exercism | /rust/poker/src/lib.rs | UTF-8 | 4,241 | 3.4375 | 3 | [] | no_license | use std::cmp::{max, min, Ordering, Reverse};
use std::collections::{HashMap, HashSet};
struct Card {
rank: u8,
suit: char
}
impl From<&str> for Card {
fn from(card: &str) -> Self {
let (rank, suit) = card.split_at(card.len() - 1);
Self {
rank: match rank {
"J" =... | true |
cbe11e4ad8463705f48b33f6fb25f68393d43623 | Rust | quantumscraps/scraps | /src/arch/riscv64/drivers/clint.rs | UTF-8 | 1,470 | 3.21875 | 3 | [] | no_license | /// Core-Local Interrupt Controller (CLINT)
pub struct CLINT {
base_address: usize,
}
impl CLINT {
/// # Safety
/// Only safe if the base address is valid.
pub const unsafe fn new(base_address: usize) -> Self {
Self {
base_address: base_address,
}
}
pub const fn uni... | true |
3f65a742d2ea7f47a00f4ce9b10c08fef44693bc | Rust | coolofficials/rv6 | /kernel-rs/src/arena.rs | UTF-8 | 12,652 | 3.015625 | 3 | [
"MIT"
] | permissive | use core::convert::TryFrom;
use core::mem::{self, ManuallyDrop};
use core::ops::Deref;
use core::pin::Pin;
use pin_project::pin_project;
use crate::list::*;
use crate::lock::{Spinlock, SpinlockGuard};
use crate::pinned_array::IterPinMut;
use crate::rc_cell::{RcCell, Ref, RefMut};
/// A homogeneous memory allocator, ... | true |
f8b3d97f9e8e6044ea7fc462d5d7602f940d002e | Rust | mtrp12/fp-core.rs | /fp-examples/src/arity_example.rs | UTF-8 | 116 | 2.8125 | 3 | [
"MIT"
] | permissive | #[test]
fn arity() {
let sum = |a: i32, b: i32| a + b;
let result = sum(1, 2);
assert_eq!(result, 3);
}
| true |
01faef617635b8cabcc18200ee7ad684e711ae6b | Rust | rusenask/wasm-playground | /rust/modify_raw_query.rs | UTF-8 | 600 | 2.5625 | 3 | [] | no_license | // Define a function that is imported into the module.
// By default, the "env" namespace is used.
extern "C" {
// ext_set_request_raw_query function allows updating request query,
// for example request "https://example.com/api/foo?foo=bar" raw query is foo=bar
// so we can here update it to something=els... | true |
232cd74d5060e74ec5fb3bcf47ea1dc2343bc952 | Rust | jayong93/alt_invalid_win_chars | /src/main.rs | UTF-8 | 1,331 | 2.78125 | 3 | [] | no_license | use std::{
env::args,
fs::{metadata, read_dir, rename},
path::PathBuf,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
for ref path in args().skip(1) {
let meta = metadata(path)?;
if meta.is_dir() {
for entry in read_dir(path)? {
let entry = entry?;
... | true |
f10e24abcc10ccaddb142987d94430ad5f26aef6 | Rust | Tubbz-alt/lamellar-runtime | /examples/return.rs | UTF-8 | 1,174 | 2.703125 | 3 | [
"BSD-3-Clause"
] | permissive | use lamellar::{ActiveMessaging,LamellarAM};
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
struct DataAM {
pe: usize,
}
#[lamellar::am]
impl LamellarAM for DataAM {
fn exec() -> (usize,usize) {
(self.pe,lamellar::current_pe as usize)
}
}
fn main() {
let world = lamellar::Lamell... | true |
cd66e3656f75663dbce8ea9a7bba2c16eeea733d | Rust | vizee/leetcode | /solved/n-queens-ii.rs | UTF-8 | 1,467 | 2.53125 | 3 | [
"MIT"
] | permissive | impl Solution {
// https://leetcode.com/problems/n-queens-ii/
pub fn total_n_queens(n: i32) -> i32 {
let n = n as usize;
let mut cols = Vec::new();
cols.resize(n, false);
let mut d = Vec::new();
d.resize((n + n) as usize, false);
let mut bd = Vec::new();
b... | true |
37873db940da0a84acf83b0a75a04e654e7f935f | Rust | reitermarkus/esp32-hello | /esp-idf-hal/src/wifi/ssid.rs | UTF-8 | 2,215 | 3.125 | 3 | [] | no_license | use core::cmp::Ordering;
use core::fmt;
use core::ops::Deref;
use core::ptr;
use std::str::{self, FromStr};
use super::WifiConfigError;
const SSID_MAX_LEN: usize = 32;
/// A WiFi SSID.
#[derive(Copy, Clone)]
#[repr(transparent)]
pub struct Ssid(pub(crate) [u8; SSID_MAX_LEN]);
impl Deref for Ssid {
type Target = s... | true |
f8aac2b2cec1ee6e8d327e0f75ab730074d5a3cd | Rust | igaozp/LearnRust | /base_content/src/lifetimes.rs | UTF-8 | 1,086 | 3.421875 | 3 | [] | no_license | struct Foo<'a> {
x: &'a i32;
}
fn main() {
let x;
{
let y = &5;
let f = Foo { x: y };
x = &f.x
}
println!("{}", x);
}
// 多个生命周期
fn x_or_y<'a>(x: &'a str, y: &'a str) -> &'a str {
x
}
fn x_or_y<'a, 'b>(x: &'a str, y: &'b str) -> &'a str {
x
}
// 全局字符串
let x: &'st... | true |
99e7f2feb467b5a33bcb97b521a29bf785767229 | Rust | inda21plusplus/dtottie-hw4-raytracer | /src/main.rs | UTF-8 | 3,562 | 2.84375 | 3 | [] | no_license | //use crate::objects::{Color, Hit, Ray, Shape};
use crate::coordinate::Coordinate;
use crate::objects::*;
use crate::scene::Scene;
use image::DynamicImage;
use macaw::Vec3;
use std::fs;
use std::io::{BufWriter, Write};
mod coordinate;
mod objects;
mod scene;
fn main() {
let scene = Scene::new();
pixelator(&sc... | true |
225c547ba67e4eeee45e60c7155396ecf6f1f81c | Rust | LFalch/stalch | /src/lib.rs | UTF-8 | 10,898 | 2.703125 | 3 | [
"MIT"
] | permissive | #![warn(clippy::all)]
use std::{
fs::File,
io::{BufRead, BufReader, Read, Write},
};
mod chars;
mod cmd;
mod err;
mod state;
mod value;
mod tokeniser;
use crate::chars::*;
use crate::cmd::Command;
use crate::cmd::Command::*;
use crate::value::Value;
use crate::value::Value::*;
use crate::tokeniser::Tokeniser... | true |
bd7ee66e1bfc22a28242dc3b99fa5f822035eca1 | Rust | jackmott/mathblaster | /src/level.rs | UTF-8 | 11,956 | 3.109375 | 3 | [
"MIT"
] | permissive | use crate::assets::*;
use crate::message::*;
use ggez::Context;
use serde::{Deserialize, Serialize};
use std::collections::VecDeque;
use std::fs::File;
use std::io::{Read, Write};
use std::str;
#[derive(Deserialize, Serialize, Debug, Copy, Clone, PartialEq)]
pub enum Operation {
Add,
Subtract,
Multiply,
... | true |
a56caa9c8609d5c3cb0a7169355b6877de6f6ce3 | Rust | akegalj/algorithms_playground | /advent-of-code/2021/day8/part1.rs | UTF-8 | 834 | 2.9375 | 3 | [] | no_license | use std::cmp::{max, min};
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let reader = BufReader::new(File::open("input").unwrap());
let coords = reader.lines().map(|l| {
let s = l.unwrap();
let (left, right) = s.trim().split_once("|").unwrap();
... | true |
00a4673ed022a0695d9cdec96512eaa29ae66d92 | Rust | tribal-protocol/substrate-wasm-client | /src/common/types/consensus_error.rs | UTF-8 | 1,807 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use core::fmt;
use std::error;
use std::error::Error;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub enum ConsensusError {
/// Missing state at block with given descriptor.
StateUnavailable(String),
/// I/O terminated unexpectedly
IoTerminated,
/// Intermediate missing.
NoIntermediate... | true |
094a92372462c3c564ee462a70bb016cfc68c72f | Rust | Tamiyo/Pineapple | /src/pineapple_passes/src/lib.rs | UTF-8 | 4,468 | 2.59375 | 3 | [] | no_license | use pineapple_codegen_bytecode::module::Module;
use pineapple_codegen_ssa::analysis::cfg::CFG;
use std::cell::RefCell;
use std::path::PathBuf;
use std::time::Instant;
use pineapple_ast::ast::Stmt;
use pineapple_ir::hir::token::Token;
use structopt::StructOpt;
#[macro_export]
macro_rules! benchmark {
($name: expr,... | true |
f3311c028c12ad2e905345bbd0b69d21d07d4f43 | Rust | justinlatimer/sassaurs | /src/spec/adapter.rs | UTF-8 | 2,709 | 3.09375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate sassaurs;
use std::path;
pub trait Adapter : Sync {
fn description(&self) -> &str;
fn version(&self) -> String;
fn compile(&self, input_path: &path::PathBuf) -> Result<String, String>;
}
pub struct ExecutableAdapter {
command: String
}
impl<'c> ExecutableAdapter {
pub fn new(command... | true |
387c5989a5a5075c940c3d3f46ef6949c63d9544 | Rust | jasonhansel/relibc | /src/header/stdlib/lcg48.rs | UTF-8 | 1,734 | 3.203125 | 3 | [
"MIT"
] | permissive | //! Helper functions for pseudorandom number generation using LCG, see http://pubs.opengroup.org/onlinepubs/7908799/xsh/drand48.html
use platform::types::*;
/* The current element of the linear congruential generator's sequence. Any
* function that sets this variable must ensure that only the lower 48 bits get
* se... | true |
bbf567956dc799f8f9fe0f0811577ba273df30dc | Rust | MaderNoob/mather | /src/interpreter/lexer/mod.rs | UTF-8 | 983 | 3.09375 | 3 | [] | no_license | mod chars_iter;
mod numbers;
mod operators;
mod parentheses;
mod util;
mod variables;
use super::errors::LexResult;
use bigdecimal::BigDecimal;
use chars_iter::CharsIterator;
use numbers::NumberTokenLexer;
use operators::{Operator, OperatorTokenLexer};
use parentheses::ParenthesesTokenLexer;
use std::collections::Hash... | true |
deb7c98ac63419d37428d050ed73d3918361918b | Rust | gspu/zc | /src/dialogs.rs | UTF-8 | 13,748 | 2.703125 | 3 | [
"BSD-2-Clause",
"BSD-4-Clause"
] | permissive |
use ncurses::*;
use crate::contents::{ Content, ContentType };
const MIN_HEIGHT: i32 = 7;
const DEFAULT_WIDTH: i32 = 80;
const BAR: &str = "-------------------------------------";
const SPACE: &str = " ";
const KEY_TAB: i32 = 0x009;
const KEY_ENTER: i... | true |
f1bdbad0ec14677d58415b94b32172cc72329d2a | Rust | sujayakar/baobab-rs | /src/header.rs | UTF-8 | 4,232 | 2.875 | 3 | [
"MIT"
] | permissive | use std::alloc::Layout;
use std::cmp;
use std::fmt;
use std::mem;
use std::marker::PhantomData;
use std::ops::Range;
use crate::packable::Header;
use crate::packed_node::PackedNode;
pub const MAX_PREFIX_LEN: usize = 64 - 1;
#[derive(Debug, Eq, PartialEq)]
pub enum NodeChildrenType {
Empty,
Pairs,
Sparse,... | true |
31b8e1a76a74041620fbc1863b48d72c9e3fd3bf | Rust | gmackie/webapp | /src/main.rs | UTF-8 | 1,099 | 2.515625 | 3 | [] | no_license | extern crate http;
extern crate serialize;
extern crate nickel;
use http::status::NotFound;
use std::io::net::ip::Ipv4Addr;
use nickel::{
Nickel, NickelError, ErrorWithStatusCode,
Action, Continue, Halt, Request,
Response, IntoErrorHandler, HttpRouter,
};
fn main() {
let mut server = Nickel::new(... | true |
aab1db5687dd199c28a64abc59722f81ea793c37 | Rust | boarder2/synacor-challenge | /src/ops/add.rs | UTF-8 | 1,395 | 2.96875 | 3 | [] | no_license | use ops::operation::Operation;
use vm::state;
pub struct Add;
impl Operation for Add {
fn run(&self, vm_state: &mut state::VMState) {
let ci = vm_state.get_current_instruction();
let val1 = vm_state.get_mem_or_register_value(ci + 2);
let val2 = vm_state.get_mem_or_register_value(ci + 3);
let reg = vm_state.ge... | true |
6ba7c18c86a96373fd499d6e09223b3ef24371d3 | Rust | smoke-installer/smoke-installer | /src/installed.rs | UTF-8 | 1,131 | 2.890625 | 3 | [] | no_license | use orbtk::{Button, Click, Place, Point, Rect, Text, Window};
use std::fs::{File, read_to_string};
use std::io::Read;
use std::process::exit;
fn check_x(x_value: i32) -> bool {
if x_value > 1100 {
return true;
} else {
return false;
}
}
pub fn installed_init() {
let mut window = Window... | true |
29cdde7415f5db1daac64bfe276e154c665c4e4a | Rust | AndrewGi/caltex | /src/math/tests/num_tests.rs | UTF-8 | 260 | 2.90625 | 3 | [] | no_license |
mod basic_number {
use crate::math::basic_number::BasicNumber;
#[test]
fn construction() {
let f1: BasicNumber = 1f64.into();
assert_eq!(f1, BasicNumber::Float(1f64));
let i1: BasicNumber = 1i64.into();
assert_eq!(i1, BasicNumber::Int(1i64));
}
} | true |
bafd94e18074e9a0b15147c0ed9d7c5ce6a33b5d | Rust | jhnstrk/fitreader-rs | /src/fitfield.rs | UTF-8 | 6,989 | 2.625 | 3 | [
"MIT"
] | permissive | use std::io::{Read, Write};
use crate::fittypes::{FitDataType, FitFieldData, FitFileContext};
use crate::fitread::{fit_read_i8, fit_read_u8, fit_read_u16, fit_read_i16, fit_read_i32,
fit_read_u32, fit_read_string, fit_read_f32, fit_read_f64,
fit_read_i64, fit_read_u64};
use cr... | true |
bec5de689cd1127afe9e28d2141b5dc5fd8be5d5 | Rust | museun/noye | /src/modules/builtin.rs | UTF-8 | 8,656 | 2.765625 | 3 | [] | no_license | use super::*;
pub(super) async fn initialize_module<R>(init: &mut ModuleInit<R>) -> anyhow::Result<()>
where
R: Responder + Send + 'static,
{
init.commands.add("join", join)?;
init.commands.add("part", part)?;
init.commands.add("uptime", uptime)?;
init.commands.add("restart", restart)?;
init.co... | true |
904f0e10b5c88dbc65b10cc08b171f9d86b3bb5f | Rust | KristonCosta/five-am | /src/server/map_builders/basic_builders.rs | UTF-8 | 4,316 | 2.59375 | 3 | [] | no_license | use crate::geom::Rect;
use crate::map::{Map, TileType};
use crate::server::map_builders::{BaseMapBuilder, BuiltMap};
use rand::prelude::ThreadRng;
use rand::Rng;
use std::cmp::{max, min};
pub struct RoomMapBuilder;
impl BaseMapBuilder for RoomMapBuilder {
fn build(&mut self, _: &mut ThreadRng, build_data: &mut Bu... | true |
87e5c09523314bc0f3752e926e5879857be41c59 | Rust | Liu-WeiHu/learn-rust | /rand/learn-rand/src/main.rs | UTF-8 | 1,323 | 3.8125 | 4 | [] | no_license | use rand::prelude::*;
fn main() {
//可以直接使用random()。它可以产生许多常见类型的值:
let x = random::<u8>();
println!("{}",x);
//生成一个布尔值
if random() {
println!("heads!")
}
//如果我们想要更明确(和更有效),我们可以
//创建线程本地生成器的句柄:
let mut rng = thread_rng();
if rng.gen() {
let x = rng.gen::<u8>();
... | true |
650ff1472051d112fb418d750826f97161db0077 | Rust | thomaseizinger/usbw | /src/libusb/interface_descriptor.rs | UTF-8 | 3,068 | 2.59375 | 3 | [] | no_license | use crate::libusb::endpoint_descriptor::EndpointDescriptors;
#[derive(Copy, Clone)]
pub struct Interfaces<'a>(pub &'a [libusb1_sys::libusb_interface]);
impl<'a> Interfaces<'a> {
pub fn from_slice(slice: &'a [libusb1_sys::libusb_interface]) -> Interfaces<'a> {
Interfaces(slice)
}
/// # Safety
//... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.