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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8c94fd9a88f4069d0e428aa68831fb84d80bcf1b | Rust | anagav/advent_code_rust | /src/bin/day1.rs | UTF-8 | 786 | 2.96875 | 3 | [] | no_license | #[allow(non_snake_case)]
#[allow(dead_code)]
use std::io;
use std::io::prelude::*;
pub fn run() {
//let mut map = HashMap::new();
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let (count,basement) = input.trim().chars().map(
|x| match x{
'(' => 1,
... | true |
75336afd593a2c89904591556069356da1bb9b35 | Rust | wvanbreukelen/rust-research | /src/hal/pin.rs | UTF-8 | 1,992 | 2.5625 | 3 | [] | no_license | pub use cortex_m::peripheral::syst;
//pub use sam3x8e as target;
// #[macro_use]
// // Source: https://github.com/stm32-rs/stm32f4xx-hal/blob/9dab1701bc68efe3a1df8eb3b93c866d7ef1fa0e/src/lib.rs
// #[cfg(not(feature = "device-selected"))]
// compile_error!("This crate requires one of the following device features enabl... | true |
e34ed5dffca59b990151aba4b3acbce2904b7b7f | Rust | samscott89/ReCrypt | /src/profile.rs | UTF-8 | 7,089 | 2.59375 | 3 | [
"MIT"
] | permissive | //! Methods to profile schemes
extern crate rand;
extern crate time;
use super::*;
use generic::*;
use io::*;
use std::fs::{metadata,remove_dir_all,create_dir,File};
use std::io::{Write,BufWriter};
use std::path::{Path,PathBuf};
use std::env;
// type ProfileCipher = Kss<RingAes, RingAes>;
type ProfileCipher = ReCry... | true |
721a821355cac2b57a86188534b50b713f8b9cc6 | Rust | no111u3/ist7920 | /src/mode/buffered_graphics.rs | UTF-8 | 2,423 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use crate::Ist7920;
use display_interface::{DisplayError, WriteOnlyDataCommand};
#[derive(Debug, Clone)]
pub struct BufferedGraphicsMode {
buffer: [u8; 128 * 128 / 8],
}
impl BufferedGraphicsMode {
/// Create a new buffered graphics mode instance
pub(crate) fn new() -> Self {
Self {
bu... | true |
243afd7cc5df51dbad462b888ede42b23e0f7adf | Rust | joaonmatos/exercism | /rust/rna-transcription/src/lib.rs | UTF-8 | 1,824 | 2.828125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2020 João Nuno Matos
//
// 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... | true |
931a245a52cb42f8481b72ced2a19d452446d031 | Rust | scritchley/stm32-dsp | /src/dsp/mod.rs | UTF-8 | 9,520 | 2.875 | 3 | [] | no_license | use micromath::F32Ext;
use no_std_compat::slice::IterMut;
pub trait IntoF32 {
fn into_f32(self) -> f32;
}
impl IntoF32 for u16 {
fn into_f32(self) -> f32 {
self as i16 as f32
}
}
pub trait FromF32 {
fn from_f32(value: f32) -> Self;
}
impl FromF32 for u16 {
fn from_f32(value: f32) -> Self... | true |
0ea33524b69a7aa96417e39a17bda2559b2e434c | Rust | sampullman/rust-scheme | /src/environment.rs | UTF-8 | 5,245 | 3.0625 | 3 | [] | no_license | #![allow(unused_variables)]
use std::collections::HashMap;
use std::cell::RefCell;
use std::rc::Rc;
use std::mem;
use atom::Atom;
use interpreter::evaluate;
use builtins::*;
#[derive(Clone, PartialEq)]
pub struct SchemeLambda {
pub name: String,
pub arg_list: Vec<String>,
pub body: Vec<Atom>,
}
pub type S... | true |
ba38e8d6e2bb6cdbedb31ead10bf1da1173980aa | Rust | fospring/feature_workspace | /xtask/src/main.rs | UTF-8 | 1,077 | 2.609375 | 3 | [] | no_license | use argh::FromArgs;
use std::{
env,
process::{Command, Stdio},
};
/// fospring build tools
#[derive(FromArgs, Debug)]
struct Options {
#[argh(subcommand)]
command: Cmd
}
#[derive(FromArgs, Debug)]
#[argh(subcommand)]
/// Reach new heights.
enum Cmd {
Build(BuildCmd)
}
fn main() -> anyhow::Result<(... | true |
d7d38a9e5a0cc652bfde3743ac3c80fd2d6e0d68 | Rust | vstepchik/sprack | /sprack/src/structs/mod.rs | UTF-8 | 1,962 | 2.78125 | 3 | [
"MIT"
] | permissive | mod bin;
mod node;
mod options;
pub use self::bin::*;
pub use self::node::*;
pub use self::options::*;
use super::{SortHeuristic, ALL as DEFAULT_HEURISTICS};
use std::cmp::max;
use std::fmt::{Debug, Result, Formatter};
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct PackInput { pub dim: Dimension, pub id: u... | true |
20120aa8145393f2466fb2aeb7390f2840cf2d75 | Rust | brightly-salty/rox | /src/parser.rs | UTF-8 | 10,278 | 3.3125 | 3 | [] | no_license | use crate::ast::{Expr, Stmt};
use crate::error;
use crate::tokens::TokenType::{
Bang, BangEqual, Class, Else, Eof, Equal, EqualEqual, False, For, Fun, Greater, GreaterEqual,
Identifier, If, LeftBrace, LeftParen, Less, LessEqual, Minus, Nil, Number, Or, Plus, Print,
Return, RightBrace, RightParen, Semicolon,... | true |
4e022df829565ecac2a9211d18171e21ee155067 | Rust | devillove084/reclaim | /src/unprotected.rs | UTF-8 | 4,193 | 2.78125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::fmt;
use core::marker::PhantomData;
use typenum::Unsigned;
use crate::internal::Internal;
use crate::pointer::{Marked, MarkedNonNull, MarkedNonNullable, MarkedPointer};
use crate::{Reclaim, Shared, Unprotected};
/********** impl Clone ************************************************************************... | true |
99dbf37a70d03bea513ecc9a970735845ce6fe05 | Rust | kerskuchen/Advent-of-Code-2017-Rust | /day4_high_entropy_passphrases/src/main.rs | UTF-8 | 1,087 | 3.3125 | 3 | [
"Unlicense"
] | permissive | extern crate itertools;
use itertools::Itertools;
use std::fs::File;
use std::io::*;
fn main() {
let lines: Vec<Vec<String>> = BufReader::new(File::open("input.txt").unwrap())
.lines()
.filter_map(|line| line.ok())
.map(|line| {
line.trim()
.split_whitespace()
... | true |
d0a1e97ee74b6d2b073607df95ee8cd7f9217cc9 | Rust | uu-haunter/busplus | /server/src/config.rs | UTF-8 | 5,554 | 3.359375 | 3 | [] | no_license | //! Utility for reading values from a config file.
use std::fs;
use std::path::Path;
use yaml_rust::{Yaml, YamlLoader};
/// The file path to the config file.
pub const CONFIG_FILE_PATH: &str = "../config.yml";
/// The YAML key where all trafiklab data is stored.
/// Example:
///
/// trafiklab_api: <-- this is t... | true |
848c68aa1342464a872d917409cf3b8a1de46d8c | Rust | tirust/msp432e4 | /src/sysctl/pcuart.rs | UTF-8 | 13,559 | 2.8125 | 3 | [
"BSD-3-Clause"
] | permissive | #[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PCUART {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &... | true |
222277d89f50298110defa98ac6e1dd8729f6b95 | Rust | michaelstarmer/rust-examples | /src/impl_/src/main.rs | UTF-8 | 591 | 3.984375 | 4 | [] | no_license | /*
* Tutorial 06
*/
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn print_description(&self) {
println!("Rectangle: {} x {}", self.width, self.height);
}
fn is_square(&self) -> bool {
self.width == self.height
}
}
fn main() {
let rect1 = Rectangle { wi... | true |
ab2a724844a4e981a04bac9db4122696c0567a9f | Rust | PSeitz/stainless | /tests/expression.rs | UTF-8 | 875 | 2.890625 | 3 | [
"MIT"
] | permissive | // Copyright 2016 The Stainless Developers. See the LICENSE file at the top-level directory of
// this distrubution.
//
// Licensed under the MIT license. This file may not be copied, modified, or distributed except
// according to those terms.
#![feature(plugin)]
#![plugin(stainless)]
describe! expression_at_end_of_... | true |
aef9d66fc29a007a902ba936e8b1d63d88391b98 | Rust | BattleMage0231/borz-client | /src/app.rs | UTF-8 | 1,946 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use crate::api::fetch::APIFetcher;
use crate::widgets::page::{GroupPage, ThreadPage, UserPage};
use crate::TOP_LEVEL_ID;
use clap::ArgMatches;
use crossterm::event::KeyEvent;
use json::JsonValue;
use url::Url;
#[derive(Debug)]
pub enum AppPage {
User(UserPage),
Group(GroupPage),
Thread(ThreadPage),
}
#[de... | true |
2735b2b67a7eff5bc8f42f59a49fe0a590c0a481 | Rust | cosmo0920/ruroonga_client | /src/uri_base.rs | UTF-8 | 2,052 | 3.703125 | 4 | [
"MIT"
] | permissive | use std::borrow::Cow;
#[derive(Clone, Debug)]
pub struct URIBase<'a> {
base_uri: Cow<'a, str>,
port: u16,
}
impl<'a> Default for URIBase<'a> {
fn default() -> URIBase<'a> {
URIBase {
base_uri: "localhost".into(),
port: 10041,
}
}
}
impl<'a> URIBase<'a> {
//... | true |
1a463cd0c14a1c73c411e8847e7ec8e4b202d4e7 | Rust | pkalivas/radiate | /radiate_matrix_tree/src/matrix_tree/evenv.rs | UTF-8 | 6,146 | 3.09375 | 3 | [
"MIT"
] | permissive |
extern crate radiate;
use radiate::engine::environment::Envionment;
/// unique mutations:
/// start_height height of the starting tree to generate
/// max height the maximum height of a tree
/// network mutation rate the probability of mutating the neural network inside a node
... | true |
06ce87863fb2d4837a3acc33f521b36a26ea5ebb | Rust | qiuchengxuan/max7456 | /src/incremental_writer.rs | UTF-8 | 3,490 | 3.265625 | 3 | [] | no_license | use peripheral_register::Register;
use crate::registers::{DisplayMemoryMode, OperationMode, Registers};
use crate::{display_memory_address, Attributes, Display};
/// Incremental writer starting from given row and column
/// based on MAX7456 incremental write capability
pub struct IncrementalWriter<'a> {
bytes: &'... | true |
421c7b680f283183e87f49379f28f7a208607c46 | Rust | jblindsay/whitebox-tools | /whitebox-tools-app/src/tools/lidar_analysis/lidar_tile.rs | UTF-8 | 16,565 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 26/06/2017
Last Modified: 05/02/2019
License: MIT
*/
use whitebox_lidar::*;
use crate::tools::*;
use std;
use std::env;
use std::fs::DirBuilder;
use std::io::{Error, ErrorKind};
use std::path;
use std::path::Path;
... | true |
9f6aeaede2913829ea563ff15b5307ae63d85fdd | Rust | stadust/dash-rs | /src/model/level/object/speed.rs | UTF-8 | 764 | 3.40625 | 3 | [
"MIT"
] | permissive | // TODO: Speed portals and stuff
use serde::{Deserialize, Serialize};
/// Enum modelling the different speeds a player can have during gameplay
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
pub enum Speed {
Slow,
#[default]
Normal,
Medium,
Fast,
VeryFast,
Unk... | true |
b1037b727e3f7aff27a72763f62006fb684b1b43 | Rust | RRRadicalEdward/memmap | /src/memory.rs | UTF-8 | 6,946 | 2.53125 | 3 | [] | no_license | use std::{
fmt::{self, Formatter},
mem::size_of_val,
ptr,
rc::Rc,
};
use winapi::{
shared::{
minwindef::{BYTE, FALSE, MAX_PATH, TRUE},
ntdef::LPSTR,
},
um::{
handleapi::{CloseHandle, INVALID_HANDLE_VALUE},
memoryapi::VirtualQueryEx,
psapi::GetMappedFi... | true |
ef5af7c47079556fc187cf823f085562ab1e09b3 | Rust | johanlindblad/advent-of-code-2018 | /src/day15.rs | UTF-8 | 7,722 | 3.046875 | 3 | [] | no_license | use std::collections::BTreeSet;
use std::collections::VecDeque;
#[derive(Debug, Clone)]
pub struct Unit {
hit_points: isize,
friendly: bool,
}
#[derive(Debug, Clone)]
pub enum Square { Wall, Space, Occupied(Unit) }
fn parse_line(input: &str) -> Vec<Square> {
input.chars().map(|c| match c {
'#' =... | true |
55c84135051fbb71ac6e9868d8e9d950f4c995bd | Rust | bytecodealliance/wasmtime | /cranelift/reader/src/isaspec.rs | UTF-8 | 4,491 | 3.359375 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! Parsed representation of `set` and `isa` commands.
//!
//! A test case file can contain `set` commands that set ISA-independent settings, and it can
//! contain `isa` commands that select an ISA and applies ISA-specific settings.
//!
//! If a test case file contains `isa` commands, the tests will only be run agains... | true |
fd30b2e0a2229b3c4c20dd39e02f442cd9c04fb6 | Rust | mariuspod/safe-client-gateway | /src/models/converters/tests/get_address_info.rs | UTF-8 | 1,620 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::models::converters::get_address_info;
use crate::providers::address_info::AddressInfo;
use crate::providers::info::*;
#[rocket::async_test]
async fn get_address_info_address_diff_than_safe() {
let address = "0x1234";
let safe = "0x4321";
let mut mock_info_provider = MockInfoProvider::new();
... | true |
5887d4f102ec213c516e797f534812b46cd85265 | Rust | yoshuawuyts/markdown-edit | /src/lib.rs | UTF-8 | 2,968 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![cfg_attr(feature = "nightly", deny(missing_docs))]
#![cfg_attr(feature = "nightly", feature(external_doc))]
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
#![cfg_attr(test, deny(warnings))]
extern crate pulldown_cmark;
extern crate pulldown_cmark_to_cmark;
#[macro_use]
extern crate failure;
use p... | true |
d3a0d4f18bf8341503c79008f464bcb94db8a22a | Rust | funn1est/leetcode-rust | /src/solutions/n557_reverse_words_in_a_string_iii/mod.rs | UTF-8 | 1,364 | 3.78125 | 4 | [] | no_license | /// https://leetcode.com/problems/reverse-words-in-a-string-iii/
///
/// https://leetcode-cn.com/problems/reverse-words-in-a-string-iii/
pub struct Solution {}
impl Solution {
pub fn reverse_words(s: String) -> String {
s.split_whitespace()
.map(|str| str.chars().rev().collect::<String>())
... | true |
1d812d300452c8eabe448ef35b3c913172365320 | Rust | velyan/rust-skia | /skia-org/src/drivers/pdf.rs | UTF-8 | 619 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::artifact;
use crate::drivers::DrawingDriver;
use skia_safe::Canvas;
use std::path::Path;
pub struct PDF;
impl DrawingDriver for PDF {
const NAME: &'static str = "pdf";
fn new() -> Self {
Self
}
fn draw_image(
&mut self,
size: (i32, i32),
path: &Path,
... | true |
41102f38b5d3d8d066c20e4ef41ca7038e59a575 | Rust | repos-rust/iron | /src/response/mod.rs | UTF-8 | 1,883 | 3.328125 | 3 | [
"MIT"
] | permissive | //! An augmentation of the rust-http Response struct.
use std::io::{IoResult, File};
use std::io::util::copy;
use std::path::BytesContainer;
use http::status::Status;
pub use Response = http::server::response::ResponseWriter;
use self::mimes::get_generated_content_type;
mod mimes;
/// Adds common serving methods ... | true |
3e76044afc3dde3f3f1b0000c30e8dc790f0b375 | Rust | chrisk699/twitch-discord-relay | /src/connectors/irc_parser.rs | UTF-8 | 2,770 | 3.203125 | 3 | [] | no_license | use regex::Regex;
pub struct IrcParser {
regex: Regex
}
pub struct IrcMessage {
pub raw: String,
pub prefix: String,
pub nick: String,
pub username: String,
pub hostname: String,
pub command: String,
pub params: Vec<String>
}
impl IrcParser {
pub fn new() -> IrcParser {
IrcParser {
/*
Regex t... | true |
c9ed789d8ef2cd1d0c6ff220ff8af822ad07bae9 | Rust | ACRONYM-Group/ACIRustServer | /tests/database.rs | UTF-8 | 5,036 | 2.75 | 3 | [] | no_license | //! Integration tests for the DatabaseInterface object, this object is used for access to individual databases
extern crate aci_server;
use aci_server::database::{Database, DatabaseInterface, UserAuthentication};
#[test]
pub fn integration_test_database_read_write()
{
let db = DatabaseInterface::new(Database::new... | true |
47d4432fbceb3ddb47ab4de00ae7839af5af335f | Rust | andrewhickman/json-view | /src/ser/exclude.rs | UTF-8 | 7,213 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::BTreeMap;
use std::io::{self, Write};
use std::ops::Range;
use failure::Fallible;
use json::ser::{CharEscape, Formatter, PrettyFormatter};
pub fn write<'de, F, W>(excludes: ExcludeSet, writer: W, f: F) -> Fallible<()>
where
F: FnOnce(&mut json::Serializer<W, Excluder>) -> Fallible<()>,
W... | true |
36310afe2ba44ed8921a9f6bdbacf70e9231a6dc | Rust | canpok1/atcoder-rust | /contests/abc188/src/bin/a.rs | UTF-8 | 445 | 2.890625 | 3 | [] | no_license | fn main() {
let (x, y) = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut ws = line.trim_end().split_whitespace();
let n1: isize = ws.next().unwrap().parse().unwrap();
let n2: isize = ws.next().unwrap().parse().unwrap();
(n1, n2)... | true |
580b82c57b67138bda311950f009a980f482f0b6 | Rust | mislav-markovic/advent-of-code | /aoc-17/day03_spiral_memory/src/main.rs | UTF-8 | 4,152 | 3.28125 | 3 | [] | no_license | use std::collections::HashMap;
enum SquareSide {
Down(i32),
Up(i32),
Left(i32),
Right(i32),
}
#[derive(PartialEq, Eq, Hash)]
struct Point {
x: i32,
y: i32,
}
fn main() {
println!("Enter part 1 input: ");
let location = read_number();
println!("Enter part 2 input: ");
let thres... | true |
f3a2880c062b8427ecf1ba77d7e6a684278ae36e | Rust | yijie37/DaQiao | /bridge/parity-ethereum/ethcore/machine/src/substate.rs | UTF-8 | 2,841 | 2.9375 | 3 | [
"Unlicense"
] | permissive | // Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at yo... | true |
0c2d9fed22cc119167ee4211ff61855c3ea9847c | Rust | KaoImin/bft-core | /src/types.rs | UTF-8 | 6,716 | 2.859375 | 3 | [
"MIT"
] | permissive | use serde_derive::{Deserialize, Serialize};
use std::{collections::HashMap, fmt};
/// Type for node address.
#[derive(Serialize, Deserialize, Clone, Eq, PartialEq, Hash)]
pub struct Address(Vec<u8>);
impl fmt::Debug for Address {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.0.len() > 5 {... | true |
000dc4bfba067eed169b14073b9d26022f85139a | Rust | DavidMikeSimon/lotsa | /lotsa/src/unique_descrip.rs | UTF-8 | 681 | 2.75 | 3 | [
"MIT"
] | permissive | pub trait UniqueDescrip {
// TODO: Const?
fn unique_descrip(&self) -> String;
}
impl UniqueDescrip for u8 {
fn unique_descrip(&self) -> String { format!("{}u8", self) }
}
impl UniqueDescrip for u16 {
fn unique_descrip(&self) -> String { format!("{}u16", self) }
}
impl UniqueDescrip for u32 {
fn unique_desc... | true |
829bc16467b10293cb06f1dd5524f801e9566916 | Rust | koivunej/aoc | /2019/day12/src/main.rs | UTF-8 | 9,271 | 2.96875 | 3 | [] | no_license | use std::str::FromStr;
use std::fmt;
use std::io::Read;
//use itertools::Itertools;
fn main() {
let mut buffer = String::new();
let stdin = std::io::stdin();
let mut locked = stdin.lock();
locked.read_to_string(&mut buffer).unwrap();
let initial = System {
time: 0,
bodies: buffer.... | true |
7f84345a7b05db323178b8162b66ef3bc78e7ef4 | Rust | JoshOrndorff/advent-of-code-2019 | /day14/src/djkstra.rs | UTF-8 | 4,740 | 3.21875 | 3 | [] | no_license | use super::{parser, Reaction, Reagent};
use std::collections::{BTreeMap, HashSet};
use std::convert::TryInto;
#[derive(Hash, Debug, PartialEq, Eq, Clone)]
struct State {
reagents: BTreeMap<String, i64>,
ore_consumed: u64,
}
impl State {
fn new() -> Self {
Self {
reagents: BTreeMap::new... | true |
b4ba7bfbbe393f043bc5d55f758c901efa638ea3 | Rust | alexey-mz/rust | /pascals-triangle/src/lib.rs | UTF-8 | 373 | 2.671875 | 3 | [] | no_license | mod binom;
use binom::binom::pascal_row;
pub struct PascalsTriangle(Vec<Vec<u32>>);
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
let result = (0..row_count).into_iter().map(|x| pascal_row(x)).collect();
PascalsTriangle(result)
}
pub fn rows(&self) -> Vec<Vec<u32>> {
... | true |
e54e0b00eefe535bd15bd7f4aaae9ccaa5e611c8 | Rust | yomaytk/ruscaml | /src/lib.rs | UTF-8 | 3,421 | 2.65625 | 3 | [] | no_license | use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::env;
use std::fs;
use std::sync::Mutex;
pub mod closure;
pub mod codegen;
pub mod flat;
pub mod lexer;
pub mod normal;
pub mod parser;
pub mod regalloc;
pub mod vm;
use lexer::*;
type Id = String;
type NV = normal::Value;
type FV = flat::Value;
pub ... | true |
99242e5e3186d0d70dc2ca568df13095358b7051 | Rust | rustyforks/warden | /src/main.rs | UTF-8 | 893 | 2.640625 | 3 | [
"MIT"
] | permissive | use axum::routing::get;
use axum::{AddExtensionLayer, Json, Router};
use serde::Serialize;
use warden::config::Config;
use warden::state::State;
#[tokio::main]
async fn main() {
let config = Config::new().expect("Failed to load values from config sources.");
println!("{:#?}", config);
let config = State:... | true |
fcd3b1cbad0d5b81ecd826dfdf0a9401aadc1c2c | Rust | j-carpentier/ALVR | /alvr/xtask/src/main.rs | UTF-8 | 2,626 | 2.953125 | 3 | [
"MIT"
] | permissive | use alvr_xtask::*;
use pico_args::Arguments;
fn ok_or_exit<T, E: std::fmt::Display>(res: Result<T, E>) {
use std::process::exit;
if let Err(e) = res {
#[cfg(not(windows))]
{
use termion::color::*;
println!("\n{}Error: {}{}", Fg(Red), e, Fg(Reset));
}
#[c... | true |
9682151b8339d91d54ce000584c5ed3416a5132e | Rust | forgerpl/hyena-edge | /hyena-engine/src/storage/memory.rs | UTF-8 | 5,819 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | use super::{ByteStorage, Realloc, Storage};
use crate::error::*;
use hyena_common::map_type::{map_type, map_type_mut};
use std::fmt;
use std::fmt::Debug;
use std::intrinsics::copy_nonoverlapping;
use std::marker::PhantomData;
use std::mem::{size_of, zeroed, MaybeUninit};
const PAGE_SIZE: usize = 1 << 12;
#[derive(Deb... | true |
cd1582309453455382767524057c2618298cfaa2 | Rust | schizobulia/ave | /ave-video/src/page/home.rs | UTF-8 | 5,499 | 2.59375 | 3 | [] | no_license | use crate::app::app_message::Message;
use crate::app::state::home::HomeState;
use crate::gstr;
use crate::model::receive_msg::ReceiveMsg;
use crate::model::vide_type::VideoContainerType;
use ave_tool::file_tool::{get_filename, mkdir};
use iced::{
Align, Button, Column, Command, Container, Length, PickList, Row, Scr... | true |
bb363b1c3d5eec1533f90d888587f9be6bf3776d | Rust | kazyamaz200/bibi-zip-loader | /wasm/src/utils.rs | UTF-8 | 1,254 | 2.640625 | 3 | [
"MIT"
] | permissive | use wasm_bindgen::prelude::*;
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
... | true |
ce2dfa97e4e5beb28df06be563ebb5258a0bd84d | Rust | wotsushi/competitive-programming | /etc/ttpc2019/c.rs | UTF-8 | 1,902 | 2.9375 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]
fn main() {
let (N, X): (usize, i64) = {
let mut line: String = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut iter = line.split_whitespace();
(
iter.next().unwrap().parse(... | true |
118d759e339248f5772b3c7e4f6e34de8ae57212 | Rust | IThawk/rust-project | /rust-master/src/test/ui/not-sync.rs | UTF-8 | 826 | 2.65625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | use std::cell::{Cell, RefCell};
use std::rc::{Rc, Weak};
use std::sync::mpsc::{Receiver, Sender};
fn test<T: Sync>() {}
fn main() {
test::<Cell<i32>>();
//~^ ERROR `std::cell::Cell<i32>` cannot be shared between threads safely [E0277]
test::<RefCell<i32>>();
//~^ ERROR `std::cell::RefCell<i32>` cannot... | true |
cfd4bbad4f7804387e872985ee9350401c09573d | Rust | yiransheng/relooper | /src/types.rs | UTF-8 | 4,899 | 3.171875 | 3 | [] | no_license | use std::marker::PhantomData;
use fixedbitset::FixedBitSet;
use petgraph::graph::{DiGraph, IndexType, NodeIndex};
pub type DefaultIndex = u32;
/// Id for shapes (loops and switches).
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct ShapeId<Ix = DefaultIndex>(Ix);
#[derive(Default)]
pub... | true |
f58122cac84cfb0172ff9cc491bc44a30278e733 | Rust | stm32-rs/stm32g4xx-hal | /src/dma/config.rs | UTF-8 | 2,957 | 3.53125 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"LicenseRef-scancode-unknown"
] | permissive | use super::Bits;
/// Priority of the DMA stream, defaults to `Medium`. If two requests have
/// the same software priority level, the stream with the lower number takes
/// priority over the stream with the higher number. For example, Stream 2
/// takes priority over Stream 4.
#[derive(Debug, Clone, Copy)]
pub enum Pr... | true |
e15d8fe5d98c4e239542189e2cdd4487bcef07c3 | Rust | Afterglow/aoc-2020 | /day2-1/src/main.rs | UTF-8 | 999 | 3 | 3 | [] | no_license | use regex::Regex;
fn main() {
let mut ok: usize = 0;
let file = std::fs::read_to_string("input.txt").unwrap();
// 6-10 g: rhtwpsxrzgpgxhk
let re = Regex::new(r"^(?P<from>[0-9]+)-(?P<to>[0-9]+) (?P<needle>\w): (?P<haystack>\S+)$")
.unwrap();
for line in file.lines() {
let cap... | true |
3622ce9c0eec799f37eb1054bd9e99a63d74b1fa | Rust | lin20121221/Yazz | /src/ctrl_map.rs | UTF-8 | 10,286 | 3.203125 | 3 | [
"MIT"
] | permissive | //! Maps MIDI controllers to synth parameters.
use super::{ParamId, MenuItem};
use super::SoundData;
use super::SynthParam;
use super::ValueRange;
use log::{info, trace};
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
#[derive(... | true |
eb1a21776b7683ff71ad472ffec89ff7705d7b85 | Rust | nicooffee/map-app | /map-app/src/engine/engine.rs | UTF-8 | 4,569 | 2.84375 | 3 | [] | no_license | use std::{
io::Stdout,
io::stdout,
io::Write,
thread,
time,
sync::{Arc, Mutex, mpsc::*}
};
use termion::{
input::TermRead,
event::Key,
color,
async_stdin,
raw::RawTerminal,
raw::IntoRawMode,
screen::AlternateScreen
};
use super::window::screen::{
Screen,
Panel... | true |
0edc369c6e64ac7ff0e2034233f8f8b3f54bea1c | Rust | utilForever/BOJ | /Rust/10632 - Unfair Game.rs | UTF-8 | 2,550 | 3.3125 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{cmp, io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_ite... | true |
ee6b7b0aba236600963051f2a0daec793d1457a4 | Rust | LPGhatguy/aoc2018 | /day-01/src/main.rs | UTF-8 | 787 | 3.140625 | 3 | [] | no_license | use std::collections::HashSet;
static INPUT: &str = include_str!("../input.txt");
fn part_one() {
let result: i32 = INPUT
.lines()
.map(str::trim_right)
.map(|v| v.parse::<i32>().unwrap())
.sum();
println!("part one: {:?}", result);
}
fn part_two() {
let changes = INPUT
... | true |
8d1123bb288701428c8ab1e5c345dfac6980d308 | Rust | rome/tools | /crates/rome_js_formatter/src/js/any/declaration.rs | UTF-8 | 1,392 | 2.625 | 3 | [
"MIT"
] | permissive | //! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
use crate::prelude::*;
use rome_js_syntax::AnyJsDeclaration;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyJsDeclaration;
impl FormatRule<AnyJsDeclaration> for FormatAnyJsDeclaration {
type C... | true |
14e3f17ddbfb62a8b61ca2e7ebc96b7e7d31f0bb | Rust | stanxii/vidl-rs | /src/youtube.rs | UTF-8 | 10,644 | 2.5625 | 3 | [
"Unlicense"
] | permissive | use anyhow::{Context, Result};
use chrono::offset::TimeZone;
use log::{debug, trace};
use crate::common::{Service, YoutubeID};
fn api_prefix() -> String {
#[cfg(test)]
let prefix: &str = &mockito::server_url();
#[cfg(not(test))]
let prefix: &str = "https://invidio.us";
prefix.into()
}
/*
[
{... | true |
5e735e4276f1a6d5da8ac41ebbeb31e246e71550 | Rust | shybyte/exercism-rust | /isogram/src/lib.rs | UTF-8 | 394 | 3.453125 | 3 | [] | no_license | use std::collections::HashSet;
pub fn check(s: &str) -> bool {
let letters = s.chars()
.filter(|c| c.is_alphabetic())
.flat_map(|c| c.to_lowercase());
let mut letter_set = HashSet::new();
for letter in letters {
if letter_set.contains(&letter) {
return false;
}... | true |
07258e2084b85e760699fbbcbd600b0d6e851159 | Rust | jrmaingo/rust-tutorials | /projects/area/src/main.rs | UTF-8 | 1,417 | 3.703125 | 4 | [] | no_license | #[derive(Debug)]
struct Rect {
len: u32,
wid: u32
}
// return the area of the rectangle structure
fn area(r: &Rect) -> u32 {
r.len * r.wid
}
impl Rect {
// return the area of the rectangle structure
fn area(&self) -> u32 {
self.len * self.wid
}
// return boolean for whether this i... | true |
9147b14e44902df1acbe21e8426db8984b37a7cc | Rust | Schenk75/Learn-Rust | /leetcode-by-rust/LCOF/lcof17-打印从1到最大的n位数/src/main.rs | UTF-8 | 1,201 | 3.546875 | 4 | [] | no_license | struct Solution;
impl Solution {
pub fn print_numbers(n: i32) -> Vec<i32> {
let mut result = Vec::new();
let x = 10i32.saturating_pow(n as u32);
for i in 1..x {
result.push(i);
}
result
}
pub fn bn_print_numbers(n: i32) -> Vec<i32> {
let mut res... | true |
10807b9f28620af74f8ccb94a4353935cfcd6935 | Rust | rust-lang/rustfmt | /tests/target/issue-4926/enum_struct_field.rs | UTF-8 | 900 | 2.921875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // rustfmt-struct_field_align_threshold: 30
// rustfmt-enum_discrim_align_threshold: 30
// rustfmt-imports_layout: HorizontalVertical
#[derive(Default)]
struct InnerStructA {
bbbbbbbbb: i32,
cccccccc: i32,
}
enum SomeEnumNamedD {
E(InnerStructA),
F {
ggggggggggggggggggggggggg: bool,
h... | true |
2ded54581d3bf80facc756e9c2dcbac44ed5938b | Rust | filipegoncalves/irc-tools | /src/protocol/mod.rs | UTF-8 | 2,770 | 2.8125 | 3 | [
"MIT"
] | permissive |
pub mod unreal;
use cmd::IrcMsg;
use conf::Config;
use std::fmt::{Display, Formatter};
use std::fmt::Result as FmtResult;
use std::rc::Rc;
use std::cell::RefCell;
/// A list of possible error types in the server-to-server protocol
/// Any error that is not `Fatal` will yield a warning but keep the
/// link active. ... | true |
4fe9758c3eb865a612efd410007f576229e964e0 | Rust | DrStiev/rs-gfa2 | /src/tag.rs | UTF-8 | 5,948 | 3.15625 | 3 | [
"MIT"
] | permissive | /// file that tries to mimic the behaviour of the file optfields.rs
/// optfields.rs find, parse and store all the different types of
/// optional fields associated to each kind of lines.
/// with the format GFA2 the optional field tag is been replaced by a
/// simple tag element with 0 or N occurencies.
/// So, I don'... | true |
34970a6e75cdae0270c437a26c3818eac4d0d1e9 | Rust | yskszk63/pwl | /src/segment.rs | UTF-8 | 1,013 | 3.0625 | 3 | [
"MIT"
] | permissive | use crate::Color;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Group {
GitStatus,
}
#[derive(Debug)]
pub struct Builder {
color: Color,
text: String,
group: Option<Group>,
}
impl Builder {
pub fn group(&mut self, group: Group) -> &mut Self {
self.group = Some(group);
self
}... | true |
a61a3f8b42810f80197324c8a17b75cbf3d52be2 | Rust | kmc-jp/cerussite | /cerussite-test-tool/src/main.rs | UTF-8 | 11,861 | 2.65625 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate colored_print;
extern crate atty;
use colored_print::color::ConsoleColor;
use colored_print::color::ConsoleColor::*;
use std::env;
use std::ffi::OsStr;
use std::fmt;
use std::fmt::Display;
use std::fs;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
u... | true |
881a5a1e4b36b8c23f84e7290c09d8b0811a10a6 | Rust | aopicier/cryptopals-rust | /challenges/src/errors.rs | UTF-8 | 2,527 | 3.265625 | 3 | [
"MIT"
] | permissive | use std::{error, fmt};
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync + 'static>>;
#[derive(Debug, Clone)]
pub enum ChallengeError {
ComparisonFailed {
// Can this be made generic?
expected: String,
actual: String,
},
NotImplemented,
ItemN... | true |
e44736bcda02f03aefaaddbd49ef8a4c9396b383 | Rust | irrustible/macaron | /macaron-impl/src/metagroups.rs | UTF-8 | 4,152 | 2.90625 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::*;
use proc_macro2::TokenStream;
use quote::ToTokens;
use smallvec::SmallVec;
use std::{borrow::Cow, collections::HashMap, fmt::{self, Debug}};
use syn::{token, parse::{discouraged::Speculative, ParseStream, Result}};
#[derive(Clone)]
pub struct MetaGroup<T> {
pub dollar: token::Dollar,
pub bra... | true |
e816124b47f5fcd77071e517066dc7576a40a75a | Rust | StupidHackTH/stupid-hack-5-api-challenge | /code/src/modules/not_found/controllers.rs | UTF-8 | 2,400 | 2.609375 | 3 | [] | no_license | use actix_web::{HttpResponse, http::header};
const NOT_FOUND: &'static str = r#"
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Not found</title>
<meta charset="utf8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-si... | true |
c9deb8245fb8e88d41caf1abad8a7c199d4c7ffb | Rust | Thearas/rust-analyzer | /crates/ra_analysis/src/descriptors/module/scope.rs | UTF-8 | 3,589 | 3.3125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Backend for module-level scope resolution & completion
use ra_syntax::{ast, AstNode, SmolStr};
use crate::syntax_ptr::LocalSyntaxPtr;
/// `ModuleScope` contains all named items declared in the scope.
#[derive(Debug, PartialEq, Eq)]
pub(crate) struct ModuleScope {
entries: Vec<Entry>,
}
/// `Entry` is a sing... | true |
05e3cffd3b85febc73cb4691a59bbe947a653e34 | Rust | aep000/ReactiveDB | /reactive_db/src/storage/storage_manager.rs | UTF-8 | 9,558 | 2.578125 | 3 | [] | no_license | use crate::utilities::max_size_hash_map::MaxSizeHashMap;
use crate::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashSet;
use std::fs::File;
use std::fs::OpenOptions;
use std::io;
use std::io::prelude::*;
use std::io::BufReade... | true |
3e8d7e2b8de12dbe032e85bce3806fd5532f67c1 | Rust | Logicalshift/flowbetween | /user_interfaces/cocoa_pipe/src/action.rs | UTF-8 | 7,828 | 3.21875 | 3 | [
"Apache-2.0"
] | permissive | use flo_ui::*;
use flo_canvas::{Draw, Color};
use super::view_type::*;
///
/// Represents a property binding in a Cocoa application
///
#[derive(Clone, PartialEq, Debug)]
pub enum AppProperty {
Nothing,
Bool(bool),
Int(i32),
Float(f64),
String(String),
/// Property is bound to a property ID i... | true |
a447faae286b21fe46e00c137e87c7937ed1649a | Rust | Alpvax/rust-aoc-2015 | /src/bin/day6.rs | UTF-8 | 3,725 | 3.203125 | 3 | [] | no_license | use rust_2015::read_lines;
use fancy_regex::Regex;
use std::collections::HashMap;
fn main() {
let pattern = Regex::new(r"(?:(?P<toggle>toggle)|turn (?:(?P<on>on)|(?P<off>off))) (?P<fx>\d+),(?P<fy>\d+) through (?P<tx>\d+),(?P<ty>\d+)").unwrap();
let mut map1: HashMap<CoOrd, bool> = HashMap::new();
let mut m... | true |
d1dff7f6bf7e2ac8584274748e8c05d8f41e0e52 | Rust | kenoss/frum | /src/commands/completions.rs | UTF-8 | 11,529 | 2.53125 | 3 | [
"MIT"
] | permissive | use crate::cli::build_cli;
use crate::command::Command;
use crate::config::FrumConfig;
use crate::outln;
use crate::shell::{infer_shell, AVAILABLE_SHELLS};
use crate::version::{is_dotfile, Version};
use clap::Shell;
use thiserror::Error;
const USE_COMMAND_REGEX: &str = r#"opts=" -h -V --help --version "#;
const INST... | true |
15868ca87c8cd504fa1f5fdcae2ae78d950d6135 | Rust | cmaves/rustbus | /rustbus_derive_test/src/lib.rs | UTF-8 | 1,926 | 2.796875 | 3 | [
"MIT"
] | permissive | #[test]
fn test_derive() {
use rustbus::message_builder::MessageBuilder;
use rustbus_derive::{Marshal, Signature, Unmarshal};
#[derive(Marshal, Unmarshal, Signature, Default, Debug, Eq, PartialEq)]
struct A {
y: u32,
x: u64,
strct: (u8, u8, String),
raw_data: Vec<u8>,
... | true |
c53468ec489512e652786e0f7e16a3eed8ce8ef7 | Rust | dimes/violetta | /src/entities/mod.rs | UTF-8 | 789 | 3.0625 | 3 | [] | no_license | use components::Component;
use std::any::Any;
use std::collections::HashMap;
#[derive(Debug)]
pub struct Entity {
id: u64,
components: HashMap<&'static str, Box<Any>>,
}
impl Entity {
pub fn new(id: u64) -> Entity {
return Entity {
id: id,
components: HashMap::new(),
... | true |
40661d120e5d39e726bca669a56ce561f9ab442d | Rust | viechang/TimeClue | /src/main.rs | UTF-8 | 523 | 3.109375 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
fn say_what(name: &str, func: fn(&str)) {
func(name);
}
fn test(string: &str) {
println!("{}", string);
}
fn foo(_: &str) {
println!("foobar.");
}
lazy_static!{
static ref VEC: Vec<(&'static str, fn(&str))> = vec![
("Hello, Rust!", test),
("null... | true |
171aca2a8e5edb06f0a14f5e129444df3204132f | Rust | klausklemens/render_frog | /src/util/color.rs | UTF-8 | 309 | 3.140625 | 3 | [] | no_license | pub struct ColorRGB {
pub r: u8,
pub g: u8,
pub b: u8,
}
impl ColorRGB {
pub fn new(r: u8, g: u8, b: u8) -> ColorRGB {
ColorRGB {
r,
g,
b,
}
}
pub fn clone(&self) -> ColorRGB {
ColorRGB::new(self.r, self.g, self.b)
}
}
| true |
17fbc73f53a814932b35e1945522492e1888206c | Rust | redox-os/pkgar | /pkgar-keys/src/lib.rs | UTF-8 | 13,280 | 2.546875 | 3 | [
"MIT"
] | permissive | mod error;
use std::fs::{self, File, OpenOptions};
use std::io::{self, stdin, stdout, Write};
use std::ops::Deref;
use std::os::unix::fs::OpenOptionsExt;
use std::path::{Path, PathBuf};
use error_chain::bail;
use hex::FromHex;
use lazy_static::lazy_static;
use seckey::SecBytes;
use serde::{Deserialize, Serialize};
us... | true |
a2d19a89cab1140e68bc47a44600a81803745bf2 | Rust | teddyzhu/clobber | /src/tcp.rs | UTF-8 | 10,415 | 3.171875 | 3 | [
"MIT"
] | permissive | //! # TCP handling
//!
//! This file contains the TCP handling for `clobber`. The loop here is that we connect, write,
//! and then read. If the client is in repeat mode then it will repeatedly write/read while the
//! connection is open.
//!
//! ## Performance Notes
//!
//! ### Perform allocations at startup
//!
//! T... | true |
9e2d664427a4944608af856527c194b958118494 | Rust | k-start/untitled_os | /src/keyboard.rs | UTF-8 | 824 | 2.640625 | 3 | [] | no_license | use crate::print;
use lazy_static::lazy_static;
use pc_keyboard::{layouts, DecodedKey, HandleControl, ScancodeSet1};
use spin::Mutex;
lazy_static! {
static ref KEYBOARD: Mutex<pc_keyboard::Keyboard<layouts::Us104Key, ScancodeSet1>> = Mutex::new(
pc_keyboard::Keyboard::new(layouts::Us104Key, ScancodeSet1, H... | true |
3c436d090197fb29c39d7461cbac3a1b94705709 | Rust | bottlerocket-os/bottlerocket | /tools/pubsys/src/aws/mod.rs | UTF-8 | 1,144 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use aws_sdk_ec2::config::Region;
use aws_sdk_ec2::types::ArchitectureValues;
#[macro_use]
pub(crate) mod client;
pub(crate) mod ami;
pub(crate) mod promote_ssm;
pub(crate) mod publish_ami;
pub(crate) mod ssm;
pub(crate) mod validate_ami;
pub(crate) mod validate_ssm;
/// Builds a Region from the given region name.
fn... | true |
ec0279a404025635dd074621246d39d799ae535f | Rust | veer66/khatson | /chawuek/src/lib.rs | UTF-8 | 4,010 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use anyhow::Result;
use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
use tch::jit::IValue;
use tch::CModule;
use tch::Tensor;
use thiserror::Error;
#[allow(dead_code)]
pub fn cargo_dir() -> &'static Path {
Path::new(env!("CARGO_MANIFEST_DIR"))
}
#[derive(Error, Debug)... | true |
fe93129d18ef141b1896a9eb2544ac6ec7d9462f | Rust | psinghal20/linkerd2-proxy | /linkerd/http-box/src/request.rs | UTF-8 | 1,386 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | //! A middleware that boxes HTTP request bodies.
use crate::Payload;
use futures::Poll;
#[derive(Debug)]
pub struct Layer<B>(std::marker::PhantomData<fn(B)>);
#[derive(Debug)]
pub struct BoxRequest<S, B>(S, std::marker::PhantomData<fn(B)>);
impl<B> Layer<B>
where
B: hyper::body::Payload + 'static,
{
pub fn ... | true |
40e33bfb6686dc9cad01ab8f29151d00697819d7 | Rust | forkkit/kas | /crates/kas-widgets/src/frame.rs | UTF-8 | 2,151 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | // 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 in the LICENSE-APACHE file or at:
// https://www.apache.org/licenses/LICENSE-2.0
//! A simple frame
use kas::{event, prelude::*};
/// A fr... | true |
a8a17378491d44611f5971ba2251bae6377cae5c | Rust | accounts-inheritance-finders-of-america/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee | /e.rs | UTF-8 | 349 | 2.84375 | 3 | [] | no_license | #![feature(main)]
#[cfg(feature = "functional")]
#[main]
fn e() {
std::iter::repeat('e').for_each(|e| print!("{}", e));
}
#[cfg(not(feature = "functional"))]
#[main]
fn e() -> ! {
loop {
print!("e");
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn teeeeest() {
e();
unreachable... | true |
1d72a47daf7338d3c9781479d4158b44bbd5cbe7 | Rust | MichaelAquilina/adventofcode2018 | /day11/src/main.rs | UTF-8 | 388 | 2.546875 | 3 | [] | no_license | // https://adventofcode.com/2018/day/11
mod grid;
use grid::Grid;
fn main() {
let serial_number = 7857;
let grid = Grid::generate(300, 300, serial_number);
let (point, power) = grid.find_max_power_point();
println!("{:?} (power: {})", point, power);
let (point, power) = grid.find_max_power_poi... | true |
2b74a11bec6f2a23a1cd9fd887266fa1ece839fe | Rust | nowei/learning-rust | /generics/src/main.rs | UTF-8 | 1,693 | 3.59375 | 4 | [] | no_license | mod lib;
use lib::Tweet;
use lib::Summary;
fn largest<T: PartialOrd>(list: &[T]) -> &T {
let mut largest = &list[0];
for item in list.iter() {
if item > largest {
largest = &item;
}
}
return largest;
}
fn largest_alt<T>(list: &[T]) -> T
where T: PartialOrd + Copy {
le... | true |
8f5dbdc04afe94c260b32cbe7b235a1aed3720bb | Rust | kitchenSpoon/solana | /src/accountant_stub.rs | UTF-8 | 7,320 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | //! The `accountant_stub` module is a client-side object that interfaces with a server-side Accountant
//! object via the network interface exposed by AccountantSkel. Client code should use
//! this object instead of writing messages to the network directly. The binary
//! encoding of its messages are unstable and may ... | true |
0bdfea5d9744ac989abf10b66eb5355448b83c96 | Rust | pimeys/napi-rs | /napi/src/win_delay_load_hook.rs | UTF-8 | 2,614 | 2.640625 | 3 | [
"MIT"
] | permissive | //! The following directly was copied from [neon][].
//!
//! Rust port of [win_delay_load_hook.cc][].
//!
//! When the addon tries to load the "node.exe" DLL module, this module gives it the pointer to the
//! .exe we are running in instead. Typically, that will be the same value. But if the node executable
//! was ren... | true |
78c0079234e14187086d68ceaa08b363750cdbd9 | Rust | jng985/terra_rps | /src/contract.rs | UTF-8 | 1,980 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | #[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cosmwasm_std::Addr;
use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use crate::state::{State, STATE};
#[cfg_attr(not... | true |
04f8320b4e7589ee0d5d0c84dd0cd2b56eafd3ad | Rust | irraco/yew | /examples/mount_point/src/main.rs | UTF-8 | 1,579 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[macro_use]
extern crate yew;
#[macro_use]
extern crate stdweb;
use yew::html::{App, Html, InputData};
use stdweb::web::{IElement, document, INode};
struct Context {}
struct Model {
name: String,
}
enum Msg {
UpdateName(String),
}
fn update(_: &mut Context, model: &mut Model, msg: Msg) {
match msg {
... | true |
0393ea8f888b1ae8c2291ee5415dc88092fbf8f1 | Rust | cundd/rcoin | /src/rate_provider/cryptonator/mod.rs | UTF-8 | 2,075 | 2.828125 | 3 | [] | no_license | // https://api.cryptonator.com/api/ticker/ltc-usd
//{
// "ticker": {
// "base": "LTC",
// "target": "USD",
// "price": "248.16084013",
// "volume": "286939.69094764",
// "change": "-0.67224984"
// },
// "timestamp": 1515878702,
// "success": true,
// "error": ""
//}
m... | true |
aa10ddec486aa9e82d082b3a9f14df931bead4e5 | Rust | wangjia184/rholang-rust | /model/src/rho_types/SourcePosition.rs | UTF-8 | 419 | 2.703125 | 3 | [] | no_license |
// Extends generated SourcePosition structure
impl SourcePosition {
pub fn new (row : i32, col : i32, len : usize) -> SourcePosition {
SourcePosition {
row : row,
col : col,
len : len as i32,
}
}
}
impl fmt::Display for SourcePosition {
fn fmt(&self, f: ... | true |
f7c568d1172417ce997f57ec4da556fca0205639 | Rust | knokko/wasmuri-container | /src/layer/simple/keylistening.rs | UTF-8 | 4,557 | 2.640625 | 3 | [
"MIT"
] | permissive | use crate::*;
use std::cell::RefCell;
use std::rc::Weak;
use wasmuri_core::*;
pub struct KeyListenManager {
hover_down_listeners: WeakMetaVec<dyn ComponentBehavior, Region>,
hover_up_listeners: WeakMetaVec<dyn ComponentBehavior, Region>,
full_down_listeners: WeakMetaVec<dyn ComponentBehavior, i8>,
... | true |
2a4ccb181085f1db5be21cff609f50d3516f6d1d | Rust | Misterio77/ncspot | /src/theme.rs | UTF-8 | 2,151 | 2.671875 | 3 | [
"BSD-2-Clause"
] | permissive | use cursive::theme::BaseColor::*;
use cursive::theme::Color::*;
use cursive::theme::PaletteColor::*;
use cursive::theme::*;
use crate::config::Config;
macro_rules! load_color {
( $cfg: expr, $member: ident, $default: expr ) => {
$cfg.theme
.as_ref()
.and_then(|t| t.$member.clone())... | true |
5b48c225b7bcc6a9fc64702b1f481250555d16d3 | Rust | CodeSandwich/Mocktopus | /src/mock_store.rs | UTF-8 | 4,041 | 2.859375 | 3 | [
"MIT"
] | permissive | use crate::mocking::MockResult;
use std::{any::TypeId, marker::Tuple};
use std::cell::RefCell;
use std::collections::HashMap;
use std::mem::transmute;
use std::rc::Rc;
pub struct MockStore {
layers: RefCell<Vec<MockLayer>>,
}
impl MockStore {
pub fn clear(&self) {
for layer in self.layers.borrow_mut()... | true |
84666255aab4d6e6ffea12795613dfed450f83c1 | Rust | ItsHoff/Rusty | /src/statistics.rs | UTF-8 | 4,034 | 2.9375 | 3 | [
"MIT"
] | permissive | mod accumulator;
use std::collections::HashMap;
use std::fmt::Write;
use std::sync::Mutex;
use std::time::{Duration, Instant};
use prettytable::{cell, ptable, row, table};
use self::accumulator::SumAccumulator;
lazy_static::lazy_static! {
static ref STATS: Mutex<Vec<Statistics>> = Mutex::new(Vec::new());
}
mac... | true |
833704443753dea3634e8e3a13ab1b3052e7f4fc | Rust | richwandell/rustjs | /src/ast_interpreter/interpreter.rs | UTF-8 | 22,312 | 2.53125 | 3 | [] | no_license | use crate::parser::symbols::{JSItem, Operator, Statement, StdFun, AssignOp};
use crate::parser::symbols::Expression;
use crate::ast_interpreter::bin_op::{bin_add, bin_mul, bin_sub, bin_div, bin_less};
use std::collections::HashMap;
use crate::lexer::js_token::Tok;
use crate::ast_interpreter::std::{create_std_objects};
... | true |
731d9ae92f3bb8c48f0757781ba305b3698bb320 | Rust | prabhugopal/Sprocket | /lib/mem_utils/src/lib.rs | UTF-8 | 3,474 | 2.84375 | 3 | [
"MIT"
] | permissive | #![no_std]
use core::ops::Sub;
// Memory layout
pub const KERNBASE: VirtAddr = VirtAddr(0x80000000);
pub const KERNLINK: VirtAddr = VirtAddr(KERNBASE.0 + EXTMEM.0); // Address where kernel is linked
pub const EXTMEM: PhysAddr = PhysAddr(0x100000); // Start of extended memory
pub const PHYSTOP: PhysAddr = PhysAddr(0xE... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.