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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
7f4ef5f8afee6f7c52749d9066bcc89dc8e849c6 | Rust | Diggsey/rust-crud-example | /src/database/middleware.rs | UTF-8 | 1,389 | 2.90625 | 3 | [] | no_license | use std::sync::Arc;
use std::ops::Deref;
use iron::prelude::*;
use iron::{typemap, BeforeMiddleware};
use database::interface::Database;
// The DatabaseMiddleware is constructed from a concrete
// database implementation, and provides it to all
// request handlers via the `.db()` method.
// Shared reference to a da... | true |
e3b68c89e109ba8c109e31f551846e56561ab4d0 | Rust | JoshMcguigan/cargo-run-script | /src/main.rs | UTF-8 | 1,711 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde_derive::Deserialize;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::env;
use std::process::Command;
mod arg_parse;
#[derive(Deserialize, Debug)]
struct Config {
package: Package
}
#[derive(Deserialize, Debug)]
struct Package {
metadata: Metadata
}
#[derive(Deserializ... | true |
ff1b81932387e6ea61ebba4de3573b5c660879f0 | Rust | Horki/wasm-tools | /crates/wasm-mutate/src/mutators/translate.rs | UTF-8 | 13,526 | 2.78125 | 3 | [
"LLVM-exception",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{Error, Result};
use wasm_encoder::*;
use wasmparser::{DataKind, ElementKind, FunctionBody, Global, Operator, Type};
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub enum Item {
Function,
Table,
Memory,
Tag,
Global,
Type,
Data,
Element,
}
#[derive(Debug, Hash, Eq, Part... | true |
2b538100624a61d9fb85bac7b1a900d3ec1ec14a | Rust | joaovitor123jv/rust-web-crawler | /src/lib/web.rs | UTF-8 | 484 | 2.90625 | 3 | [] | no_license |
pub fn get_page(page_url: String) -> Result<String, Box<dyn std::error::Error>> {
Ok(reqwest::blocking::get(&page_url)?.text()?)
}
pub fn extract_links(tokens: Vec<String>) -> Vec<String> {
let mut links: Vec<String> = [].to_vec();
for (index, token) in tokens.iter().enumerate() {
if token == "hr... | true |
3d6e55ed7228042d7c2094e13311e2fd98fff1e8 | Rust | liv-dumea/blue-pill-infrared-nec-decoding | /src/ir_dec_nec.rs | UTF-8 | 3,475 | 2.984375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! State module for ir receiver
#![allow(dead_code)]
#![allow(unused_variables)]
use core::cell::Cell;
use core::marker::PhantomData;
const START1_MIN: u32 = 7900; //us
const START1_MAX: u32 = 10100; //us
const START2_MIN: u32 = 3400; //us
const START2_MAX: u32 = 5600; //us
const SHORT_MIN: u32 = 350; //us
const SH... | true |
9590e23511717709d41a664db9e8b712de73574f | Rust | servo/green-rs | /libgreen/src/simple.rs | UTF-8 | 3,297 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | true |
9a96174fa72074568127d35ff02e1778ed22dedc | Rust | azula-lang/azula | /parser/src/token.rs | UTF-8 | 1,782 | 3.390625 | 3 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq, Clone)]
pub struct Span {
pub start: usize,
pub end: usize,
}
#[derive(Debug, PartialEq, Clone)]
pub enum TokenKind<'a> {
Identifier(&'a str),
String(&'a str),
Char(&'a str),
Integer(i64),
BracketOpen, // (
BracketClose, // )
SquareOpen, // [
Squar... | true |
78b3ab68e1d5f6093849841f99da4d08adc97623 | Rust | teohhanhui/makepad | /widget/src/textbuffer.rs | UTF-8 | 32,473 | 2.640625 | 3 | [
"MIT"
] | permissive | use makepad_render::*;
use crate::textcursor::*;
#[derive(Clone, Default)]
pub struct TextBuffer {
// Vec<Vec<char>> was chosen because, for all practical use (code) most lines are short
// Concatenating the total into a utf8 string is trivial, and O(1) for windowing into the lines is handy.
// Also inser... | true |
a85f188e83373655ae5b671f7dd027843da5731f | Rust | developers-algorithm-study/mjy9088 | /acmicpc.net/1259/src/main.rs | UTF-8 | 518 | 3.234375 | 3 | [] | no_license | use std::io;
trait Palindrome {
fn is_palindrome(&self) -> bool;
}
impl Palindrome for str {
fn is_palindrome(&self) -> bool {
self.chars()
.zip(self.chars().rev())
.all(|(asc, desc)| asc == desc)
}
}
fn main() {
loop {
let mut line = String::new();
io:... | true |
5e385ad7f6c4c929db3b562e9a16da8d7b7a199a | Rust | rust-lang/cargo | /src/cargo/util/semver_ext.rs | UTF-8 | 7,916 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"GPL-2.0-only",
"Apache-2.0",
"MIT",
"GCC-exception-2.0",
"BSD-3-Clause",
"LGPL-2.0-or-later",
"Zlib",
"OpenSSL",
"curl",
"LGPL-2.1-only",
"BSD-2-Clause",
"LicenseRef-scancode-ssleay-windows",
"Unlicense"
] | permissive | use semver::{Comparator, Op, Version, VersionReq};
use std::fmt::{self, Display};
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
pub enum OptVersionReq {
Any,
Req(VersionReq),
/// The exact locked version and the original version requirement.
Locked(Version, VersionReq),
}
pub trait VersionExt {
fn ... | true |
ce0798146c04f7399802cd7b4a6aa7ce23bcdd97 | Rust | exit91/miniserve | /tests/fixtures/mod.rs | UTF-8 | 853 | 2.796875 | 3 | [
"MIT"
] | permissive | use assert_fs::fixture::TempDir;
use assert_fs::prelude::*;
use port_check::free_local_port;
use rstest::fixture;
/// Error type used by tests
pub type Error = Box<std::error::Error>;
/// File names for testing purpose
#[allow(dead_code)]
pub static FILES: &[&str] = &["test.txt", "test.html", "test.mkv"];
/// Test f... | true |
76a79a5ae782dce55f22181747bb0f2b60633a7f | Rust | debragail/prisma-engines | /introspection-engine/connectors/introspection-connector/src/lib.rs | UTF-8 | 3,505 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | mod error;
use core::fmt;
use datamodel::common::preview_features::PreviewFeature;
use datamodel::{Datamodel, Datasource};
use enumflags2::BitFlags;
pub use error::{ConnectorError, ErrorKind};
use serde::*;
use serde_json::Value;
pub type ConnectorResult<T> = Result<T, ConnectorError>;
#[async_trait::async_trait]
pu... | true |
ce1bf1beb679ee3b939829a0542b5ffba96f20d3 | Rust | TylerHorth/advent-of-code-2020 | /src/day22.rs | UTF-8 | 3,886 | 3.125 | 3 | [] | no_license | use std::collections::VecDeque;
use std::hash::{Hash, Hasher};
use aoc_runner_derive::{aoc, aoc_generator};
use fnv::{FnvHasher, FnvHashSet};
use itertools::Itertools;
#[aoc_generator(day22)]
fn parse(input: &str) -> (VecDeque<u8>, VecDeque<u8>) {
let (p1, p2) = input.split("\n\n").next_tuple().unwrap();
let... | true |
6969be7f7180c19d6d8e03ad97c126bd706208bd | Rust | SleepingPills/bushhammer | /server/lib/neutronium/src/system.rs | UTF-8 | 31,848 | 2.609375 | 3 | [] | no_license | use crate::component::Component;
use crate::component::{ComponentCoords, Shard};
use crate::entity::{EntityId, TransactionContext};
use crate::identity::ShardKey;
use crate::messagebus::{Batcher, Bus, Message};
use crate::sentinel::Take;
use anymap::AnyMap;
use hashbrown::HashMap;
use indexmap::IndexMap;
use std::marke... | true |
c7836c9b40d21fe15165cfc99ec42ed983bc0f41 | Rust | fujexo/adfinis-codechallenge-2020 | /chall04/src/advm.rs | UTF-8 | 6,212 | 3.4375 | 3 | [] | no_license | pub mod virtual_machine {
use serde::Deserialize;
use std::process;
#[derive(Debug)]
pub struct Vm {
memory: [f64; 7],
pub counter: usize,
register: f64,
}
#[derive(Debug, Deserialize)]
pub struct Instruction {
counter: u32,
instruction: String,
... | true |
8e5fda2b59343c6cab1d0aa594f8fee9d59b7c14 | Rust | klgraham/graph-rs | /src/lib.rs | UTF-8 | 4,397 | 3.65625 | 4 | [] | no_license |
use std::collections::HashMap;
use std::fmt::{Display, Result, Formatter};
// Adjacency list graph
#[derive(Debug)]
pub struct Vertex {
pub id: usize,
pub string_props: HashMap<String, String>,
pub int_props: HashMap<String, i64>,
pub float_props: HashMap<String, f64>
}
// struct Edge {
// pub w... | true |
c048d8f0c24e26576c4be0eb5ca42fbbc89000ef | Rust | ruma/ruma | /crates/ruma-events/src/room/message/image.rs | UTF-8 | 1,936 | 2.96875 | 3 | [
"MIT"
] | permissive | use ruma_common::OwnedMxcUri;
use serde::{Deserialize, Serialize};
use crate::room::{EncryptedFile, ImageInfo, MediaSource};
/// The payload for an image message.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
#[serde(tag = "msgtype", rename = "... | true |
7c4bfccd6549af4cdabccf02e303e39c5e3082b9 | Rust | csixteen/LeetCode | /Problems/Algorithms/src/Rust/ransom-note/src/lib.rs | UTF-8 | 2,838 | 3.546875 | 4 | [
"MIT"
] | permissive | // https://leetcode.com/problems/ransom-note/
use std::collections::HashMap;
struct Solution {}
impl Solution {
// First solution. I over engineered, since there is no need to
// use a HashMap to keep the frequency of chars in each string.
// This solution runs in 8ms.
pub fn can_construct(ransom_not... | true |
7d176dea8cef7b83416c13f3d3c8f991ac3f8fcb | Rust | Alexendoo/density | /src/main.rs | UTF-8 | 2,701 | 3.15625 | 3 | [
"MIT"
] | permissive | extern crate getopts;
use std::env;
use std::fs;
use std::io;
use std::path::Path;
use std::string::String;
use std::vec::Vec;
fn main() {
let mut opts = getopts::Options::new();
opts.optflag(
"h",
"human-readable",
"display human readable sizes (e.g. 1G, 50K)",
);
opts.optflag... | true |
b3e63b21f3f58945f3291a0af28bd52126448486 | Rust | txus/rye | /src/world.rs | UTF-8 | 20,251 | 3.03125 | 3 | [] | no_license | use crate::color::Color;
use crate::light::{Light, PointLight};
use crate::linear::{Matrix4, Point};
use crate::materials::Material;
use crate::rays::{Intersection, Precomputation, Ray};
use crate::shapes::{Shape, Sphere};
use crate::registry::Registry;
use std::cell::RefCell;
use std::rc::Rc;
pub const MAX_REFLECTIO... | true |
926285dd6cce32d23be4e316591e7663323f0be6 | Rust | fernando-jascovich/tij | /src/tij/conf.rs | UTF-8 | 570 | 2.625 | 3 | [] | no_license | use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct ConfModel {
host: String,
user: String,
pass: String
}
impl std::default::Default for ConfModel {
fn default() -> Self {
ConfModel { host: "".into(), user: "".into(), pass: "".into() }
}
}
pub fn load() -> R... | true |
4637456711fb128c3398dc59d1bc34d2b8e6dfd2 | Rust | barnabee/narwhal | /rust/dag_core/src/manage_primary.rs | UTF-8 | 2,833 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
use super::types::*;
use crate::committee::Committee;
use crate::primary::*;
use crate::primary_net::*;
use crypto::SecretKey;
use log::*;
use store::*;
use tokio::sync::mpsc::{channel, Receiver, Sender};
/// A ManageWorker is instatiated in a physical machine to coo... | true |
aedc2ed6105e37815bbc25a335fb203a30f30afb | Rust | maueki/dotfiles2 | /.emacs.d/snippets/rust-mode/tests/tests/st_test.rs | UTF-8 | 218 | 2.53125 | 3 | [] | no_license | use std::cmp::min;
include!("../../st");
#[test]
fn st_test() {
let mut st = SegTree::new(100, std::usize::MAX, min);
st.update(50, 1);
assert_eq!(st.get(50), 1);
assert_eq!(st.query(0, 51), 1);
}
| true |
6bd632dcc6fd1bce695cdbe82ba4c7a28e7260b6 | Rust | davefol/competitive-programming-in-rust | /codeforces/154_div2/A_Boys_and_Girls/src/main.rs | UTF-8 | 2,603 | 3.3125 | 3 | [] | no_license | #![allow(unused_imports)]
use std::collections::{HashSet, HashMap};
use std::cmp::{min,max};
use std::io;
use std::str;
use std::fs::File;
use std::io::BufReader;
struct Scanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitWhitespace<'static>,
}
impl<R: io::BufRead> Scanner<R> {
fn new(reader... | true |
73dd18559db37bab52f22f3f3e1b839353d70f42 | Rust | yin939/Exercism | /rust/dot-dsl/src/lib.rs | UTF-8 | 2,985 | 3.296875 | 3 | [] | no_license | pub mod graph {
use graph_items::edge::Edge;
use graph_items::node::Node;
use std::collections::HashMap;
#[derive(Default, PartialEq, Debug)]
pub struct Graph {
pub nodes: Vec<Node>,
pub edges: Vec<Edge>,
pub attrs: HashMap<String, String>,
}
impl Graph {
pub... | true |
1edd62724e6eaf5e3461ea64079871fedb73319e | Rust | caesarchad/DeCore | /core/src/service.rs | UTF-8 | 1,766 | 3.828125 | 4 | [
"Apache-2.0"
] | permissive | //! The `service` module implements a trait used by services and phases.
//!
//! A Service is any object that implements its functionality on a separate thread. It implements a
//! `join()` method, which can be used to wait for that thread to close.
//!
//! The Service trait may also be used to implement a pipeline pha... | true |
e84539043e53e7e52be784aa5b4e3f42477c26df | Rust | CertainLach/kct | /bin/src/cli/package.rs | UTF-8 | 863 | 3.03125 | 3 | [
"MIT"
] | permissive | use clap::ArgMatches;
use clap::{App, Arg, SubCommand};
use kct_package::Package;
use std::error::Error;
use std::path::PathBuf;
pub fn command() -> App<'static, 'static> {
SubCommand::with_name("package")
.about("package a KCP into a KCP Archive")
.arg(
Arg::with_name("package")
.help("Directory containin... | true |
75adf9e87ee3347664c4219797c2bd6269b3e99e | Rust | irrum6/CRustC | /rustlings/ddays/src/main.rs | UTF-8 | 3,010 | 3.328125 | 3 | [] | no_license | // days between days
fn days_between(date1: String, date2: String) -> i32 {
let date1 = epoch_days(date1);
let date2 = epoch_days(date2);
(date1 - date2).abs()
}
//from_1970_01_01
fn epoch_days(date: String) -> i32 {
let days_by_month = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
let ... | true |
19c0269c77098d517f0016de7e77d36e1d905ce2 | Rust | twitter/rustcommon | /time/src/lib.rs | UTF-8 | 8,002 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use core::sync::atomic::AtomicUsize;
use core::sync::atomic::{AtomicU32, AtomicU64, Ordering};
mod datetime;
mod duration;
mod instant;
#[macro_use]
mod macros;
mod units;
mod unix;
pub use... | true |
e025c0a30c77af7be524db6f0d58349463704312 | Rust | EFanZh/LeetCode | /src/problem_0126_word_ladder_ii/mod.rs | UTF-8 | 1,070 | 2.9375 | 3 | [] | no_license | pub mod bidirectional_search;
pub trait Solution {
fn find_ladders(begin_word: String, end_word: String, word_list: Vec<String>) -> Vec<Vec<String>>;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [
(
("hit", "cog", &["hot"... | true |
aa3bfb8c1be599b79f046bab2b9832f89412cece | Rust | morganfogg/zanthe | /src/loader/blorb.rs | UTF-8 | 2,491 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use crate::game::Result;
use crate::game::error::GameError;
pub enum IndexKind {
Picture,
Sound,
Data,
Executable,
}
impl IndexKind {
pub fn from_index_name(name: &str) -> Option<IndexKind> {
match name {
"Pict" => Some(IndexKind::Picture),
... | true |
b5c860e1d5b761c1745aae0b2c66aca661f2cdf4 | Rust | BearzRobotics/setup_tablet | /src/main.rs | UTF-8 | 3,195 | 3.03125 | 3 | [] | no_license | // This program is to setup my tablet so I don't
// have to do it manually every time.
// Furtue plans mnake code to auto detecte new monitor and set that up.
// That would evole using clap.
#[macro_use]
extern crate clap;
use clap::App;
use std::process::Command;
use std::io::stdin;
use std::env;
// I need to pars... | true |
537e5009069df7944a25bc06c0ff247ad1e2f37f | Rust | ewilken/hap-rs | /src/transport/bonjour.rs | UTF-8 | 666 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
/// Bonjour Feature Flag.
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub enum BonjourFeatureFlag {
Zero = 0,
SupportsHardwareAuthentication = 0x01,
SupportsSoftwareAuthentication = 0x02,
}
/// Bonjour Status Flag.
#[derive(Debug, Copy, Clone, ... | true |
157ad17ec67e5c3037cb8bbf47bc06da540ebe6f | Rust | ShashankaNataraj/Juggernaut | /src/file/mod.rs | UTF-8 | 435 | 2.640625 | 3 | [
"MIT"
] | permissive | #[macro_use]
use std::fs::File;
use std::io::Write;
use std::io::Read;
extern crate serde_json;
pub fn read_file(file:String) -> String{
let path = file.clone();
let mut file = File::open(file)
.expect("Unable to open the file");
let mut contents = String::new();
file.read_to_string(&mut content... | true |
46b578ad4a875729a735864396c5f8a709480eec | Rust | MaxOhn/Bathbot | /bathbot-model/src/rkyv_util/unwrap_or_default.rs | UTF-8 | 1,470 | 2.65625 | 3 | [
"ISC"
] | permissive | use rkyv::{
with::{ArchiveWith, DeserializeWith, SerializeWith},
Archive, Archived, Deserialize, Fallible, Resolver, Serialize,
};
pub struct UnwrapOrDefault;
impl<T: Archive + Default> ArchiveWith<Option<T>> for UnwrapOrDefault {
type Archived = Archived<T>;
type Resolver = Resolver<T>;
#[inline... | true |
d6dfad649045b8a60a50947544edbceb41df2b34 | Rust | sinkuu/RustLSP | /lib/melnorme_util/src/string.rs | UTF-8 | 1,450 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2016 Bruno Medeiros
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0>.
// This file may not be copied, modified, or distributed
// except according to those terms.
// WARNING: Rust newbie code ahead (-_-)'
use core::*;
use std::io;
... | true |
32cd5cba00956e9b1cd211291233949a3f0fd43f | Rust | kroeckx/ruma | /crates/ruma-client-api/src/r0/account/whoami.rs | UTF-8 | 893 | 2.796875 | 3 | [
"MIT"
] | permissive | //! [GET /_matrix/client/r0/account/whoami](https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-account-whoami)
use ruma_api::ruma_api;
use ruma_identifiers::UserId;
ruma_api! {
metadata: {
description: "Get information about the owner of a given access token.",
method: GET,
... | true |
df532e05d1842daeebd99a73a57884500840ff69 | Rust | Zabrane/gleam | /src/codegen/erlang_record_headers.rs | UTF-8 | 1,295 | 2.703125 | 3 | [
"Swift-exception",
"Apache-2.0"
] | permissive | use crate::{build::Module, codegen::CodeGenerator, config::PackageConfig, erl, fs::OutputFile};
use std::path::PathBuf;
/// A code generator that creates a .hrl Erlang header file containing a record
/// definition for each Gleam custom type with all named fields in the package.
#[derive(Debug)]
pub struct ErlangRecor... | true |
deb9543647a4a161dd63c80fabbf397015a02cab | Rust | Mr-Llama-s-Wonderful-Soundboard/soundboard | /src/hotkey.rs | UTF-8 | 4,696 | 3.0625 | 3 | [] | no_license | use rdev::{listen, Event, Key, EventType};
use crossbeam_channel::{unbounded, Sender, Receiver};
use lazy_static::lazy_static;
use std::collections::{HashMap, HashSet};
use std::hash::Hash;
#[allow(unused)]
use log::{warn, info, error};
lazy_static!{
static ref EVENT_CHANNEL: (Sender<Event>, Receiver<Event>) = unbo... | true |
ec87bf1ace87b1ebb96d871a13f97ba1c6c8fcfa | Rust | Bestra/advent-2018-rs | /src/day_1.rs | UTF-8 | 1,319 | 3.8125 | 4 | [] | no_license | pub fn part_1(input: &str) -> String {
let nums: Vec<u32> = input.chars().map(|c| c.to_digit(10).unwrap()).collect();
run(nums, 1)
}
pub fn part_2(input: &str) -> String {
let nums: Vec<u32> = input.chars().map(|c| c.to_digit(10).unwrap()).collect();
let l = nums.len();
run(nums, l / 2)
}
fn run(i... | true |
f1a286c5a5461e424642016ce177126d6d3a2014 | Rust | Drumato/peachili | /src/debug/dump_ir.rs | UTF-8 | 1,198 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::common::file_util;
use crate::common::three_address_code as tac;
/// 三番地コードの関係をDOT言語で記述し,ファイルに書き出す
pub fn dump_hir(ir_module: &tac::IRModule) {
let mut dumper = IRDumper {
output: Default::default(),
filename: "hir_dump".to_string(),
};
dumper.construct_hir_program(ir_module);
... | true |
c92a110f9e8431a779e06b626eaa350c96605cee | Rust | jtanguy/metallircd | /libmetallirc/src/users/newuser.rs | UTF-8 | 3,687 | 3.046875 | 3 | [] | no_license | //! Structs for handling new connections
use std::io;
use std::io::BufferedStream;
use std::io::net::tcp::TcpStream;
use messages::{IRCMessage, numericreply};
use conf::ServerConf;
use util;
/// A user with possibly missing data, not to be shared until
/// initial negociation is done and a proper user is created.
#... | true |
698a4e68f4bf7accc8a4ce6534d9051fc483ec91 | Rust | autocatalytic/witter | /backend/src/tests/users.rs | UTF-8 | 962 | 2.609375 | 3 | [] | no_license | use crate::tests::test_helpers::*;
#[async_std::test]
async fn get_profile_of_other_user() {
let mut server = test_setup().await;
let username = "bob";
create_user_and_authenticate(&mut server, Some(username.to_string())).await;
let (json, status, _) = get(&format!("/users/{}", username)).send(&mut s... | true |
7e5fb654f813ea5f50d19ff4e711dc7a0e94f24d | Rust | senofsky/leetcode | /rust/src/bin/design_linked_list.rs | UTF-8 | 4,369 | 3.953125 | 4 | [
"MIT"
] | permissive | // Design your implementation of the linked list. You can choose to use the
// singly linked list or the doubly linked list. A node in a singly linked list
// should have two attributes: val and next. val is the value of the current
// node, and next is a pointer/reference to the next node. If you want to use
// the do... | true |
7a1c3e5297fe0f6a55db4d48657724f3e3ce1b6d | Rust | torao/bumblebees | /src/bridge/io/dispatcher/mod.rs | UTF-8 | 12,552 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::future::Future;
use std::io::{Read, Write};
use std::net::SocketAddr;
use std::ops::DerefMut;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Receiver, Sender};
use std::task::{Context, Waker};
use std::thread::spawn;
use log;
use mio::{Events, Int... | true |
cc8da51638b3886f99167e19260f4d2a8b297f63 | Rust | mtfcd/exercism-rust | /rna-transcription/src/lib.rs | UTF-8 | 2,615 | 3.421875 | 3 | [] | no_license | use std::convert::{TryFrom, TryInto};
// fn make_xna(xna: &str, valid: [char; 4]) -> Result<Vec<char>, usize> {
// let mut nucleotides = Vec::with_capacity(xna.len());
// for (i, c) in xna.chars().enumerate() {
// if !valid.contains(&c) {
// return Err(i)
// }
// nucleotides... | true |
fe1c7b6bfa153b28199c9393d6a594f9699d56d4 | Rust | sinistersnare/fula | /src/routes/server/update_server.rs | UTF-8 | 4,343 | 2.546875 | 3 | [
"MIT"
] | permissive |
use diesel::prelude::*;
use rustful::{Context, Response, header, StatusCode};
use ::models::{UpdatedGameServer, GameServer};
pub fn update_server(mut context: Context, mut response: Response) {
use ::schema::game_servers::dsl::*;
let conn = match ::establish_connection() {
Ok(c) => c,
Err(e)... | true |
a2e6b4006694c20724138b068f06a87a2b37f83e | Rust | yakov-bakhmatov/wna | /examples/menu.rs | UTF-8 | 1,293 | 2.84375 | 3 | [
"MIT"
] | permissive | extern crate wna;
use wna::*;
fn main() {
println!("hello!");
let mut wna = Wna::new();
wna
.icon(Icon::File("resources/ico.ico".to_string()))
.tip("Hello!")
.menu_item(MenuItem::action("Quit".to_string(), quit))
.menu_item(MenuItem::Separator)
.menu_item(MenuItem::a... | true |
dce792324ea4c086fc374d47910ef98ecccdafa7 | Rust | 2color/prisma-engines | /query-engine/query-engine/src/request_handlers/graphql/schema_renderer/object_renderer.rs | UTF-8 | 2,577 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
#[derive(Debug)]
pub enum GqlObjectRenderer {
Input(InputObjectTypeWeakRef),
Output(ObjectTypeWeakRef),
}
impl Renderer for GqlObjectRenderer {
fn render(&self, ctx: &mut RenderContext) -> String {
match &self {
GqlObjectRenderer::Input(input) => self.render_input_object(... | true |
e822a4a122d07946d959147d87ca922ee151708f | Rust | amiyatulu/Near-Fungible-Token | /near-contract-standards/src/storage_management/mod.rs | UTF-8 | 2,417 | 2.765625 | 3 | [] | no_license | use near_sdk::json_types::{ValidAccountId, U128};
use near_sdk::serde::Serialize;
#[derive(Serialize)]
#[serde(crate = "near_sdk::serde")]
pub struct StorageBalance {
pub total: U128,
pub available: U128,
}
#[derive(Serialize)]
#[serde(crate = "near_sdk::serde")]
pub struct StorageBalanceBounds {
pub min:... | true |
f4d1bcac968e6950ed8976318b97bc387a06c448 | Rust | likr/atcoder | /abc287/src/bin/d.rs | UTF-8 | 1,343 | 2.71875 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
#[... | true |
21650a4afef281766e2364ff77bf5ac25059a04b | Rust | curtisxk38/rcheer | /src/parse.rs | UTF-8 | 11,857 | 3.21875 | 3 | [] | no_license | use std::{fmt::format, iter::Peekable, slice::Iter};
use crate::{ast::{Binary, BinaryOp, Expr, Grouping, If, Literal, LiteralType, Unary, UnaryOp}, token::{Token, TokenType}};
pub enum ParseResult<'t> {
AST(Expr<'t>),
Error(ParseError)
}
pub struct ParseError {
pub message: String,
}
// program => expr... | true |
a4169857d0d373419bd24a708fb8dc5492164e90 | Rust | Velfi/Gray-Scott-Reaction-Diffusion | /src/gradient.rs | UTF-8 | 2,541 | 3.140625 | 3 | [] | no_license | use crate::utils::map_t_of_range_a_to_range_b;
use crate::utils::Interpolate;
use itertools::Itertools;
type Rgba = [u8; 4];
type TColor = (f32, Rgba);
struct Spectrum(Vec<TColor>);
impl Spectrum {
pub fn from_colors(color_a: Rgba, color_b: Rgba) -> Self {
Self(vec![(0f32, color_a), (1f32, color_b)])
... | true |
db79dfe83c1314eb511ac5e6dcc9ce2d3d6b7991 | Rust | jblindsay/whitebox-tools | /whitebox-tools-app/src/tools/math_stat_analysis/two_sample_ks_test.rs | UTF-8 | 21,482 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
This tool is part of the WhiteboxTools geospatial analysis library.
Authors: Dr. John Lindsay
Created: 21/10/2019
Last Modified: 24/10/2019
License: MIT
*/
use whitebox_raster::*;
use whitebox_common::rendering::html::*;
use whitebox_common::rendering::LineGraph;
use crate::tools::*;
use rand::prelude::*;
use std::... | true |
0ebcba35cab483e7ceeeccfec63bae6fe3150018 | Rust | IThawk/rust-project | /rust-master/src/test/ui/consts/const-eval/union-ub.rs | UTF-8 | 684 | 2.75 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #![allow(const_err)] // make sure we cannot allow away the errors tested here
#[repr(C)]
union DummyUnion {
u8: u8,
bool: bool,
}
#[repr(C)]
#[derive(Copy, Clone)]
enum Enum {
A,
B,
C,
}
#[derive(Copy, Clone)]
#[repr(C)]
union Foo {
a: bool,
b: Enum,
}
#[repr(C)]
union Bar {
foo: Foo... | true |
1a4890a9958311dd1c3ebdd94ef78db9950c4942 | Rust | wasv/cbor-telemetry-relay | /src/input.rs | UTF-8 | 2,154 | 2.71875 | 3 | [
"BSD-3-Clause"
] | permissive | extern crate serial;
use std::os::unix::net::UnixStream;
use std::process;
use std::fs::File;
use std::io::{self, BufRead, BufReader, Read};
use input::serial::prelude::*;
/// Serial Port settings. Defaults are fine, sinc$e BluePill autonegottaiates.
const SETTINGS: serial::PortSettings = serial::PortSettings {
... | true |
8ec679923a2e86acfa4f02153b986687aa60e3e4 | Rust | emimvi/pathtracer | /src/algebra/vec3.rs | UTF-8 | 9,451 | 3.359375 | 3 | [] | no_license | use std::f64;
use std::fmt;
use std::ops::*;
#[derive(Debug, Copy, Clone)]
pub struct Vec3<T = f64> {
pub x: T,
pub y: T,
pub z: T,
}
pub const BLACK: Vec3 = Vec3 {
x: 0.,
y: 0.,
z: 0.,
};
pub const WHITE: Vec3 = Vec3 {
x: 255.,
y: 255.,
z: 255.,
};
pub const GREY: Vec3 = Vec3 {
... | true |
064a16e871f69cbf9c1a7e94d4b6d058ea1f7c24 | Rust | prefixaut/aevum-rust | /src/tokenizer.rs | UTF-8 | 3,858 | 3.390625 | 3 | [
"MIT"
] | permissive | pub mod tokenizer {
struct Token {
is_text: bool;
text_content: String;
optional: bool;
type: char;
length: u8;
format: Vec<Token>;
}
enum State {
STRING,
ESCAPE_STRING,
ESCAPE_OPTIONAL_FORMAT,
IN_FORMAT,
IN_OPTIONAL_TY... | true |
23e5309f14a53ef3a1b9e409c0b5d363a069763a | Rust | sseg/rusty_sword_arena | /src/lib.rs | UTF-8 | 9,777 | 3.28125 | 3 | [
"MIT"
] | permissive | //! 💡 **Did You Know?** You can generate your own, offline version of this document by running this
//! command in your own clone of the repository.
//!
//! ```bash
//! cargo doc --lib --no-deps --open
//! ```
//!
//! **Other Tutorial References**
//!
//! - [Git repository for Rusty Sword Arena](https://github.com/Cle... | true |
cf289f714ca25ed15691a84c38146721e0f1830d | Rust | Piratach/livesplit-core | /src/rendering/mesh.rs | UTF-8 | 3,808 | 3.09375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use lyon::tessellation::{
geometry_builder::{
vertex_builder, BasicGeometryBuilder, FillGeometryBuilder, StrokeGeometryBuilder,
},
math::Point,
FillAttributes, StrokeAttributes, VertexBuffers,
};
/// The vertex types describes a single point of a mesh used to form triangles.
/// It uses a C com... | true |
0fb0fca0fc80febf81ec467b84d9bd9e0a712731 | Rust | Yuiki/rgit | /src/main.rs | UTF-8 | 7,434 | 2.65625 | 3 | [] | no_license | use flate2::write::ZlibEncoder;
use flate2::Compression;
use hex;
use sha1::{Digest, Sha1};
use std::env;
use std::fs;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::Result;
use std::os::unix::fs::MetadataExt;
use std::path::Path;
const DIR_ROOT: &'static str... | true |
ee5d2773b09ade3d4ca7714e5245cf14891fe222 | Rust | steamroller-airmash/serde-deserialize-over | /serde-deserialize-over/tests/derive_deserialize_with.rs | UTF-8 | 859 | 3.125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use serde_derive::Deserialize;
use serde_deserialize_over::DeserializeOver;
use std::time::Duration;
mod duration {
use serde::{Deserialize, Deserializer};
use std::time::Duration;
pub(super) fn deserialize<'de, D: Deserializer<'de>>(de: D) -> Result<Duration, D::Error> {
f64::deserialize(de).map(Duration::... | true |
ed0df57fd16447d244dc0188ef88efb7567abe00 | Rust | elaffey/bewbew | /sdk/src/auth.rs | UTF-8 | 2,741 | 2.96875 | 3 | [] | no_license | use error::Error;
use ring::signature::{Ed25519KeyPair, KeyPair, UnparsedPublicKey, ED25519};
use ring::{digest, pbkdf2};
use std::num::NonZeroU32;
use types::{Claims, Token};
pub fn gen_token(key_pair: &Ed25519KeyPair, email: &str) -> Result<Token, Error> {
let claims = Claims {
email: String::from(email)... | true |
d38a00ea938603dd63f809a1d4d126afc5f82484 | Rust | chickenbreeder/krebs | /src/config.rs | UTF-8 | 427 | 3 | 3 | [] | no_license | use std::net::SocketAddr;
pub struct Config {
pub addr: SocketAddr
}
impl Config {
pub fn with_port(port: u16) -> Config {
let addr = format!("127.0.0.1:{}", port).parse().expect("socket addr");
Config {
addr: addr
}
}
}
impl Default for Config {
fn default() -> C... | true |
b9d5bd9f476a23f482bfd1d41d8044e5033b40f0 | Rust | fluo10/timekeeper | /api/src/timekeeper.rs | UTF-8 | 989 | 2.859375 | 3 | [] | no_license | use chrono::{TimeZone, Weekday,ParseResult};
use chrono::prelude::{DateTime, Utc, Local, Datelike, Timelike};
pub struct Timekeeper{
lasttime: DateTime<Local>,
currenttime: DateTime<Local>
}
impl Timekeeper{
pub fn new() -> Timekeeper{
Timekeeper{
lasttime: Local::now(),
currenttime: Lo... | true |
54a6a9ec7725212760b37036e518e7d5649412ca | Rust | floydawong/LeetCode | /rust/108.rs | UTF-8 | 1,610 | 3.71875 | 4 | [] | no_license | /*
https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/
108. 将有序数组转换为二叉搜索树
将一个按照升序排列的有序数组,转换为一棵高度平衡二叉搜索树。
本题中,一个高度平衡二叉树是指一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过 1。
示例:
给定有序数组: [-10,-3,0,5,9],
一个可能的答案是:[0,-3,9,-10,null,5],它可以表示下面这个高度平衡二叉搜索树:
0
/ \
-3 9
/ /
-10 5
*/
// Defini... | true |
8f8f63d1995ae1e3ae1a642d265dde49a6c6caf9 | Rust | michaelwoerister/sip-endian | /main.rs | UTF-8 | 19,490 | 3.125 | 3 | [] | no_license |
use std::hash::Hasher;
fn main() {
let key = 0x1234_5678_9ABC_DEF0;
test(old::SipHasher128::new_with_keys(key, key), "old");
test(new::SipHasher128::new_with_keys(key, key), "new");
}
fn test<H: Hasher + Hasher128>(mut hasher: H, label: &str) {
hasher.write_u32(0xDDCCBBAA);
hasher.write_u8(0... | true |
9c99f32c5af74208a75b3b7505fa760ed6455ef7 | Rust | kildevaeld/tasks-rs | /tasks-vinyl/src/util.rs | UTF-8 | 1,146 | 2.875 | 3 | [] | no_license | use bytes::Bytes;
use futures_core::Stream;
use futures_io::AsyncRead;
use pin_project::pin_project;
use std::io::Error;
use std::pin::Pin;
use std::task::{Context, Poll};
#[pin_project]
pub struct ByteStream<R>(#[pin] R);
impl<R> ByteStream<R> {
pub fn new(read: R) -> ByteStream<R> {
ByteStream(read)
... | true |
c57bf51abfd6a01423bccbdaf5a6399d944982d6 | Rust | toVersus/ods-rs | /ex1/ex1-4.rs | UTF-8 | 1,652 | 3.53125 | 4 | [] | no_license | #![feature(test)]
extern crate test;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader, Read};
static DATAPATH: &'static str = "./data/ex1-4-sequence-of-numbers.txt";
fn push_bottom(stack: &mut Vec<i32>, x: i32) {
if stack.is_empty() {
stack.push(x);
return;
}
let... | true |
bfd6f8665bbaa808ad9e087c7025eff1564300d0 | Rust | nicu-chiciuc/advent_of_code_2019 | /day12/src/prob1.rs | UTF-8 | 3,109 | 3.4375 | 3 | [] | no_license | use std::collections::HashMap;
use std::collections::HashSet;
use std::env;
use std::fs;
use std::io;
#[derive(Debug, Clone, Eq, PartialEq)]
struct Vector {
x: i32,
y: i32,
z: i32,
}
impl Vector {
fn new() -> Vector {
Vector { x: 0, y: 0, z: 0 }
}
fn add(&mut self, other: &Vector) {
self.x += oth... | true |
ff437f352bc73396c2aa16e23c51f888cac42c62 | Rust | chromium/chromium | /third_party/rust/clap/v4/crate/src/util/color.rs | UTF-8 | 2,526 | 3.46875 | 3 | [
"BSD-3-Clause",
"Apache-2.0",
"MIT",
"GPL-1.0-or-later",
"LGPL-2.0-or-later"
] | permissive | use crate::builder::PossibleValue;
use crate::derive::ValueEnum;
/// Represents the color preferences for program output
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ColorChoice {
/// Enables colored output only when the output is going to a terminal or TTY.
///
/// **NOTE:** This is the default b... | true |
cc063c15fd8671965560071f53e1392fee37f14a | Rust | xmithd/xmithd-site | /src/entity/mod.rs | UTF-8 | 1,523 | 3.109375 | 3 | [] | no_license |
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct User {
pub name: String,
pub is_admin: u32,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct PostIdent {
// Post ID
pub id: u32,
// Post Title
pub title: String,
// Timestamp when it was creat... | true |
6da1b0bf30017ef9f69f072efda0a026d9812893 | Rust | Canop/walk_pace | /src/main.rs | UTF-8 | 3,399 | 3.421875 | 3 | [] | no_license | use std::path::{Path, PathBuf};
use std::fs;
use std::time::Instant;
use walkdir::{self, WalkDir};
////////// Just counting
// count files using walkdir::WalkDir
fn count_files_walking(path: &Path) -> u32 {
let mut n: u32 = 0;
for e in WalkDir::new(path) {
if let Ok(_) = e {
n += 1;
... | true |
5cc731486b147519e2827f135b47211093179fdc | Rust | isgasho/ssf | /ssf/src/verify/type_check/type_checker.rs | UTF-8 | 5,603 | 3.1875 | 3 | [
"MIT"
] | permissive | use super::error::TypeCheckError;
use crate::ast::*;
use crate::types::{self, Type};
use std::collections::*;
#[derive(Clone, Debug)]
pub struct TypeChecker {}
impl TypeChecker {
pub fn new() -> Self {
Self {}
}
pub fn check(&mut self, module: &Module) -> Result<(), TypeCheckError> {
let ... | true |
5cab9a42156e0e1c767d6e12eac28856105469a7 | Rust | welociraptor/adventofcode-2019 | /src/03/main.rs | UTF-8 | 4,733 | 3.609375 | 4 | [] | no_license | use std::collections::HashSet;
use std::fs;
fn main() {
let input = fs::read_to_string("src/03/input.txt").expect("error reading input");
let mut data = Vec::new();
for i in input.lines() {
data.push(i);
}
let wire0 = Wire::new(data[0]);
let wire1 = Wire::new(data[1]);
println!(
... | true |
82b44c35090b0ace40d49e96ac74385eb5896316 | Rust | EoinDavey/Competitive | /AdventOfCode2018/rust/d06/src/main.rs | UTF-8 | 2,982 | 2.859375 | 3 | [] | no_license | #![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use std::ops::RangeInclusive;
use std::collections::LinkedList;
use std::collections::HashMap;
use std::collections::HashSet;
fn ns(pt: (i32, i32)) -> Vec<(i32, i32)> {
return [(0, 1), (1, 0), (-1, 0), (0, -1)].iter()
.map(|(dx, dy... | true |
9bd024a664fd0d22bd84624088c7bbca4413aaa0 | Rust | actix/actix-web | /awc/src/test.rs | UTF-8 | 3,492 | 3.234375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Test helpers for actix http client to use during testing.
use actix_http::{h1, header::TryIntoHeaderPair, Payload, ResponseHead, StatusCode, Version};
use bytes::Bytes;
#[cfg(feature = "cookies")]
use crate::cookie::{Cookie, CookieJar};
use crate::ClientResponse;
/// Test `ClientResponse` builder
pub struct Test... | true |
716fec856abe2658f548450012d7639b433cf97c | Rust | adrianloh/rustyone | /src/bin/channelretry.rs | UTF-8 | 2,879 | 3.109375 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::str::FromStr;
use std::thread;
use crossbeam::channel::{self, Receiver, Sender};
#[derive(Debug)]
struct Doug(String, u64);
const THREADS: usize = 8;
const ZEROLEN: u64 = 0;
fn main() {
// The pipe looks like this:
// get --> get... | true |
c087fcfd56e0eaa5337de5a52d65dea5fb4adbfb | Rust | fasterthanlime/wrt | /bindings/src/async_util.rs | UTF-8 | 3,353 | 2.734375 | 3 | [] | no_license | use std::sync::{Arc, Condvar, Mutex};
use crate::generated::windows::foundation::{
AsyncActionCompletedHandler, AsyncActionWithProgressCompletedHandler,
AsyncOperationCompletedHandler, AsyncOperationWithProgressCompletedHandler, AsyncStatus,
IAsyncAction, IAsyncActionWithProgress, IAsyncInfo, IAsyncOperati... | true |
9bf5f6bebd5c3c5ef19d31c223a4ecf10d6248a3 | Rust | namalkanti/DynamicEntryBot | /src/api/serenity.rs | UTF-8 | 6,375 | 2.5625 | 3 | [] | no_license | use std::sync::mpsc;
use super::api::ApiMessage;
//Typedefs for mpsc channels
pub type Tx = mpsc::Sender<ApiMessage>;
pub type Rx = mpsc::Receiver<ApiMessage>;
pub type MTx = mpsc::Sender<String>;
pub type MRx = mpsc::Receiver<String>;
///Spawns external api and waits for close signal
pub fn spawn_api(token: String... | true |
bbc05953b292231ab8c88ee3d9c7e3203139999a | Rust | TheRincon/rexsearch | /src/io/file_utils.rs | UTF-8 | 334 | 2.578125 | 3 | [] | no_license |
pub fn collect_strings(file_path: &str) -> Vec<String> {
let reader = fasta::Reader::from_file(file_path.to_string()).unwrap();
let mut string_vec = Vec::new();
for (i, mut result) in enumerate(reader.records()) {
let mut rec = result.unwrap();
string_vec.push(rec.seq_string())
}
... | true |
defac17d86cb09ec5647c362584fdf2b9a80eb8a | Rust | 0xflotus/noria | /noria/src/channel/poll.rs | UTF-8 | 16,060 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::rpc::*;
use super::tcp::*;
use mio::net::{TcpListener, TcpStream};
use mio::{Events, Poll, PollOpt, Ready, Token};
use serde::de::DeserializeOwned;
use serde::Serialize;
use std;
use std::net::SocketAddr;
use std::time::Duration;
const LISTENER: usize = 0;
const CHANNEL_OFFSET: usize = LISTENER + 1;
const ... | true |
16cf75922f9de4f6a499d90165e33a80702f45a7 | Rust | argmin-rs/argmin | /argmin-math/src/ndarray_m/sub.rs | UTF-8 | 7,469 | 2.5625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright 2018-2022 argmin developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according... | true |
09616e0a0276e6ea3e6b6db35e835e510ff31d50 | Rust | rymndhng/advent-of-code-2020 | /src/day10.rs | UTF-8 | 4,364 | 3.21875 | 3 | [] | no_license | use std::collections::HashMap;
use std::io::BufReader;
use std::fs::File;
use std::io::prelude::*;
#[allow(dead_code)]
pub fn main() -> std::io::Result<()> {
let file = File::open("input/010.txt")?;
let reader = BufReader::new(file);
let mut joltage = reader
.lines()
.map(|s| s.unwrap().par... | true |
5f81be722a33b3971cba068d5b60d97278b5fa62 | Rust | doytsujin/rustcommon | /histogram/src/bucket/mod.rs | UTF-8 | 952 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use crate::Counter;
/// A bucket stores a count across a range of values
pub struct Bucket<Value, Count> {
pub(crate) min: Value,
pub(crate) max: Value,
pub(crate) value: Value,
... | true |
fd775f6a6fc398a7daf961058b56d6c6d41e01be | Rust | veminovici/kaantor | /kaantor/src/protocol/message.rs | UTF-8 | 1,226 | 2.6875 | 3 | [] | permissive | use crate::{ActorId, IntoActorId, SenderId, SessionId};
use actix::prelude::*;
use log::info;
use std::fmt::Debug;
pub struct ProtocolMsg<P> {
sid: SenderId,
kid: SessionId,
pld: P,
}
impl<P: Debug> Debug for ProtocolMsg<P> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
... | true |
d505e20f7cca201a8f3c82ff1667bf1f1073978b | Rust | graphprotocol/graph-node | /runtime/wasm/src/module/into_wasm_ret.rs | UTF-8 | 1,327 | 2.515625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use never::Never;
use wasmtime::Trap;
use graph::runtime::AscPtr;
/// Helper trait for the `link!` macro.
pub trait IntoWasmRet {
type Ret: wasmtime::WasmRet;
fn into_wasm_ret(self) -> Self::Ret;
}
impl IntoWasmRet for () {
type Ret = Self;
fn into_wasm_ret(self) -> Self {
self
}
}
impl... | true |
d16a78499f86b6362f84bb290b970dc23ee0e484 | Rust | Vengarioth/tinypath | /src/segment.rs | UTF-8 | 452 | 3.203125 | 3 | [
"MIT"
] | permissive | #[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub enum Segment {
Separator,
Segment(String),
Dot,
DotDot,
}
impl Segment {
pub fn get_segment(&self) -> Option<&str> {
match self {
Segment::Segment(ref segment) => Some(segment),
_ => None,
}
}
pub fn i... | true |
e748a817e9c9ad4f9efc08713fd2e6eb903ac004 | Rust | eldruin/pcf857x-rs | /src/pin_flag.rs | UTF-8 | 2,634 | 3.828125 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Pin flag definition
/// I/O pin flags, used to select which pins to read in the `get` functions.
/// It is possible to select multiple of them using the binary _or_ operator (`|`).
/// ```
/// # use pcf857x::PinFlag;
/// let pins_to_be_read = PinFlag::P0 | PinFlag::P1;
/// ```
/// Note that P10-17 can only be used... | true |
9be081f784732b4313590e7f98887a83173eea0c | Rust | actix/actix-web | /actix-http/src/ws/frame.rs | UTF-8 | 12,245 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::cmp::min;
use bytes::{Buf, BufMut, BytesMut};
use tracing::debug;
use super::{
mask::apply_mask,
proto::{CloseCode, CloseReason, OpCode},
ProtocolError,
};
/// A struct representing a WebSocket frame.
#[derive(Debug)]
pub struct Parser;
impl Parser {
fn parse_metadata(
src: &[u8],
... | true |
a286f6685609e2d12b65f482ba1178004a6c7449 | Rust | Berna-L/advent-of-code-2020 | /src/day5/code.rs | UTF-8 | 1,432 | 3.3125 | 3 | [] | no_license | use regex::Regex;
use std::fs::File;
use std::io;
use std::io::BufRead;
use std::iter::FromIterator;
use std::path::Path;
pub fn day_5_puzzle_1() {
let path = Path::new("src/day5/input.txt");
let file = File::open(&path).expect("Could not open file");
let mut seat_ids = read_seat_ids(file);
println!(... | true |
9631d1908213a22a094ac02e5d286d7f0781c84d | Rust | JaBoG32-Warblade/DATIS | /crates/datis-module/src/mission_info.rs | UTF-8 | 6,951 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::str::FromStr;
use std::sync::{Arc, Mutex};
use anyhow::Context;
use datis_core::{
mission_info::{Clouds, MissionInfo, WeatherInfo},
station::Position,
};
use hlua51::{Lua, LuaFunction, LuaTable};
#[derive(Debug)]
pub struct DcsMissionInfoInner {
lua: Lua<'static>,
clouds: Option<Clouds>,
... | true |
9f910df5b61f921346c8b207b2edf94943927c00 | Rust | Dushistov/flapigen-rs | /cpp-example/rust-part/src/lib.rs | UTF-8 | 573 | 3.046875 | 3 | [
"BSD-3-Clause"
] | permissive | // ANCHOR: connect
mod cpp_glue;
pub use crate::cpp_glue::*;
// ANCHOR_END: connect
// ANCHOR: rust_class
pub struct Foo {
data: i32,
}
impl Foo {
fn new(val: i32) -> Foo {
Foo { data: val }
}
fn f(&self, a: i32, b: i32) -> i32 {
self.data + a + b
}
fn set_field(&mut self, v:... | true |
f5d18ef37b9fe4bfbd690f23c60c68fcc54329b2 | Rust | srufle/maze-book-rs | /src/maze/binary_tree.rs | UTF-8 | 2,020 | 3.1875 | 3 | [
"Apache-2.0"
] | permissive | use crate::maze::Grid;
use crate::maze::utils;
pub fn generate(maze: &mut Grid) {
for row in 0..maze.length() {
for col in 0..maze.width() {
if maze.at_upper_right(col, row) {
// nothing to do. just leave alone
} else if maze.at_upper(row) {
maze.link... | true |
e4e55fb8fa153533c58316c6dcbbe0cd07cb61c0 | Rust | canova/container-rs | /src/pull.rs | UTF-8 | 533 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::registries::{DockerRegistry, Registry};
use crate::Result;
/// Main entry for the pull subcommand
/// TODO: Move all the subcommands into their own directory.
pub async fn pull(args: &clap::ArgMatches<'static>) -> Result<()> {
let registry = args.value_of("registry").unwrap();
let mut registry = match r... | true |
abb25053d73fa0ead3c827d4f7e05733912046e4 | Rust | xiaozan-dev/Horust | /src/horust/supervisor/repo.rs | UTF-8 | 3,802 | 2.9375 | 3 | [
"MIT"
] | permissive | use crate::horust::bus::BusConnector;
use crate::horust::formats::{Service, ServiceName};
use crate::horust::supervisor::service_handler::ServiceHandler;
use crate::horust::Event;
use nix::unistd::Pid;
use std::collections::HashMap;
#[derive(Debug)]
pub(crate) struct Repo {
pub services: HashMap<ServiceName, Servi... | true |
3fd5504171eabad5e69c71be5976c0a390fb5e1f | Rust | LaylBongers/markedly | /markedly/src/component.rs | UTF-8 | 7,716 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use nalgebra::{Point2, Vector2};
use class::{ComponentClass};
use render::{Renderer};
use scripting::{ScriptRuntime};
use template::{ComponentTemplate, Style, TemplateValue, Attributes, Coordinates};
use {ComponentId, Error, Context, EventSink};
/// A component generated from a template, active in a UI.
pub struct Co... | true |
a2d3d09fec6a739b0d483f8a119cb2b7a908d4af | Rust | terryyrliang/rust-http2 | /httpbis/src/client/req.rs | UTF-8 | 3,226 | 2.75 | 3 | [
"MIT"
] | permissive | use crate::assert_types::assert_send;
use crate::client::types::ClientTypes;
use crate::common::sender::CommonSender;
use crate::common::sender::SendError;
use crate::common::window_size::StreamDead;
use crate::result;
use crate::ErrorCode;
use crate::Headers;
use crate::HttpStreamAfterHeaders;
use crate::SenderState;... | true |
76180aeb2bb5cccd1e78bb5a9062ccc8efebb7db | Rust | L3pereira/exchange_interface | /orderbook/common/src/bitstamp_config_utils.rs | UTF-8 | 2,031 | 2.640625 | 3 | [] | no_license | use std::collections::HashMap;
use anyhow::Result;
use url::Url;
use serde::{Deserialize, Deserializer};
use tokio_tungstenite::tungstenite::protocol::Message;
use crate::*;
#[derive(Deserialize)]
#[derive(Clone, Debug)]
pub struct BitstampConfiguration {
#[serde(deserialize_with = "to_url")]
websocket_base_u... | true |
b2bd244abd8ad62c68e81efaec303f28c1553fe3 | Rust | alastairong/lair | /crates/lair_keystore_api/src/internal/crypto_box.rs | UTF-8 | 10,910 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | use crate::internal::rayon::rayon_exec;
use crate::internal::x25519;
use block_padding::Padding;
use crypto_box as lib_crypto_box;
use std::sync::Arc;
/// Length of the crypto box aead nonce.
/// Ideally this would be exposed from upstream but I didn't see a good way to get at it directly.
pub const NONCE_BYTES: usize... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.