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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3695f4a932425f07ff3d59594761f9e35d246748 | Rust | risooonho/kludgine | /src/sprite/sheet.rs | UTF-8 | 3,472 | 3.1875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
math::Size,
math::{Point, Rect},
sprite::{SpriteCollection, SpriteMap, SpriteSource},
texture::Texture,
};
use async_handle::Handle;
use async_trait::async_trait;
use std::{collections::HashMap, fmt::Debug, hash::Hash};
#[derive(Debug, Clone)]
pub struct SpriteSheet<T>
where
T: Debug,
... | true |
cbf23bbf5ea307a854371b01a21b600aae8c1039 | Rust | Kixiron/sruth | /src/repr/value.rs | UTF-8 | 4,681 | 2.875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::Type;
use crate::repr::{
constant::Constant,
instruction::VarId,
utils::{DisplayCtx, IRDisplay},
};
use abomonation_derive::Abomonation;
use lasso::Resolver;
use pretty::{DocAllocator, DocBuilder};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Abomonation)]
pub struct Value {
... | true |
baa9eb007fa764f162d7050bfc357318401f2922 | Rust | Kloenk/netbox-rs | /src/builder.rs | UTF-8 | 2,765 | 2.828125 | 3 | [] | no_license | use super::{NetBox, Result};
use std::error::Error;
use reqwest::ClientBuilder;
#[derive(Debug)]
pub struct NetBoxBuilder {
// the netbox token
token: String,
// the base url of nebox (including /api/)
base_url: String,
// the reqwest request builder
client_builder: Option<ClientBuilder>,
}... | true |
9cdead3e31117a9ab05f22bbecd75cc88bed9cf4 | Rust | galenelias/AdventOfCode_2017 | /src/Day12/mod.rs | UTF-8 | 1,451 | 3.09375 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::collections::{HashSet, HashMap, VecDeque};
use regex::Regex;
fn build_graph(input : Vec<Vec<i32>>) -> HashMap<i32,Vec<i32>> {
let mut graph : HashMap<i32,Vec<i32>> = HashMap::new();
for line in input {
let children = line.iter().skip(1).cloned().collect::<Vec<i32>>();
grap... | true |
f1bad7edb2517bd922e445eb3dd03318c8d0ad5f | Rust | baitcenter/ascii-pay-server | /src/core/products.rs | UTF-8 | 10,514 | 2.8125 | 3 | [] | no_license | use chrono::{Local, NaiveDateTime};
use diesel::prelude::*;
use std::fs::{self, File};
use std::path::Path;
use uuid::Uuid;
use crate::core::schema::product_barcode;
use crate::core::{
env, generate_uuid, Category, DbConnection, Money, Price, ServiceError, ServiceResult, DB,
};
/// Represent a product
#[derive(De... | true |
cd7be78d099a36a29f1ccf709a7cb0f84ad2ff91 | Rust | joesan/lychee | /src/lib.rs | UTF-8 | 1,242 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[deny(missing_docs)]
/**
* `lychee` is a library for checking links.
* "Hello world" example:
* ```
* use std::error::Error;
*
* #[tokio::main]
* async fn main() -> Result<(), Box<dyn Error>> {
* let response = lychee::check("https://github.com/lycheeverse/lychee").await?;
* println!("{}", response);
* Ok(())
*... | true |
56d29e6d76eba2ceb7121abc1244fa03f5b864d8 | Rust | Borrus-sudo/aero | /src/aero_kernel/src/utils/buffer.rs | UTF-8 | 1,428 | 3.6875 | 4 | [
"Apache-2.0"
] | permissive | use core::fmt::Write;
/// Special special kind of buffer that stores valid UTF-8 text
/// is always a constant size, removing the oldest messages when
/// new messages are received without allocating memory on the
/// kernel heap.
#[derive(Debug)]
pub struct RingBuffer<S: AsRef<[u8]> + AsMut<[u8]>> {
storage: S,
... | true |
eb296a12a14ab518ee475ce87b8dfb78e60fa025 | Rust | fabianboesiger/strata | /src/operator/save.rs | UTF-8 | 540 | 3.03125 | 3 | [] | no_license | use super::{
Operation,
View,
error,
};
use std::path::PathBuf;
pub struct Save {
path: PathBuf
}
impl Save {
pub fn new(path: PathBuf) -> Save {
Save {
path
}
}
}
impl Operation for Save {
fn apply(&self, view: View) -> error::Result<View> {
println!("... | true |
5252e327d719a75045d4c9d783abecdf8512bff2 | Rust | infinityb/surface | /src/colorspace/conversion/yuv2rgb.rs | UTF-8 | 1,523 | 2.5625 | 3 | [] | no_license | use std::cmp::{min, max, Ord};
use std::ops::Deref;
use ::Surface;
use super::super::super::Channel;
use super::super::{ColorYUV, ColorRGB, Pixel};
use super::super::super::unified::{Yuv444, Rgb, Format};
use ::unsafe_impl::chunks3_mut;
fn clamp<T: Ord>(value: T, min_value: T, max_value: T) -> T {
max(min(value, ... | true |
8de425a8261cda87e48ed23bb739aef77f451522 | Rust | tqdv/switchable | /src/util.rs | UTF-8 | 1,451 | 3.546875 | 4 | [
"Artistic-2.0"
] | permissive | //! Actual utility functions that go nowhere else, and aren't syntax extensions (`slang`)
/// Given two Vecs, returns their set difference as two Vecs
pub fn set_diff<T :Ord> (mut left :Vec<T>, mut right :Vec<T>) -> (Vec<T>, Vec<T>) {
use std::cmp::Ordering::*;
if left.is_empty() || right.is_empty() {
... | true |
fd23ee8e2ed062df5b7007f407c5a2f204abd274 | Rust | lazytiger/pbrt-rs | /src/core/texture.rs | UTF-8 | 11,670 | 2.890625 | 3 | [
"MIT"
] | permissive | use crate::core::{
geometry::{spherical_phi, spherical_theta, Point2, Point2f, Point3f, Vector2f, Vector3f},
interaction::SurfaceInteraction,
pbrt::{clamp, lerp, Float, INV_2_PI, INV_PI, PI},
transform::{Point3Ref, Transformf, Vector3Ref},
};
use std::{any::Any, fmt::Debug, sync::Arc};
pub trait Textur... | true |
18ef2b9ade933a184d2a2cd693014f5cbb62b0f2 | Rust | yusdacra/nut_self | /example/src/main.rs | UTF-8 | 558 | 3.1875 | 3 | [
"MIT"
] | permissive | use nut_self::nut;
struct Nuts(u8);
impl Nuts {
nut! {
fn nut(&nut self) {
self.0 += 1;
}
}
nut! {
fn reset_nuts(&nut self) -> u8 {
let my_nuts = self.0;
self.0 = 0;
my_nuts
}
}
}
nut! {
fn main() {
let nut n... | true |
0c947ae6101c00ebae60a82604619fbae6331568 | Rust | amilajack/rust-playground | /src/trie.rs | UTF-8 | 2,330 | 3.9375 | 4 | [] | no_license | use std::collections::HashMap;
#[derive(Debug)]
pub struct TrieNode {
map : HashMap<char,TrieNode>,
ending : bool,
}
fn moving<T>(t: T) -> T { t }
impl TrieNode {
/// Instantiate the root node of your trie
/// Just start it like this:
/// ```
/// let trie = TrieNode::new();
/// ```
... | true |
e2692b493540b18b0d05f5845b095e4713739698 | Rust | Jackywathy/mipsy | /crates/mipsy_interactive/src/interactive/commands/step2syscall.rs | UTF-8 | 1,471 | 2.671875 | 3 | [] | no_license | use crate::interactive::error::CommandError;
use super::*;
use super::{Command};
use colored::*;
pub(crate) fn step2syscall_command() -> Command {
command(
"step2syscall",
vec!["s2s"],
vec![],
vec![],
"step forwards until next syscall",
&format!(
"Steps ... | true |
71d494f4c5134a8b7f6c59dd79c2883cc36addf0 | Rust | scullionw/project-euler | /rust/src/bin/p008.rs | UTF-8 | 627 | 2.578125 | 3 | [] | no_license | #![feature(test)]
use benchtest::benchtest;
const BASE_CASE_INPUT: usize = 4;
const PROBLEM_INPUT: usize = 13;
const PROBLEM_DATA: &str = include_str!("data/p008_data.txt");
fn solve(seq: &str, n: usize) -> u64 {
seq.chars()
.filter_map(|x| x.to_digit(10).map(u64::from))
.collect::<Vec<_>>()
... | true |
236f6acbecd5a45804b6a59fb39bb48fd7f77303 | Rust | potatosalad/leetcode | /src/n0040_combination_sum_ii.rs | UTF-8 | 2,774 | 3.671875 | 4 | [
"Apache-2.0"
] | permissive | /**
* [40] Combination Sum II
*
* Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.
*
* Each number in candidates may only be used once in the combination.
*
* Note:
*
*
* All numbers (incl... | true |
38d3d73fd93a7dc30ec4146c3a3ee006bb86cad1 | Rust | livexia/algorithm | /blind_75_leetcode/src/solution/s0338_counting_bits.rs | UTF-8 | 618 | 3.40625 | 3 | [] | no_license | #![allow(dead_code)]
pub struct Solution {}
impl Solution {
pub fn count_bits(n: i32) -> Vec<i32> {
let mut bits = Vec::with_capacity(n as usize + 1);
bits.push(0);
let mut offset = 0;
for i in 1..=n as usize {
if i & (i - 1) == 0 {
offset = i;
... | true |
0e9e703f2266ec03a77ba5b610bddc9d458dd865 | Rust | BartMassey/groupby | /examples/basic.rs | UTF-8 | 523 | 2.84375 | 3 | [
"MIT"
] | permissive | // Copyright © 2019 Bart Massey
// [This program is licensed under the "MIT License"]
// Please see the file LICENSE in the source
// distribution of this software for license terms.
use groupby::*;
fn main() {
let s = "1515026263737430145";
println!("{}", s);
let ts: Vec<char> = s.chars().collect();
... | true |
cd86069cd411fe9d93451b2116bc0ef00369a4e2 | Rust | CosmicBagel/learn_rust | /src/chp8_exercises.rs | UTF-8 | 8,197 | 3.625 | 4 | [] | no_license | use std::io::Write;
fn main() {
calcs();
pig_latin();
employee_app();
}
fn employee_app() {
use std::collections::HashMap;
use std::io::stdin;
use std::io::stdout;
use std::collections::hash_map::Entry;
// not using parallel vectors to store the vector of employees and department name... | true |
b489e53dbfb0b7789cfd8a38ae29745ea4cbe50a | Rust | jwilm/git-build-version | /src/lib.rs | UTF-8 | 1,549 | 2.71875 | 3 | [
"MIT"
] | permissive | extern crate git2;
#[macro_use]
extern crate quick_error;
use git2::{Repository, DescribeOptions};
use std::env;
use std::convert::AsRef;
use std::fs::{File, create_dir_all};
use std::io::{Write, Read, BufWriter};
use std::path::Path;
quick_error! {
#[derive(Debug)]
pub enum Error {
Io(err: std::io::E... | true |
9e6e5eee0cc047f17af24ef3db81c3b702325159 | Rust | dovahcrow/scirust | /src/linalg/matrix/mat_traits.rs | UTF-8 | 486 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive |
// local imports
use number::{Number, Signed};
use error::SRError;
/// Linear algebra methods for matrix of numbers
pub trait LANumberMatrix<T:Number+Signed> {
/// Returns the determinant of the matrix
fn det(&self) -> Result<T,SRError>;
}
/// Linear algebra methods for integer matrix
pub trait LAIntMat... | true |
a70818067e804afb5f6b4bbc2c0075cbce346e00 | Rust | solarsail/RagaMuffin | /src/widgets/button.rs | UTF-8 | 635 | 3.171875 | 3 | [] | no_license | pub struct Clickable {
area: Rect,
is_down: bool,
}
impl Clickable {
fn on_clicked(&self, f: F)
where F: FnMut()
{
f(ith);
}
fn click(&self) {}
}
impl Widget for Clickable {
fn handle_event(&mut self, e: &Event) -> bool {
match e {
Event::MouseDown => {... | true |
3253b3492bef590e4d0b63b4671dd76ac69093e0 | Rust | h2gb/h2datatype | /src/simple/character/utf8.rs | UTF-8 | 3,890 | 3.234375 | 3 | [] | no_license | #[cfg(feature = "serialize")]
use serde::{Serialize, Deserialize};
use simple_error::SimpleResult;
use sized_number::Context;
use crate::{Alignment, H2Type, H2Types, H2TypeTrait, Offset};
use crate::simple::character::common;
/// Defines a UTF-8 value.
///
/// A UTF-8 value is a character that's represented by 1-4 b... | true |
8505581977e4a90a9e57874b17a3a35ab307f0a8 | Rust | sam701/syconf | /syconf-lib/src/compiler/methods/mod.rs | UTF-8 | 2,023 | 3.375 | 3 | [
"Apache-2.0"
] | permissive | use crate::compiler::value::{Func, Method};
use crate::compiler::{Error, Value};
pub mod hashmap;
pub mod list;
pub mod string;
pub fn index(args: &[Value]) -> Result<Value, Error> {
debug!(?args, "index");
match &args[0] {
Value::HashMap(hm) => {
let key = args[1].as_value_string()?;
... | true |
8130bdb4eeb7650120aaa6363b506cff49ddd2e4 | Rust | etheryal/building-blocks | /examples/lod_terrain/frame_budget.rs | UTF-8 | 1,924 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use std::time::Duration;
pub struct FrameBudget {
num_threads: u32,
item_time_estimate_us: u32,
target_frame_time_us: u32,
timer: Option<WorkTimer>,
}
struct WorkTimer {
total_cpu_time: Duration,
items_completed: u32,
}
impl WorkTimer {
pub fn start() -> Self {
... | true |
f77c82baf71be281f93f4720ae8dc09248406f45 | Rust | jordwest/xtypes | /xtypes-json-rust/src/code_gen.rs | UTF-8 | 2,131 | 2.71875 | 3 | [] | no_license | use xtypes::ast::{MessageType, SymbolType};
use xtypes::module_loader::ModuleScope;
use jens::Block;
use jens_derive::Template;
#[derive(Template)]
#[filename = "rust.jens"]
struct Template {}
mod gen {
use super::Template;
use xtypes::ast::{EnumVariant, StructField, SymbolDefinition, Tuple, TypeName};
u... | true |
14d1d638b75b7c253091ca6aa791a08ebe33ed00 | Rust | caibirdme/leetcode_rust | /src/prob_343.rs | UTF-8 | 942 | 3.375 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn integer_break(n: i32) -> i32 {
use std::cmp::max;
let mut ans = 1;
if n == 3 {
return 2;
}
if n == 2 {
return 1;
}
let t = n/3;
for i in 0..=t {
let rest = n-i*3;
if rest&1==0 {
... | true |
c4717c8ef5ce2e09f43be7f934dd84f4cc279731 | Rust | drataiczak/Rust | /RustV2/references/src/main.rs | UTF-8 | 689 | 3.875 | 4 | [] | no_license | fn main() {
let mut st = String::from("Hello");
// Passes a reference to st so we do not have to return a tuple
let len = calc_len(&mut st);
{
let st2 = &mut st;
}
// We cannot have to mutable references to the same data
// in the same scope. However, in different scopes we can
let st3 = &mut st;
// This ... | true |
3fb33001ab6dec445c1da424f29ca7d25188b8fe | Rust | Fantom-foundation/solidity-rs | /src/parser/mod.rs | UTF-8 | 44,580 | 2.8125 | 3 | [
"MIT"
] | permissive | mod non_empty;
use crate::parser::non_empty::NonEmpty;
use std::convert::TryFrom;
use std::str::FromStr;
#[inline]
fn is_ascii_hexdigit(c: char) -> bool {
c.is_ascii_hexdigit()
}
#[inline]
fn is_valid_string_character(c: char) -> bool {
c != '\n' && c != '\r' && c != '"'
}
#[inline]
fn is_first_digit_identif... | true |
2b08ba30ce56fda43b3a17d6ac6bab62865e7d67 | Rust | janpauldahlke/fhir-rs | /src/model/Organization.rs | UTF-8 | 19,549 | 2.796875 | 3 | [
"MIT"
] | permissive | #![allow(unused_imports, non_camel_case_types)]
use crate::model::Address::Address;
use crate::model::CodeableConcept::CodeableConcept;
use crate::model::ContactPoint::ContactPoint;
use crate::model::Element::Element;
use crate::model::Extension::Extension;
use crate::model::Identifier::Identifier;
use crate::model::M... | true |
2764adbc2e2070f8a6b77b5f38ec333ded65aac3 | Rust | ayushmishra2005/rust | /compiler/rustc_mir_build/src/thir/visit.rs | UTF-8 | 6,304 | 2.578125 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | use crate::thir::*;
pub trait Visitor<'thir, 'tcx>: Sized {
fn visit_expr(&mut self, expr: &'thir Expr<'thir, 'tcx>) {
walk_expr(self, expr);
}
fn visit_stmt(&mut self, stmt: &'thir Stmt<'thir, 'tcx>) {
walk_stmt(self, stmt);
}
fn visit_block(&mut self, block: &Block<'thir, 'tcx>)... | true |
8108f95ff3526184d75caaae7868857d4c1ab107 | Rust | weykon/rust-softrender | /src/primitive.rs | UTF-8 | 5,373 | 3.65625 | 4 | [] | no_license | //! Primitive type-ids and reference enums
use ::numeric::FloatScalar;
use ::geometry::ClipVertex;
/// Defines the kinds of primitives that can be rendered by themselves.
pub trait Primitive {
/// Get's the number of vertices for the given primitive type
fn num_vertices() -> usize;
#[inline(always)]
... | true |
78b27f2e2d3bf1713124e8445f044cbf9837adc7 | Rust | Slowyn/rust-tracer | /src/physics/aabb.rs | UTF-8 | 1,413 | 3.15625 | 3 | [] | no_license | use crate::math::Vec3;
use crate::physics::Ray;
#[inline]
fn ffmin(a: f32, b: f32) -> f32 {
if a < b {
a
} else {
b
}
}
#[inline]
fn ffmax(a: f32, b: f32) -> f32 {
if a > b {
a
} else {
b
}
}
// Axis Aligned Bounding Box
#[derive(Copy, Clone)]
pub struct AABB {... | true |
55ded641ec6e8f86e51175f26024e9a22ea92349 | Rust | byron7cueva/learn-wasm | /graphics/src/lib.rs | UTF-8 | 2,384 | 3.21875 | 3 | [] | no_license | use wasm_bindgen::prelude::*;
// Definiendo el tamaño del tablero
const CHECKBOARD_SIZE: usize = 20;
// 20x20 pixeles y 4 colores por pixel (r,g,b,a) lo que soporta canvas
const OUTPUT_BUFFER_SIZE: usize = CHECKBOARD_SIZE * CHECKBOARD_SIZE * 4;
// Esta sera utilizada para poner la salida de nuestro grafico y pasarla... | true |
8e19d40624175d46f8542853c95af3c7462fd9c7 | Rust | intellij-rust/intellij-rust | /src/test/resources/org/rust/lang/core/mir/fixtures/struct_named_fields_complex.rs | UTF-8 | 177 | 2.78125 | 3 | [
"MIT"
] | permissive | struct A { x: i32 }
struct B {
y: i32,
z: A,
}
fn main() {
let a1 = A { x: 1 };
let b1 = B { y: 2, z: a1 };
let a2 = b1.z;
let b2 = B { y: 3, z: a2 };
}
| true |
172d97e0995007f9f348fd0cdeaa53e9179dfdb5 | Rust | tari-project/tari | /base_layer/core/src/mempool/priority/prioritized_transaction.rs | UTF-8 | 7,256 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2019 The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// dis... | true |
67907d6e0c8b08d63aa8052a2f0851a5f01399cc | Rust | drahnr/tokio-mqtt-1 | /src/clientoptions.rs | UTF-8 | 7,416 | 3.296875 | 3 | [
"MIT"
] | permissive | use rand::{self, Rng};
use std::path::{Path, PathBuf};
use mqtt3::QoS;
#[derive(Clone)]
pub struct MqttOptions {
pub addr: String, // TODO: Use a default localhost here instead of option
pub keep_alive: u16,
pub clean_session: bool,
pub client_id: String,
pub username: Option<String>,
pub passw... | true |
30508c32784c873c6a7978355b1c4d40ee87f5e6 | Rust | onelson/destiny2-api-rs | /codegen/src/models/destiny_definitions_director_destiny_linked_graph_definition.rs | UTF-8 | 4,609 | 2.609375 | 3 | [] | no_license | /*
* Bungie.Net API
*
* These endpoints constitute the functionality exposed by Bungie.net, both for more traditional website functionality and for connectivity to Bungie video games and their related functionality.
*
* OpenAPI spec version: 2.0.0
* Contact: support@bungie.com
* Generated by: https://github.com... | true |
6e301ed69694269b2469acd486636c8fa12c1efa | Rust | chainseeker/chainseeker-server | /server/src/db/utxo_server.rs | UTF-8 | 4,608 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::*;
use indexmap::IndexMap;
use bitcoin::{Txid, Script, Block, WScriptHash};
use crate::db::utxo::UtxoEntry;
#[derive(Debug, Clone, PartialEq)]
pub struct UtxoServerValue {
pub txid: Txid, // +32 = 32
pub vout: u32, // + 4 = 36
}
#[derive(Debug, Clone)]
pub struct UtxoServer {
db: IndexMap<WS... | true |
4ad7be9c207a26f0e94c59a9c7f5a2ed20b986a3 | Rust | franktea/leetcode-rust | /src/bin/0005.rs | UTF-8 | 1,227 | 3.28125 | 3 | [] | no_license | // 以index为中心的最长回文
pub fn longest_palindrome_of(index: usize, sv: &Vec<char>) -> std::ops::Range<usize> {
// 基数长度的回文
let mut r1 = index..(index+1);
for (i, j) in (0..=index).rev().zip(index..sv.len()) {
if sv[i] != sv[j] {
break;
}
r1 = i..(j+1);
}
// 偶数长度的回文
... | true |
9766100b1d864996e15227069547cc5d4627da1c | Rust | Text-Input/Ray_Tracer | /src/hit/instancing.rs | UTF-8 | 6,917 | 2.984375 | 3 | [] | no_license | use crate::hit::hitable_list::*;
use crate::hit::rectangle::*;
use crate::hit::HitRecord;
use crate::hit::Hitable;
use crate::hit::AABB;
use crate::material::Material;
use crate::ray::Ray;
use crate::vec3::Vec3;
use std::sync::Arc;
#[derive(Debug)]
pub struct FlipFace<T: Hitable> {
obj: T,
}
impl<T: Hitable> Fli... | true |
0ed4e0d6a6406a21e2a99791c0ec69fd1e3021c8 | Rust | apawn/rust-search-extension | /manage/src/main.rs | UTF-8 | 2,322 | 2.703125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Build manage directory html pages.
use std::{error::Error, fs, io::Write, path::PathBuf, sync::mpsc::channel, time::Duration};
use notify::{watcher, Watcher};
use tera::{Context, Tera};
pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
const TEMPLATES: [&str; 5] = [
"index.html",
"crates.html... | true |
9ffb95f2ac784254943ea38df9df752311b7a16d | Rust | lonski/tgs | /src/config.rs | UTF-8 | 3,621 | 3.8125 | 4 | [] | no_license | pub struct Config {
pub images: Vec<String>,
pub size: u32,
pub prefix: String,
pub start_service: bool,
pub service_port: u32,
}
impl Config {
pub fn new(args: &[String]) -> Result<Config, String> {
let mut iter = args.iter();
let mut cfg = Config {
images: Vec::ne... | true |
c6e335cda9ae602bcc4890adbdf17429916fd2c6 | Rust | zshipko/rust-kv | /src/value.rs | UTF-8 | 1,179 | 3.09375 | 3 | [
"ISC"
] | permissive | use crate::Error;
/// A trait used to convert between types and `Raw`
pub trait Value: Sized {
/// Wrapper around AsRef<[u8]>
fn to_raw_value(&self) -> Result<Raw, Error>;
/// Convert from Raw
fn from_raw_value(r: Raw) -> Result<Self, Error>;
}
/// Raw is an alias for `sled::IVec`
pub type Raw = sled... | true |
5a99847911fa1c737843f2e99be2ecdf714d8265 | Rust | AaronShah2/SGDA_Game_Jam_Proj | /src/systems/dog.rs | UTF-8 | 4,712 | 2.828125 | 3 | [] | no_license | // dog obj that stops player and enemy
use crate::{
components::{Dog, Enemy, Player},
resources::Paused,
};
use amethyst::{
core::Transform,
derive::SystemDesc,
ecs::{Join, Read, ReadStorage, System, SystemData, WriteStorage},
};
use nalgebra::base::Vector3;
// lets dog move left and right
const AR... | true |
40571d233afab2e19c35cafa69efd7858196887f | Rust | eda3/rust_sandbox | /01_itp1/itp1_5_d_StructuredProgramming/src/main.rs | UTF-8 | 402 | 2.84375 | 3 | [] | no_license | fn main() {
let v:u64 = {
let mut b = String::new();
let s = std::io::stdin();
s.read_line(&mut b).unwrap();
b.trim().parse().unwrap()
};
let mut f;
let mut c = 0;
while c < v{
f = true;
c += 1;
let mut x = c;
if x % 3 == 0{
print!(" {}", c);
continue
}
while x != 0 && f{
if x % 10 == ... | true |
742c32490b07fb943c467f398ee5c04cc2057c40 | Rust | chris-oo/crafting-interpreters-rust | /src/value.rs | UTF-8 | 868 | 3.34375 | 3 | [] | no_license | use crate::lox_string_table::LoxString;
use std::fmt;
// TODO - the book has two different nested types - values and objects.
// It seems to me they could be flattened? Does it make sense to do that?
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
ValBool(bool),
ValNil,
ValNumber(f64),
ValObjString... | true |
89fa928049d42c8f32d2baf522d229ecce31dfe7 | Rust | moisutsu/arxiv-rs | /tests/query.rs | UTF-8 | 1,207 | 2.765625 | 3 | [
"MIT"
] | permissive | use arxiv::{ArxivQuery, ArxivQueryBuilder};
#[test]
fn builder() {
let query = ArxivQuery {
base_url: "http://export.arxiv.org/api/query?".to_string(),
search_query: "search_query".to_string(),
id_list: "id_list".to_string(),
start: Some(3),
max_results: Some(5),
sor... | true |
5d375eb69968c0facdee7951b00ee562ed6ac963 | Rust | chridou/towers-rs | /src/iterative_solver.rs | UTF-8 | 1,083 | 3.203125 | 3 | [] | no_license | use super::*;
pub fn next_move(n: u64, board: &Board) -> Option<(usize, usize)> {
if board.is_finished() {
None
} else {
calculate_next(n, board)
}
}
fn calculate_next(n: u64, board: &Board) -> Option<(usize, usize)> {
let num_disks = board.num_disks();
let (aux_pole, dest_pole) = ... | true |
60acfa1b069d1495d1bdd3838b5b057ba160f071 | Rust | jbert/cpals-rust | /src/sha1.rs | UTF-8 | 5,775 | 3.1875 | 3 | [] | no_license | // From https://github.com/Munksgaard/sha1
extern crate byteorder;
use byteorder::{BigEndian, ByteOrder, WriteBytesExt};
use std::num::Wrapping;
fn rotate_left(n: Wrapping<u32>, m: u32) -> Wrapping<u32> {
Wrapping(n.0.rotate_left(m))
}
/// Returns the SHA-1 hash of the input
///
/// # Arguments
///
/// * `input... | true |
f0cf8503deed9112e985cfae85978c6c1dda2539 | Rust | dangduoc08/rust-concepts | /src/error/src/question_mark_operation.rs | UTF-8 | 468 | 3.3125 | 3 | [] | no_license | use super::error_fnc;
fn test_question_mark_operation(n: i8) -> Result<i8, Option<String>> {
let res: i8 = error_fnc::err_fn(n)?; // => Work like match but shorter
Ok(res * 10)
}
pub fn using() {
let number: i8 = -10;
match test_question_mark_operation(number) {
Ok(n) => println!("Number will be multiply... | true |
e8de71ec3d5a728e4b760db98f570848d61d7dfb | Rust | afaber999/dicom-pipe | /dcmpipe_lib/src/defn/vr.rs | UTF-8 | 39,420 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | //! Value Representation
use std::fmt;
use std::hash::{Hash, Hasher};
use crate::core::charset::{CSRef, DEFAULT_CHARACTER_SET};
/// The BACKSLASH used to delimit multi-value character string values, `\`
pub const CHARACTER_STRING_SEPARATOR: char = 0x5C as char;
/// The SPACE character used for padding
pub const SPAC... | true |
9788d2791b06a60e3e2493d73e4a9ad56ecd30e0 | Rust | iCodeIN/MuRust | /murust-service/src/lib.rs | UTF-8 | 3,218 | 2.53125 | 3 | [] | no_license | #![feature(vec_remove_item, range_contains)]
#[cfg(test)]
extern crate tempdir;
#[cfg(test)]
#[cfg_attr(test, macro_use)]
extern crate matches;
#[macro_use]
extern crate failure;
extern crate bcrypt;
extern crate murust_data_model;
extern crate murust_repository;
extern crate num_traits;
extern crate uuid;
pub use ... | true |
0ec16087248b3ee5ff0aec5125dc9050df6508c6 | Rust | mutexlox/aoc-2019 | /src/day23_network.rs | UTF-8 | 3,105 | 3.078125 | 3 | [] | no_license | use std::collections::{HashMap, VecDeque};
use std::env;
use std::fs;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
const NUM_NICS: usize = 50;
fn run_nics(ints: &HashMap<usize, i64>, part_one: bool) -> i64 {
let mut senders = Vec::new();
let mut receivers = Vec::new();
let mut meta_recei... | true |
e32636c49637d00d86437fa775ef3ad4f8858eaa | Rust | ikanago/qz | /examples/chat/src/model.rs | UTF-8 | 449 | 2.90625 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct User {
username: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Post {
username: String,
text: String,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
pu... | true |
0fd9b90c34bb7df4c1e57464f726c654383995e9 | Rust | mjc-gh/r3xx-svc-redirector | /src/main.rs | UTF-8 | 2,729 | 2.734375 | 3 | [] | no_license | extern crate docopt;
extern crate fred;
extern crate futures;
extern crate hyper;
extern crate url_shortener;
use docopt::Docopt;
use fred::RedisClient;
use fred::types::*;
use futures::{Future};
use hyper::server::{Http};
use std::net::{SocketAddr};
use std::env;
use url_shortener::UrlShortener;
const USAGE: &'sta... | true |
b4fc5bb3422a39a811b2ef401e0f586c6f13f8d0 | Rust | kellpossible/sentry-tracing | /src/integration.rs | UTF-8 | 2,901 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | use sentry_core::{ClientOptions, Integration};
use tracing::Level;
use tracing_subscriber::EnvFilter;
/// Integration that performs
#[derive(Debug)]
pub struct TracingIntegrationOptions {
/// The sentry specific tracing span/event level filter (defaults to `info`).
pub filter: EnvFilter,
/// If set to `tru... | true |
62c558f05d003ff6045a7049c3efcd950c7e5ad4 | Rust | Trivaxy/leibniz-lang | /runtime/src/value.rs | UTF-8 | 10,058 | 3.3125 | 3 | [] | no_license | use core::panic;
use std::{fmt, ops};
use linked_hash_map::LinkedHashMap;
use num_complex::Complex64;
#[derive(Clone, Debug)]
pub enum Value {
Real(f64),
Complex(Complex64),
Array(Vec<Value>),
Custom(LinkedHashMap<String, Value>),
LString(String),
}
use Value::*;
impl Value {
pub fn real(n: ... | true |
0e13958d231c1c54cd4362280095a1eec8213552 | Rust | TimeToogo/wezterm | /src/keyassignment.rs | UTF-8 | 13,966 | 2.8125 | 3 | [
"MIT"
] | permissive | use crate::config::configuration;
use crate::frontend::gui::SelectionMode;
use crate::mux::domain::DomainId;
use crate::mux::tab::Pattern;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::PathBuf;
use wezterm_term::input::MouseButton;
use wezterm_term::{KeyCode, KeyModifiers};
/// A m... | true |
5af64d5ec7e380c76b8852ec7e63e08bae2cf829 | Rust | qingzhu521/paradfs | /src/utils/load_source_text.rs | UTF-8 | 1,626 | 2.953125 | 3 | [] | no_license | use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
use crate::structure::{Graph, AdjacentList};
pub fn load_data(static_path: String, dynamic_path: String) -> Result<Graph, LoadError> {
let mut graph = Graph::new(AdjacentList::new(), AdjacentList::new());
let f = File::open(static_path)?;
... | true |
0141271914e3e33a321607423ae1725c839ab752 | Rust | vt6/vt6.rs | /src/server/handler.rs | UTF-8 | 4,381 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | /*******************************************************************************
* Copyright 2020 Stefan Majewsky <majewsky@gmx.net>
* SPDX-License-Identifier: Apache-2.0
* Refer to the file "LICENSE" for details.
*******************************************************************************/
use crate::common::core:... | true |
cd0463bc427a5a5dc16f89fe79f0a8b276d35927 | Rust | funfoolsuzi/emojibomb | /src/lib.rs | UTF-8 | 2,364 | 2.75 | 3 | [
"MIT"
] | permissive | #[macro_use]
pub mod helpers;
pub mod map;
pub mod player;
pub mod server_engine;
pub mod client_engine;
pub mod transport;
pub mod msg;
pub mod log;
pub mod state {
use std::sync::{Arc, RwLock};
#[derive(Clone)]
pub struct GameState {
pub map: Arc<RwLock<crate::map::Map>>,
pub characters... | true |
095f516c09820c0fad1ef9c39b97f7ea8c03b4e6 | Rust | dlee67/ThirdPracticeBucket | /RustPrac/AfterLeavingRustForAwhile/BackToBasic/src/main.rs | UTF-8 | 607 | 3.796875 | 4 | [] | no_license | use std::io;
fn main() {
let x = String::from("I am the lullest");
//The below shadows the x above, where x essentially gets dropped and re-initialized.
let x = take_and_give_ownership(x);
println!("{}, still is.", x);
let mut y = String::from("Not so ");
// I have to declare to the function ... | true |
aaab59eb7aea522ebe651af60c344499014aca90 | Rust | Azure/azure-sdk-for-rust | /services/mgmt/eventgrid/src/package_2022_06/models.rs | UTF-8 | 211,577 | 3.25 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | #![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::de::{value, Deserializer, IntoDeserializer};
use serde::{Deserialize, Serialize, Serializer};
use std::str::FromStr;
#[doc = "This is the base type that represents an advanced filter. To configure an advanced filter, do not directly instantiate an obj... | true |
84d98909df15fdfec3650223b3e194d6db9374f9 | Rust | nmbr7/CBnB_qemu_server | /src/api.rs | UTF-8 | 5,228 | 2.84375 | 3 | [] | no_license | use crate::message::{Message, ServiceMessage, ServiceMsgType, ServiceType};
use indicatif::{ProgressBar, ProgressStyle};
use serde_json::{json, Value};
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::SeekFrom;
use std::net::TcpListener;
use std::net::TcpStream;
use std::process::... | true |
69a24c0b635788da6cdb1a94e9bca7ce4068fe3f | Rust | michelleN/bindle | /src/authn/always/mod.rs | UTF-8 | 392 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use super::Authenticator;
use crate::authz::always::Anonymous;
/// An authenticator that simply returns an anonymous user
#[derive(Clone, Debug)]
pub struct AlwaysAuthenticate;
#[async_trait::async_trait]
impl Authenticator for AlwaysAuthenticate {
type Item = Anonymous;
async fn authenticate(&self, _auth_da... | true |
ba960e8ec52f4057d3ace1faa35bd01eeda45676 | Rust | qqdog1/rust-test | /src/console_input_test.rs | UTF-8 | 316 | 3.078125 | 3 | [] | no_license | use std::io;
fn main() {
let mut input = String::new();
loop {
println!("input anything:");
io::stdin().read_line(&mut input).expect("Failed to read line.");
println!("{}", input);
// the result string will append on the address if input string let outside of while
}
} | true |
674d34cd744a622c2cfa3f61d1233ab56301d2b7 | Rust | PacktPublishing/Rust-Programming-Cookbook | /Chapter10/regex/src/lib.rs | UTF-8 | 2,900 | 3.15625 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod tests {
use regex::Regex;
use std::cell::RefCell;
use std::collections::HashMap;
#[test]
fn simple_parsing() {
let re = Regex::new(r"(?P<y>\d{4})-(?P<m>\d{2})-(?P<d>\d{2})").unwrap();
assert!(re.is_match("1999-12-01"));
let date = re.captures("2019-02-27")... | true |
5b47c28779dd0db6aeb1742db4d541ef3c02cdae | Rust | MichaelShaw/jam | /src/ui/layer.rs | UTF-8 | 1,349 | 3.015625 | 3 | [
"MIT"
] | permissive | use super::RectI;
use Color;
use color;
use ui::{Pattern, Source};
use cgmath::Vector2;
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
pub struct Layer {
pub frame: RectI,
pub content: Element,
}
#[derive(Eq, PartialEq, Clone, Debug, Hash)]
pub enum Element {
Text(Text),
Image(ImageSource),
Draw(P... | true |
03482498667526216c84d1fdb29a055b2d9d2e06 | Rust | zmax5477/rustarok | /client/src/grf/spr.rs | UTF-8 | 8,403 | 2.84375 | 3 | [] | no_license | use rustarok_common::grf::binary_reader::BinaryReader;
use std::rc::Rc;
use std::sync::Arc;
pub struct SpriteFile {
pub frames: Vec<SprFrame>,
pub buffer: Vec<u8>,
}
pub enum SpriteType {
PAL,
ABGR,
}
pub struct SprFrame {
pub typ: SpriteType,
pub width: usize,
pub height: usize,
pub ... | true |
96c57b2d744ccec7fb0ea510ac5c4082bd226649 | Rust | rusticata/asn1-rs | /tests/run-pass/custom_errors.rs | UTF-8 | 1,295 | 2.9375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use asn1_rs::{oid, Any, Error, FromDer, Oid, ParseResult, Sequence};
use hex_literal::hex;
#[derive(Debug)]
pub enum X509Error {
NotYetImplemented,
DerError(Error),
}
impl From<Error> for X509Error {
fn from(e: Error) -> Self {
X509Error::DerError(e)
}
}
#[derive(Debug)]
pub struct AttrValue... | true |
1275d6b9fe243a63905064663282f7f98dcbfa00 | Rust | utilForever/BOJ | /Rust/1992 - Quadtree.rs | UTF-8 | 1,497 | 3.359375 | 3 | [
"MIT"
] | permissive | use std::io;
fn input_integers() -> Vec<i32> {
let mut s = String::new();
io::stdin().read_line(&mut s).unwrap();
let values: Vec<i32> = s
.as_mut_str()
.split_whitespace()
.map(|s| s.parse().unwrap())
.collect();
values
}
fn compress(movie: &Vec<Vec<char>>, y_start:... | true |
5cd5f4414adcdcb8aa1e5ba5bdc0e92ded12dedb | Rust | hessifer/Rust | /structs_enums_examples/src/main.rs | UTF-8 | 1,033 | 4.125 | 4 | [] | no_license | #[derive(Debug)]
pub struct Person {
// data
name: String, // pointer
age: i32,
children: i32,
fav_color: Color,
}
impl Person {
// implementation
pub fn print(self) -> String {
format!("name = {}, age = {} has {} children", self.name, self.age, self.children)
}
}
#[derive(Debu... | true |
f40c9b3bf67c63d4ab1639d95465e895cbf8a5ba | Rust | tchaudhry91/cowin-slack | /src/main.rs | UTF-8 | 5,789 | 2.625 | 3 | [] | no_license | use chrono::Utc;
use clap::{AppSettings, Clap};
use failure::{err_msg, Error};
use reqwest::StatusCode;
use serde::{Deserialize, Serialize};
const DUMMY_BROWSER_AGENT: &str =
"Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0";
const API_BASE: &str = "https://cdn-api.co-vin.in/api/v2/appointmen... | true |
38f09843e4244aa5a9014c9aa49310315b6d5462 | Rust | krasnobaev/rust | /sandbox/wiki/rs_inp/wiki3.rs | UTF-8 | 800 | 3.421875 | 3 | [] | no_license | /* This code taken from
http://en.wikipedia.org/wiki/Rust_(programming_language) */
/* This function creates ten "tasks" that all execute concurrently.
To verify this, run the program several times and observe the irregular
order in which each task's output is printed. */
fn main() {
// This string is immu... | true |
543c581ccb043e15c498389ce4552e8585bb781f | Rust | daniel5151/clicky | /clicky-core/src/devices/platform/pp/cfg_timer.rs | UTF-8 | 6,943 | 2.671875 | 3 | [] | no_license | use crate::devices::prelude::*;
use std::time::Duration;
use futures::future::{self, Either};
use pin_utils::pin_mut;
use relativity::{Instant, Timeout};
use crate::signal::irq;
#[derive(Debug, Copy, Clone)]
enum InterrupterState {
Oneshot { next: Instant },
Repeating { next: Instant, period: Duration },
... | true |
3909536e4a6dd0cf41dc1e45e12a6b66000bcb2f | Rust | kaimast/iced | /graphics/src/gradient.rs | UTF-8 | 2,684 | 3.84375 | 4 | [
"MIT"
] | permissive | //! A gradient that can be used as a [`Fill`] for some geometry.
//!
//! For a gradient that you can use as a background variant for a widget, see [`Gradient`].
//!
//! [`Gradient`]: crate::core::Gradient;
use crate::core::gradient::ColorStop;
use crate::core::{Color, Point};
use std::cmp::Ordering;
#[derive(Debug, Cl... | true |
62339a47c6e75582b42b7f6f39497042a58fee39 | Rust | AndrewMendezLacambra/rust-programming-contest-solutions | /atcoder/tkppc4_2_d.rs | UTF-8 | 1,893 | 3.1875 | 3 | [] | no_license | use std::collections::BTreeMap;
fn main() {
let s = std::io::stdin();
let mut sc = Scanner { stdin: s.lock() };
let n: usize = sc.read();
let p: i64 = sc.read();
let q: i64 = sc.read();
let a: Vec<i64> = sc.vec(n);
if (p + q).abs() % 2 != 0 {
println!("0");
return;
}
... | true |
2e6f6187320a74fcc9c44a4e2608ae57583103cd | Rust | azdavis/advent-of-code | /years/y2020/src/d06.rs | UTF-8 | 670 | 3.140625 | 3 | [
"MIT"
] | permissive | use helpers::HashSet;
pub fn p1(s: &str) -> usize {
s.split("\n\n")
.map(|group| {
group
.lines()
.flat_map(str::chars)
.collect::<HashSet<_>>()
.len()
})
.sum()
}
pub fn p2(s: &str) -> usize {
s.trim_end()
.split("\n\n")
.map(|group| {
let mut sets ... | true |
ae15f3af10124ac55f41313a702cfa334dc4a919 | Rust | Lexkane/Rust | /Concurrency/src/LazyStuct.rs | UTF-8 | 480 | 2.828125 | 3 | [] | no_license | pub struct Lazy<T: Sync> (Cell <Option<T>> ,Once);
impl<T:Sync>Lazy<T>{
pub const fn new ():Self{
Lazy(Cell::new(None),Once::new())
}
pub fn get<F> (&' static self, f: impl FnOnce()->T) ->& T{
self.1.call_once(||{
self.0.set(Some(f()));
});
unsafe {
match *sel... | true |
96c6c83da0e236be53f84be9ee5046263dc8ae1d | Rust | TomMonks/rust-intro | /chapter3/exercises/src/main.rs | UTF-8 | 837 | 3.859375 | 4 | [
"MIT"
] | permissive | fn main() {
println!("Hello, world!");
let deg_f = convert_celsius_to_fahrenheit(39.2);
println!("Degress fahrenheit = {}", deg_f);
convert_data();
let nth_fib = fib_iter(40);
println!("The 40th fibonnaci number is: {}", nth_fib);
}
// Exercise 1: convert celsius to fahrenheit
fn convert_dat... | true |
f440403200c081c5bdcda014bbfdb72d7f1dbc08 | Rust | hydro-project/hydroflow | /hydro_cli_examples/examples/topolotree_latency_measure/main.rs | UTF-8 | 3,701 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::atomic::AtomicU64;
use std::sync::{mpsc, Arc};
use std::thread;
use std::time::Instant;
use futures::{SinkExt, StreamExt};
use hydroflow::bytes::Bytes;
use hydroflow::serde::{Deserialize, Serialize};
use hydroflow::tokio;
use hydroflow::util::cli::{ConnectedDirect, ConnectedSink, ConnectedSource};
use h... | true |
935c467780228788f6c66e29e706b7f7cfba037b | Rust | Kailari/kokonaisuus | /src/vector.rs | UTF-8 | 1,800 | 3.796875 | 4 | [] | no_license | use std::ops::{Add, Mul, AddAssign, Sub};
use std::fmt::{Display, Formatter};
#[derive(Copy, Clone)]
pub struct Vector2d {
pub x: f64,
pub y: f64,
}
impl From<(f64, f64)> for Vector2d {
fn from(source: (f64, f64)) -> Self {
Vector2d { x: source.0, y: source.1 }
}
}
impl Display for Vector2d {... | true |
67f8a49e76b7e9f23b14304c174fc9737fe7c0c1 | Rust | anstylian/advent-of-code | /src/bin/day06.rs | UTF-8 | 1,027 | 2.75 | 3 | [] | no_license | use advent_of_code::file_lines;
use anyhow::Result;
use itertools::Itertools;
fn main() -> Result<()> {
let (unique, everyone) = solution()?;
println!("Part one answer: {}", unique);
println!("Part two answer: {}", everyone);
Ok(())
}
fn solution() -> Result<(u32, u32)> {
let lines = file_lines("... | true |
ee37a99674f2caa789211fdcd0fb7b7767418934 | Rust | jmcomets/artsy | /src/node256.rs | UTF-8 | 3,220 | 2.765625 | 3 | [] | no_license | use std::mem;
use super::{
Child,
NodeImpl,
};
pub(crate) struct Node256<'a, T> {
children: [Option<Box<Child<'a, T>>>; 256]
}
impl<'a, T> Default for Node256<'a, T> {
fn default() -> Self {
Node256 {
children: [
None, None, None, None, None, None, None, None, None... | true |
0b9ac814fc737d209ca8a30cb0da8836293797f5 | Rust | apparentorder/aoc | /2017/src/day13.rs | UTF-8 | 2,743 | 3.125 | 3 | [] | no_license | use crate::aoc;
// key insight: the scanners' up-and-down movements can be interpreted as a
// circle, i.e. a scanner reaches its top position every (range*2 - 2) cycles.
//
// as a packet always travels at one "depth" per time index, depth and time are
// the same (plus delay, for part 2).
type Layers = Vec<i32>;
f... | true |
bf3b38d796cd60a4e41d9c4871beb7c2843f44e2 | Rust | srufle/rust_book | /generic_example/src/main.rs | UTF-8 | 1,087 | 3.921875 | 4 | [
"Apache-2.0"
] | permissive | #[derive(Debug)]
struct Rectangle {
width: u32,
height: u32,
}
impl Rectangle {
fn area(&self) -> u32 {
self.width * self.height
}
}
fn main() {
let width1 = 30;
let length1 = 50;
println!(
"The area_with_raw_nums of the rectangle is {} pixels.",
area_with_raw_nums... | true |
ac9817dbdc1e7bbde8e6eb1284014456a4f5f783 | Rust | tokio-rs/tracing | /tracing-subscriber/tests/env_filter/per_subscriber.rs | UTF-8 | 9,938 | 2.625 | 3 | [
"MIT"
] | permissive | //! Tests for using `EnvFilter` as a per-subscriber filter (rather than a global
//! `subscriber` filter).
#![cfg(feature = "registry")]
use super::*;
use tracing_mock::{span, subscriber};
#[test]
fn level_filter_event() {
let filter: EnvFilter = "info".parse().expect("filter should parse");
let (subscriber, h... | true |
898d8197ce095f89c4b6add7b15f914aaf3d8d55 | Rust | davisma20/routinator | /src/collector/rrdp.rs | UTF-8 | 75,799 | 2.53125 | 3 | [
"BSD-3-Clause"
] | permissive | //! Local repository copy synchronized with RRDP.
//!
//! The RRDP collector works as follows:
//!
//! Data is kept in a sled database. This is normally the same database that
//! is used by the store. Each RRDP repository has one tree in that database whose
//! name is the repository’s rpkiNotify URI prefixed by `"rrd... | true |
d177b37d511dd0c70700249e373e31e8e8a9a61c | Rust | Gawaboumga/rustracer | /src/raytracer/camera.rs | UTF-8 | 1,607 | 3.15625 | 3 | [] | no_license | use super::ray::Ray;
use super::vec3::Vec3;
use rand::Rng;
pub struct Camera {
left_corner: Vec3,
lens_radius: f32,
horizontal: Vec3,
position: Vec3,
vertical: Vec3,
}
impl Camera {
pub fn new(
position: Vec3,
lookat: Vec3,
up: Vec3,
aspect: f32,
fovy: f... | true |
4ba3c5e132224855c47338e689447295eff280e6 | Rust | adam-mcdaniel/xasm | /examples/xasm_core/src/lib.rs | UTF-8 | 4,306 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | extern crate xmachine;
use xmachine::{Machine, Value};
pub fn xasm_list(xasm: &mut Machine) {
let mut result = vec![];
let val = xasm.get_arg();
let count = i32::from(val.clone());
for _ in 0..count {
result.push(xasm.pop());
}
xasm.return_value(Value::List(result));
}
pub fn xa... | true |
94ab0cd9b531839505ae3ac1e0636f5f05afa3d3 | Rust | albmar/comdirect_api | /src/types/order/execution.rs | UTF-8 | 1,017 | 2.796875 | 3 | [] | no_license | use chrono::{DateTime, Utc};
use pecunia::price::Price;
use serde::Deserialize;
use crate::types::order::ExecutionId;
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub struct Execution {
#[serde(with = "ExecutionId")]
#[serde(rename = "executionId")]
id: ExecutionId,
/// indicates the chronological ... | true |
0d4d6a223511f6af4f5424143b1ccc14aee313b6 | Rust | MattiasBuelens/advent-of-code-2019 | /src/bin/day1/main.rs | UTF-8 | 1,151 | 3.21875 | 3 | [
"MIT"
] | permissive | use advent_of_code_2019::input::parse_list;
fn main() {
let input: Vec<u32> = parse_list(include_str!("input"), '\n');
println!("Answer to part 1: {}", part1(&input));
println!("Answer to part 2: {}", part2(&input));
}
fn part1(masses: &Vec<u32>) -> u32 {
masses.iter().map(|&x| get_fuel_part1(x)).sum(... | true |
8278a540029f34696b249928a3906e2f5e59ca8f | Rust | mhirai-bit/Rust-modules | /std_io/BufReader_and_BufWriter/src/main.rs | UTF-8 | 1,096 | 3.34375 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::BufWriter;
use std::fs::File;
fn main() -> io::Result<()> {
buf_reader()?;
buf_writer()?;
buf_reader()?;
Ok(())
}
fn buf_reader() -> io::Result<()> {
let f = match File::open("foo.txt") {
Ok(f) => f,
Err(... | true |
9e21a38e0697ece56966d739ecb20b24f35668f7 | Rust | Bestra/advent-2018-rs | /src/lib.rs | UTF-8 | 2,751 | 3.453125 | 3 | [] | no_license | pub mod day_1;
pub mod day_2;
pub mod day_3;
pub mod day_4;
use std::fs::File;
use std::io::{BufRead, BufReader, Write};
use std::io::prelude::*;
use std::path::Path;
use std::process::exit;
use std::cmp::Ordering;
pub fn read_input(day: &str) -> Vec<String> {
let path = format!("./inputs/{}.txt", day);
if !P... | true |
95fb3d96eba0be8ecf3b4cfff64c71d14fc00b82 | Rust | IThawk/rust-project | /rust-master/src/test/ui/resolve/tuple-struct-alias.rs | UTF-8 | 175 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | struct S(u8, u16);
type A = S;
fn main() {
let s = A(0, 1); //~ ERROR expected function
match s {
A(..) => {} //~ ERROR expected tuple struct/variant
}
}
| true |
8da3575199078292fd4ae86c85a9e40b450136a6 | Rust | AgentX1994/chip8_emu | /src/memory.rs | UTF-8 | 1,793 | 3.4375 | 3 | [
"MIT"
] | permissive | #[derive(Copy, Clone, Debug)]
pub struct OutOfBoundsError;
pub type Result<T> = std::result::Result<T, OutOfBoundsError>;
pub const MEMORY_SIZE: u16 = 4096;
pub struct Memory {
memory: [u8; MEMORY_SIZE as usize],
}
impl Default for Memory {
fn default() -> Self {
Memory {
memory: [0; MEM... | true |
9d7223338e08b2be11952b3bf927c8306553e11d | Rust | genya0407/image2aa | /core/src/filter/shrink.rs | UTF-8 | 644 | 2.59375 | 3 | [
"MIT"
] | permissive | extern crate ndarray;
use crate::utils;
use ndarray::*;
pub fn default() -> ShrinkFilter {
let filter = Array1::<f32>::from(vec![1., 1., 1., 1., 1., 1., 1., 1., 1.])
.into_shape((3, 3))
.unwrap();
ShrinkFilter {
thresh: 5.,
filter: filter,
}
}
pub struct ShrinkFilter {
... | true |
515b4bcada2ea91bb53def40289b9ede28970713 | Rust | wking/cincinnati | /vendor/protobuf/src/reflect/field.rs | UTF-8 | 6,967 | 3.109375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::descriptor::FieldDescriptorProto;
use crate::descriptor::FieldDescriptorProto_Label;
use crate::json::json_name;
use crate::message::Message;
use crate::reflect::acc::Accessor;
use crate::reflect::acc::FieldAccessor;
use crate::reflect::map::ReflectMap;
use crate::reflect::repeated::ReflectRepeated;
use crat... | true |
88b34abf3c3fca927cab12fdf788775bf0866b3e | Rust | gifnksm/jaba | /src/gitlab_ext.rs | UTF-8 | 1,059 | 2.546875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use config::Gitlab as GitlabConfig;
use errors::*;
use gitlab::{Gitlab, UserFull};
use slog::Logger;
#[derive(Debug)]
pub struct GitlabExt {
log: Logger,
gitlab: Gitlab,
current_user: UserFull,
}
impl GitlabExt {
pub fn new(log: &Logger, conf: &GitlabConfig) -> Result<Self> {
let log = log.new... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.