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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
97d03e67e3ed370a792cc1b4278d8e41e390c542 | Rust | stevenleadbeater/oil-level-monitor | /oil-level-monitor/src/mapper/distance_history_mapper.rs | UTF-8 | 1,087 | 2.875 | 3 | [] | no_license | use crate::model::distance_history::DistanceHistory;
use std::time::SystemTime;
use tokio_postgres::Row;
pub fn map_one(rows: Vec<Row>) -> Result<DistanceHistory, String> {
if rows.len() != 1 {
return Err("Expecting exactly one row for queries by id".to_string());
}
if rows.get(0).unwrap().len() !=... | true |
88477ad2bc5107b239dfb4b65f6d62837f50bade | Rust | little-dude/xi-editor | /rust/core-lib/src/tabs.rs | UTF-8 | 11,252 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2016 Google Inc. All rights reserved.
//
// 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... | true |
8932fc100c214349b9cf617864b5efc1c6a9bfce | Rust | racer161/pipeline-rs | /src/server_core/event_handler/mod.rs | UTF-8 | 1,374 | 2.921875 | 3 | [] | no_license | extern crate serde_json;
extern crate ws;
use ws::{listen, Handler, Sender, Message, CloseCode};
use serde_json::{Value};
use std::io;
use std::result::Result;
use std::path::Path;
mod file_manager;
pub fn handle_message(message : String) -> Result<Message, io::Error>
{
// Parse the string of data into serde_jso... | true |
dbb2de7bdc7443171fb1c62c7dafb99ad95d0aba | Rust | jarod/rust-assimp | /src/material.rs | UTF-8 | 36,544 | 3.21875 | 3 | [
"MIT"
] | permissive | //! Defines the material system of the library
use libc::{c_uchar, c_uint, c_float};
use std::{ptr, mem};
use types::{Vector2D, AiString, Return};
use util::{ptr_ptr_to_slice, ptr_to_slice};
use ffi;
// /// Name for default materials (2nd is used if meshes have UV coords)
// const AI_DEFAULT_MATERIAL_NAME : &'static... | true |
6ccbe4f8824bf0aa202227a7d9dfbf870735465c | Rust | LorenzoEvans/kurogane_os | /tests/stack_overflow.rs | UTF-8 | 2,112 | 2.625 | 3 | [] | no_license | #![feature(abi_x86_interrupt)]
#![no_std]
#![no_main]
use kurogane_os::serial_print;
use kurogane_os::{exit_qemu, QemuExitCode, serial_println};
use x86_64::structures::idt::InterruptStackFrame;
use core::panic::PanicInfo;
use lazy_static::lazy_static;
use x86_64::structures::idt::InterruptDescriptorTable;
extern "x86... | true |
ac401723ad97a594d6b41085d58c33d0909ad4a6 | Rust | jpalip/RustGlass | /src/lang/lexer/position/fragment.rs | UTF-8 | 1,156 | 3.015625 | 3 | [] | no_license | use crate::errorsystem::dispatch_error;
use crate::errorsystem::error_type::ErrorType;
use crate::lang::lexer::position::Position;
pub struct PositionFragment {
source: String,
pos: Position,
}
impl PositionFragment {
pub fn new(source: String, pos: Position) -> Self {
return PositionFragment { so... | true |
e484a26e76df205cd25bc2d6239365577b0456fe | Rust | IsaacShelton/phpxx | /src/lex.rs | UTF-8 | 2,927 | 3.546875 | 4 | [
"MIT"
] | permissive | use logos::Logos;
use std::ops::Range;
pub struct Tokens<'a> {
items: &'a [Token],
spans: &'a [Range<usize>],
next: usize
}
impl<'a> Tokens<'a> {
pub fn new(items: &'a [Token], spans: &'a [Range<usize>]) -> Tokens<'a> {
Tokens { items: items, spans: spans, next: 0 }
}
pub fn peek(&sel... | true |
66923af3da1556754f0d7979ed899aa0d93a13e3 | Rust | tglanz/mypl | /mypl_ast/src/ast.rs | UTF-8 | 2,504 | 3.09375 | 3 | [] | no_license | use mypl_lex::prelude::*;
#[derive(Clone, Debug, PartialEq, Copy)]
pub enum BinOp {
Add,
Sub,
Mul,
Div,
Rem,
And,
Or,
Eq,
Lt,
Le,
Ne,
Ge,
Gt,
}
impl BinOp {
pub fn as_code(&self) -> &str {
match self {
BinOp::Add => "+",
BinOp::S... | true |
5aad13ca1e2ea40b6301c670f39c2f19c0d8d75e | Rust | chaintope/openassets-tapyrus | /src/openassets/address.rs | UTF-8 | 7,517 | 2.875 | 3 | [
"MIT"
] | permissive | use std::fmt::{self, Display, Formatter};
use tapyrus::consensus::encode;
use tapyrus::hashes::hex::FromHex;
use tapyrus::network::constants::Network;
use tapyrus::util::address::Payload;
use tapyrus::util::base58;
/// A Open Assets Address
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Address {
... | true |
c178d188b7518595f8e2bf5514e13aac18f93a2f | Rust | GuVictory/current_lines_2d | /src/msh_worker/render.rs | UTF-8 | 1,740 | 3.046875 | 3 | [
"MIT"
] | permissive | use crate::entity::node::Node;
use std::fs::OpenOptions;
use std::io::{Error, Write};
pub struct GeoRenderer {
size: f64,
main_counter: usize,
node_counter: usize,
}
impl GeoRenderer {
pub fn new(size: f64) -> GeoRenderer {
let mut file = OpenOptions::new()
.create(true)
... | true |
f1746d99abe2acb8b67b2c75d65c64e467b62265 | Rust | oliver-giersch/webview_rs | /src/error.rs | UTF-8 | 1,931 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::error::Error;
use std::ffi::{FromBytesWithNulError, NulError};
use std::fmt;
use self::WebviewError::*;
use crate::conversion::CStrConversionError;
use crate::ffi::LibraryError;
#[derive(Debug)]
pub enum WebviewError {
Build,
DispatchFailed,
Library(LibraryError),
InvalidPath,
InvalidStr(... | true |
b7d2c250c68e3dc0f0bcd521cf2ec66f1e1a4204 | Rust | alisomay/koto_midi | /midi/src/message/channel_voice.rs | UTF-8 | 7,703 | 2.640625 | 3 | [
"MIT"
] | permissive | use crate::impl_midi_message;
use crate::Category;
use crate::MidiMessage;
#[derive(Debug)]
pub struct NoteOff {
bytes: [u8; 3],
pub category: Category,
}
impl NoteOff {
pub fn new(note: u64, velocity: u64, channel: u64) -> Self {
Self {
bytes: [
0x80 | channel.min(15) a... | true |
a9c6129df54789c88c0279df94ec42443b683e13 | Rust | Wind-River/rust | /src/test/ui/half-open-range-patterns/half-open-range-pats-exhaustive-pass.rs | UTF-8 | 1,319 | 2.765625 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | // check-pass
// Test various exhaustive matches for `X..`, `..=X` and `..X` ranges.
#![feature(half_open_range_patterns)]
#![feature(exclusive_range_pattern)]
fn main() {}
macro_rules! m {
($s:expr, $($t:tt)+) => {
match $s { $($t)+ => {} }
}
}
macro_rules! test_int {
($s:expr, $min:path, $max... | true |
728b9e1fdc6fcf795135b4ba4ad78803ad3e93af | Rust | tamamu/roman-numeral-parser | /src/main.rs | UTF-8 | 7,220 | 3.3125 | 3 | [] | no_license |
use std::env;
use std::io;
#[derive(Debug, Clone)]
enum Token {
One(usize),
Five(usize)
}
#[derive(Debug)]
enum ParseError {
UnknownCharacter,
NoInput,
IllegalAlignment,
Unknown
}
struct Parser {
src: String,
pos: usize,
toks: Vec<Token>,
result: usize,
max: usize
}
impl... | true |
3cff26cf6993c5bff614f68048e3100309f992e8 | Rust | huggingface/tokenizers | /tokenizers/src/models/wordlevel/mod.rs | UTF-8 | 6,966 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use super::OrderedVocabIter;
use crate::tokenizer::{Model, Result, Token};
use serde_json::Value;
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufReader, Read, Write};
use std::path::{Path, PathBuf};
mod serialization;
mod trainer;
// Re-export
pub use trainer::*;
type Vocab = HashMap<String, u32>... | true |
ba09eea5dc2fdc9aed2eac79abfd4f9267789f29 | Rust | Phibonacci/adventofcode2020 | /day03/src/main.rs | UTF-8 | 1,874 | 3.625 | 4 | [] | no_license | fn main() {
let before = std::time::Instant::now();
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
panic!("Not enough arguments");
}
let filename = &args[1];
println!("Loading file {}", filename);
let data = parse_file(filename);
part1(&data);
part2(&data);
println!("Tot... | true |
d491dba1ad1454251ed778430e1efce2788c229d | Rust | BenMcH/conrod | /src/widget/canvas.rs | UTF-8 | 20,352 | 3.203125 | 3 | [
"MIT"
] | permissive | use {
CharacterCache,
Color,
Colorable,
Dimensions,
FontSize,
Frameable,
FramedRectangle,
FramedRectangleStyle,
IndexSlot,
Labelable,
Padding,
Place,
Position,
Positionable,
Range,
Rect,
Scalar,
Sizeable,
TextStyle,
Theme,
TitleBar,
... | true |
661d0ad63b5d494d0a81bb744c280d148d8aed63 | Rust | tsmarsh/archese | /archese/src/lib.rs | UTF-8 | 215 | 2.75 | 3 | [] | no_license | pub fn tokenize(program: &str) -> Vec<String>{
program.replace("(", " ( ")
.replace(")", " ) ")
.split(" ")
.filter(|s| !s.is_empty())
.map(|s| s.to_owned())
.collect()
}
| true |
3170d5b243708b270633d283e3e000efcf04e109 | Rust | rrybarczyk/strs | /src/run.rs | UTF-8 | 3,655 | 3.453125 | 3 | [
"CC0-1.0"
] | permissive | use crate::error::{Error};
use std::{fs::File, io::Read, path::PathBuf};
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "strs")]
struct Config {
/// Minimum string length
#[structopt(
short = "n",
long = "number",
default_value = "4",
help = "Specify th... | true |
5df07e753b55e5f6bb4371b9390208f819f73475 | Rust | nonnish/musicio | /src/main.rs | UTF-8 | 4,925 | 2.6875 | 3 | [
"MIT"
] | permissive | use crossbeam_channel::bounded;
use directories::BaseDirs;
use libpulse_binding::error::Code;
use libpulse_binding::sample;
use libpulse_binding::stream::Direction;
use libpulse_simple_binding::Simple;
use serde::{Deserialize, Serialize};
use std::fs;
use std::io::ErrorKind;
use std::path::PathBuf;
use std::thread;
#[... | true |
be3c32dfaea38ae91b8bb25969a51f6b54a80470 | Rust | pygaur/Rust-Training | /examples/01-variables-and-types/shadow_constants.rs | UTF-8 | 117 | 2.90625 | 3 | [] | no_license | fn main() {
const THE_ANSWER : i32 = 42;
let THE_ANSWER = 7;
println!("The answer is {}", THE_ANSWER)
}
| true |
37fa35f0288f008ee4a48a69433ad3317d508e26 | Rust | visd0m/yaged | /src/decoder/steps/image_descriptor.rs | UTF-8 | 957 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::decoder::steps::nth_bit;
use crate::types::ImageDescriptor;
pub fn decode(bytes: &[u8], cursor: usize) -> (ImageDescriptor, usize) {
let to_index = cursor + 10;
let image_descriptor = &bytes[cursor..to_index];
let image_left = ((image_descriptor[2] as u16) << 8) | image_descriptor[1] as u16;
... | true |
923bb1adf60ef53b01d1b4445d86dcef1b05f193 | Rust | IsaSca/rustCaesar | /src/main.rs | UTF-8 | 1,247 | 3.6875 | 4 | [
"MIT"
] | permissive | mod cipher_decipher;
use std::io;
use cipher_decipher::encipher;
use crate::cipher_decipher::decipher;
fn main() {
let decipher = String::from("d\n");
let encipher = String::from("e\n");
let mut choice = String::new();
println!("Do you want to decipher(d) or encipher(e)?");
io::stdin()
.re... | true |
7bdfccedfd676b96b8b715072b1ce93e236e1a91 | Rust | skillzaa/qndr | /src/main.rs | UTF-8 | 461 | 2.875 | 3 | [] | no_license | use qndr;
fn main(){
let result_a = qndr::begin_with_alphanumeric(&String::from("!!!!Hayyy"));
assert_eq!(false,result_a);
let result_b = qndr::begin_with_alphabet(&String::from("_1234?"));
assert_eq!(false,result_b);
let result_c = qndr::allow_alphabets_only(&String::from("0123456789"));
assert_eq!(false,result_c)... | true |
a799b0d8af296a7f4977cca8bc43adb70d13ba6c | Rust | cmsd2/recon | /archive/recon-gossip/src/service.rs | UTF-8 | 4,796 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use tokio_core::reactor::Handle;
use futures::{self, Async, Future, Stream, Sink, Poll};
use futures::sync::mpsc::{channel, Sender, Receiver};
use std::io;
use std::net::{SocketAddr, TcpListener};
use ::framing::*;
pub trait AsyncService {
type Request;
type Error;
fn send(&self, req: Self::Request) -> io:... | true |
554b906b2950a80241856bf0c1401c55acabe485 | Rust | viruscamp/rust-play | /reentrant_lock/src/reentrant_lock.rs | UTF-8 | 2,701 | 3.21875 | 3 | [] | no_license | use std::{cell::RefCell, ops::{Deref, DerefMut}, sync::{Mutex, MutexGuard}};
use std::rc::Rc;
use lockfree::tls::ThreadLocal;
/// add extention method reentrant_lock for Mutex<T: ?Sized>
///```rust
/// extern crate reentrant_lock;
/// use std::sync::Mutex;
/// use reentrant_lock::{ReentrantMutex, ReentrantMute... | true |
591ffcaed62661aa6b705c0d3f553028fc99894e | Rust | alienfacepalm/www | /src/slideshows.rs | UTF-8 | 3,201 | 2.8125 | 3 | [
"MIT"
] | permissive | use util::{nl,create_el};
use stdweb::web::event::{
ClickEvent,
KeyUpEvent
};
use stdweb::traits::*;
use stdweb::unstable::TryInto;
use stdweb::web::{
document,
window,
HtmlElement
};
macro_rules! prev_next {
($slideshow:expr, $slides:expr, $dir:expr) => {
let data_index: usize = $slideshow.get_attribu... | true |
da4468bcbfcd92bf224480403c596714653e2112 | Rust | hopv/hoice | /src/learning/ice/synth/helpers.rs | UTF-8 | 15,875 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | //! Macros factoring code for the synthesis process.
use super::TermVals;
use crate::common::*;
/// Applies `$f` to `$term`.
///
/// Early returns if the application is an error. Early returns `Ok(true)` if
/// the application yields true.
macro_rules! apply {
($f:ident to $term:expr) => {
if $f($term)? {... | true |
46bfacc97248a50db36b14f7af963af89e2de629 | Rust | try-harder/rhyme-harder-rust | /rhyme-harder.rs | UTF-8 | 2,732 | 3.03125 | 3 | [] | no_license | use std;
#[test]
fn testLettersDontRepeat_passIfTrue()
{
assert lettersDontRepeat("ab".chars());
}
#[test]
fn testLettersDontRepeat_failIfFalse()
{
assert !lettersDontRepeat("aba".chars());
}
#[test]
fn testAFirstIfPresent_passIfIs()
{
assert aIsFirstIfPresent("ab".chars());
}
#[test]
fn testAFirstIfPresent_pass... | true |
fda0eec81262dfda9f4632671896764e6380c1fe | Rust | vaibhavantil2/third-party-api-clients | /docusign/src/envelope_document_fields.rs | UTF-8 | 6,802 | 2.734375 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use crate::Client;
pub struct EnvelopeDocumentFields {
pub client: Client,
}
impl EnvelopeDocumentFields {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
EnvelopeDocumentFields { client }
}
/**
* Gets the custom document fields from an existing envelope doc... | true |
d99b084bc41695442808fd1eb0bddecd42dea38f | Rust | muandrew/pcx | /src/low_level/rle.rs | UTF-8 | 8,008 | 3.3125 | 3 | [
"WTFPL"
] | permissive | //! Implementation of compression/decompression using variant of RLE (run-length-encoding) used in PCX files.
use std::io;
use byteorder::{ReadBytesExt, WriteBytesExt};
/// Decompress RLE.
#[derive(Clone, Debug)]
pub struct Decompressor<S: io::Read> {
stream: S,
run_count: u8,
run_value: u8,
}
impl<S: i... | true |
04c8d9c1bf6288d100e4284a0d5f20ba6d64dac7 | Rust | triplef87/advent_of_code_2015 | /day_4/src/main.rs | UTF-8 | 620 | 2.84375 | 3 | [] | no_license | extern crate crypto;
use crypto::md5::Md5;
use crypto::digest::Digest;
fn main() {
let base = "iwrupvqb";
let mut counter = 0;
loop {
let hash = format!("{}{}", base, counter);
let mut encode = Md5::new();
encode.input_str(&hash);
let result = encode.result_str();
... | true |
9ea9344ae22df5e05819ba2dd5ad213578937e17 | Rust | dvshur/grpc-postgres-template | /src/repo.rs | UTF-8 | 658 | 2.75 | 3 | [] | no_license | use crate::error::*;
use sqlx::PgPool;
#[derive(Debug)]
pub enum Platform {
IOS,
Android,
}
#[derive(Clone)]
pub struct Repo {
pgpool: PgPool,
}
impl Repo {
// pgpool should probably be borrowed in order to be reused between repos
pub fn new(pgpool: &PgPool) -> Self {
Repo {
p... | true |
81f1f43c2290d2e5c839ce274c94a53023b20884 | Rust | humb1t/unleash-client-rust | /src/http.rs | UTF-8 | 2,045 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Cognite AS
//! The HTTP Layer
use http_types::headers;
pub struct HTTP {
authorization_header: headers::HeaderName,
app_name_header: headers::HeaderName,
instance_id_header: headers::HeaderName,
app_name: String,
instance_id: String,
authorization: Option<String>,
client:... | true |
6f1311b185cf018eb78dfaf81efa93c12d217f98 | Rust | ayosec/netusage | /src/devices.rs | UTF-8 | 1,470 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
#[derive(PartialEq, Debug)]
pub struct Device {
pub interface: String,
pub rx: isize,
pub tx: isize,
}
impl Device {
pub fn new(interface: &str, rx: isize, tx: isize) -> Device {
Device {
interface: interfac... | true |
6e0af355f5324b4ef8322679ed8b7332aa895438 | Rust | a-dma/aoc17 | /day14/src/main.rs | UTF-8 | 3,811 | 2.640625 | 3 | [] | no_license | #![feature(slice_rotate)]
extern crate petgraph;
use petgraph::algo::connected_components;
use petgraph::graphmap::UnGraphMap;
use std::fs::File;
use std::io::{BufReader, BufRead, Seek, SeekFrom};
const STANDARD_SUFFIX: &[u8] = &[17, 31, 73, 47, 23];
fn sparse_hash(list: &mut [u8], lengths: &mut Vec<u8>, rounds: u... | true |
b9d2234ff574cb4f4854e543317e0005aeb38e6e | Rust | isgasho/beek | /src/interpreter/env.rs | UTF-8 | 8,447 | 3.34375 | 3 | [
"MIT"
] | permissive | use super::{EvalError, EvalResult};
use crate::language::{Expression, Identifier, Number};
use rand::Rng;
use std::{
collections::{HashMap, HashSet},
fmt,
};
#[derive(Debug, Clone)]
pub enum Field {
Variable(Number),
Constant(Number),
}
impl fmt::Display for Field {
fn fmt(&self, f: &mut fmt::Form... | true |
456628d0bc27bdf982871f31edfa7c613678c062 | Rust | MGlolenstine/kaitai-rs | /kaitai/tests/fixed.rs | UTF-8 | 745 | 2.921875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use kaitai::{kaitai_source, KaitaiStruct};
#[kaitai_source("formats/fixed.ksy")]
pub struct Fixed;
#[test]
fn fixed_ok() {
let mut input: Vec<u8> = Vec::new();
input.extend(b"test string");
input.extend(&[0xab, 0xad, 0xba, 0xbe]);
input.extend(&[0x12, 0x34]);
let result = Fixed::from_bytes(&input... | true |
0982b0bbbc75f37018789b55e700b17ad93334ab | Rust | billyfbrain/cache | /src/slru.rs | UTF-8 | 9,065 | 2.890625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::borrow::Borrow;
use std::collections::hash_map::RandomState;
use std::hash::{BuildHasher, Hash};
use std::ptr;
use super::map::LinkedHashMap;
const DEFAULT_MAIN_CF: f64 = 0.75;
pub struct Cache<K, V, S = RandomState> {
max_size: usize,
max_size_in: usize,
max_size_main: usize,
hit_count: us... | true |
dc854a54e7ca6233b9697e28b4945f5c9951085b | Rust | samothx/balena-migrate-rs | /src/linux/util.rs | UTF-8 | 2,343 | 2.6875 | 3 | [] | no_license | use failure::{Fail, ResultExt};
use log::debug;
use regex::Regex;
use std::fs::read_to_string;
use std::io::Read;
const MODULE: &str = "Linux::util";
const WHEREIS_CMD: &str = "whereis";
use crate::common::call;
use crate::{MigErrCtx, MigError, MigErrorKind};
pub fn parse_file(fname: &str, regex: &Regex) -> Result<S... | true |
3ba434e26516c43c85b1fcac786c7e1772005c78 | Rust | WLBF/log4rs | /src/priv_serde.rs | UTF-8 | 920 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use log::LogLevelFilter;
use serde::de::{self, Deserialize};
use std::fmt;
pub fn de_filter<'de, D>(d: D) -> Result<LogLevelFilter, D::Error>
where D: de::Deserializer<'de>
{
struct S(LogLevelFilter);
impl<'de2> de::Deserialize<'de2> for S {
fn deserialize<D>(d: D) -> Result<S, D::Error>
... | true |
b3f4fbea5967d2921e21f2bfcdc6c0d0f551b263 | Rust | videah/array-init | /src/lib.rs | UTF-8 | 9,698 | 3.796875 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | #![no_std]
//! The `array-vec` crate allows you to initialize arrays
//! with an initializer closure that will be called
//! once for each element until the array is filled.
//!
//! This way you do not need to default-fill an array
//! before running initializers. Rust currently only
//! lets you either specify all in... | true |
f2c3a5ee3e3ddba0957fb8a6d95295ed170adcd6 | Rust | jungle-bits/pdf | /src/shading/function_based.rs | UTF-8 | 3,045 | 3.265625 | 3 | [
"MIT"
] | permissive | use crate::{
catalog::assert_len,
data_structures::Matrix,
error::PdfResult,
function::Function,
objects::{Dictionary, Object},
Resolve,
};
/// In Type 1 (function-based) shadings, the colour at every point in the domain is defined by a specified
/// mathematical function. The function need not... | true |
b5f9bc2c9e204db67ada750cfd8d080325881cbd | Rust | mdsherry/aoc2020 | /day-06/src/main.rs | UTF-8 | 439 | 2.765625 | 3 | [] | no_license | use std::collections::HashSet;
static INPUT: &str = include_str!("input.txt");
fn main() {
let groups = INPUT.split("\n\n");
let counts = groups.map(|group| {
let group_bitmap = group.lines().map(|line| {
line.bytes().fold(0u32, |mask, value| mask | (1 << (value - b'a')))
}).fold(0... | true |
7ba6a1b9b965669fdafd40bdaa4eed977dec6364 | Rust | lfn3/rs-advent | /src/one.rs | UTF-8 | 2,158 | 3.421875 | 3 | [] | no_license | use std::collections::HashSet;
pub fn solve(s: &String) {
let (s1, s2) = testable_solve(s);
println!("Solutions are: {}, {}", s1, s2)
}
fn testable_solve(s: &String) -> (i32, i32) {
(solve_part_one(s), solve_part_two(s))
}
#[test]
fn should_solve_sample_input() {
assert_eq!((0, 0), testable_solve(&"+... | true |
b0dbb72c1cc250668481997f6b41b93b40aaed04 | Rust | gwy15/leetcode | /src/46.全排列.rs | UTF-8 | 1,325 | 3.171875 | 3 | [] | no_license | /*
* @lc app=leetcode.cn id=46 lang=rust
*
* [46] 全排列
*/
struct Solution;
// @lc code=start
impl Solution {
pub fn permute(mut nums: Vec<i32>) -> Vec<Vec<i32>> {
match nums.len() {
0 => return Vec::new(),
1 => return vec![nums],
2 => return vec![vec![nums[1], nums[0]]... | true |
61dcebb870443d86e8a4ad921813e6e788f5c4f7 | Rust | oasislabs/oasis-cli | /src/subcommands/deploy.rs | UTF-8 | 4,721 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use std::{collections::BTreeMap, ffi::OsString};
use colored::*;
use crate::{
command::{BuildTool, Verbosity},
config::{Config, DEFAULT_GATEWAY_URL},
emit,
errors::{ProfileError, ProfileErrorKind, Result},
utils::{print_status_in, Status},
workspace::{ProjectKind, Target, Workspace},
};
macro... | true |
5bfb305718607f658f64f43751d8050c94a52681 | Rust | hawkw/hyper-compress | /src/stream.rs | UTF-8 | 4,589 | 3.046875 | 3 | [] | no_license | use flate2::Compression;
use flate2::write::GzEncoder;
use futures::{Async, AsyncSink, Poll, Sink};
use futures::sync::mpsc;
use hyper::{self, Body, Chunk};
use tokio_io::{AsyncRead, AsyncWrite};
use std::io::{self, Read, Write};
pub type MaybeGzWriter<W> = MaybeCompressed<W, GzEncoder<W>>;
impl<W: Write> MaybeGzW... | true |
f292ade02bcbd1c3120e71377bdb2c3f1b4d27bc | Rust | ex0ns/Rust-Experiments | /thread_snake/src/segment.rs | UTF-8 | 1,041 | 2.9375 | 3 | [] | no_license | use super::rawlink;
use super::direction;
pub struct Segment {
pub dir: direction::Direction,
pub size: usize,
pub x: i32,
pub y: i32,
pub next: Option<Box<Segment>>,
pub prev: rawlink::RawLink<Segment>,
}
impl Segment {
pub fn new() -> Segment {
Segment { dir: direction::Directio... | true |
9b911183b9891a7e9566df67fc0c5f0ea56ff02a | Rust | alexisfontaine/ocean | /macros/style.rs | UTF-8 | 1,230 | 2.703125 | 3 | [] | no_license | use proc_macro::TokenStream;
use quote::ToTokens;
use std::env::{var, VarError};
use std::fs::OpenOptions;
use std::io::{Read, Seek, SeekFrom, Write};
use std::path::Path;
use syn::LitStr;
pub struct Style<'a> {
name: &'a LitStr,
style: String
}
impl<'a> Style<'a> {
pub fn new (name: &'a LitStr, mut style: Strin... | true |
efcf92e1a14e2dfb4fe55c4ee6d83dd3e45dfa04 | Rust | playXE/boehm-rs | /src/lib.rs | UTF-8 | 2,310 | 2.921875 | 3 | [
"MIT"
] | permissive | #![no_std]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
pub mod bindings;
use self::bindings::*;
///! Rust interface to BoehmGC
///!
///! This crate provides FFI with BoehmGC and Global allocator that uses this GC
///!
pub use core as std;
/// Enable GC
pub fn gc_enabl... | true |
4db9e54c0e3fba4815740e2bce4da4475cd9cd30 | Rust | nuta/archives | /noa-lsp/src/compositor/terminal_exts.rs | UTF-8 | 1,399 | 3.015625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fmt;
/// An terminal extension which allows applying multiple changes in the terminal
/// at once not to show intermediate results.
///
/// There're two specifications for this purpose and we support both of them:
///
/// - iTerm2 / Alacritty: <https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-s... | true |
504ef3cd0cac9ad3fea38122a291c5d39f5ffa31 | Rust | m4b/faerie | /tests/elf.rs | UTF-8 | 13,192 | 2.546875 | 3 | [
"MIT"
] | permissive | extern crate faerie;
extern crate goblin;
extern crate scroll;
#[macro_use]
extern crate target_lexicon;
use anyhow::{ensure, Error};
use faerie::{Artifact, ArtifactBuilder, Decl, Link};
use goblin::elf::*;
use std::str::FromStr;
#[test]
// This test is for a known bug (issue #31).
fn file_name_is_same_as_symbol_name... | true |
2eb0cbc29ec8e8ce7fad2f8e2523646b63c47cd0 | Rust | jiegec/rcore_plus | /kernel/src/arch/x86_64/interrupt/handler.rs | UTF-8 | 4,677 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! 中断服务例程
//!
//! # 中断处理总流程
//!
//! * 中断发生时,CPU首先完成以下工作:
//! * 设置rsp的值(Ring3->0 或 DoubleFault,在TSS中设置)
//! * 向栈中push一些值(Ring0时3项,Ring3时5项,某些中断还有错误码)
//! * 跳转到`vector{i}`符号(位于`vector.asm`)
//! * 进入中断服务例程后,完成以下工作:
//! * `vector{i}`向栈中push空错误码(如CPU没有做)和中断号
//! * 跳转到`__alltraps`(位于`trap.asm`)
//! *... | true |
8f1da761681e73946ed0348765e642dfbca72bea | Rust | GopherJ/xactor | /src/context.rs | UTF-8 | 6,325 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::addr::ActorEvent;
use crate::broker::{Subscribe, Unsubscribe};
use crate::runtime::{sleep, spawn};
use crate::{Addr, Broker, Error, Handler, Message, Result, Service, StreamHandler};
use futures::channel::mpsc;
use futures::{Stream, StreamExt};
use once_cell::sync::OnceCell;
use std::sync::atomic::{AtomicU64... | true |
1cc147b0da398071e5f6dea590c181720bea7a49 | Rust | venil7/rust-minimax | /src/network/protocol.rs | UTF-8 | 3,913 | 3.34375 | 3 | [] | no_license | use crate::error::GameError;
use crate::field::Field;
use crate::player::Player;
const REQUEST_NEW_GAME: u8 = 0xfa;
const REQUEST_MOVE: u8 = 0xfb;
const RESPONSE_GAME_STATE: u8 = 0xfc;
const RESPONSE_ERROR: u8 = 0xfd;
#[derive(Debug)]
pub enum Frame {
RequestNewGame,
RequestMove(u8),
ResponseGameState { fields:... | true |
775351967233a8939ef1e2ae3844714afcc6f68e | Rust | cstorey/stomping-rs | /src/errors.rs | UTF-8 | 1,895 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::{collections::BTreeMap, fmt};
use thiserror::Error;
use crate::parser::ParseError;
use crate::protocol::Frame;
pub type Result<T> = std::result::Result<T, StompError>;
#[derive(Debug, Error)]
pub enum StompError {
#[error("stomp error: {0}")]
StompError(ErrorFrame),
#[error("Protocol error")]
... | true |
a0d8cad961efd57508afe7e39f28d9b08b17d780 | Rust | MichaelHe1125/rust-leetcode | /src/p0461_hamming_distance.rs | UTF-8 | 908 | 4.03125 | 4 | [] | no_license | // 461. Hamming Distance
// Easy
// The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
// Given two integers x and y, calculate the Hamming distance.
// Note:
// 0 ≤ x, y < 231.
// Example:
// Input: x = 1, y = 4
// Output: 2
// Explanation:
// 1 ... | true |
51ffcfd589ac332ee5101f6f708d1baf15612c80 | Rust | Seeker14491/async-timer | /src/lib.rs | UTF-8 | 3,830 | 2.828125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A crate that wraps some functionality from [tokio-timer] for use in futures 0.3 code that
//! doesn't use tokio.
//!
//! [tokio-timer]: https://crates.io/crates/tokio-timer
#![warn(
rust_2018_idioms,
deprecated_in_future,
macro_use_extern_crate,
missing_debug_implementations,
unused_labels,
... | true |
0478bc751110e5a71d09d34f2d7982bc4a67496d | Rust | aead/libgc | /src/cbmc/parser.rs | UTF-8 | 3,425 | 2.875 | 3 | [] | no_license |
use std::path::{Path, PathBuf};
use std::io::{BufRead, BufReader, Error as IOError, Result as IOResult, ErrorKind};
use std::fs::File;
use super::types::*;
use super::error::Error;
const GATES: &'static str = "output.gate.txt";
const INPUTS: &'static str = "output.inputs.txt";
const CONSTS: &'static str = "output.co... | true |
091df5ee1698c621030995b15a0e52a9dfe3ec50 | Rust | hsabouri/rust_fir | /examples/simple_tree.rs | UTF-8 | 1,191 | 3.328125 | 3 | [
"MIT"
] | permissive | mod tree;
mod node;
use tree::{Tree};
#[derive(Clone)]
struct State {
name: &'static str,
age: i32,
}
fn is_age_over_21(state: State) -> (State, bool) {
(state.clone(), state.age > 21)
}
fn say_hello(state: State) -> State {
println!("Hello {}!", state.name);
state
}
fn say_bye(state: State) ->... | true |
0eef9c23692aab01b38dc12b1dd7baa34f8af588 | Rust | sean-h/tdmath | /src/vector2i.rs | UTF-8 | 4,822 | 3.46875 | 3 | [
"MIT"
] | permissive | use vector3::Vector3;
use std::cmp::{min, max};
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
/// A 2 axis vector of `i32` values.
#[derive(Debug, Copy, Clone)]
pub struct Vector2i {
pub x: i32,
pub y: i32,
}
impl Vector2i {
/// Returns a new `Vector2i`.
pub fn new(x: i32, y: i32) -> Vecto... | true |
b5359eeb0df9f9611deb1fbaf87987e612e114dd | Rust | ferrosync/coingecko-cache | /domfi_loader_historical/src/coingecko.rs | UTF-8 | 1,211 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use chrono::{DateTime, Utc};
use chrono::serde::{ts_milliseconds};
use bigdecimal::BigDecimal;
use serde::{Deserialize};
use serde_with::serde_as;
use domfi_ext_serde::BigDecimalExact;
#[serde_as]
#[derive(Deserialize, Debug)]
pub struct Series {
pub name: String,
pub data: Vec<SeriesEntry>,
}
#[serde_as]
#[... | true |
8d7b4c4fe0cf08a7618567a34c6cec7f1e53126b | Rust | akdir/rust-whereis | /src/main.rs | UTF-8 | 1,129 | 2.609375 | 3 | [] | no_license | use structopt::StructOpt;
use std::vec;
use std::path::PathBuf;
#[derive(Debug, StructOpt)]
#[structopt(name = "whereis Options", about = "Different Options for whereis CLI command.")]
struct Opt {
/// Activate debug mode
#[structopt(short = "b")]
debug: bool,
/// Search for binaries
#[structopt(sh... | true |
5280a0fcf88a59606428f1e0d5f9b17c258c019e | Rust | jimmychu0807/exercism | /simple-linked-list/src/lib_box.rs | UTF-8 | 2,583 | 3.765625 | 4 | [] | no_license | use std::iter::{FromIterator, IntoIterator};
use std::fmt::Debug;
#[derive(Debug)]
struct Node<T: Debug> {
data: T,
next: Option<Box<Node<T>>>,
}
#[derive(Debug)]
pub struct SimpleLinkedList<T: Debug> {
head: Option<Box<Node<T>>>,
size: usize,
}
impl<T: Debug> SimpleLinkedList<T> {
pub fn new() -> Self {
... | true |
4dd4c367e74045e0579a483254871173bf0d1560 | Rust | ithinuel/hackerrank_rust | /regex_patterns_and_intro_to_databases/src/main.rs | UTF-8 | 1,585 | 3.140625 | 3 | [
"MIT"
] | permissive | extern crate regex;
use std::io;
use std::error::Error;
use regex::Regex;
fn read_line() -> Result<String, io::Error> {
let mut buffer = String::new();
io::stdin().read_line(&mut buffer)?;
Ok(buffer)
}
fn read_n_lines(n: usize) -> Result<Vec<String>, io::Error> {
let mut result = Vec::new();
for ... | true |
3e15e4b171b4e550320dcfaf576e831cf9e01b49 | Rust | xanahopper/leetcode | /src/leetcode/editor/cn/solution_838.rs | UTF-8 | 3,034 | 3.015625 | 3 | [] | no_license | //n 张多米诺骨牌排成一行,将每张多米诺骨牌垂直竖立。在开始时,同时把一些多米诺骨牌向左或向右推。
//
// 每过一秒,倒向左边的多米诺骨牌会推动其左侧相邻的多米诺骨牌。同样地,倒向右边的多米诺骨牌也会推动竖立在其右侧的相邻多米诺骨牌。
//
// 如果一张垂直竖立的多米诺骨牌的两侧同时有多米诺骨牌倒下时,由于受力平衡, 该骨牌仍然保持不变。
//
// 就这个问题而言,我们会认为一张正在倒下的多米诺骨牌不会对其它正在倒下或已经倒下的多米诺骨牌施加额外的力。
//
// 给你一个字符串 dominoes 表示这一行多米诺骨牌的初始状态,其中:
//
//
// dominoes[i] = 'L',表示第 i 张多米诺... | true |
e2d7234015e97e0aa0fba0d98e7dfa2830147b73 | Rust | segeljakt/advent-of-code-2018 | /day-22/src/main.rs | UTF-8 | 6,716 | 3.140625 | 3 | [] | no_license | use scan_fmt::*;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::cmp::Reverse;
#[derive(Clone,Copy,Debug,Eq,PartialEq)]
enum Kind {
Rocky,
Narrow,
Wet
}
#[derive(Hash,Ord,PartialOrd,Clone,Copy,Debug,Eq,PartialEq)]
struct Pos {
x: usize,
y: u... | true |
7e028870fd96834cc584ce54f44be7dade877873 | Rust | duzhanyuan/mamba | /src/desugar/control_flow.rs | UTF-8 | 3,333 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::core::construct::Core;
use crate::desugar::node::desugar_node;
use crate::desugar::result::DesugarResult;
use crate::desugar::result::UnimplementedErr;
use crate::desugar::state::Imports;
use crate::desugar::state::State;
use crate::parse::ast::Node;
use crate::parse::ast::AST;
#[allow(clippy::comparison_ch... | true |
c9abdc05812e43b8cf8971fa47f5c70adb40f910 | Rust | emabee/rust-hdbconnect | /hdbconnect_impl/src/protocol/parts/server_error.rs | UTF-8 | 5,670 | 2.9375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[cfg(feature = "async")]
use crate::protocol::util_async;
#[cfg(feature = "sync")]
use crate::protocol::util_sync;
#[cfg(feature = "sync")]
use byteorder::{LittleEndian, ReadBytesExt};
use crate::{protocol::util, HdbResult};
use std::error::Error;
/// Severity of a server message
#[derive(Clone, Debug, Eq, PartialEq... | true |
fd39ff71dc308f8b7879e306b6d3f3c24e4001b5 | Rust | cassandraoconnell/rustdown | /src/document/renderers/void_element.rs | UTF-8 | 568 | 3.359375 | 3 | [] | no_license | use super::Render;
// [SPEC]: https://html.spec.whatwg.org/multipage/syntax.html#elements-2
pub struct VoidElement {
attributes: Vec<(String, String)>,
tag: String,
}
impl VoidElement {
pub fn new(tag: String) -> VoidElement {
VoidElement {
attributes: Vec::new(),
tag,
... | true |
295d797369a3829d97ef8b87055dc842194ea1ec | Rust | fabura/icu4x | /utils/zerovec/src/ule/error.rs | UTF-8 | 981 | 2.828125 | 3 | [
"Apache-2.0",
"ICU",
"MIT",
"LicenseRef-scancode-unicode"
] | permissive | // This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
use core::fmt;
/// A generic error type to be used for decoding slices of ULE types
#[derive(Copy, Clone, Debug)]
pu... | true |
a4dbf1d3ec6a7952dd71b50f0bf46776f2c89c06 | Rust | phamtrongthang123/VNLang-rust | /src/lexer.rs | UTF-8 | 6,877 | 3.40625 | 3 | [
"MIT"
] | permissive | use crate::token;
use crate::token::Token;
use std::iter::Peekable;
use std::str::Chars;
pub struct Lexer<'a> {
input: Peekable<Chars<'a>>,
}
impl<'a> Lexer<'a> {
pub fn new(input: &'a str) -> Lexer<'_> {
Lexer{
input: input.chars().peekable(),
}
}
pub fn next_token(&mut s... | true |
60c477df566e70f374b7d64c3bb71f85afd26266 | Rust | smokku/naia-socket | /client/src/impls/miniquad/message_sender.rs | UTF-8 | 837 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::error::Error;
use super::shared::{naia_create_u8_array, naia_send};
use crate::Packet;
/// Handles sending messages to the Server for a given Client Socket
#[derive(Clone, Debug)]
pub struct MessageSender {}
impl MessageSender {
/// Create a new MessageSender, if supplied with the RtcDataChannel and a
... | true |
049be3589a3215db5ea2bef52de3d812e1dc52db | Rust | jdpgrailsdev/advent_of_code_2020 | /src/day_14.rs | UTF-8 | 1,887 | 3.125 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
use regex::Regex;
pub fn exercise() {
let mask_regex = Regex::new(r"^mask = ([01: X]+)$").unwrap();
let memory_regex = Regex::new(r"^mem\[(\d+)\] = (\d+)$").unwrap();
let mut memory_map: HashMap<i32,String> = HashMap::new();
... | true |
87befcd57279af19f7671ffd3457def258e55c66 | Rust | rust-lang/rustup | /src/utils/units.rs | UTF-8 | 4,642 | 3.703125 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fmt::{self, Display};
#[derive(Copy, Clone, Debug)]
pub enum Unit {
B,
IO,
}
pub(crate) enum UnitMode {
Norm,
Rate,
}
/// Human readable size (some units)
pub(crate) enum Size {
B(usize, UnitMode),
IO(usize, UnitMode),
}
impl Size {
pub(crate) fn new(size: usize, unit: Unit, uni... | true |
1843dca1ea4cbe54efa679725b15550fc52c39c7 | Rust | ZaneStauffer/holomon | /server/src/routes/app_routes.rs | UTF-8 | 1,216 | 2.6875 | 3 | [] | no_license | use rocket::*;
use rocket::response::status::NotFound;
use rocket::response::content;
use rocket::serde::{Serialize, json::Json};
use rocket::http::Status;
use std::result::Result;
use futures::stream::StreamExt;
use mongodb::{
bson::{doc, Bson},
options::FindOptions,
};
use crate::db_connection::db_connect;
... | true |
0f5e2cb1661cd3d1c38e8e9c1a9aaa6f59daea17 | Rust | enso-org/enso | /app/gui/view/graph-editor/src/component/edge/render.rs | UTF-8 | 16,959 | 2.625 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! Definitions, constructors, and management for the EnsoGL shapes that are used to draw an edge.
//!
//! The core function of this module is to translate edge layouts into the shape parameters that
//! will implement them.
use crate::prelude::*;
use ensogl::display::shape::*;
use crate::GraphLayers;
use super::lay... | true |
86a3561ea06d40f754d7796c819bba7a1bfcd377 | Rust | ygina/dclabels | /src/dclabels.rs | UTF-8 | 6,889 | 3.65625 | 4 | [] | no_license | //! DCLabel
//!
//! Main DCLabel type. @DCLabel@s use 'CNF' boolean formulas over
//! principals to express authority exercised by a combination of
//! principals. A @DCLabel@ contains two 'CNF's. One, 'dcSecrecy',
//! specifies the minimum authority required to make data with the
//! label completely public. The s... | true |
346133bc8dbd6617893c00093fb8890a8a985d18 | Rust | HerringtonDarkholme/leetcode | /src/701_insert_into_bst.rs | UTF-8 | 1,067 | 3.484375 | 3 | [] | no_license | // Definition for a binary tree node.
// #[derive(Debug, PartialEq, Eq)]
// pub struct TreeNode {
// pub val: i32,
// pub left: Option<Rc<RefCell<TreeNode>>>,
// pub right: Option<Rc<RefCell<TreeNode>>>,
// }
//
// impl TreeNode {
// #[inline]
// pub fn new(val: i32) -> Self {
// TreeNode {
// val,... | true |
8e097111988f4ec30563479439538239e0c487d4 | Rust | kvakvs/ErlangRT | /lib-erlangrt/src/term/boxed/map.rs | UTF-8 | 5,466 | 3.25 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::cmp::Ordering;
use crate::{
defs::{Word, SizeWords},
emulator::heap::{AllocInit, THeap},
fail::RtResult,
term::{
boxed::{
boxtype::{self, BoxType},
trait_interface::TBoxed,
BoxHeader,
},
classify,
compare::cmp_terms,
Term,
},
};
use core::ptr;
enum MapType {
... | true |
cba86ae259724a1bfc7cb077b3c1911959486da1 | Rust | shashankhacker730/feroxbuster | /src/heuristics.rs | UTF-8 | 9,277 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::sync::Arc;
use anyhow::{bail, Result};
use console::style;
use uuid::Uuid;
use crate::{
config::OutputLevel,
event_handlers::{Command, Handles},
filters::WildcardFilter,
progress::PROGRESS_PRINTER,
response::FeroxResponse,
skip_fail,
url::FeroxUrl,
utils::{ferox_print, fmt_err... | true |
a2bc7339c5e30195387d1ae695a100529f14c07f | Rust | logtopus/logtopus | /src/main.rs | UTF-8 | 1,688 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | mod constants;
use clap::{App, Arg};
use log::*;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let cli_matches = parse_cli();
init_log(&cli_matches);
logtopus::run(&cli_matches.value_of("config"))
}
fn init_log(matches: &clap::ArgMatches) {
let loglevel = match matches.occurrence... | true |
07f6056d6e673bd1e8ca5f63d1f7739abd0751cb | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-57819.rs | UTF-8 | 1,188 | 3.3125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-rustfix
#![allow(warnings)]
// This test checks that the following error is emitted and the suggestion works:
//
// ```
// let _ = vec![1, 2, 3].into_iter().collect::<<<Vec<usize>>();
// ^^ help: remove extra angle brackets
// ```
trait Foo {
type Output;
}
fn f... | true |
ae95b8d2afd43aa80ab6d8d210aa48a107c8f02f | Rust | nerdalert/rust-examples | /implementations/src/main.rs | UTF-8 | 1,733 | 4.28125 | 4 | [
"WTFPL"
] | permissive | /// An implementation is an item that associates items with an implementing type.
/// Implementations are defined with the keyword impl and contain functions that
/// belong to an instance of the type that is being implemented or to the type
/// statically.
struct Person {
first_name: String,
age: u32,
}
impl ... | true |
a6d98fe24d7a7cfd6741a5849c6551fa84742d2c | Rust | 872409/rebuild-token-vesting | /rs/src/state.rs | UTF-8 | 7,764 | 3 | 3 | [] | no_license | use arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs};
use solana_program::{
msg,
program_error::ProgramError,
program_pack::{IsInitialized, Pack, Sealed},
pubkey::Pubkey,
};
#[derive(Debug, PartialEq)]
pub struct VestingSchedule {
pub release_time: u64,
pub amount: u64,
}
#[der... | true |
bca17b16bbb711898d9e36643863287a76070176 | Rust | Psychedelic/candid | /rust/candid/src/ser.rs | UTF-8 | 14,331 | 2.6875 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! Serialize a Rust data structure to Candid binary format
use super::error::{Error, Result};
use super::parser::{typing::TypeEnv, value::IDLValue};
use super::types;
use super::types::{internal::Opcode, Field, Type};
use byteorder::{LittleEndian, WriteBytesExt};
use leb128::write::{signed as sleb128_encode, unsigned... | true |
928202df720dc6190e9b6530ad91f51e0927b2dc | Rust | Shiroifuyu/Raytracing-in-one-weekend | /src/hitable.rs | UTF-8 | 4,293 | 3.046875 | 3 | [] | no_license | extern crate rand;
use crate::vec3::{ Vec3, unit_vector };
use crate::ray::Ray;
#[derive(Clone, Copy)]
pub struct HitRecord<'a> {
pub t: f32,
pub p: Vec3,
pub normal: Vec3,
pub material: &'a dyn Material
}
pub trait Hitable {
fn hit(&self, r: &Ray, tmin: f32, tmax: f32) -> Option<HitRecord>;
}
impl Hitable... | true |
3172e36453d25d793d5859fb39cd14ba84624dba | Rust | shadowsocks/shadowsocks-rust | /crates/shadowsocks-service/src/local/socks/client/socks4/tcp_client.rs | UTF-8 | 2,101 | 2.71875 | 3 | [
"MIT"
] | permissive | //! SOCKS 4/4a client implementation
use std::{
io,
pin::Pin,
task::{self, Poll},
};
use log::trace;
use pin_project::pin_project;
use tokio::{
io::{AsyncRead, AsyncWrite, ReadBuf},
net::{TcpStream, ToSocketAddrs},
};
use crate::local::socks::socks4::{Address, Command, Error, HandshakeRequest, Ha... | true |
c7b6cb5759b9447a91604f6dc2e39f067d9bb28d | Rust | sigp/lighthouse | /common/monitoring_api/src/gather.rs | UTF-8 | 6,749 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use super::types::{BeaconProcessMetrics, ValidatorProcessMetrics};
use lazy_static::lazy_static;
use lighthouse_metrics::{MetricFamily, MetricType};
use serde_json::json;
use std::collections::HashMap;
use std::path::Path;
/// Represents a metric that needs to be fetched from lighthouse metrics registry
/// and sent t... | true |
e9601b2157a683bc8c9a5de67e0f0388a710c804 | Rust | knknkn1162/nlp100_rust | /src/ch02/command.rs | UTF-8 | 13,310 | 3.1875 | 3 | [] | no_license | use std::process::{Command, Stdio};
use std::io::{BufReader, BufRead, Read, Write}; // Read is used for read_to_string
use std::fs::File;
use std::path::Path;
pub struct Commander {path: String}
impl Commander {
pub fn new<P: AsRef<Path>>(save_path: P) -> Commander {
Commander {
path: save_pat... | true |
40eb7259bf0946583640760ff0df73903eb589c2 | Rust | linasdev/uri-pattern-matcher | /src/pattern_part.rs | UTF-8 | 1,052 | 3.671875 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | #[derive(Debug, Clone)]
pub(crate) enum PatternPart<'a> {
Joker,
Value(&'a str),
}
impl<'a> From<&'a str> for PatternPart<'a> {
fn from(part: &'a str) -> Self {
match part {
p if p.starts_with('{') && p.ends_with('}') => Self::Joker,
p => Self::Value(p),
}
}
}
i... | true |
6bb11b2ef02edff3746503de2427ae22b3237f2e | Rust | sieginglion/RustyThreads | /ThreadPool.rs | UTF-8 | 1,796 | 3.140625 | 3 | [] | no_license | use std::sync::{Arc, Mutex};
use std::collections::VecDeque;
use std::thread::{JoinHandle, spawn};
use std::sync::atomic::{AtomicBool, Ordering};
pub struct ThreadPool<F, T> {
queue: Arc<Mutex<VecDeque<F>>>,
workers: Vec<JoinHandle<()>>,
results: Arc<Mutex<Vec<T>>>,
joining: Arc<AtomicBool>
}
impl<F: ... | true |
1fd6a2fd5c05df1fea588a4298708eb5e8ecfd01 | Rust | damons-git/rusty-chain | /src/wallet_struct.rs | UTF-8 | 3,289 | 2.796875 | 3 | [] | no_license | extern crate ring;
use crate::env::{KEY_ALGO, KEY_SIZE, KEY_PUB_EXP};
use crate::key_parser;
use std::process;
use std::process::Command;
use ring::{rand, signature};
#[derive(Debug, Copy, Clone, PartialEq)]
enum SignatureState {
SignatureInvalid,
SignatureValid
}
/**
* A struct to hold a public and private... | true |
1e080b17359245d416e88a04faf249626b73f87d | Rust | mhammerly/uiefi | /src/ui/components/menu.rs | UTF-8 | 6,629 | 2.71875 | 3 | [
"MIT"
] | permissive | use log::info;
use uefi::proto::console::text::{Key, ScanCode};
use no_std_compat::prelude::v1::{vec, Box};
use no_std_compat::string::String;
use no_std_compat::vec::Vec;
use crate::graphics::{FontSize, Graphics};
use crate::ui::core::{font, UIResult};
use crate::widget::{Button, MultiWidget, Widget};
const BUTTON... | true |
7f15292198193614c1899ea4da134316fe2e7b06 | Rust | jasonincanada/kattis | /rust/pandemicshopping/src/main.rs | UTF-8 | 13,930 | 3.390625 | 3 | [] | no_license | /* https://open.kattis.com/problems/pandemicshopping */
use std::collections::HashMap;
fn main() {
let mall = get_input_from_stdin();
println!("{}", mall.count_floor_plans());
}
struct Mall {
// the directions of Aisle A and B if they were specified in the input
aisle_a : Option<Direction>,
ais... | true |
a6f3ff6477d0b0675deee9e8b03c7d60c5a45a71 | Rust | BafDyce/adventofcode | /2017/rust/day08/src/part1.rs | UTF-8 | 371 | 2.515625 | 3 | [
"Unlicense"
] | permissive | use super::*;
use std::collections::HashMap;
pub fn solve(instructions: &Vec<Instruction>) -> i32 {
let mut registers: HashMap<String, i32> = HashMap::new();
for instruction in instructions {
instruction.perform(&mut registers);
}
if let Some(max) = registers.values().max() {
*max
... | true |
1703a3f6a8a185ce4a9fdba913f8bb223d49932c | Rust | iCodeIN/kakikun | /src/canvas.rs | UTF-8 | 21,121 | 3.0625 | 3 | [
"MIT"
] | permissive | // Here, we define our own Canvas, Colour Picker and associated functions.
use image::{RgbImage, Rgb, DynamicImage};
use cursive::direction::Direction;
use cursive::event::{Event, EventResult, MouseButton, MouseEvent};
use cursive::theme::{Color, ColorStyle};
use cursive::Printer;
use cursive::Vec2;
// The big weak... | true |
2bfcecfef3828eee544cdc103645ec1603ba6ea8 | Rust | birkenfeld/stm_display_rust | /lib/src/console.rs | UTF-8 | 9,596 | 2.90625 | 3 | [] | no_license | //! The console display
use btoi::btoi;
use crate::framebuf::{CONSOLEFONT, Colors, FrameBuffer, FbImpl};
use crate::{WIDTH, HEIGHT, CHARW, CHARH};
const DEFAULT_COLOR: u8 = 7;
const DEFAULT_BKGRD: u8 = 0;
/// Number of characters in the visible screen.
const COLS: u16 = WIDTH / CHARW;
const ROWS: u16 = HEIGHT / CHA... | true |
db89e28cd5f6b486d85720c5eb8353c001c83ddb | Rust | hemangandhi/brian-rs | /src/spike_generators.rs | UTF-8 | 13,606 | 3.3125 | 3 | [] | no_license | //! This module represents neurons, generalized as "spike generators." To
//! support a wider range of abstractions, the input neurons are divided into
//! discrete and continuous implementations.
/// The general trait encapsulating a spike generator that has an output voltage
/// V.
pub trait SpikeGenerator<V> {
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.