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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
577b35b570ce4f189455bed51c5e3dcd2faca759 | Rust | rishabh3/rust_by_example | /src/variables/constants1.rs | UTF-8 | 133 | 2.828125 | 3 | [] | no_license | fn main()
{
println!("Example for mutable constants");
const mut A: i32 = 10;
println!("The value of const A: {}", A);
}
| true |
de28b193d7604cb6d9516c98a8c2ca318657a420 | Rust | ubnt-intrepid/siro | /xtask/src/main.rs | UTF-8 | 2,342 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
env,
ffi::OsStr,
path::{Path, PathBuf},
process::{Command, Stdio},
};
use walkdir::WalkDir;
fn main() -> anyhow::Result<()> {
setup_path()?;
let examples_dir = project_root().join("examples");
if let Some(name) = env::args_os().nth(1) {
let manifest_dir = examples_dir.j... | true |
f571cfe41b278a05451df3d5c8086b18f413429d | Rust | makoki13/satrapia_lib | /src/juego/tomtom.rs | UTF-8 | 1,434 | 3.375 | 3 | [] | no_license | pub mod tomtom {
pub use juego::punto::punto::Punto;
pub struct TomTom {
ruta: Vec<Punto>
}
impl TomTom {
pub fn calcula_viaje(origen: Punto, destino: Punto) -> Vec<Punto> {
let mut ruta = Vec::new();
let mut x_actual:i32 = origen.get_x();
let mut y... | true |
c4104c2607e133a6c71f7cd9b873d66d2c76c753 | Rust | akhramov/expressions_evaluator | /src/expression/boolean/factor.rs | UTF-8 | 3,416 | 3.71875 | 4 | [] | no_license | /// This module is used to parse variables in boolean expressions,
/// including constants (true / false).
use std::collections::HashMap;
use anyhow::{Context, Result};
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::{alpha1, space0};
use nom::combinator::{map, opt};
use nom::sequen... | true |
6d7d3defb80936e72491e07ce69dd9d5155426b0 | Rust | stobias2014/rust-basics | /formatted.rs | UTF-8 | 213 | 3.421875 | 3 | [] | no_license | // This is a program showing formatted text
fn main() {
// Use '{}' will be replaced with argument
println!("{} days in some month", 31);
println!("{0} this is {1}", "Saul", "Brenda");
}
| true |
a4a46a55a90f156680dbaeffe7a33cda3dea25c9 | Rust | connorlwilkes/consequences | /consequences_backend/src/game/game_logic.rs | UTF-8 | 1,775 | 2.6875 | 3 | [] | no_license | use r2d2_redis::RedisConnectionManager;
use r2d2::PooledConnection;
use itertools::{Tuples, Itertools};
use self::redis::Commands;
use r2d2_redis::redis;
static MAX_ROUNDS: u8 = 8;
type RedisConnection = PooledConnection<RedisConnectionManager>;
#[derive(Debug, Serialize, Deserialize)]
pub struct Lobby {
pub nam... | true |
3d186d4cffc9823df9c0809e18185cb9ce9fd610 | Rust | maikelwever/docker-network-test | /src/main.rs | UTF-8 | 854 | 2.578125 | 3 | [
"MIT"
] | permissive | extern crate trust_dns_resolver;
use trust_dns_resolver::Resolver;
use trust_dns_resolver::config::*;
use core::time::Duration;
use std::io::{Result, Error, ErrorKind};
fn do_lookup() -> Result<()> {
let mut opts = ResolverOpts::default();
// The actual runtime timeout is not even close to 2 seconds,
/... | true |
eb0bc0d246854fa0922830288dfa0a4603085bce | Rust | olivierlemasle/cap-std | /cap-directories/src/user_dirs.rs | UTF-8 | 5,844 | 2.953125 | 3 | [
"MIT",
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::not_found;
use cap_std::{fs::Dir, AmbientAuthority};
use std::io;
/// `UserDirs` provides paths of user-facing standard directories, following
/// the conventions of the operating system the library is running on.
///
/// This corresponds to [`directories_next::UserDirs`], except that the
/// functions open... | true |
20bdb44728b3b101d616b99676c781d5bd7381f8 | Rust | suke/palette | /src/palette_options.rs | UTF-8 | 432 | 2.921875 | 3 | [] | no_license | use crate::rgb::Rgb;
use std::collections::HashSet;
#[derive(Debug)]
pub struct PaletteOptions {
pub(crate) colors: HashSet<Rgb>,
}
impl PaletteOptions {
pub fn default() -> Self {
PaletteOptions {
colors: HashSet::new(),
}
}
pub fn ignore_colors(mut self, colors: Vec<Rgb>... | true |
abcca2af9cf6ac2631f66868c5ba47d7d45fc27f | Rust | nathanfaucett/rs-mat32 | /src/misc.rs | UTF-8 | 2,047 | 3.21875 | 3 | [
"MIT"
] | permissive | use approx_eq::ApproxEq;
use num::Num;
use signed::Signed;
use set::identity;
#[inline]
pub fn inverse<'a, 'b, T: Copy + Signed>(out: &'a mut [T; 6], a: &'b [T; 6]) -> &'a mut [T; 6] {
let m11 = a[0];
let m12 = a[2];
let m13 = a[4];
let m21 = a[1];
let m22 = a[3];
let m23 = a[5];
let d =... | true |
103992e13041389c755407b272fb677d27a51108 | Rust | hawkw/weathergirl-rs | /dht-hal/src/kind.rs | UTF-8 | 1,393 | 3.296875 | 3 | [] | no_license | pub trait DhtKind {
#[doc(hidden)]
const START_DELAY_US: u16;
#[doc(hidden)]
fn temp_celcius(integral: u8, decimal: u8) -> f32;
#[doc(hidden)]
fn humidity_percent(integral: u8, decimal: u8) -> f32;
}
pub struct Dht11 {
_p: (),
}
pub struct Dht22 {
_p: (),
}
impl DhtKind for Dht11 {
... | true |
bddaf96abc05de9689fef5ea88069c67ec9373dd | Rust | mbrner/rustlind | /perm/src/main.rs | UTF-8 | 1,215 | 3.171875 | 3 | [] | no_license | use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let contents = fs::read_to_string(filename)
.expect("Something went wrong reading the file");
let n = contents.parse::<u32>().unwrap();
let list = generate_permutations(&n);
... | true |
3acacee09594543dbb84497cc2f0e5574c63425d | Rust | bnjjj/apollo-rs | /crates/apollo-parser/src/parser/syntax_tree.rs | UTF-8 | 4,441 | 3.125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::fmt;
use rowan::GreenNodeBuilder;
use crate::{ast::Document, Error, SyntaxElement, SyntaxKind};
use super::GraphQLLanguage;
/// An AST generated by the parser.
pub struct SyntaxTree {
pub(crate) ast: rowan::SyntaxNode<GraphQLLanguage>,
pub(crate) errors: Vec<crate::Error>,
}
impl SyntaxTree {
... | true |
cc6ebc70d9d9b603f230744f9430a534c66451a4 | Rust | AdamCDunlap/wk4-starter | /replace_with/tests/required.rs | UTF-8 | 2,403 | 3.40625 | 3 | [] | no_license | extern crate replace_with;
pub use replace_with::replace_with;
// This macro is an assertion with nicely formatted failure output
macro_rules! assert_expected_eq_actual {
($a:expr, $b:expr) => ({
let (a, b) = (&$a, &$b);
assert!(*a == *b,
"\nExpected `{:?}` is not equal to Actual `... | true |
89bdc1f3c642916fd43ad703758964b7a5a04039 | Rust | mgeisler/textwrap | /benchmarks/unfill.rs | UTF-8 | 855 | 2.828125 | 3 | [
"LicenseRef-scancode-other-permissive",
"MIT"
] | permissive | use criterion::{criterion_group, criterion_main, Criterion};
pub fn benchmark(c: &mut Criterion) {
let words_per_line = [
5, 10, 15, 5, 5, 10, 5, 5, 5, 10, // 10 lines
10, 10, 5, 5, 5, 5, 15, 10, 5, 5, // 20 lines
10, 5, 5, 5, 15, 10, 10, 5, 5, 5, // 30 lines
15, 5, 5, 10, 5, 5, 5, ... | true |
b67ddb07368d434ba3540230546301c3aa564ee0 | Rust | tuanemuy/cartta | /src/tests/note_test.rs | UTF-8 | 8,691 | 2.703125 | 3 | [] | no_license | use rocket::local::Client;
use rocket::http::{Status, ContentType};
use serde_json::Value;
use super::helpers::*;
use crate::contexts::cms::NewNote;
use crate::contexts::cms::note::*;
use super::*;
#[test]
fn test_cms() {
run_test!(|client, conn| {
let note_new = r#"{ "title": "test", "content": "test", "t... | true |
108e2043fcc0c361f9330a4d9fcd689643a26e1b | Rust | cmourglia/rs_raytracer | /src/math/vector.rs | UTF-8 | 3,782 | 3.546875 | 4 | [] | no_license | use std::ops;
use math::*;
#[derive(Clone, Copy, PartialEq, PartialOrd, Debug)]
pub struct Vector3 {
pub x: f32,
pub y: f32,
pub z: f32
}
impl Vector3 {
pub fn new(x: f32, y: f32, z: f32) -> Vector3 {
Vector3 { x: x, y: y, z: z }
}
pub fn zero() -> Vector3 { Vector3 { x: 0.0, y: 0.0, ... | true |
4bff75948d9702dddd7629aeabd5a15bc871f5ed | Rust | leonardoarcari/rust-hexagonal-architecture | /src/domain/account.rs | UTF-8 | 6,888 | 3.15625 | 3 | [] | no_license | use super::{activity::ActivityBuilder, activity::ActivityWindow, money::Money};
#[derive(Debug, Builder)]
#[builder(pattern = "owned")]
pub struct Account {
#[builder(setter(strip_option))]
id: Option<AccountId>,
baseline_balance: Money,
activity_window: ActivityWindow,
}
impl Account {
pub fn new... | true |
536a2872dfd8f04f65188aafb32f748c6343566b | Rust | coord-e/r53ddns | /src/domain/ttl.rs | UTF-8 | 213 | 3.0625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | pub struct TTL(u32);
impl From<u32> for TTL {
fn from(ttl: u32) -> Self {
TTL(ttl)
}
}
impl Into<i64> for TTL {
fn into(self) -> i64 {
let TTL(ttl) = self;
ttl as i64
}
}
| true |
2efa1ac1070e4a10756e21b390970d5ba7212cde | Rust | uv-beluga/twitter-text | /twitter-text/src/hit_highlighter.rs | UTF-8 | 3,588 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Robert Sayre
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
extern crate pest;
use pest::Parser;
use pest::iterators::Pairs;
use twitter_text_parser::highlighter::HighlightParser;
use twitter_text_parser::highlighter::Rule;
type Hit = (usize, usize);
... | true |
c22be098f83e69a8c6f60cebbe2b4f120688d725 | Rust | SierraSoftworks/bender | /src/api/error.rs | UTF-8 | 1,535 | 2.765625 | 3 | [
"MIT"
] | permissive | use actix_web::{error, http::StatusCode, HttpResponse};
use std::fmt;
#[derive(Debug, Serialize, Deserialize)]
pub struct APIError {
pub code: u16,
pub error: String,
pub message: String,
}
impl APIError {
pub fn new(code: u16, error: &str, message: &str) -> Self {
Self {
code,
... | true |
8ee4f35cd934fe8b0f668b19c25f2129a86bacc7 | Rust | samfauble/rust-algorithms | /src/divide_conquer.rs | UTF-8 | 7,547 | 3.09375 | 3 | [] | no_license | pub mod dc_algos {
extern crate bit_vec;
extern crate median;
extern crate imageproc;
extern crate num;
extern crate either;
use either::*;
use num::complex::Complex;
use imageproc::hough::PolarLine;
use std::f64::consts::PI;
use bit_vec::BitVec;
use std::convert::TryInto;
... | true |
a91c1dbced0bc2159d46fe499562c66ed84ba4fe | Rust | zfazek/projecteuler | /rust/problem004.rs | UTF-8 | 396 | 3.109375 | 3 | [] | no_license | fn main() {
let mut nums: Vec<i32> = Vec::new();
let min = 100;
let max = 1000;
for i in min..max {
for j in min..max {
let s = (i * j).to_string();
let r: String = s.chars().rev().collect();
if s == r {
nums.push(i * j);
}
... | true |
8493c25fe1b9f227393d1f1d98cabb82722162a2 | Rust | forksbot/embedded-graphics | /simulator/src/display.rs | UTF-8 | 2,179 | 3.4375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use embedded_graphics::{
drawable::Pixel,
geometry::{Point, Size},
pixelcolor::{BinaryColor, PixelColor},
DrawTarget,
};
/// Display
pub struct SimulatorDisplay<C> {
size: Size,
pixels: Box<[C]>,
}
impl<C> SimulatorDisplay<C>
where
C: PixelColor,
{
/// Creates a new display filled with... | true |
2f93845a701740b253e2bbc7761f68aeafc2cda4 | Rust | tarberd/prime-generator | /src/lib.rs | UTF-8 | 2,619 | 3.234375 | 3 | [] | no_license | pub use num_bigint::BigUint;
pub struct Rng {
state: u32,
}
impl Rng {
pub fn new(seed: u32) -> Self {
Rng { state: seed }
}
#[allow(dead_code)]
pub fn xorshift(&mut self) -> u32 {
let x = self.state;
let x = x ^ (x << 13);
let x = x ^ (x >> 17);
let x = x... | true |
a6c54b1d3bc133394309f3b9a0dafbf2c9341084 | Rust | stsewd/programming-problems-rust | /src/bin/nice_strings.rs | UTF-8 | 1,056 | 3.109375 | 3 | [
"MIT"
] | permissive | // https://www.hackerearth.com/problem/algorithm/monk-and-nice-strings-3-e5800d05/
use std::io::{self, BufRead, Write};
fn solve(strings: &[String], output: &mut impl Write) {
for (i, string) in strings.iter().enumerate() {
let count = strings
.iter()
.take(i)
.filter(|&... | true |
7dd8c32bef091e7b918b9ef743ba32e7c8f3ed6e | Rust | Utkarsh-Patel-13/FileSystem-Rust | /src/main.rs | UTF-8 | 1,366 | 3.21875 | 3 | [] | no_license | use std::io;
use std::io::{stdout, Write};
use std::fs::create_dir_all;
mod mkdir;
mod ls;
mod cd;
fn get_input() -> String {
/*
Function to get input and return String after trimming the input
*/
let _ = stdout().flush();
let mut input = String::new();
input.clear();
match io::stdi... | true |
17418e58ef9b3170aeb7d00cc5e142454f097e56 | Rust | Disco-Dave/contact-api | /src/settings.rs | UTF-8 | 2,365 | 3.171875 | 3 | [] | no_license | use std::{ffi::OsString, net::TcpListener};
use config::{Config, ConfigError, FileFormat};
#[derive(Debug, PartialEq, Eq, Clone, serde::Deserialize)]
pub struct HttpSettings {
pub host: String,
pub port: u16,
}
impl HttpSettings {
pub fn tcp_listener(&self) -> std::io::Result<TcpListener> {
let a... | true |
5db8be6d7e205a4679e4682f1765a577520236e7 | Rust | ErichDonGubler/cargo-release | /src/steps/push.rs | UTF-8 | 5,705 | 2.59375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::HashSet;
use crate::error::CliError;
use crate::ops::git;
use crate::steps::plan;
/// Push tags/commits to remote
#[derive(Debug, Clone, clap::Args)]
pub struct PushStep {
#[command(flatten)]
manifest: clap_cargo::Manifest,
#[command(flatten)]
workspace: clap_cargo::Workspace,
... | true |
7b7540397a903e4502fb25cf089c5c25ba83f015 | Rust | siccegge/ctf-gameserver | /rust/tests/trivial.rs | UTF-8 | 641 | 2.65625 | 3 | [
"ISC",
"MIT"
] | permissive | use checkerlib::{Checker, Error, Context, CheckerResult};
struct TrivialChecker {
}
impl TrivialChecker {
fn new() -> Self {
TrivialChecker {}
}
}
impl Checker for TrivialChecker {
fn setup(&mut self, context:&Context) -> () {}
fn place_flag(&mut self) -> Result<(), Error> { Err(Error:... | true |
c145dc1e98a64dfc7bf643b777c13fc7ba3142b3 | Rust | kubehe/yewprint | /yewprint-doc/src/radio/example.rs | UTF-8 | 2,726 | 3.21875 | 3 | [
"MIT"
] | permissive | use yew::prelude::*;
use yewprint::{Label, Radio, RadioGroup};
pub struct Example {
props: ExampleProps,
link: ComponentLink<Self>,
selected_value: Lunch,
}
#[derive(Clone, PartialEq, Properties)]
pub struct ExampleProps {
pub disabled: bool,
pub inline: bool,
pub large: bool,
}
pub enum Msg ... | true |
7cf333cbf00655141efe9571697b2ab333ab85e5 | Rust | baseoursteps/rct | /llist/src/linked_list/mod.rs | UTF-8 | 2,706 | 3.40625 | 3 | [
"MIT"
] | permissive | use std::rc::Rc;
use std::fmt::Debug;
use std::sync::RwLock;
type Elem<T> = Option<Rc<RwLock<Node<T>>>>;
struct Node<T>
where
T: Debug,
{
val: T,
next: Elem<T>,
}
impl<T: Debug> Node<T> {
fn new(v: T) -> Self {
Node { val: v, next: None }
}
}
pub struct LList<T>
where
T: Debug,
{
... | true |
1add73b7429b1ae398013e3ed94938f0cef4da7c | Rust | fralken/ray-tracing-the-next-week | /src/aabb.rs | UTF-8 | 1,168 | 2.90625 | 3 | [] | no_license | use std::f32;
use nalgebra::Vector3;
use crate::ray::Ray;
pub fn surrounding_box(box0: &AABB, box1: &AABB) -> AABB {
let min = Vector3::new(
f32::min(box0.min.x, box1.min.x),
f32::min(box0.min.y, box1.min.y),
f32::min(box0.min.z, box1.min.z));
let max = Vector3::new(
f32::max(bo... | true |
b0c65f0b5e90ec503536181a35dedfe27aa17986 | Rust | jrasky/kernel | /paging/src/lib.rs | UTF-8 | 3,604 | 2.53125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![feature(stmt_expr_attributes)]
#![feature(shared)]
#![feature(const_fn)]
#![feature(collections)]
#![feature(alloc)]
#![feature(inclusive_range_syntax)]
#![cfg_attr(not(test), no_std)]
#[cfg(not(test))]
extern crate core as std;
extern crate rlibc;
#[macro_use]
extern crate collections;
#[macro_use]
extern crate log... | true |
abc57771712fc8b30aa51193f3dad48d50fde19b | Rust | Nertsal/ludumdare48 | /src/model/generation.rs | UTF-8 | 2,469 | 2.953125 | 3 | [] | no_license | use super::*;
impl Model {
pub fn get_area(&self, depth_start: i32, depth_end: i32) -> Area {
AABB::from_corners(
vec2(-(self.rules.chamber_width as i32), depth_start),
vec2(self.rules.chamber_width as i32, depth_end),
)
}
pub fn fill_area(&mut self, area: Area, til... | true |
60d047116f0ee698efe25f22840739eb0deed7f3 | Rust | drupalio/comprakt | /compiler-lib/src/linter/lints/unused_arguments.rs | UTF-8 | 3,263 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::{AstLintPass, EarlyContext, LintContext, LintPass};
use asciifile::Spanned;
use diagnostics::{declare_lint, lint::LintArray, lint_array};
use parser::{ast::*, visitor::NodeKind};
use std::collections::HashMap;
use strtab::Symbol;
declare_lint!(
pub UNUSED_ARGUMENTS,
Warning,
"unused arguments of... | true |
62546d5081b094058c9a4cf19fdd9fb76b2b3f1d | Rust | samtoth/rust-pwa | /src/main.rs | UTF-8 | 2,216 | 2.734375 | 3 | [] | no_license | use web_view::*;
use std::{borrow::Cow, sync::mpsc, thread};
use mime_guess::from_path;
use rust_embed::RustEmbed;
use actix_web::{body::Body, web, App, HttpRequest, HttpResponse, HttpServer};
#[derive(RustEmbed)]
#[folder = "frontend/static"]
struct Asset;
fn assets(req: HttpRequest) -> HttpResponse {
let path =... | true |
474e5ce7e07c8e1fbe19094a9caa2d80ffada5a1 | Rust | rheehot/FFXIVTools | /libs/ffxiv_parser/src/ffxiv_string.rs | UTF-8 | 2,915 | 3.203125 | 3 | [
"MIT"
] | permissive | use alloc::{
borrow::ToOwned,
format, str,
string::{String, ToString},
};
use core::convert::Into;
pub struct FFXIVString<'a> {
data: &'a [u8],
}
impl<'a> FFXIVString<'a> {
const MARKUP_START: u8 = b'\x02';
pub fn new(data: &'a [u8]) -> Self {
let end = data.iter().position(|&x| x == b... | true |
25d9329197459de383205a6d89c4bf8be0c79fbd | Rust | lazareviczoran/advent-of-code-2020 | /day-23/src/main.rs | UTF-8 | 2,381 | 3.671875 | 4 | [] | no_license | fn main() {
let input = 963275481;
println!("part1 solution: {}", move_cups(input, 100));
println!("part2 solution: {}", move_cups2(input, 10_000_000));
}
fn shuffle(input: usize, num_repeats: usize, num_of_items: usize) -> Vec<usize> {
let mut successors = vec![0; num_of_items + 1];
let mut value ... | true |
c5754e5e3ff3b16d549f591c3dd77e949290b265 | Rust | HerbLuo/db-sync-tool | /src/ui.rs | UTF-8 | 1,259 | 2.578125 | 3 | [] | no_license | use crate::types::ZzErrors;
use tray_item::TrayItem;
use crate::helper::arguments::MATCHES;
fn open_browser() {
MATCHES.with(|matches| {
let address = matches.value_of("ADDRESS").unwrap();
let port = matches.value_of("PORT").unwrap();
webbrowser::open(&format!("http://{}:{}", address, port)... | true |
aba1d8cb2ef6305461261f8ff750e5c66e55f11b | Rust | derrickbaldwin/euler-project | /rust/problem_14/src/lib.rs | UTF-8 | 1,560 | 3.625 | 4 | [] | no_license | /*
Problem 14:
The following iterative sequence is defined for the set
of positive integers:
n → n/2 (n is even)
n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate
the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and
f... | true |
55cc07591d12ed452f16d69460785c032d6c67e2 | Rust | hawkingrei/sparser-rs | /src/utils/memory.rs | UTF-8 | 1,993 | 2.625 | 3 | [] | no_license | use std::mem;
use libc;
use super::error::{Result, SparserError};
use std::mem::MaybeUninit;
const ALIGNMENT: usize = 64;
#[cfg(windows)]
#[link(name = "msvcrt")]
extern "C" {
fn _aligned_malloc(size: libc::size_t, alignment: libc::size_t) -> libc::size_t;
fn _aligned_free(prt: *const u8);
}
#[cfg(windows)... | true |
09ef98c313c0729830cb6946efffccd9d9322e9d | Rust | p0lunin/graphics | /src/storage.rs | UTF-8 | 1,971 | 3.3125 | 3 | [] | no_license | use na::{Point3};
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Point3ID(pub usize);
impl From<usize> for Point3ID {
fn from(val: usize) -> Self {
Self(val)
}
}
pub trait Storage<T> {
type Id;
fn store(&mut self, element: T) -> Self::Id;
fn get(&self, id: Self::Id) -> Option<&T>... | true |
ed32f056491d763e8616ab5eae4ee96afe900d71 | Rust | kilicmu/rust-note | /generics/src/main.rs | UTF-8 | 949 | 3.28125 | 3 | [] | no_license | mod summary;
use summary::Summary;
use std::fmt::Display;
pub fn notify(item: impl Summary) {
item.summarize_author();
}
pub fn trait_bound<T: Summary + Display>(item: T) {
item.summarize_author();
}
pub fn where_trait_bound<T, U>(_item: T, _next: U) -> String
where T: Display + Summary,
U: Displ... | true |
b794b65761d0bd62fa484a9cf76d7a0efe64dda0 | Rust | Viewtiful/rust-fp-meetup-montpellier | /code/ownership_2.rs | UTF-8 | 418 | 3.25 | 3 | [] | no_license | #[derive(Debug)]
struct Book {
name: String,
page_number: u32
}
fn main() {
let mut library: Vec<Book> = Vec::with_capacity(3);
library.push(Book { name: "To Kill a Mockingbird".to_string(), page_number: 324 });
library.push(Book { name: "The Little Prince".to_string(), page_number: 93 });
lib... | true |
7b5c1196971c8679ec9802e3da45dbd55fcda773 | Rust | henryv11/auth-rust | /src/domains/session/service.rs | UTF-8 | 2,619 | 2.734375 | 3 | [] | no_license | use crate::{
database::Pool,
domains::session::repository::{
create_session, find_active_session, find_active_session_by_token,
find_sessions_by_request_data, update_session_ended_at, Session,
},
error::Error,
request_data::RequestData,
};
use chrono::prelude::Utc;
pub async fn get_... | true |
1bb7ad475f258b59a77c69848f5351143762779e | Rust | wbowling/rcc | /src/parser/ops.rs | UTF-8 | 3,013 | 3.28125 | 3 | [] | no_license | use super::token::Token;
#[derive(Debug, Eq, PartialEq)]
pub enum Size {
Int,
Byte,
}
#[derive(Debug, Eq, PartialEq)]
pub struct Variable {
pub name: String,
pub size: Size,
}
#[derive(Debug)]
pub struct Program {
pub func: Vec<Function>,
pub globals: Vec<String>
}
#[derive(Debug)]
pub struc... | true |
289006b8fd4a1f11f8cafee0757d1de9cb2ea17e | Rust | toshi-search/Toshi | /toshi-server/src/utils.rs | UTF-8 | 1,533 | 3.125 | 3 | [
"MIT"
] | permissive | use http::{Response, StatusCode};
use hyper::Body;
use serde::Serialize;
use toshi_types::{Error, ErrorResponse};
pub fn with_body<T>(body: T) -> Response<Body>
where
T: Serialize,
{
let json = serde_json::to_vec::<T>(&body).unwrap();
Response::builder()
.header(hyper::header::CONTENT_TYPE, "appli... | true |
4b995896a041dc861b573a4ebb0ddc061c970b8f | Rust | tuzz/laika | /src/util/circle/mod.rs | UTF-8 | 506 | 3.390625 | 3 | [] | no_license | use super::point::Point;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Circle {
pub center: Point,
pub radius: f32,
}
impl Circle {
pub fn new(center: Point, radius: f32) -> Self {
Circle { center, radius }
}
pub fn contains(&self, point: Point) -> bool {
self.center.distanc... | true |
75d316c35ef254d1920324bc330ef2b01c4a8e6d | Rust | planet-s/area8051 | /src/lib.rs | UTF-8 | 1,752 | 2.640625 | 3 | [
"MIT"
] | permissive | #[cfg(feature = "debug")]
macro_rules! debug {
($($arg:tt)*) => (eprint!($($arg)*));
}
#[cfg(not(feature = "debug"))]
macro_rules! debug {
($($arg:tt)*) => (());
}
pub use self::addr::Addr;
mod addr;
pub use self::isa::Isa;
mod isa;
pub use self::mem::Mem;
mod mem;
pub use self::reg::Reg;
mod reg;
pub str... | true |
4313926f7c3c897abb264311c86840047dd64304 | Rust | helgefmi/exercism-rust | /nucleotide-count/src/lib.rs | UTF-8 | 714 | 3.21875 | 3 | [] | no_license | use std::collections::HashMap;
use std::iter::once;
const NUCLEOTIDES: &'static str = "ACGT";
pub fn count(nucleotide: char, dna: &str) -> Result<usize, char> {
let all_chars = dna.chars().chain(once(nucleotide));
match all_chars.filter(|&c| !NUCLEOTIDES.contains(c)).nth(0) {
Some(c) => Err(c),
... | true |
6b02b7c3ee9693316851786c723ba349ad4ed5d7 | Rust | mschmo/rust-csv | /src/encoder.rs | UTF-8 | 6,473 | 3.234375 | 3 | [
"MIT",
"Unlicense"
] | permissive | use rustc_serialize as serialize;
use {ByteString, Result, Error};
/// A record to be encoded.
///
/// This is a "wrapper" type that allows the `Encoder` machinery from the
/// `serialize` crate to encode a *single* CSV record from your custom types.
///
/// Generally, you should not need to use this type directly. I... | true |
cbefceaf4708f62185c4d14c0ef01c9fb8decc20 | Rust | mike-lloyd03/calc_time_rs | /src/main.rs | UTF-8 | 1,339 | 3.3125 | 3 | [] | no_license | use chrono::Duration;
use chrono::NaiveTime;
use std::io;
fn main() {
calc_time();
}
fn calc_time() {
println!("Enter all times as four digit 24 hr times without colons (e.g. \"1415\").");
println!("Enter start time: ");
let start_time_obj = get_time_input();
println!("Enter lunch start time: ")... | true |
c19581c8e876daf5b0f4c60c50b7d9669a932f02 | Rust | arapat/sparrow | /src/commons/labeled_data.rs | UTF-8 | 1,202 | 3.53125 | 4 | [] | no_license | use std::cmp::PartialEq;
/// Training example. It consists of two fields: `feature` and `label`.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct LabeledData<TFeature, TLabel> {
pub feature: Vec<TFeature>,
pub label: TLabel
}
impl<TFeature, TLabel> LabeledData<TFeature, TLabel> {
pub fn new(fe... | true |
be43e9feac14d9d26dd4571072ff9c66176a810a | Rust | am0d/rocket-test | /src/controllers/transaction.rs | UTF-8 | 3,134 | 3 | 3 | [] | no_license | use std::borrow::Cow;
use rocket;
use rocket::request::{FlashMessage, Form};
use std::vec::Vec;
use db;
use models;
use super::context::{IndexTemplateContext, TemplateContext};
use util::*;
use util::response::*;
use models::prelude::*;
/// Returns all the routes defined on this controller
pub fn all_routes() -> Vec<r... | true |
b05e35673f9d1b757a391dfafd2ca0d377a3cc35 | Rust | ericrobolson/Septik | /septik/src/ecs/components/mod.rs | UTF-8 | 5,883 | 2.71875 | 3 | [] | no_license | use crate::ecs::Entity;
use crate::lib_core::{
math::{FixedNumber, Range, Rotation3d, Vec3d},
voxels::voxel_chunk::VoxelChunk,
Aabb, Direction, InputType,
};
pub mod gfx_components;
pub mod unit_components;
#[derive(Clone)]
pub struct ThirdPersonCameraComponent {
pub relative_position: Vec3d,
pub ... | true |
89d14449ad92b5cbb4c0437276ac581f89331bba | Rust | mathw/adventofcode | /aoc2022/src/common/command.rs | UTF-8 | 2,036 | 3.59375 | 4 | [] | no_license | use crate::common::position::Position;
use std::str::FromStr;
#[derive(Copy, Clone, Debug)]
pub enum Command {
Forward(u32),
Up(u32),
Down(u32),
}
impl FromStr for Command {
type Err = String;
fn from_str(l: &str) -> std::result::Result<Self, <Self as std::str::FromStr>::Err> {
let parts =... | true |
ea642dd8dbc72a1c3d87a04d1f68afef7dce315a | Rust | sogapalag/contest | /codeforces/501/3d.rs | UTF-8 | 1,790 | 3.015625 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok().unwrap();
ret
}
fn get_word() -> String {
let mut stdin = std::io::stdin();
... | true |
86e110d8bfa087aa3ab18cdf31cd694cd2661862 | Rust | JinshengRuan/6.829-pset2-3 | /your_code/newcc/src/agg_measurement.rs | UTF-8 | 3,654 | 2.765625 | 3 | [] | no_license | use std;
use portus::lang::Scope;
use portus::Report;
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum ReportStatus {
Report,
NoReport,
UrgentReport,
}
// CCP may return before the specified time. This struct will aggregate relevant
// values till the time is right
pub struct AggMeasurement {
// In fr... | true |
692acc460023e8473ca3b1c41a20bbf5a663957f | Rust | WhoisDavid/advent2020 | /src/day11.rs | UTF-8 | 5,326 | 3.140625 | 3 | [] | no_license | use anyhow::{anyhow, Result};
use aoc_runner_derive::{aoc, aoc_generator};
use std::convert::TryFrom;
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Space {
Floor,
Seat(bool),
}
impl TryFrom<char> for Space {
type Error = anyhow::Error;
fn try_from(s: char) -> Result<Self, Self::Error> {
m... | true |
b9eeeba5878329e10f4d235b82da251a704519b6 | Rust | ijanos/euler-rust | /src/euler4.rs | UTF-8 | 369 | 3.421875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
pub fn ispalindrome(n: u32) -> bool {
let s = n.to_string();
s.chars().zip(s.chars().rev()).all(|(x, y)| x == y)
}
pub fn main() {
let mut max = 0;
for i in 100..1000 {
for j in 100..1000 {
let n = i * j;
if n > max && ispalindrome(n) {
max = n;
... | true |
729220704ebaea03511d3f6f6a7fc4726976c519 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/tokio/src/io/util/take.rs | UTF-8 | 2,726 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::io::{AsyncBufRead, AsyncRead, ReadBuf};
use pin_project_lite::pin_project;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::{cmp, io};
pin_project! {
/// Stream for the [`take`](super::AsyncReadExt::take) method.
#[derive(Debug)]
#[must_use = "streams do nothing unless you `.await` o... | true |
180e374b908139a151a35c67ab338f741b10bee5 | Rust | kylegalloway/tinyVM | /src/lib.rs | UTF-8 | 12,237 | 3.5 | 4 | [] | no_license | ///
/// |=============================== INSTRUCTION ================================|
/// COMMAND VALUE DESCRself.ipTION
/// -------------------------------------------------------------------------------
/// HLT 0 :: halts the program
///
/// PSH, [value ] ... | true |
0c90f83317829958c338ca25c86d97d128fce64e | Rust | calebzulawski/symtool | /symtool-backend/src/object.rs | UTF-8 | 2,029 | 3.171875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Apply transformations to an object.
use crate::error::{Error, TransformError, TransformResult};
use crate::patch::Patch;
use goblin::elf::Elf;
use goblin::mach::MachO;
use std::convert::TryInto;
/// A generic object type
pub enum Object<'a> {
Elf(Box<Elf<'a>>),
MachO(Box<MachO<'a>>),
}
/// The type of a ... | true |
869a796c4021734a3b4d14a0920795dee75f448d | Rust | tverghis/aoc_2019 | /rust/day_05/src/program/instruction.rs | UTF-8 | 1,912 | 3.453125 | 3 | [] | no_license | #[derive(Debug)]
pub(crate) struct Instruction {
pub(crate) opcode: OpCode,
pub(crate) parameters: Vec<Parameter>,
}
impl Instruction {
pub(crate) fn new(opcode: OpCode, parameters: Vec<Parameter>) -> Self {
Instruction { opcode, parameters }
}
}
#[derive(Debug, PartialEq)]
pub(crate) enum OpC... | true |
d615ad840a09dcd035c0c6bf9bc9bbe7f8326190 | Rust | skairunner/threed2vox | /src/bin/main.rs | UTF-8 | 4,659 | 2.59375 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::path::Path;
use clap::{App, Arg};
use simplelog::*;
use threed2vox::config::Config as AppConfig;
use threed2vox::to_schematic;
fn main() -> anyhow::Result<()> {
let config = ConfigBuilder::new()
.set_location_level(LevelFilter::Error)
.build();
TermLog... | true |
b48ec8ae293bb04a87c347b49c210feb1d9467e4 | Rust | Xan0C/raytracing_in_one_weekend | /src/render.rs | UTF-8 | 4,683 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::vec::Vec3;
use crate::ray::Ray;
use crate::color;
use crate::hitable::Hitable;
use crate::hitable::HitableList;
use crate::sphere::Sphere;
use crate::camera::Camera;
use crate::material::Diffuse;
use crate::material::Metal;
use crate::material::Dielectric;
use rand::random;
use std::f32::consts:... | true |
f8080c139485f1ccd37300685b16b4b58874f213 | Rust | wurstmineberg/wurstminebot-discord | /crate/wurstminebot/src/log.rs | UTF-8 | 8,301 | 2.625 | 3 | [
"MIT"
] | permissive | use {
std::{
collections::HashMap,
convert::Infallible as Never,
fmt,
io,
str::FromStr,
},
chase::{
ChaseError,
Chaser,
},
derive_more::From,
futures::{
compat::Stream01CompatExt as _,
future::try_join_all,
pin_mut,
... | true |
58747bb7529e6cdfdf5779bfceed42553846dfb1 | Rust | SueKayTian/gargamel | /src/large_evidence_acquirer.rs | UTF-8 | 3,515 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::process_runner::create_report_path;
use std::path::Path;
use crate::remote::{Connector, Compression, SevenZipCompressCopier, RemoteFileCopier, Command};
use std::time::Duration;
use std::thread;
pub(crate) struct LargeEvidenceAcquirer<'a> {
pub(crate) store_directory: &'a Path,
pub(crate) connector:... | true |
103c3344161960c97d14ca92c6587ca507588a49 | Rust | Canop/lapin | /src/pos/pos_map.rs | UTF-8 | 5,337 | 3.265625 | 3 | [
"MIT"
] | permissive | use {
fnv::{
FnvHashMap,
},
serde::{Serialize, Deserialize},
super::*,
};
/// A structure keeping pos indexed values.
/// It makes sense when most of them are in a known rect but
/// it allows outliers.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PosMap<V>
where V: Copy
{
... | true |
ce254bc5eead8e531ebdd65dafbdddd259f21b7e | Rust | booyaa/scratchpad | /rust/json/src/main.rs | UTF-8 | 1,226 | 2.703125 | 3 | [
"Artistic-2.0"
] | permissive | #![cfg_attr(feature = "serde_macros", feature(plugin, custom_derive))]
#![cfg_attr(feature = "serde_macros", plugin(serde_macros))]
extern crate serde;
extern crate serde_json;
#[cfg(feature = "serde_macros")]
include!("serde_types.in.rs");
#[cfg(feature = "serde_codegen")]
include!(concat!(env!("OUT_DIR"), "/serde_... | true |
d44724260cf76d6643ca33c48a118ba96319ce51 | Rust | rbrincke/6502-emulator | /src/memory/default.rs | UTF-8 | 935 | 3.0625 | 3 | [] | no_license | use crate::memory::Memory;
use emulator::RESET_VECTOR_ADDR;
pub const SIZE: usize = 0xFFFF + 1;
pub struct DefaultMemory {
pub memory: [u8; SIZE],
}
impl Memory for DefaultMemory {
fn read(&self, address: u16) -> u8 {
self.memory[(address as usize)]
}
fn write(&mut self, address: u16, value:... | true |
c3641bddc6723f061931a7ae4ae38150ff406c53 | Rust | liyiheng/talent-plan-rs | /building-block-03/src/lib.rs | UTF-8 | 4,304 | 3.375 | 3 | [] | no_license | //! A lib for RESP encoding and decoding
#![deny(missing_docs)]
use failure::{self, Error};
use std::io::prelude::*;
/// Implemented Deserialize and Visitor, but not the Deserializer.
///
/// It seems a full implementatiion needs hundreds of lines of code,
/// far longer than hand-written version, not sure if I got po... | true |
a14f7b2bf6e2a36e98bdd2c747fbcd7e779b0016 | Rust | ordovicia/kd-tree | /src/trie/kdtree_map.rs | UTF-8 | 15,875 | 3.578125 | 4 | [] | no_license | use num_traits::Float;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use crate::{cell::Cell, error::ErrorKind, point_dist::PointDist, split::Split, Result};
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct KdTreeMap<Axis, Point, Valu... | true |
921b0010cf2ae8ae4c390a7827fafbaab8c48edf | Rust | twitchyliquid64/defmt | /firmware/qemu/src/bin/log.rs | UTF-8 | 10,543 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![no_std]
#![no_main]
use core::sync::atomic::{AtomicU32, Ordering};
use cortex_m_rt::entry;
use cortex_m_semihosting::debug;
use defmt::Format;
use defmt_semihosting as _; // global logger
#[entry]
fn main() -> ! {
defmt::info!("Hello!");
defmt::info!("World!");
defmt::info!("The answer is {:u8}", 42);... | true |
c5008d8423a74cf91e47a3c2d68c3524c2e280fc | Rust | baszalmstra/rosty | /crates/rosty/src/tcpros/header.rs | UTF-8 | 1,693 | 2.921875 | 3 | [
"MIT"
] | permissive | use super::read_packet;
use rosty_msg::RosMsg;
use std::collections::HashMap;
use std::io;
use std::io::Cursor;
use tokio::io::AsyncWriteExt;
#[derive(Fail, Debug)]
pub enum InvalidHeaderError {
#[fail(display = "missing field '{}'", 0)]
MissingField(String),
#[fail(display = "field mismatch, expected '{}... | true |
d0b433b54217966f3be38dcfba11a3a802bb2d9e | Rust | caibirdme/leetcode_rust | /src/prob_334.rs | UTF-8 | 3,253 | 3.515625 | 4 | [
"MIT"
] | permissive | impl Solution {
pub fn increasing_triplet(nums: Vec<i32>) -> bool {
let n = nums.len();
if n < 3 {
return false;
}
let mut least = nums[0];
let mut opt_least: Option<i32> = None;
let mut mid: Option<i32> = None;
for i in 1..n {
let t= n... | true |
c40a02c6699a8002ddb23ee4b9f765b19dd5de8b | Rust | wrenby/raytrace-rs | /src/world.rs | UTF-8 | 594 | 2.875 | 3 | [] | no_license | use crate::primitive::Primitive;
use crate::ray::{Ray, Hit};
use ord_subset::OrdSubsetIterExt;
pub struct World {
pub primitives: Vec<Box<dyn Primitive + Send + Sync>>,
// TODO: lights
// TODO: acceleration data structure
}
impl World {
pub fn cast(&self, r: &Ray) -> Option<Hit> {
self.primitiv... | true |
9bf26e13380bffcb0ac6cc81c5e33f268dd09b02 | Rust | carllerche/eventual_io | /src/reactor.rs | UTF-8 | 11,572 | 2.640625 | 3 | [] | no_license | use core::{self, Bytes, Pair, Sender};
use net::{self, Action};
use mio::{self, EventLoop, Handler, Interest, NonBlock, ReadHint, PollOpt, Token};
use mio::tcp::{TcpListener, TcpStream};
use mio::util::Slab;
use std::io;
use std::sync::Arc;
pub struct Reactor {
inner: Arc<Inner>,
}
impl Reactor {
pub fn start... | true |
b5a9e9cd624b17f40c6a07937578a12d69314d98 | Rust | nebgnahz/uscis-opt | /src/main.rs | UTF-8 | 1,891 | 2.75 | 3 | [] | no_license | use std::{thread, time};
extern crate chrono;
extern crate env_logger;
extern crate uscis;
#[macro_use]
extern crate log;
fn main() {
env_logger::init();
let args: Vec<String> = std::env::args().collect();
if args.len() < 2 {
println!("Usage: cargo run -- <end>");
return;
}
let e... | true |
f91e681756fc4c24ae39c76003f8b83852206634 | Rust | Urcra/CrankSet | /src/crankset/store.rs | UTF-8 | 7,716 | 3.0625 | 3 | [] | no_license | use crankset::types::RevType;
use crankset::lang::RevExpr;
use crankset::lang::RevExpr::*;
use crankset::lang::RevStmnt;
use crankset::lang::RevStmnt::*;
use crankset::procs::ProcHandler;
use std::collections::HashMap;
pub struct StoreHandler {
store: HashMap<String, RevType>,
}
impl StoreHandler {
pub fn n... | true |
ffb664dd60e4f3c802132a3d2ee45c5aa0588b55 | Rust | fyang93/rust-leetcode | /src/p0145_binary_tree_postorder_traversal.rs | UTF-8 | 477 | 2.90625 | 3 | [] | no_license | use crate::treenode::*;
use std::rc::Rc;
use std::cell::RefCell;
pub fn postorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
let mut vals = vec![];
Self::traverse(&root, &mut vals);
vals
}
fn traverse(root: &Option<Rc<RefCell<TreeNode>>>, vals: &mut Vec<i32>) {
if let Some(rc) = root... | true |
03b22f8be58ef2ba0c3a31a1f85cf937d7af2982 | Rust | SamPeng87/smoltcp | /src/iface/ethernet.rs | UTF-8 | 48,621 | 2.640625 | 3 | [
"0BSD",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Heads up! Before working on this file you should read the parts
// of RFC 1122 that discuss Ethernet, ARP and IP.
use core::cmp;
use managed::ManagedSlice;
use {Error, Result};
use phy::{Device, DeviceCapabilities, RxToken, TxToken};
use wire::{EthernetAddress, EthernetProtocol, EthernetFrame};
use wire::{Ipv4Addr... | true |
86b5daa75a5179e98ec46b860e776148b0500da4 | Rust | duanjp8617/async | /rust/rcbytes/src/my/myrefcell.rs | UTF-8 | 5,928 | 3.28125 | 3 | [] | no_license | use std::mem;
use std::ops::{Deref, DerefMut};
#[repr(transparent)]
pub struct MyUnsafeCell <T> {
value : T,
}
impl<T> MyUnsafeCell<T> {
pub fn new(value : T) -> Self{
MyUnsafeCell {
value : value
}
}
pub fn into_inner(self) -> T {
self.value
}
pub fn get(... | true |
26d58910c3e54ddb0a03521e7727c4798b165cc0 | Rust | jimmyhmiller/PlayGround | /rust/editor/src/color.rs | UTF-8 | 1,938 | 2.6875 | 3 | [] | no_license | use sdl2::pixels::Color;
use crate::tokenizer::{RustSpecific, Token};
pub const BACKGROUND_COLOR: Color = Color::RGB(0x29, 0x2D, 0x3E);
pub const STANDARD_TEXT_COLOR: Color = Color::RGB(0x95, 0x9D, 0xCB);
pub const PURPLE_TEXT_COLOR: Color = Color::RGB(0xC7, 0x92, 0xEA);
pub const BLUE_TEXT_COLOR: Color = Color::R... | true |
74c9a1f5ae56a577d4cd7dd503e5d2d030dda0c7 | Rust | rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust | /Chapter 10/stacker.rs | UTF-8 | 2,797 | 3.265625 | 3 | [] | no_license | // stacker.rs -- testing the Stack struct
mod stack;
use stack::*;
use std::io;
use std::io::prelude::*;
use std::string::String;
fn main() -> io::Result<()> {
let mut stdout: io::Stdout = io::stdout();
let mut stdin: io::Stdin = io::stdin();
let mut st: Stack = Stack::new(); // create an empty stack
... | true |
17d483f0af27472f1b66ce6ec0130eb4b76572f8 | Rust | georobGWJ/design-pattern-recognition | /creational_patterns/abstract_factory/src/main.rs | UTF-8 | 906 | 3.09375 | 3 | [
"MIT"
] | permissive | extern crate abstract_factory;
use abstract_factory::Direction;
use abstract_factory::door::*;
use abstract_factory::wall::*;
use abstract_factory::room::*;
use abstract_factory::map_site::*;
fn main() {
println!("\nI'm a library driver! ^_^");
// Make a door, for testing
let door = Door::new(23, 25);
... | true |
18f043d54efc46a4c5d308afd2d267ceb3403f51 | Rust | yfliuu/ros_64 | /src/kern/spinlock.rs | UTF-8 | 544 | 2.9375 | 3 | [] | no_license | use core::sync::atomic::AtomicBool;
use core::sync::atomic::Ordering;
pub struct SpinLock {
lock: AtomicBool,
}
// Just a very simple spin lock.
impl SpinLock {
pub const fn new() -> Self {
SpinLock { lock: AtomicBool::new(false) }
}
pub fn acquire(&self) -> () {
while self.lock.com... | true |
8dfe54b9cce98d906688c32517add28b3b7c14f2 | Rust | boymaas/streaker | /frontend/src/components/flash.rs | UTF-8 | 2,660 | 3.03125 | 3 | [] | no_license | use std::time;
use yew::prelude::*;
use yew::services::interval::IntervalService;
use yew::services::Task;
use yew_router::prelude::*;
use chrono::{DateTime, Duration, TimeZone, Utc};
pub struct Flash {
message: Option<String>,
message_time: Option<DateTime<Utc>>,
props: Properties,
interval_service: ... | true |
4817d42a98cb8206802e154e32d91c5ca322d308 | Rust | glacyr/giraffe | /src/proto.rs | UTF-8 | 397 | 2.703125 | 3 | [] | no_license | pub enum Multiplexed<T> {
Pack(T),
Progress(String),
Fatal(String),
}
pub struct Status<E> {
pub unpack_error: Option<E>,
pub commands: Vec<CommandStatus>,
}
pub enum CommandStatus {
Ok(String),
NoGood(String, String),
}
pub fn packet(source: impl AsRef<str>) -> String {
let length = ... | true |
24de267cc2d6806a56b110ad007b490e64e61f57 | Rust | Hxuhao233/lan-play | /lan-play/src/proxy/direct.rs | UTF-8 | 1,326 | 2.53125 | 3 | [] | no_license | use super::{Proxy, socket, ToSocketAddrs, SocketAddr};
use tokio::task::{self, JoinHandle};
use tokio::net::{TcpStream, UdpSocket};
use tokio::io;
#[async_trait(?Send)]
impl socket::Tcp for TcpStream {
}
#[async_trait(?Send)]
impl socket::Udp for UdpSocket {
async fn send_to<A: ToSocketAddrs>(&mut self, buf: &[u... | true |
eca8a6e6e3a4bf0acda12c7f0ba94a054cf0e6b9 | Rust | Weltraumschaf/minivm | /src/frontend/token.rs | UTF-8 | 2,539 | 3.6875 | 4 | [] | no_license | use std::fmt;
use frontend::Position;
/// Sentinel to indicate end of file.
pub const END_OF_FILE: char = 0 as char;
/// Defines a recognized token in the source.
#[derive(Debug, PartialEq)]
pub struct Token {
position: Position,
token_type: TokenType,
literal: String,
}
impl Token {
/// Creates a ne... | true |
208d2f582076e5f858d768847f63e19f647a4847 | Rust | fisherdarling/WRECK | /src/bin/main.rs | UTF-8 | 6,031 | 2.609375 | 3 | [] | no_license | #![allow(non_snake_case)]
use wreck::cfg::CFG;
use wreck::input::LexerConfig;
use wreck::ll_table::LLTable;
use wreck::nfa_generator::NFAGenerator;
use wreck::parser::Parser;
use std::collections::BTreeSet;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, Clone... | true |
dcc6cda6997052e161adf247fe4fde60a2d7b790 | Rust | bakolisty/rayt_rust_project | /src/main.rs | UTF-8 | 3,470 | 2.8125 | 3 | [
"MIT"
] | permissive | extern crate minifb;
extern crate rand;
mod vec3;
mod ray;
mod hitable;
mod sphere;
mod camera;
use minifb::{Key, WindowOptions, Window};
use rand::Rng;
use vec3::Vec3;
use ray::Ray;
use hitable::{HitableList, Hitable};
use camera::Camera;
const WIDTH: usize = 640;
const HEIGHT: usize = 320;
const NS: usize = 32; //... | true |
34aaf5c7e6e90489a815d217951979f6d6750c75 | Rust | giuliop/advent-of-code-2020 | /src/day14.rs | UTF-8 | 3,871 | 3.46875 | 3 | [] | no_license | use lazy_static::lazy_static;
use regex::Regex;
use std::collections::HashMap;
use std::fs;
use std::ops::BitAnd;
use std::ops::BitOr;
const MASK_LEN: usize = 36;
pub fn a() -> String {
let mut computer = Computer::new();
computer.run(read_program());
computer.memory.values().sum::<usize>().to_string()
}
... | true |
991ffb26172c4f71ea7da5c1f789de514f7777c1 | Rust | slerpyyy/ndi-rs | /ndi/src/find.rs | UTF-8 | 5,228 | 2.65625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::internal::{lib_unwrap, OnDrop};
use super::*;
use std::{ffi::CString, thread::yield_now, time::Instant};
/// Builder for [`Find`] struct
#[derive(Debug, Clone)]
pub struct FindBuilder {
show_local_sources: Option<bool>,
groups: Option<String>,
extra_ips: Option<String>,
}
impl FindBuilder {
... | true |
b52e3b63d445d847e0be0d35a4509165f083ed6b | Rust | DarthStrom/rust-ray-tracer-challenge | /src/transformations.rs | UTF-8 | 10,369 | 3.203125 | 3 | [] | no_license | use std::ops::Mul;
use bevy::math::{Mat4, Vec3, Vec4};
use crate::{float_eq, tuple::Tuple};
#[derive(Clone, Copy, Debug, Default)]
pub struct Transform(Mat4);
pub const IDENTITY: Transform = Transform(Mat4::IDENTITY);
impl Transform {
pub fn inverse(&self) -> Self {
Self(self.0.inverse())
}
pu... | true |
eebf7427facbd41fe03946c836856b88fc356f02 | Rust | Arnavion/k8s-openapi | /src/v1_27/api/networking/v1/http_ingress_path.rs | UTF-8 | 10,261 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | // Generated from definition io.k8s.api.networking.v1.HTTPIngressPath
/// HTTPIngressPath associates a path with a backend. Incoming urls matching the path are forwarded to the backend.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct HTTPIngressPath {
/// backend defines the referenced service endpoint to w... | true |
bc3ccb0006d89036f2cb8ae076d9ecc2196371aa | Rust | dutt/synacore | /runner/src/host.rs | UTF-8 | 13,595 | 2.984375 | 3 | [] | no_license | use std::collections::vec_deque;
use std::io;
use log::{debug, error, info};
use messages::VmState;
use code::opcodes::OpCodes;
use code::program::Program;
pub struct Host {
registers: [u16; 8],
stack: Vec<u16>,
memory: Vec<u16>,
ip: usize,
input_buffer: vec_deque::VecDeque<u16>,
halted: boo... | true |
15033113e235e528fca1a483ddb1fca5b6233bac | Rust | archseer/cosmwasm | /packages/vm/src/wasm_backend/compile.rs | UTF-8 | 967 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::Arc;
use wasmer::{Module, ModuleMiddleware};
use crate::errors::VmResult;
use crate::size::Size;
use super::store::make_compile_time_store;
/// Compiles a given Wasm bytecode into a module.
/// The given memory limit (in bytes) is used when memories are created.
/// If no memory limit is passed, the ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.