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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36bbacec5419efd3d896c050926e87a27eadc458 | Rust | hauleth/geopost | /src/zip_codes.rs | UTF-8 | 1,450 | 3.234375 | 3 | [] | no_license | use std::collections::HashMap;
use std::io;
use std::str::FromStr;
use csv;
#[derive(Clone, Debug)]
pub struct ZipCodes {
data: HashMap<String, Region>,
}
#[derive(Serialize, Clone, Debug)]
pub struct Region {
country: String,
zip: String,
place_name: String,
lat: f64,
lng: f64,
}
impl ZipCod... | true |
8f28f5f8e4f4b33c491d97b22737da3bd2d6cb5c | Rust | millerjs/complesh | /src/util.rs | UTF-8 | 4,221 | 2.84375 | 3 | [] | no_license | use ::errors::Result;
use nix::sys::signal;
use nix::unistd;
use std::env::home_dir;
use std::env;
use std::fmt::Display;
use std::io::{self, Write, Stdout, Read, stdin};
use std::path::{Path, PathBuf};
use std::process::Command;
use std::time::{SystemTime, Duration};
use termion::color::{self, Green, Fg};
use termion:... | true |
cf7ab5e404de056cceb877ad0698228e0f7b129b | Rust | nindalf/advent-2019 | /src/day10.rs | UTF-8 | 7,162 | 3.203125 | 3 | [] | no_license | use std::collections::BTreeMap;
#[aoc_generator(day10)]
pub fn input_generator(input: &str) -> Vec<Vec<i32>> {
input.lines()
.map(|line| {
let line = line.trim();
let mut output = Vec::with_capacity(line.len());
let mut chars = line.chars();
whil... | true |
2b81d50151534df7ac7647fbde66739f546efa9d | Rust | samgiles/naulang-runtime | /src/naulang/interpreter/task.rs | UTF-8 | 3,646 | 3.375 | 3 | [
"MIT"
] | permissive | use naulang::interpreter::frame::Frame;
#[derive(PartialEq)]
pub enum TaskState {
Continue,
Halt,
Yield,
Suspend,
}
/// Represents a independently running function and its call stack
pub struct Task<'task> {
/// The current state of this task as TaskState
pub state: TaskState,
/// R... | true |
9aba8e4619e083c21c6597821eb6d2523f83d97a | Rust | wangonya/learning-rust | /common-concepts/src/main.rs | UTF-8 | 1,901 | 3.875 | 4 | [] | no_license | fn main() {
// variables
let mut x = 23;
println!("x before mut = {}", x);
x = 32;
println!("x after mut = {}", x);
// shadowing
let spaces = " ";
let spaces = spaces.len();
println!("spaces len = {}", spaces);
// consts
const MAX_POINTS: u32 = 100_000;
println!("c... | true |
0868df2e4383dc6c1130828d2c171e042d62409f | Rust | gaertn/rust-lp | /src/data/linear_program/network/representation.rs | UTF-8 | 7,436 | 2.5625 | 3 | [
"MIT"
] | permissive | //! # Representation
//!
//! Representing network data.
use std::fmt;
use std::ops::{Add, AddAssign, Div, Mul};
use std::slice::Iter;
use crate::algorithm::two_phase::matrix_provider::column::{Column, OrderedColumn};
use crate::algorithm::two_phase::matrix_provider::column::identity::IdentityColumn;
use crate::algorit... | true |
8dbfcce3e553a43346af1f6bb3a796c09c209a61 | Rust | Manishearth/mathema | /src/quiz/presentation/text.rs | UTF-8 | 3,209 | 3.1875 | 3 | [] | no_license | use crate::prelude::*;
crate struct TextPresentation<D: TextDelegate> {
delegate: D
}
impl<D: TextDelegate> TextPresentation<D> {
crate fn new(delegate: D) -> Self {
TextPresentation { delegate }
}
}
crate trait TextDelegate {
fn read_answer(&mut self, prompt: Prompt<'_>) -> Fallible<Option<S... | true |
99455a4e306332739d36174505be5f29f992cd4d | Rust | mocsy/playground_rs | /largest/src/main.rs | UTF-8 | 540 | 3.71875 | 4 | [
"MIT"
] | permissive |
fn largest<T>(list: &[T]) -> T
where T: PartialOrd + Copy {
let l = list.len();
if l == 1 {
list[0]
} else {
let c = list[0];
let n = largest(&list[1 .. ]);
if c < n {n} else {c}
}
}
fn main() {
let number_list = vec![34, 50, 25, 100, 65];
let result = largest(... | true |
8a93823760616cf87e0222bfd1540119b72a77e3 | Rust | GiantBlargg/Pluto | /plasma/src/assembler/mod.rs | UTF-8 | 2,521 | 3.09375 | 3 | [] | no_license | mod parser;
use parser::{Address, Instruction, Parser, Statement};
use std::{
collections::HashMap,
fs::File,
io::{self, Write},
path::PathBuf,
};
struct Label {
address: Option<u32>,
repl_address: Vec<u32>,
}
impl Label {
fn new() -> Self {
Self {
address: None,
repl_address: Vec::new(),
}
}
}
pub... | true |
6b1d51987cecc9c28a56d5ffc30438096ad28b9b | Rust | Devolutions/picky-rs | /picky-asn1-x509/src/pkcs7/ctl.rs | UTF-8 | 18,883 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{oids, AlgorithmIdentifier};
use picky_asn1::wrapper::{
Asn1SequenceOf, Asn1SetOf, BitStringAsn1, IntegerAsn1, ObjectIdentifierAsn1, OctetStringAsn1,
OctetStringAsn1Container, UTCTimeAsn1,
};
use serde::{de, ser, Deserialize, Deserializer, Serialize};
/// ``` not_rust
/// CTL ::= SEQUENCE {
/// ... | true |
b158cdfabf171e99a0727e03ee75e21d425dbabd | Rust | mwillsey/egg | /src/pattern.rs | UTF-8 | 13,998 | 3.421875 | 3 | [
"MIT"
] | permissive | use fmt::Formatter;
use log::*;
use std::borrow::Cow;
use std::fmt::{self, Display};
use std::{convert::TryFrom, str::FromStr};
use thiserror::Error;
use crate::*;
/// A pattern that can function as either a [`Searcher`] or [`Applier`].
///
/// A [`Pattern`] is essentially a for-all quantified expression with
/// [`... | true |
9a5f8ddce7593641e9313e256f4e9087e8a3933b | Rust | tuxmark5/north | /north_core/src/trait_manager.rs | UTF-8 | 2,161 | 2.578125 | 3 | [] | no_license | use {
crate::{
util::cast::{
Cast, CastKind, CastRaw, DefaultCaster
}
},
std::{
any::{Any, TypeId},
collections::HashMap,
marker::Unsize,
mem::{transmute_copy},
ptr,
raw::{TraitObject},
},
};
/////////////////////////////////////////////////////////////////////////////////... | true |
9b48323cae2e1f0efacf56b7812b972d5b41d86b | Rust | unipro/hls_m3u8 | /src/tags/master_playlist/stream_inf.rs | UTF-8 | 13,625 | 2.78125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt;
use std::ops::{Deref, DerefMut};
use std::str::FromStr;
use crate::attribute::AttributePairs;
use crate::types::{
ClosedCaptions, DecimalFloatingPoint, HdcpLevel, ProtocolVersion, StreamInf, StreamInfBuilder,
};
use crate::utils::{quote, tag, unquote};
use crate::{Error, RequiredVersion};
/// # [4.3... | true |
69a2fe6717cf0322e34fbe0b209d8b779ed3ad41 | Rust | cjbassi/skim | /src/query.rs | UTF-8 | 10,997 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::model::QueryPrintClosure;
use crate::options::SkimOptions;
use std::mem;
#[derive(Clone, Copy)]
enum QueryMode {
CMD,
QUERY,
}
pub struct Query {
cmd_before: Vec<char>,
cmd_after: Vec<char>,
query_before: Vec<char>,
query_after: Vec<char>,
yank: Vec<char>,
mode: QueryMode,
... | true |
3c6c0ea08cec9e25889367bbda09f1b2e0f4f66c | Rust | hockeybuggy/recurring_tasks | /src/process_task_file.rs | UTF-8 | 9,747 | 3.109375 | 3 | [
"MIT"
] | permissive | use std::fs;
use std::path::Path;
use chrono_tz::Tz;
use toml::Value as Toml;
use crate::Task;
pub fn parse_toml_file(source_path: &Path) -> Result<(chrono_tz::Tz, Vec<Task>), String> {
let contents = fs::read_to_string(source_path).expect("Unable to read the source file");
let parsed: Toml = match contents.... | true |
4b3c0f4a0979335f716bdf9e8597f0d003fc44e0 | Rust | LibreTuner/LibreTuner-rs | /src/app.rs | UTF-8 | 3,382 | 2.71875 | 3 | [] | no_license | use std::{
fs,
path::PathBuf,
cell::RefCell,
};
use crate::error::{Error, Result};
use directories::ProjectDirs;
use tuneutils::{
protocols::{can, isotp, uds::{UdsInterface, UdsIsotp}},
definition::Definitions,
link::{self, PlatformLink}, rom,
download::DownloadCallback,
};
pub struct App {
pub config_dir... | true |
1df35039233d02eabe7598d909942b5ac44a749d | Rust | RobertZ2011/yith | /sothoth/kernel/common/src/console.rs | UTF-8 | 579 | 3.46875 | 3 | [] | no_license | use core::fmt::Write;
#[allow(dead_code)]
#[repr(u8)]
#[derive(Debug, Clone, Copy)]
pub enum Color {
Black = 0x0,
Blue = 0x1,
Green = 0x2,
Cyan = 0x3,
Red = 0x4,
Magenta = 0x5,
Brown = 0x6,
LightGray = 0x7,
DarkGray = 0x8,
LightBlue = 0x9,
LightGreen = 0xA,
LightCyan... | true |
b1284ad19a52b8f52ed7580d32127954465b4f48 | Rust | enso-org/enso | /lib/rust/ensogl/component/dynamic-assets/src/shaders.rs | UTF-8 | 1,651 | 2.75 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! Offline optimization of runtime-generated shader programs.
use enso_prelude::*;
use ensogl_core::system::web::JsValue;
use ensogl_core::system::web::Map;
// =================
// === Constants ===
// =================
/// Path within the asset directory to store the vertex shader.
const VERTEX_FILE: &str = "ve... | true |
ddd7f9e7b33bcc61e95dc54e7693b6d16b798559 | Rust | Bilalh/vgmdb-rust | /src/client.rs | UTF-8 | 2,162 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | use crate::types::{albums::Album, search, VgmdbError};
use reqwest::header::{ACCEPT, CONTENT_TYPE};
use serde::Deserialize;
use serde::Serialize;
use serde_json::Value;
/// Rust Client for vgmdb
pub struct VgmdbClient {
client: reqwest::Client,
}
impl VgmdbClient {
pub fn new() -> Self {
Self {
... | true |
572f30ffe1ba100ea19e3651e2dd84a0fb2fa4b4 | Rust | mlex121/rusty-flop | /src/poker/card.rs | UTF-8 | 1,560 | 3.484375 | 3 | [] | no_license | use std::fmt;
use std::cmp;
use super::rank::Rank;
use super::suit::Suit;
#[derive(Clone, Hash)]
pub struct Card {
pub rank: Rank,
pub suit: Suit,
}
impl Card {
pub fn from_str(s: &str) -> Option<Self> {
let rank = match s.chars().nth(0) {
Some(x) => Rank::from_char(x),
_ ... | true |
ba6b11a7c6ec08a13bd955a6e3a925a4812bc999 | Rust | simster7/redux | /src/main.rs | UTF-8 | 699 | 2.765625 | 3 | [] | no_license | use crate::lru_cache::new_lru_cache;
use std::io::stdin;
mod lru_cache;
mod linked_list;
fn main() {
// println!("Cache size?");
// let size: u32 = read_line().parse().unwrap();
let mut cache = new_lru_cache(5);
cache.add("1", 1);
cache.add("2", 2);
cache.add("3", 3);
cache.add("4", 4);
... | true |
a67997ef82330653e9ebaf96a12ff0ad5f5ada5e | Rust | snsvrno/deimos-rs | /deimos-core/src/error/mod.rs | UTF-8 | 5,125 | 3.3125 | 3 | [] | no_license | pub mod codeinfo; use codeinfo::CodeInfo;
pub mod scanner;
pub mod parser;
const LEFT_PADDING : &str = " ";
const MARKER : &str = "^";
const TERMINAL_WIDTH : usize = 120;
pub fn display_error_general(f : &mut std::fmt::Formatter<'_>, description : &str) -> std::fmt::Result {
//! a general error message, this doe... | true |
06fbdd6eec57868c083b554cdaad8cb12676f1f6 | Rust | justinpombrio/PuzzleHunt-PH | /src/server.rs | UTF-8 | 17,645 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::path::{Path, PathBuf};
use rocket;
use rocket::request::Request;
use rocket::http::Cookies;
use data::{Hunt, Team, ReleasedPuzzle, Correctness, AGuess, AddToData};
use page::{Page, file, xml, redirect, error, not_found, error_msg};
use database::Database;
use forms::*;
use cookies::{Puzzler};
use expandable_... | true |
c33eb0384339ba6b9b0ad3f1ed41216ccbf72c80 | Rust | danpker/breakdown | /src/tasks.rs | UTF-8 | 1,237 | 4.15625 | 4 | [
"MIT"
] | permissive | pub struct Task {
// A task is essentially just a node in a tree.
// It has a title and (optional) children.
pub title: String,
pub children: Vec<Task>,
}
impl Task {
pub fn new(title: String) -> Task {
Task {
title: title,
children: Vec::new(),
}
}
... | true |
4595e0517a50798bd142417278295146dbaee72f | Rust | dorucioclea/tract | /linalg/src/hash.rs | UTF-8 | 607 | 3.0625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::hash::Hash;
pub trait DynHash {
fn dyn_hash(&self, state: &mut dyn std::hash::Hasher);
}
pub fn hash_f32<H: std::hash::Hasher>(s: &f32, state: &mut H) {
Hash::hash(&s.to_bits(), state)
}
struct WrappedHasher<'a>(&'a mut dyn std::hash::Hasher);
impl<'a> std::hash::Hasher for WrappedHasher<'a> {
... | true |
4df82d778abb6b7913672ea5815141d9b004362d | Rust | IThawk/rust-project | /rust-master/src/test/ui/self/string-self-append.rs | UTF-8 | 358 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
pub fn main() {
// Make sure we properly handle repeated self-appends.
let mut a: String = "A".to_string();
let mut i = 20;
let mut expected_len = 1;
while i > 0 {
println!("{}", a.len());
assert_eq!(a.len(), expected_len);
a = format!("{}{}", a, a);
i -= ... | true |
1d2b1b5071079f52c31c6c75b74f96f9be438629 | Rust | utterstep/advent-2019 | /day-6/src/orbit_graph.rs | UTF-8 | 4,568 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::{convert::TryFrom, iter::FromIterator, ptr};
use fnv::FnvHashMap;
const INITIAL_PLANET: &str = "COM";
#[derive(Debug)]
struct Planet {
parent: Option<usize>,
order: usize,
system: Vec<usize>,
}
#[derive(Debug)]
pub struct Planets<'a> {
planets: Vec<Planet>,
// use slightly faster (and l... | true |
ca50899e92f21fc4944b33d1b7532e1b99bd1817 | Rust | wg/rusoto | /rusoto/credential/tests/instance-profile-test.rs | UTF-8 | 977 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use rusoto_credential::{InstanceMetadataProvider, ProvideAwsCredentials};
use std::time::Duration;
// This test is marked ignored because it requires special setup.
// It's run with the `credential_integration_test` Makefile target.
#[tokio::test]
#[ignore]
async fn it_fetches_basic_role() {
// set env vars to poi... | true |
a5aad9a3b15f4abf3ea089a3b8dafb2591de4f94 | Rust | jspaulsen/webview-rs | /webview-rs/src/content.rs | UTF-8 | 268 | 3.203125 | 3 | [
"MIT"
] | permissive | /// Content displayable inside a [`WebView`].
///
/// # Variants
///
/// - `Url` - Content to be fetched from a URL.
/// - `Html` - A string containing literal HTML.
///
/// [`WebView`]: struct.WebView.html
pub enum Content<T: AsRef<str>> {
Url(T),
Html(T),
}
| true |
8e570d7a73616dc02079abc34bcdc7c63391bcaf | Rust | 8tomat8/sketches | /rust/vec_map_filter_reduce/src/main.rs | UTF-8 | 788 | 2.984375 | 3 | [
"WTFPL"
] | permissive | fn main() {
let x1: Vec<i32> = Vec::from([1, 2, 3, 4, 5, 6]);
let x_map: Vec<i32> = x1.iter().map(|&val| val * 3).collect::<Vec<i32>>();
println!("x_map: {:?}", x_map);
let x_filtered: Vec<i32> = x_map
.iter()
.filter(|&&val| val % 4 != 0)
.rev()
.cloned()
.coll... | true |
47cea375bce100043474573596b01d3c13eec453 | Rust | dasch-swiss/dsp-meta | /src/dsp_meta/parser/version.rs | UTF-8 | 879 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use hcl::{Attribute, Expression};
use crate::errors::DspMetaError;
pub fn parse_version(attributes: Vec<&Attribute>) -> Result<u64, DspMetaError> {
let mut version: u64 = 0;
for attribute in attributes {
if attribute.key() == "version" {
version = match attribute.expr() {
E... | true |
ddf4441af479a70e0632312483e60b6526669eeb | Rust | nugend/advent-of-code-2018 | /src/day_5.rs | UTF-8 | 1,235 | 2.90625 | 3 | [] | no_license | use aoc_runner_derive::aoc;
#[aoc(day5, part1)]
pub fn polymerization(input: &str) -> usize {
let mut last_str = input.to_string();
loop {
let (mut s, last) = last_str.chars().fold((String::new(),' '),{|(s,p),x|
if p == ' ' {
(s,x)
... | true |
b0e6da00ec53b53a0fc9ebe56cb9c105106c370c | Rust | erynofwales/sibil | /types/src/bool.rs | UTF-8 | 1,339 | 3.5625 | 4 | [] | no_license | /* types/src/bool.rs
* Eryn Wells <eryn@erynwells.me>
*/
use std::any::Any;
use std::fmt;
use std::ops::Deref;
use object::{Obj, Object};
/// The Scheme boolean type. It can be `True` or `False`.
#[derive(Debug, PartialEq)]
pub enum Bool { True, False }
impl Object for Bool {
fn as_any(&self) -> &Any { self }
... | true |
da6dfdc2794a377d956caa101177d321c6132a81 | Rust | pantsbuild/pants | /src/rust/engine/fs/store/src/snapshot.rs | UTF-8 | 8,000 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::HashMap;
use std::fmt;
use std::hash;
use std::iter::Iterator;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use deepsize::DeepSizeOf;
use futures::future;
u... | true |
df51a427efe808b017490bac95dfa82fba2eb563 | Rust | rcore-riscv-hypervisor-dev/RVM | /examples/ko/rust/src/logging.rs | UTF-8 | 1,410 | 2.6875 | 3 | [
"MIT"
] | permissive | use {
core::fmt,
log::{self, Level, LevelFilter, Log, Metadata, Record},
};
#[macro_export]
macro_rules! print {
($($arg:tt)*) => ({
$crate::logging::print(format_args!($($arg)*));
});
}
#[macro_export]
macro_rules! println {
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $(... | true |
dcaec0d51c929791502b05570a57662d017b3dcb | Rust | paul-sud/giftbox | /giftbox-api/src/main.rs | UTF-8 | 1,036 | 2.65625 | 3 | [
"MIT"
] | permissive | use actix_web::{get, post, web, middleware::Logger, App, HttpResponse, HttpRequest, HttpServer, Responder};
use serde::Deserialize;
#[derive(Deserialize)]
struct Box {
items: Vec<String>,
}
#[get("/")]
async fn hello() -> impl Responder {
HttpResponse::Ok().body("Hello world!")
}
#[post("/echo")]
async fn e... | true |
03580b460c668aaafcb88fe23ec1d0ff34d62228 | Rust | martica/miette | /miette-derive/src/snippets.rs | UTF-8 | 12,188 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashMap;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::{
parse::{Parse, ParseStream},
punctuated::Punctuated,
spanned::Spanned,
Token,
};
use crate::diagnostic::DiagnosticVariant;
use crate::utils::MemberOrString;
pub struct Snippets(Vec<Snippet>);
st... | true |
e747bcb3f0b13c99b8dcd507e90daf0e8eecc1dd | Rust | suomesta/rust_samples | /021_destructure_tuple/main.rs | UTF-8 | 120 | 2.84375 | 3 | [] | no_license | fn main() {
let t:(bool, i32, f64) = (true, 5, 1.5);
let (b, i, d) = t;
println!("{} {} {}", b, i, d);
}
| true |
b8f4d5349416cec5754eeb9eca44736caca78ee3 | Rust | noocene/welkin-core | /src/main.rs | UTF-8 | 2,818 | 2.65625 | 3 | [] | no_license | use std::{collections::HashMap, fmt::Debug, fs::read_to_string, io, process::exit};
#[cfg(any(feature = "graphviz", feature = "accelerated"))]
use welkin_core::net::{Index, Net, VisitNetExt};
use welkin_core::term::{alloc::System, typed::Definitions, NullCache, ParseError, Term};
fn e<E: Debug>(e: E) -> String {
f... | true |
7352580c6c8658cf7ae15bef3085440aea00d5cc | Rust | satoakick/compilers-2nd | /exercises/2.4.6/_2_4_1_c/src/main.rs | UTF-8 | 892 | 3.515625 | 4 | [] | no_license | use std::env;
fn s(look_ahead: &mut Vec<char>) {
if look_ahead.is_empty() {
return
} else {
if look_ahead[0] == '0' && look_ahead[look_ahead.len()-1] == '1' {
println!("{:?}", look_ahead);
let mut look_ahead: Vec<char> =
look_ahead.iter()
... | true |
16b63677f133266de6ee012696686fda03c67524 | Rust | parallel-programming-hwr/bdflib-rs | /src/lib.rs | UTF-8 | 4,314 | 2.90625 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod tests {
use super::io::BDFWriter;
use crate::chunks::{DataEntry, HashEntry};
use crate::io::BDFReader;
use std::fs::{remove_file, File};
use std::io::Error;
const FOO: &str = "foo";
const BAR: &str = "bar";
#[test]
fn it_writes_uncompressed() -> Result<(), Error> ... | true |
85734d02a6a6aa23c46736e7cdf5e37c32ce1e8d | Rust | lieuwex/ruma-client | /examples/hello_world.rs | UTF-8 | 1,779 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::{convert::TryFrom, env, process::exit};
use ruma_client::{
self,
api::r0,
events::{
room::message::{MessageEventContent, TextMessageEventContent},
EventType,
},
identifiers::RoomAliasId,
Client,
};
use serde_json::value::to_raw_value as to_raw_json_value;
use url::Url;
... | true |
11fe2dbe3e1322809ee23c1cf41b9d39733504e1 | Rust | wackywendell/adventofcode2019 | /src/day25/main.rs | UTF-8 | 16,953 | 2.875 | 3 | [] | no_license | use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;
use anyhow::{anyhow, Error as AnyErr, Result as An... | true |
7e94dacf743694d3c399732e53f7864429ec49c0 | Rust | ldfallas/rgwbasic | /rgwbasic/src/eval/dim_instr.rs | UTF-8 | 4,807 | 3.3125 | 3 | [
"MIT"
] | permissive | use super::{EvaluationContext,
GwInstruction, GwExpression, GwProgram,
evaluate_to_usize,
InstructionResult,
LineExecutionArgument};
use std::result::Result;
pub struct GwDimDecl {
name: String,
dimensions: Vec<Box<dyn GwExpression>>
}
impl GwDimDecl {
pub ... | true |
54c43ae55c7e40cb3f057f00200e86fab2a8111f | Rust | shoolic/wasi-libc | /tools/wasi-headers/tests/verify.rs | UTF-8 | 2,389 | 2.609375 | 3 | [
"LLVM-exception",
"Apache-2.0",
"MIT",
"NCSA",
"BSD-2-Clause"
] | permissive | use std::fs;
#[test]
fn assert_same_as_src() {
let actual =
fs::read_to_string(wasi_headers::libc_wasi_api_header()).expect("read libc wasi/api.h");
let witx_files = wasi_headers::snapshot_witx_files().expect("parse snapshot witx files");
let expected = wasi_headers::generate(&witx_files).expect("h... | true |
83e3871a1cfbb8f1c843b3c649d81d8e5747a9f9 | Rust | gba-rs/gba-emu | /src/operations/arm_arithmetic.rs | UTF-8 | 4,302 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{cpu::program_status_register::ConditionFlags};
fn _add(op1: u32, op2: u32, carry_in: bool) -> (u32, ConditionFlags) {
let output: u64 = (op1 as u64) + (op2 as u64) + (carry_in as u64);
let carryout: bool = (output >> 32) != 0;
let real_output: u32 = (output & 0xFFFFFFFF) as u32;
let op1_sig... | true |
899dc4bf2b8d62fb1aae75edaf015f9b56ba5254 | Rust | tdeith/hamster-bot | /src/main.rs | UTF-8 | 2,071 | 2.984375 | 3 | [] | no_license | // Compiler macros to specify that:
#![deny(unsafe_code)] // Unsafe code will not compile (severely limits hardware faults)
#![no_main] // Do not use the standard `main` entrypoint. (Calling the function `main` is fine, though.)
#![no_std] // Do not bake the `std` library, which is o... | true |
094373c262fb5895d6ed31c87afb0aba85921cef | Rust | Clueliss/stat-bot | /src/graphing/draw/util.rs | UTF-8 | 1,137 | 2.734375 | 3 | [] | no_license | use std::collections::BTreeMap;
use chrono::{Date, Utc};
use plotters::style::RGBColor;
pub fn split_stats(
stats: Vec<(Date<Utc>, BTreeMap<String, u64>)>,
) -> BTreeMap<String, Vec<(Date<Utc>, u64)>> {
let mut buf: BTreeMap<String, Vec<(Date<Utc>, u64)>> = BTreeMap::new();
for (date, mpsd) in stats {
... | true |
be17510c2eb2ae5f6c2f0b574d85f057f4e34595 | Rust | loganmhb/rusty-tools | /cat/src/main.rs | UTF-8 | 511 | 3.171875 | 3 | [] | no_license | use std::env;
use std::process;
use std::fs::File;
use std::io;
use std::io::Read;
fn get_file_string(filename: &str) -> Result<String, io::Error> {
let mut file = try!(File::open(filename));
let mut s = String::new();
try!(file.read_to_string(&mut s));
Ok(s)
}
fn main() {
let args = env::args().... | true |
3a98e2988c50629f56c5fe2ebb9badae3464adc2 | Rust | namuyan/bc4py_plotter | /src/cli_tool.rs | UTF-8 | 7,771 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::pochash::{HASH_LOOP_COUNT,HASH_LENGTH,generator};
use crate::utils::*;
use std::io::{BufReader, BufWriter, Read, Write, Seek, SeekFrom};
use colored::Colorize;
use serde_json::Value;
use std::fs::{create_dir, File, remove_file, rename};
use std::path::{Path,PathBuf};
use std::thread::sleep;
use std::time::{I... | true |
3034537c065b45fc2c0ddc055390b53d15ee693a | Rust | alchemydc/dcli | /src/dcli/src/utils.rs | UTF-8 | 4,078 | 2.890625 | 3 | [
"MIT"
] | permissive | /*
* Copyright 2020 Mike Chambers
* https://github.com/mikechambers/dcli
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* us... | true |
d2e52c9f5d8a0052eb7e535801c45c1a0ea19c27 | Rust | lpf32/leetcode-rust | /src/s0020_valid_parentheses.rs | UTF-8 | 1,145 | 3.8125 | 4 | [] | no_license | use std::collections::HashMap;
struct Solution();
impl Solution {
pub fn is_valid(s: String) -> bool {
let mut stack: Vec<char> = Vec::new();
for elm in s.chars().into_iter() {
match stack.last() {
None => {},
Some(&v) => {
if Solutio... | true |
b7cf392d083ac9896bd96355122fed0a195bc760 | Rust | krithin/adventofcode2020 | /day18/src/main.rs | UTF-8 | 3,475 | 3.5 | 4 | [] | no_license | use std::{io, io::prelude::*};
struct StackFrame {
val: u64,
next_op: char,
}
fn evaluate_part1(line: &str) -> u64 {
let mut curr: u64 = 0;
let mut last_op = '+';
let mut stack: Vec<StackFrame> = Vec::new();
for c in line.chars() {
// The numbers in the sample input are all single dig... | true |
515957d4b5bcd560f7e16893989f611213235c1b | Rust | hinohi/backgammon-last-stuff | /src/board.rs | UTF-8 | 5,429 | 3.53125 | 4 | [] | no_license | use std::collections::HashSet;
use std::fmt::Display;
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct Board {
cell: [u8; 7],
}
impl Display for Board {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(&format!(
"[{},{},{},{},{},{}]",
self... | true |
f8a781d1447b60b68fcd8613034498195db6f4b9 | Rust | GDGToulouse/devfest-toolkit-rs | /src/opts.rs | UTF-8 | 3,862 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use std::path::PathBuf;
use structopt::StructOpt;
use dftk_conference_hall::ConferenceHallConfig;
use dftk_database::MongodbConfig;
use dftk_hugo_site::SiteConfig;
use dftk_server::ServerConfig;
#[derive(Debug, Clone, StructOpt)]
pub struct CliOpt {
#[structopt(subcommand)]
command: Command,
}
impl CliOpt {... | true |
f0bb31ed4455798331e210d83ed146a825a64e36 | Rust | muskanmahajan37/rsass | /src/css/value.rs | UTF-8 | 11,532 | 3.59375 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::css::CallArgs;
use crate::error::Error;
use crate::ordermap::OrderMap;
use crate::output::{Format, Formatted};
use crate::sass::Function;
use crate::value::{Color, ListSeparator, Number, Numeric, Operator, Quotes};
use std::convert::TryFrom;
/// A css value.
#[derive(Clone, Debug, Eq, PartialOrd)]
pub enum ... | true |
dda1302b6effb5bb938abc23beeec4594082d862 | Rust | quilt/lighthouse | /eth2/utils/tree_hash_derive/tests/tests.rs | UTF-8 | 4,097 | 3.109375 | 3 | [
"Apache-2.0"
] | permissive | use cached_tree_hash::{CachedTreeHash, TreeHashCache};
use tree_hash::{merkle_root, SignedRoot, TreeHash};
use tree_hash_derive::{CachedTreeHash, SignedRoot, TreeHash};
#[derive(Clone, Debug, TreeHash, CachedTreeHash)]
pub struct Inner {
pub a: u64,
pub b: u64,
pub c: u64,
pub d: u64,
}
fn test_standa... | true |
211c575823c7aa99149373b928ce2e52a8f54ae1 | Rust | pedantic79/Exercism | /rust/semi-structured-logs/src/lib.rs | UTF-8 | 761 | 3.453125 | 3 | [] | no_license | #[derive(Clone, PartialEq, Debug)]
pub enum LogLevel {
Debug,
Info,
Warning,
Error,
}
impl LogLevel {
pub fn get_prefix(&self) -> &str {
match self {
Self::Debug => "DEBUG",
Self::Info => "INFO",
Self::Warning => "WARNING",
Self::Error => "ERR... | true |
b5259141293d823921b5fc324f67d608ea44a2f4 | Rust | Atul9/rust-pushrod | /src/widget/box_widget.rs | UTF-8 | 2,583 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | // Box Widget
// Extensible widget for the widget library - handles drawing a box with a border and a fill color
//
// 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.or... | true |
350e9394b2c9f94b2b0506a5477422b626d295bd | Rust | fabianschuiki/moore | /src/derive/arena.rs | UTF-8 | 4,916 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (c) 2016-2021 Fabian Schuiki
use heck::SnakeCase;
use proc_macro::TokenStream;
use proc_macro2::Ident;
use quote::{format_ident, quote, ToTokens};
use std::{cell::RefCell, collections::BTreeMap};
use syn::{Generics, Item};
// CAUTION: This is all wildly unstable and relies on the compiler maintaining
// ... | true |
67055f7545970da4a21b679ac34131ae72a4c21d | Rust | charlesbjohnson/super_happy_interview_time | /rs/src/data_structures/list/linked_list.rs | UTF-8 | 10,504 | 3.328125 | 3 | [
"MIT"
] | permissive | use std::cell::{Ref, RefCell};
use std::rc::{Rc, Weak};
struct Node<T> {
value: T,
next: Option<Rc<RefCell<Node<T>>>>,
prev: Weak<RefCell<Node<T>>>,
}
pub struct LinkedList<T> {
len: usize,
head: Option<Rc<RefCell<Node<T>>>>,
tail: Option<Rc<RefCell<Node<T>>>>,
}
pub struct IntoIter<T>(Linked... | true |
9d1c014ea2a486235be8cf71f0ab21fce26538f6 | Rust | 0Walle/Vaterite-Lisp | /src/printer.rs | UTF-8 | 10,516 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::types::{Value};
use crate::names::{NamePool};
use crate::error::Error;
pub struct Printer {}
impl Printer {
pub fn repr_name(value: &Value, names: &NamePool) -> String {
Printer::repr_name_(value, 0, names)
}
fn repr_name_(value: &Value, level: i32, names: &NamePool) -> String {
... | true |
b8fef97c9ccdd702a6ef1b0f1af5de82e6c0cefa | Rust | sile/euler.rs | /euler_02/src/problem051.rs | UTF-8 | 2,747 | 3.25 | 3 | [] | no_license | //! [51] Prime digit replacements
//! -----------------------------
//!
//! https://projecteuler.net/problem=51
//!
use num;
use euler_lib::utils::{self, Prime};
use std::collections::HashSet;
// TODO: move to utils module (also problem027)
struct Primes {
prime_seq: Prime,
prime_set: HashSet<u64>,
last: u... | true |
955855df8f012611db1c98dc03845be9575af14b | Rust | rusch95/SpaceFort | /src/game/base.rs | UTF-8 | 4,421 | 2.8125 | 3 | [] | no_license | use entities::actions::{Action, Goal};
use entities::creatures::CreatureMap;
use entities::entity::{Entities, EntID};
use entities::entity::{do_actions, resolve_dead};
use entities::pathfind::{path_to, path_next_to};
use map::tiles::{Map, PosUnit};
pub const FRAME_RATE_NS: u32 = 16_666_667;
const VALIDATION_PERIOD: i... | true |
301ed4101286508656a901bd4c5a9f4f161ddda3 | Rust | MattiasFestin/diesel-geography | /src/types.rs | UTF-8 | 4,784 | 2.640625 | 3 | [] | no_license | use crate::sql_types::*;
use diesel::deserialize::{self, FromSql};
use diesel::pg::Pg;
use diesel::serialize::{self, IsNull, Output, ToSql};
use postgis::ewkb::{MultiPolygonT, Point, PolygonT};
use std::convert::From;
use std::io::prelude::*;
#[derive(Debug, Copy, Clone, PartialEq, FromSqlRow, AsExpression)]
#[cfg_att... | true |
1bbf88562101f63421409c85005d0c8becd5ce79 | Rust | drogue-iot/drogue-ffi-compat | /src/printf/format.rs | UTF-8 | 10,548 | 2.921875 | 3 | [] | no_license | use heapless::{
Vec,
consts::*,
};
use core::fmt::Write;
use crate::atoi::atoi_usize;
use crate::printf::format::Chunk::Literal;
use crate::variadic::VaList;
use crate::strlen::strlen;
use core::slice::from_raw_parts;
#[derive(Debug)]
pub enum FormatSpec {
Char,
Decimal(DecimalFormat),
Exponential... | true |
432e2d233ab51a20685662c2ae71e580f13c80b9 | Rust | Blquinn/repose-tauri | /src-tauri/src/http.rs | UTF-8 | 3,336 | 3.078125 | 3 | [] | no_license | use std::io::Read;
use serde::{Deserialize, Serialize};
use std::io;
/// Key value pairs serialized as length 2 json string arrays ['key', 'value']
type KeyVal = Vec<String>;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HttpRequest {
pub request_id: String,
/// The request method (GET,... | true |
ea1cff040f52b42a86d28ebe003b2a17396855be | Rust | wyattlake/advent-of-code-2020 | /src/day_6/puzzle_2.rs | UTF-8 | 1,681 | 3.328125 | 3 | [] | no_license | use std::fs;
use regex::Regex;
#[derive(PartialEq, Debug)]
struct Response {
character: char,
count: usize,
}
impl Response {
pub fn add(character: char, list: &mut Vec<Response>) -> bool {
for x in list {
if character == x.character {
x.count += 1;
ret... | true |
cefce30eddb35b4ffeaba9f9e996799038408033 | Rust | jacob-pro/game-of-life | /rust/src/lib.rs | UTF-8 | 1,912 | 2.8125 | 3 | [] | no_license | mod logic;
use std::slice;
use rayon::{ThreadPoolBuilder, ThreadPool};
use rayon::prelude::*;
use logic::calculate_row;
pub struct GameOfLife {
pool: ThreadPool,
world: World,
}
pub struct World {
cells: Vec<u8>,
height: i32,
width: i32,
}
/// World is a pointer to a byte array of the flattened ... | true |
d501d838e7544657da594b42619f250bb855d0a4 | Rust | Locksidian/locksidian | /src/api/endpoints/identities.rs | UTF-8 | 2,676 | 3.015625 | 3 | [
"WTFPL"
] | permissive | //! Identity management endpoint.
use iron::prelude::*;
use persistence::prelude::*;
use blockchain::identity::*;
/// Collect all the configured node identities into a single JSON payload of the form:
///
/// ```json
/// [
/// {
/// "hash": "...",
/// "public_key": "..."
/// },
/// ...
/// ]
... | true |
b4e7d5d52c4d950af5f889537ff5cebeb095762a | Rust | LIPUU/rust-conversions | /gen/src/from_path_buf.rs | UTF-8 | 1,696 | 3.1875 | 3 | [] | no_license | use std::ffi::FromBytesWithNulError;
use std::ffi::{CStr, CString};
use std::ffi::{OsStr, OsString};
use std::os::unix::ffi::{OsStrExt, OsStringExt};
use std::path::{Path, PathBuf};
// Returns None if the input is not valid UTF-8.
pub fn path_buf_to_str(input: &PathBuf) -> Option<&str> {
input.as_path().to_str()
}... | true |
78cc6e10ff76d3a99d5a903d1870ef83669bc625 | Rust | danielteberian/Tetanus | /src/convbtc/src/main.rs | UTF-8 | 2,110 | 3 | 3 | [] | no_license | #[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate derive_more;
use reqwest;
use std::process::exit;
use structopt::StructOpt;
#[derive(From, Display, Debug)]
enum convbtc_err
{
ApiError,
Reqwest(reqwest::Error),
}
const APIURL: &str = "https://apiv2.bitcoinaverage.com/convert/global";
#[derive(Deb... | true |
5801379701bcf52d3530167bbcf62dabaacce324 | Rust | cogciprocate/voodoo | /src/image_view.rs | UTF-8 | 3,728 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::sync::Arc;
use vks;
use ::{VdResult, SwapchainKhr, Device, ImageHandle, Handle};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(C)]
pub struct ImageViewHandle(pub(crate) vks::VkImageView);
impl ImageViewHandle {
#[inline(always)]
pub fn to_raw(&self) -> vks::VkImageView {
self.0
}
}... | true |
fbe1abfb94df55886f49f064dae1e2d8155ebcca | Rust | shaneutt/lumen | /compiler/codegen/src/mlir/builder/ops/builders/trace.rs | UTF-8 | 1,920 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
use crate::mlir::builder::traits::*;
/// Handles the trace_capture operation
///
/// This operation is a terminator, it takes a destination block
/// and block arguments, and branches to that block while additionally
/// passing along a handle that represents the captured trace.
pub struct TraceCaptureB... | true |
89046f0187b76fc4d7be39e597bfcc75c87fdbdd | Rust | 17dec/json | /tests/array.rs | UTF-8 | 3,113 | 2.859375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![cfg(not(feature = "preserve_order"))]
extern crate serde;
#[macro_use]
extern crate serde_json;
use serde_json::{Deserializer, Value};
// Rustfmt issue https://github.com/rust-lang-nursery/rustfmt/issues/2740
#[cfg_attr(rustfmt, rustfmt_skip)]
macro_rules! test_stream {
($data:expr, |$stream:ident| $test:blo... | true |
5bfbee353e551b5b889433965dd0d1eab8d150f1 | Rust | declanvk/counting-networks | /benches/counters.rs | UTF-8 | 5,456 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use core::sync::atomic::{AtomicUsize, Ordering};
use counting_networks::counters::{BitonicCountingNetwork, Counter};
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use std::{sync::Arc, thread};
fn atomic_count_to(counter: Arc<AtomicUsize>, num_threads: usize, max_count... | true |
0a6859cf94ada8ffc3c4aebfa2d8b22229e0909e | Rust | phR0ze/mrsa | /core/examples/text_img.rs | UTF-8 | 796 | 2.84375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | // Display a text file as an image in macroquad
use macroquad::prelude::*;
use mrsa_core::prelude::*;
// Configure window
fn window_conf() -> Conf {
Conf {
window_title: "Text Image example".to_string(),
window_width: 1024,
window_height: 768,
high_dpi: true,
window_resizabl... | true |
2f5d3e6764f89895577b7030576f0c2aaec437ea | Rust | SteadBytes/advent-of-code-2020 | /rust/src/d04.rs | UTF-8 | 6,275 | 3.421875 | 3 | [] | no_license | use std::collections::HashMap;
use std::str::FromStr;
use PassportField::*;
const REQUIRED_FIELDS: [PassportField; 7] = [Ecl, Pid, Eyr, Hcl, Byr, Iyr, Hgt];
pub fn run(input: &str) {
let passports = parse_input(input).expect("unable to parse input");
println!("Part 1: {}", part_1(&passports));
println!("P... | true |
954f92c77fcc2bf23fe0dee2a3cfe10b0f19f140 | Rust | halzy/twitch_api2 | /src/helix/games/get_games.rs | UTF-8 | 3,729 | 3.296875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Gets game information by game ID or name.
//! [`get-games`](https://dev.twitch.tv/docs/api/reference#get-games)
//!
//! # Accessing the endpoint
//!
//! ## Request: [GetGamesRequest]
//!
//! To use this endpoint, construct a [`GetGamesRequest`] with the [`GetGamesRequest::builder()`] method.
//!
//! ```rust, no_run... | true |
1e7833d942b1e0fb39bc505a3a625139e0a5c417 | Rust | stijnh/rust-raytracer | /src/math/aabb.rs | UTF-8 | 2,162 | 3.03125 | 3 | [
"MIT"
] | permissive | use super::{Ray, Vec3D};
use crunchy::unroll;
use std::mem::swap;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct AABB {
pub min: Vec3D,
pub max: Vec3D,
}
impl AABB {
pub fn new() -> Self {
AABB {
min: Vec3D::fill(std::f32::INFINITY),
max: Vec3D::fill(std::f32::NEG_INFI... | true |
38e4b7e04bd82604a0b2dc4c4979522304f57d75 | Rust | ives9638/gimli | /permutation/src/portable.rs | UTF-8 | 1,286 | 2.90625 | 3 | [
"MIT"
] | permissive | use core::ops::Range;
use crate::S;
pub fn gimli(state: &mut [u32; S]) {
#[allow(clippy::reversed_empty_ranges)]
for round in R(24..0) {
// SP-box
for column in 0..4 {
let x = state[column ].rotate_left(24);
let y = state[column + 4].rotate_left(9);
let z... | true |
50b2acef033b2a52e9ec096ace0357d89b677d95 | Rust | mark-inderhees/aoc | /rust/src/year2022/day23.rs | UTF-8 | 8,067 | 3.125 | 3 | [
"MIT"
] | permissive | // 2022 Day 23
// https://adventofcode.com/2022/day/23
// --- Day 23: Unstable Diffusion ---
// Elves are looking where to plan star fruit trees
// They need to spread out (diffuse)
use anyhow::Result;
use std::collections::HashMap;
use std::collections::VecDeque;
use crate::puzzle::Puzzle;
use crate::utils::board::*... | true |
b5382f391328d3c7caaa6f4a11a0c33e57afe14e | Rust | letmutx/code-executor | /src/executor/client.rs | UTF-8 | 3,327 | 2.65625 | 3 | [] | no_license | use executor::error::DockerError;
use executor::log::Logs;
use hyper::Client;
use hyper::client::{Connect, Request};
use hyper::header::{Connection, ConnectionOption};
use hyper::{self, Method, StatusCode};
use hyperlocal::Uri;
use tokio_core::reactor::Handle;
use unicase::Ascii;
use std::collections::HashMap;
use url... | true |
3e15a444707df4a0e280994732a17224a71f764d | Rust | bug00r/math-rust | /src/vec/vec2.rs | UTF-8 | 3,814 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::ops::*;
#[derive(Clone)]
pub struct Vec2 {
pub x: f32,
pub y: f32,
}
impl Add<f32> for Vec2 {
type Output = Vec2;
fn add(self, rhs: f32) -> Vec2 {
Vec2 { x: self.x + rhs, y: self.y + rhs }
}
}
impl Add<Vec2> for Vec2 {
type Output = Vec2;
fn add(self, rhs: Vec2) -> Vec2 {
Vec2 { x: self.x +... | true |
571093aaad5bff950c7f740af2bd32c4b80a212a | Rust | grebnetiew/aoc2019 | /src/day08.rs | UTF-8 | 2,572 | 3.375 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
use std::fmt;
#[aoc_generator(day8)]
fn one_line_many_numbers(input: &str) -> Vec<u32> {
input
.chars()
.map(|n| n.to_digit(10).expect("Found a non-base-ten digit"))
.collect()
}
struct Sif {
pixels: Vec<u32>,
width: u32,
height: u32... | true |
56349b087f8302846d6ca8498e4eec7bd57e6828 | Rust | tnederlof/abstreet | /convert_osm/src/snappy.rs | UTF-8 | 5,857 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::{BTreeMap, HashMap, HashSet};
use abstutil::MultiMap;
use abstutil::Timer;
use geom::{Distance, FindClosest, Line, PolyLine};
use kml::{ExtraShape, ExtraShapes};
use map_model::osm::WayID;
use map_model::raw::{OriginalRoad, RawMap};
use map_model::{osm, Direction};
/// Attempt to snap separately... | true |
9d3e6f69259ac71ff195b4856c0ade4e488ef33b | Rust | zwvista/SampleMisc | /Rust/sample_rust/src/rest.rs | UTF-8 | 3,322 | 3.1875 | 3 | [] | no_license | use std::error::Error;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
struct Post {
#[serde(rename(serialize = "userId", deserialize = "userId"))]
user_id: i32,
id: i32,
title: String,
body: String,
}
const BASE_URL: &str = "http://jsonplaceholder.typicode.com... | true |
efc11b773a37b73ef13a6f2fb941f6f82ecc44fb | Rust | imishinist/rval | /src/validation.rs | UTF-8 | 1,040 | 2.765625 | 3 | [] | no_license | use std::fmt::{Debug, Display};
use anyhow::{Error, Result};
use crate::data::{Response, Spec};
fn assert<T, I>(expected: T, got: T, msg: I) -> Result<()>
where
T: Display + PartialEq,
I: Into<String>,
{
if expected != got {
let context = format!("expected: {}, but got: {}", expected, got);
... | true |
d4efdff32086083ad14ac522c90ec8e06caf7ca2 | Rust | fredemmott/hhvm | /hphp/hack/src/ocamlrep/error.rs | UTF-8 | 4,005 | 2.703125 | 3 | [
"MIT",
"PHP-3.01",
"Zend-2.0"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::error::Error;
use std::fmt;
use std::num::TryFromIntError;
use std::str::Utf8Error;
/// Returned by
/// [`OcamlRep::from_ocaml... | true |
4c2668a0de43753cc1211aa1e1662adba793ba07 | Rust | image-rs/image | /src/codecs/tga/header.rs | UTF-8 | 5,302 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::{
error::{UnsupportedError, UnsupportedErrorKind},
ColorType, ImageError, ImageFormat, ImageResult,
};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::io::{Read, Write};
pub(crate) const ALPHA_BIT_MASK: u8 = 0b1111;
pub(crate) const SCREEN_ORIGIN_BIT_MASK: u8 = 0b10_0000;
pub(c... | true |
e393a828acbf4deb5a59bd7ee1d61a895b12c35d | Rust | XMPPwocky/vel0city | /vel0city_base/src/assets.rs | UTF-8 | 625 | 2.8125 | 3 | [] | no_license | use std::io;
use std::io::Read;
use std::fs::File;
use std::path::PathBuf;
fn name_to_path(name: &str) -> PathBuf {
let mut path = PathBuf::new();
path.push("assets/");
path.push(name);
path
}
pub fn load_bin_asset(name: &str) -> io::Result<Vec<u8>> {
let path = name_to_path(name);
let mut v ... | true |
afdf0c57bde9f93f2ba3bf6afd9ad023b48d1636 | Rust | frontapp/rust_mysql_common | /src/named_params.rs | UTF-8 | 6,456 | 2.828125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright (c) 2017 Anatoly Ikorsky
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// m... | true |
75b90af7eb98ba71768a471c5f58b488ed5556e4 | Rust | DeltaEpsilon7787/TGMicroAtmosSim | /src/gas.rs | UTF-8 | 2,006 | 2.765625 | 3 | [] | no_license | extern crate enum_map;
use enum_map as EM;
use std::ops::{Add, Index, Mul};
#[derive(Copy, Clone, Debug, EM::Enum)]
#[repr(u8)]
pub enum Gas {
N2,
O2,
CO2,
N2O,
Pl,
H2O,
HNb,
NO2,
H2,
BZ,
ST,
PlOx,
}
pub const GAS_AMT: usize = 12;
impl Gas {
fn heat_cap_of(self) ->... | true |
7317c7ea477ce8ab7d09d22208d89f1d4d42dcff | Rust | ianoc/local_cache_proxy | /src/net/server_io.rs | UTF-8 | 2,159 | 2.90625 | 3 | [] | no_license | use futures::{future, Future};
use http::header;
use http::header::HeaderValue;
use http::Response;
use http::StatusCode;
use hyper::Body;
use net::buffered_send_stream;
use net::server_error::ServerError;
use std::fs;
use std::io::ErrorKind as IoErrorKind;
// Generate a response future for a given status code
pub fn ... | true |
0340af7c7f8e78280514d3d3f40996b44b241be6 | Rust | gabrielesvelto/api-daemon | /third-party/tokio-timer/src/clock/clock.rs | UTF-8 | 3,892 | 3.515625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use clock::Now;
use timer;
use tokio_executor::Enter;
use std::cell::RefCell;
use std::fmt;
use std::sync::Arc;
use std::time::Instant;
/// A handle to a source of time.
///
/// `Clock` instances return [`Instant`] values corresponding to "now". The source
/// of these values is configurable. The default source is [... | true |
b5e5da12d822ff5c34d9bd8c4f9fbe37da4eec87 | Rust | mdibble/nes-emu | /src/cartridge/uxrom_2.rs | UTF-8 | 1,529 | 3.015625 | 3 | [] | no_license | use crate::cartridge::Mapper;
use crate::cartridge::RomData;
use crate::cartridge::Mirror;
pub struct UxROM {
data: RomData,
bank: u8
}
impl UxROM {
pub fn new(mut data: RomData) -> UxROM {
data.chr_ram.resize(0x2000, 0);
UxROM {
data: data,
bank: 0
}
}... | true |
50326194c9d514ac8f1d36eb445d6a1bda59c2b0 | Rust | GaiaWorld/pi_show | /gui/src/single/oct.rs | UTF-8 | 2,563 | 2.6875 | 3 | [] | no_license | /// 八叉树单例封装
use octree::Tree;
use ecs::monitor::NotifyImpl;
use component::user::{Aabb3, Point3, Vector3};
use Z_MAX;
#[derive(Deref, DerefMut)]
pub struct Oct(Tree<f32, usize>);
impl Oct {
pub fn new() -> Self {
Oct(Tree::new(
Aabb3::new(
Point3::new(-1024f3... | true |
a2b347a3680086fe721c27daf43f198962c8d81c | Rust | Rufflewind/tokio-signal-catcher | /src/lib.rs | UTF-8 | 7,983 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Allow signal-based termination to be handled in a more graceful manner.
//!
//! ```
//! extern crate futures;
//! extern crate tokio_core;
//! extern crate tokio_signal_catcher;
//!
//! fn main() {
//! { // everything within this scope will be dropped gracefully
//! // when a signal is received
//! ... | true |
74a4519e5b6b7da99d0db700d3c96d0f1c09e482 | Rust | Lymia/enumset | /enumset/src/lib.rs | UTF-8 | 7,890 | 3.53125 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![no_std]
#![deny(missing_docs)]
#![allow(clippy::missing_safety_doc)] // The safety requirement is "use the procedural derive".
#![allow(clippy::needless_range_loop)] // range loop style is clearer in most places in enumset
#![cfg_attr(docsrs, feature(doc_cfg))]
//! A library for defining enums that can be used in c... | true |
affbcbd8bce0479002b80dd7131e86f42c5a5378 | Rust | hangsiahong/koompi-appstore | /pi-deriver-discover/src/interface.rs | UTF-8 | 15,071 | 2.5625 | 3 | [] | no_license | use super::xml::*;
use treexml::Element;
impl Application {
pub fn new(data: Element) -> Application {
let mut app: Application = Application::default();
for c in data.children.iter() {
match c.name.as_ref() {
"id" => app.id = c.text.clone().unwrap(),
"n... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.