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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
83cff0f407f98673716badcf925f108cb5034489 | Rust | Samuele0/chessrs | /src/minimax.rs | UTF-8 | 3,576 | 3.546875 | 4 | [
"MIT"
] | permissive |
use crate::board::*;
const MAX_DEPTH: u32 = 4;
pub struct Move {
pub start: (usize, usize),
pub end: (usize, usize),
value: i32,
}
impl PartialEq for Move {
fn eq(&self, mov: &Move) -> bool {
self.value == mov.value
}
}
impl PartialOrd for Move {
fn partial_cmp(&self, other: &Move) ->... | true |
ec6b18188b57f2dbb2fe4a3ab5a399ddf111c57c | Rust | ids1024/rust_os | /Kernel/Core/lib/thunk.rs | UTF-8 | 445 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | // "Tifflin" Kernel
// - By John Hodge (thePowersGang)
//
// Core/lib/thunk.rs
//! Box<FnOnce> support, similar to std::thunk
use prelude::*;
/// Trait that provides a consuming invoke function for boxed closures
pub trait Invoke<A=(), R=()>
{
/// Call the wrapped closure
fn invoke(self: Box<Self>, arg: A) -> R;
}
... | true |
4ba1336033ca1f95c5be47751b38092206f966ff | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/past202203-open/src/bin/e.rs | UTF-8 | 1,342 | 2.984375 | 3 | [] | no_license | use std::collections::HashSet;
use proconio::{input, marker::Chars};
fn main() {
input! {
s: Chars,
};
let mut y = s[0..4].iter().collect::<String>().parse::<usize>().unwrap();
let mut m = s[5..7].iter().collect::<String>().parse::<usize>().unwrap();
let mut d = s[8..10]
.iter()
... | true |
da0126ce5edf24970304f96726afab2c519ab1ac | Rust | ProgramAPE/deref_test | /src/my_collection.rs | UTF-8 | 717 | 3.328125 | 3 | [] | no_license | use core::any::Any;
use std::collections::HashMap;
pub fn my_collection(){
let mut collection = HeteroCollection::default();
collection.set("f32", 3.14f32);
collection.set("f64", 2.4156f64);
collection.set("another f32", 1.608f32);
let f32_output = *collection.get::<f32>("f32").unwrap();
assert_eq!(3.14, f32_ou... | true |
332fd0216897e6bced440a80e618fa947cd88265 | Rust | oshunter/fuchsia | /third_party/rust_crates/vendor/tracing-subscriber/src/registry/mod.rs | UTF-8 | 11,088 | 3.359375 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | //! Storage for span data shared by multiple [`Layer`]s.
//!
//! ## Using the Span Registry
//!
//! This module provides the [`Registry`] type, a [`Subscriber`] implementation
//! which tracks per-span data and exposes it to [`Layer`]s. When a `Registry`
//! is used as the base `Subscriber` of a `Layer` stack, the
//! ... | true |
24424e6c64fd3ae567d3f243d2e3fb7332dbc783 | Rust | Jazpy/AminoSim | /src/main.rs | UTF-8 | 4,499 | 2.640625 | 3 | [
"MIT"
] | permissive | mod parsers;
mod tree;
mod sequence;
mod mutator;
use crate::sequence::Sequence;
use rayon::ThreadPoolBuilder;
use rayon::prelude::*;
use clap::{Arg, App};
use std::collections::HashMap;
use std::fs::OpenOptions;
use std::io::prelude::*;
fn main() {
// Get app info
let matches = App::new("AminoSim")
... | true |
8dc79aabcbb2af50023512a9d0f70917847ded20 | Rust | enso-org/enso | /build/ci_utils/src/extensions/reqwest.rs | UTF-8 | 1,424 | 2.546875 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | use crate::prelude::*;
use mime::Mime;
use reqwest::header::HeaderMap;
use reqwest::header::HeaderName;
use reqwest::header::HeaderValue;
use reqwest::header::CONNECTION;
use reqwest::header::CONTENT_TYPE;
pub trait ClientBuilderExt: Sized {
fn default_content_type(self, mime_type: Mime) -> Self;
fn keep_al... | true |
af478119ec7f583c13ea9d16f796a4eebf0b21c5 | Rust | IThawk/rust-project | /rust-master/src/test/ui/borrowck/move-in-static-initializer-issue-38520.rs | UTF-8 | 334 | 2.984375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Regression test for #38520. Check that moves of `Foo` are not
// permitted as `Foo` is not copy (even in a static/const
// initializer).
struct Foo(usize);
const fn get(x: Foo) -> usize {
x.0
}
const X: Foo = Foo(22);
static Y: usize = get(*&X); //~ ERROR [E0507]
const Z: usize = get(*&X); //~ ERROR [E0507]
... | true |
d1ac47463e1cd491d7c2fb8e6ab0a900f3b2916b | Rust | ctsrc/kvr | /src/data.rs | UTF-8 | 1,058 | 2.6875 | 3 | [
"ISC"
] | permissive | use serde::{Deserialize, Serialize};
use ulid::Ulid;
use ulid::serde::ulid_as_u128;
#[derive(Serialize, Deserialize, PartialEq, Copy, Clone, Debug, Ord, PartialOrd, Eq)]
pub struct Revision(
#[serde(with = "ulid_as_u128")]
pub(crate) Ulid
);
impl std::fmt::Display for Revision {
fn fmt (&self, f: &mut std... | true |
4207a8238de82f96886622d601f2997f83511b76 | Rust | maxblee/recipe-app | /server/tests/steps/index.rs | UTF-8 | 962 | 2.796875 | 3 | [] | no_license | use crate::MyWorld;
use cucumber_rust::{t, Steps};
use rocket::http::Status;
use rocket::local::asynchronous::Client;
pub fn steps() -> Steps<crate::MyWorld> {
let mut steps: Steps<crate::MyWorld> = Steps::new();
steps.when_async(
"I visit the homepage",
t!(|_world, ctx| {
let clie... | true |
713120647461ba02a36b0c00b58cd0eba92b7bf1 | Rust | polydraw/polydraw | /src/sys/gl/frame/buffer.rs | UTF-8 | 2,000 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::ptr;
use error::{RuntimeError, VoidResult};
use frame::GPUFrame;
use draw::RGB;
use super::super::{Texture, Framebuffer, Buffer};
pub struct BufferFrame {
pub texture: Texture,
pub framebuffer: Framebuffer,
pub buffer: Buffer,
}
impl GPUFrame for BufferFrame {
#[inline]
fn new(width: u32, h... | true |
226fb7f768023398cc4d5378709f95626966691e | Rust | benridley/blackjack_rs | /src/main.rs | UTF-8 | 7,650 | 3.578125 | 4 | [
"MIT"
] | permissive | use std::io;
use std::fmt;
use rand::seq::SliceRandom;
use rand::thread_rng;
fn main() {
let mut dollars = 500;
println!("Welcome to blackjack");
while dollars > 0 {
println!("Enter bet (You have {} dollars).", dollars);
let bet: i32;
let mut buffer = String::new();
io::stdi... | true |
3cb024e69bc6047e6477b7fd50d6402f98e069b7 | Rust | ruizmarlon/habitat | /components/core/src/crypto/artifact.rs | UTF-8 | 19,694 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use std::{fs::File,
io::{self,
prelude::*,
BufReader,
BufWriter},
path::Path};
use base64;
use sodiumoxide::crypto::sign;
use super::{hash,
keys::parse_name_with_rev,
SigKeyPair,
HART_FORMAT_VERSION,
SIG_H... | true |
001f43e4b1c178358f8986bce5e510f8ce75b86e | Rust | andor44/capnproto-rust | /capnpc-rust/main.rs | UTF-8 | 68,412 | 2.796875 | 3 | [
"BSD-2-Clause"
] | permissive | /*
* Copyright (c) 2013-2014, David Renshaw (dwrenshaw@gmail.com)
*
* See the LICENSE file in the capnproto-rust root directory.
*/
#[feature(globs)];
#[crate_id="capnpc-rust"];
#[crate_type = "bin"];
extern crate capnp;
use capnp::*;
pub mod schema_capnp;
pub fn tuple_option<T,U>(t : Option<T>, u : Option<U>... | true |
b3d49eee22acacf599eaf1ca923cf2cb22c27890 | Rust | hannover-rust/advent_of_code_2019 | /day_1/src/main.rs | UTF-8 | 1,103 | 3.59375 | 4 | [
"Unlicense"
] | permissive | fn main() {
let input = include_str!("../input.txt");
let total_loop = using_loop(input);
let total_iter = using_iter(input);
assert_eq!(total_loop, total_iter);
println!("part1: {}", total_iter);
}
// bonus benchmark tests
fn using_loop(input: &str) -> i32 {
let mut total = 0;
for line in... | true |
2a31f6b525bef479d1d9be5134c63ad9bb429d0e | Rust | LinAGKar/advent-of-code-2017-rust | /day23b-hardcode/src/main.rs | UTF-8 | 935 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::io::Read;
fn main() {
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let mut lines = input.lines().map(|line| line.split_whitespace());
let num: i32 = lines.next().unwrap().nth(2).unwrap().parse().unwrap();
let factor_b: i32 = lines.nth(3).unwrap().nt... | true |
34c86619140b6e233a95d5c10880db5f2b9eb1be | Rust | alongubkin/openu-exercises | /algorithms-and-data-structures/max-min-heap/src/main.rs | UTF-8 | 446 | 2.796875 | 3 | [] | no_license | mod maxminheap;
extern crate rand;
use rand::prelude::*;
use maxminheap::MaxMinHeap;
fn main() {
let mut heap = MaxMinHeap::new(vec![100, 10, 20, 50, 60, 70, 80, 30, 40, 50]);
for _ in 1..10000 {
heap.insert(rand::thread_rng().gen_range(0, 5000));
}
heap.replace_maximum(0, 0);
if !h... | true |
dbcd1e4f62a87e86efb3b9008b31ba0848c1fac7 | Rust | knokko/knukki-rs | /src/font/mod.rs | UTF-8 | 780 | 2.578125 | 3 | [] | no_license | use crate::*;
mod manager;
mod included;
#[cfg(not(target_arch = "wasm32"))]
#[allow(warnings)]
mod system;
#[cfg(target_arch = "wasm32")]
mod web;
pub use manager::*;
pub use included::*;
#[cfg(not(target_arch = "wasm32"))]
pub use system::*;
#[cfg(target_arch = "wasm32")]
pub use web::*;
pub trait Font {
/// D... | true |
ed4ab4db132a29bb0e5660dd3f25e8bfb6bc8107 | Rust | deets/rabid-robot | /rabid-control/src/path.rs | UTF-8 | 15,253 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | extern crate nalgebra as na;
use na::{Vector2, Rotation2};
use std::fmt;
use std::time::Duration;
use libm::fmin;
use serde::{Deserialize, Serialize};
pub type Vector = Vector2<f64>;
pub type Rotation = Rotation2<f64>;
fn signum(n: f64) -> f64
{
if n > 0.0 {
1.0
}
else
{
-1.0
}
}
... | true |
a16aefe23d4db79edf46bc0e5a3edb1361f46ee9 | Rust | rrbutani/image-png | /src/encoder.rs | UTF-8 | 11,748 | 2.625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | extern crate deflate;
use std::borrow::Cow;
use std::error;
use std::fmt;
use std::io::{self, Write};
use std::mem;
use std::result;
use chunk;
use crc::Crc32;
use common::{AnimationControl, FrameControl, Info, ColorType, BitDepth};
use filter::{FilterType, filter};
use traits::{WriteBytesExt, HasParameters, Paramete... | true |
56a290f25247b77430354a1c7e752761399e32d7 | Rust | doomsparkles/nnshake | /examples/simple-ad.rs | UTF-8 | 2,402 | 2.59375 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | extern crate nnshake;
const SERVER_STATIC_PRIVKEY: [u8; 32] = [
228, 172, 49, 122, 10, 86, 15, 63,
30, 82, 44, 209, 15, 142, 38, 144,
20, 110, 164, 245, 17, 109, 59, 27,
158, 22, 80, 64, 178, 92, 10, 138,
];
const SERVER_STATIC_PUBKEY: [u8; 32] = [
85, 215, 107, 196, 200, 26, 154, 112,
186, 205... | true |
302888452f75811094e3b2b6db655e5891d35410 | Rust | tivek/exercism | /rust/luhn-from/src/lib.rs | UTF-8 | 1,057 | 3.90625 | 4 | [] | no_license | pub struct Luhn {
code: String,
}
impl Luhn {
pub fn is_valid(&self) -> bool {
if !self
.code
.chars()
.all(|c: char| c.is_ascii_digit() || c == ' ')
{
return false;
}
let mut s = 0;
let mut i = 0;
for mut n in sel... | true |
186f3154a7d0a24dfcc5d63c8b8d6bda9aa0f2a0 | Rust | Ice1187/compiler | /week1_integers/compiler/src/main.rs | UTF-8 | 1,080 | 2.765625 | 3 | [] | no_license | use gen_lib;
use std::env;
use std::io::{stdin, stdout, Write};
use std::process::Command;
use std::os::unix::process::CommandExt;
fn get_filename() -> (String, String) {
let mut path = String::new();
let mut filename: String;
let mut args = env::args_os();
// println!("args len: {:?}", args.len());
if args.len()... | true |
e4f3daf51a7ea7af5a0a8c7622210dfd4dded9fa | Rust | mnnxp/names-changer | /src/names_changer.rs | UTF-8 | 6,319 | 3.171875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use heck::SnakeCase;
use regex::Regex;
pub trait NamesChanger {
type Owned;
/// Convert a names of sql schemes from camelcase to snake case.
///
/// # Examples
///
/// ```
/// use names_changer::NamesChanger;
///
/// assert_eq!(&"TABLE ClientTokensRef IS 'text';".camel_to_snake(),
... | true |
dfe0baa8a0e9adbb206fba8cd66991b9c529b618 | Rust | PotHix/dive-into-rust | /exercicios/let_e_if/src/main.rs | UTF-8 | 648 | 3.65625 | 4 | [] | no_license | fn main() {
/* you may leave it blank */
}
/// A leap year happens every four years
/// except in year that are multiple of 100 and not multiple of 400.
/// Return `true` if `year` is a leap year and `false` otherwise
fn is_leap_year(year: i32) -> bool {
false
}
// Tests
#[test]
fn test_vanilla_leap_year() ... | true |
9398772b9ff59975b7365dcd7b424471abdf061b | Rust | lutostag/exercism | /rust/poker/src/lib.rs | UTF-8 | 3,671 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::collections::{HashMap, HashSet};
type Rank = u8;
type Suit = char;
type Card = (Rank, Suit);
#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum HandRank {
FiveOfAKind = 9,
StraightFlush = 8,
FourOfAKind = 7,
FullHouse = 6,
Flush = 5,
Straight = 4,
ThreeOfAKind ... | true |
b794544a695cfd3b1f6b3f90c438bc047d47a387 | Rust | vdalex/rust-turtle-graphics | /src/main.rs | UTF-8 | 2,701 | 3.1875 | 3 | [] | no_license | extern crate turtle;
use std::fs::File;
use std::io::{Write, Error};
use turtle::ast::*;
//// draw_the_world(&vec!<Line>, world_width: Option<isize>, world_height: Option<isize> ) -
fn draw_the_world(world: &Vec<Line>, world_width: Option<isize>, world_height: Option<isize>) -> Result<(), Error> {
let path = "s... | true |
264c2df92f8dede82ca4d381a7462f97a1b1d8f6 | Rust | JammyStuff/aoc-2020 | /day02/src/main.rs | UTF-8 | 4,070 | 3.609375 | 4 | [] | no_license | use lazy_static::lazy_static;
use regex::Regex;
use std::io::{self, Read};
struct Policy {
min: u16,
max: u16,
letter: char,
}
fn check_password(password: &str, policy: &Policy) -> bool {
let count = password.chars().filter(|c| *c == policy.letter).count() as u16;
return (count >= policy.min) && ... | true |
f870840cecb6232189273aea507d8201af031918 | Rust | sathishvinayk/rust_360 | /types_in_rust/arrays.rs | UTF-8 | 175 | 2.8125 | 3 | [] | no_license | fn main() {
let mut values: [u8; 5] = [4, 5, 76, 1, 7];
let values2 = ["true"; 5];
values.sort();
println!("{:?}", values);
println!("{:?}", values2);
} | true |
640967eb1c52352dbaf30b1dac201eabac4a81ed | Rust | JayPavlina/snes-apu | /src/dsp/envelope.rs | UTF-8 | 3,837 | 2.921875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | use super::dsp::Dsp;
enum Mode {
Attack,
Decay,
Sustain,
Release
}
pub struct Envelope {
dsp: *mut Dsp,
pub adsr0: u8,
pub adsr1: u8,
pub gain: u8,
mode: Mode,
pub level: i32,
hidden_level: i32
}
impl Envelope {
pub fn new(dsp: *mut Dsp) -> Envelope {
Envelop... | true |
1599c4793ecd25e0d5730172f0606980ab467854 | Rust | huxy11/AWOS_rust | /src/errors/http_errors.rs | UTF-8 | 3,185 | 2.984375 | 3 | [] | no_license | use std::fmt;
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct HttpError(u16);
impl From<u16> for HttpError {
fn from(code: u16) -> Self {
HttpError(code)
}
}
impl fmt::Display for HttpError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} {}", self.0, self.info(... | true |
5b7ee2b41b5c808f7efa0ad56e2d48609f8e71ac | Rust | SuMingXuan/autocorrect | /src/lib/src/swift.rs | UTF-8 | 1,455 | 2.8125 | 3 | [
"MIT"
] | permissive | // autocorrect: false
use super::*;
use pest::Parser as P;
use pest_derive::Parser;
#[derive(Parser)]
#[grammar = "../grammar/swift.pest"]
struct SwiftParser;
#[allow(dead_code)]
pub fn format_swift(text: &str) -> code::FormatResult {
let pairs = SwiftParser::parse(Rule::item, text);
let text = code::FormatResult... | true |
930754106d94fb8be14878eb4b5d9f8db0f9cf8e | Rust | gil0mendes/rustboy | /core/src/gpu/mod.rs | UTF-8 | 6,517 | 2.71875 | 3 | [
"MIT"
] | permissive | use self::types::Color;
pub mod types;
const VOAM_SIZE: usize = 0xa0;
const ACCESS_OAM_CYCLES: isize = 21;
const CHARACTER_RAM_TILES: usize = 384;
const OAM_SPRITES: usize = 40;
const TILE_MAP_SIZE: usize = 0x400;
const UNDEFINED_READ: u8 = 0xff;
#[derive(Clone, Copy)]
struct Tile {
data: [u8; 16]
}
impl Tile ... | true |
9e2a3a5fb3aaa29ae80f4ad40fc9bbfb790b6b53 | Rust | willfindlay/rd | /src/trace/compressed_writer.rs | UTF-8 | 15,824 | 2.671875 | 3 | [
"MIT",
"BSD-2-Clause"
] | permissive | use crate::{scoped_fd::ScopedFd, util::write_all};
use brotli_sys::{
BrotliEncoderCompressStream, BrotliEncoderCreateInstance, BrotliEncoderDestroyInstance,
BrotliEncoderSetParameter, BROTLI_OPERATION_FINISH, BROTLI_OPERATION_PROCESS,
BROTLI_PARAM_QUALITY,
};
use nix::{fcntl::OFlag, sys::stat::Mode, unistd:... | true |
153b17c47b10b8da09a7e8fb6bfe3fb0d0c748b9 | Rust | sousandrei/Advent-of-Code-2020 | /src/day13.rs | UTF-8 | 2,074 | 3.140625 | 3 | [] | no_license | use aoc_runner_derive::{aoc, aoc_generator};
fn egcd(a: i64, b: i64) -> (i64, i64, i64) {
if a == 0 {
(b, 0, 1)
} else {
let (g, x, y) = egcd(b % a, a);
(g, y - (b / a) * x, x)
}
}
fn mod_inv(x: i64, n: i64) -> Option<i64> {
let (g, x, _) = egcd(x, n);
if g == 1 {
S... | true |
fc904bfd5f3c57c706015e35f4d7fcec8dc92d9c | Rust | matago/adventofcode-2020 | /src/days/day09.rs | UTF-8 | 2,117 | 2.921875 | 3 | [] | no_license | use crate::days::utils::Part;
use futures::stream::StreamExt;
use std::{
collections::HashSet,
convert::TryInto,
fmt::Debug,
str::{self, FromStr},
usize,
};
use tokio::io::{AsyncBufReadExt, Result};
use tokio::{fs::File, io::BufReader};
const FILEPATH: &str = "./input/day09.txt";
pub async fn run... | true |
ffdafa96237e3e0b8c05fed068c628bc8e8c3da0 | Rust | placrosse/svd2rust | /src/transform/delete.rs | UTF-8 | 1,895 | 2.734375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use log::*;
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};
use super::common::*;
use crate::ir::*;
#[derive(Debug, Serialize, Deserialize)]
pub struct Delete {
pub from: String,
}
impl Delete {
pub fn run(&self, ir: &mut IR) -> anyhow::Result<()> {
let re = make_regex(... | true |
479bcdd883abb2b9c19631f949782e38998c9249 | Rust | aashah/advent_of_code | /2017/src/day1.rs | UTF-8 | 639 | 3.640625 | 4 | [] | no_license | pub fn puzzle(input: &str) -> u32 {
let mut count: u32 = 0;
let mut first_digits: Vec<u32> = input.chars().map(|c| c.to_digit(10).unwrap()).collect();
let second_digits = first_digits.split_off(input.len() / 2);
for (c, d) in first_digits.iter().zip(second_digits.iter()) {
if c == d {
... | true |
ccc6b9c54db34ef53bc4f84d8aab0775aa31c4d5 | Rust | kevinmehall/rust-soapysdr | /src/device.rs | UTF-8 | 42,475 | 2.578125 | 3 | [
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use soapysdr_sys::*;
pub use soapysdr_sys::SoapySDRRange as Range;
use std::slice;
use std::ptr;
use std::sync::Arc;
use std::ffi::{ CStr, CString };
use std::os::raw::{c_int, c_char};
use std::os::raw::c_void;
use std::marker::PhantomData;
use super::{ Args, ArgInfo, StreamSample, Format };
use crate::arginfo::arg_in... | true |
da75cfa4939eee01cc701fc7f78e168637503e6d | Rust | c0c1/salvo | /extra/src/serve/mod.rs | UTF-8 | 2,165 | 2.625 | 3 | [
"MIT"
] | permissive | mod dir;
mod fs;
pub use dir::{Options, StaticDir};
pub use fs::StaticFile;
#[cfg(test)]
mod tests {
use salvo_core::hyper;
use salvo_core::prelude::*;
use super::*;
#[derive(Debug, Serialize, Deserialize)]
pub struct JwtClaims {
user: String,
exp: i64,
}
#[tokio::test]
... | true |
45f8a2a43549beafb6dafb030f3f4630191d47e4 | Rust | d3z41k/learn-rust | /src/04_ownership_01.rs | UTF-8 | 823 | 3.921875 | 4 | [] | no_license | fn take(v: Vec<i32>) {
println!("we took v: {}", v[10] + v[100]);
}
fn cop(a: i32, b: i32) {
println!("{}", a + b);
}
fn main() {
let x = 1; // store in stack
let y = x;
{
let z = 5; // "z" exist only in this scope
}
// x + z;
let s = String::from("String!"); // store in hea... | true |
ab8c44830f3e071121d423f3ab3a709074044189 | Rust | tkygtr6/tutorials | /Rust-practice/ITP1_6_A.rs | UTF-8 | 366 | 2.6875 | 3 | [] | no_license | fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).unwrap();
let n = n.trim().parse::<u32>();
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut nums = line.trim().split_whitespace().collect::<Vec<_>>();
nums.reverse();
let nums ... | true |
1c0678d5c13f847df9dc82ba51539994f68f201a | Rust | rust-embedded/rust-raspberrypi-OS-tutorials | /14_virtual_mem_part2_mmio_remap/kernel/src/bsp/device_driver/arm/gicv2/gicd.rs | UTF-8 | 6,863 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // SPDX-License-Identifier: MIT OR Apache-2.0
//
// Copyright (c) 2020-2022 Andre Richter <andre.o.richter@gmail.com>
//! GICD Driver - GIC Distributor.
//!
//! # Glossary
//! - SPI - Shared Peripheral Interrupt.
use crate::{
bsp::device_driver::common::MMIODerefWrapper,
memory::{Address, Virtual},
stat... | true |
902844963375b1f3e5a7ab1c2219a1e60a0dcea7 | Rust | zayenz/advent-of-code-2019 | /day2-1/src/main.rs | UTF-8 | 3,996 | 2.921875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code, unused_imports)]
use failure::bail;
use failure::Error;
use rayon::prelude::*;
use strum_macros::EnumString;
use std::char;
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::io::BufRead;
use std::ops::*;
use std::str;
use std::str::FromStr;
use std::{io, pr... | true |
11b525d7d1c87750228ba704a0f357ed95b06594 | Rust | proecho/display | /src/lib.rs | UTF-8 | 4,200 | 3.28125 | 3 | [] | no_license | use std::collections::LinkedList;
use objects::*;
use std::fs;
use chrono::{DateTime, TimeZone, NaiveDateTime, Utc,};
use std::time::SystemTime;
use shared_parser::{Event_parser,time_inside};
use std::{thread, time};
//loads a file and creates a linked list containing the entrys from it, list is ordered with the list... | true |
3e1a902241bb5ffc9aea984cd723d489e4302bdd | Rust | osa1/string-matching | /src/kmp.rs | UTF-8 | 5,285 | 3.34375 | 3 | [] | no_license | #[derive(Debug)]
pub struct KMP<C> {
pat: Vec<C>,
// See `mk_pfx`
pfx: Vec<usize>,
}
// Given size of the current match (should be at least 1) n, pfx[n-1] gives the longest proper
// prefix of the pattern that is also a suffix. Examples:
//
// - Pattern: ababaca
// Pfx:
// match size | longest pre... | true |
de8d72eb2ada79ce0b74669279854cc9e34a6363 | Rust | katyo/literium | /rust/backend/src/base/timestamp.rs | UTF-8 | 4,866 | 3.28125 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::ops::{Add, Sub};
use std::time::{Duration, SystemTime};
use time::{at_utc, get_time, strftime, strptime, ParseError, Timespec, Tm};
/// Unix-time in milliseconds
///
/// This type is intended for compact representation of real time.
/// The values... | true |
8edb15d7bdb5685d14e2fb7982310d5a6a589c78 | Rust | adwhit/advent-of-code-2019 | /src/lib.rs | UTF-8 | 7,903 | 3.15625 | 3 | [] | no_license | use std::convert::TryFrom;
use std::io::{self, BufRead, Write};
pub struct Machine {
data: Vec<i64>,
ip: usize,
relative_base: i64,
input_callback: Box<dyn FnMut() -> i64 + Send>,
output_callback: Box<dyn FnMut(i64) + Send>,
initial_size: usize
}
fn read_from_stdin() -> i64 {
loop {
... | true |
095062bac7abdc3c0e888db9b2d6fd1a3466d544 | Rust | dimforge/ncollide | /src/pipeline/object/collision_object_set.rs | UTF-8 | 7,374 | 3.265625 | 3 | [
"Apache-2.0"
] | permissive | use simba::scalar::RealField;
use crate::pipeline::object::{CollisionObject, CollisionObjectRef, CollisionObjectSlabHandle};
use slab::{Iter, IterMut, Slab};
use std::hash::Hash;
use std::ops::{Index, IndexMut};
/// Trait implemented by a handle indentifying a collision object.
pub trait CollisionObjectHandle: Copy +... | true |
bd50f077b434d6efe37ae247a024744235371336 | Rust | Siilwyn/rust-minigrep-clap | /src/main.rs | UTF-8 | 693 | 2.5625 | 3 | [] | no_license | extern crate clap;
extern crate minigrep;
use clap::{App, Arg};
use std::process;
use minigrep::Config;
fn main() {
let args = App::new("minigrep")
.version("1.3.7")
.arg(Arg::with_name("query").required(true).index(1))
.arg(Arg::with_name("filename").required(true).index(2))
.arg... | true |
01817dc59ed462358eb51a78ff6789ee8517f755 | Rust | appaquet/exocore | /apps/sdk/src/client.rs | UTF-8 | 1,164 | 2.859375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use std::sync::{Arc, Mutex};
use crate::{app::App, store::Store};
lazy_static! {
static ref EXOCORE: Exocore = Exocore {
store: Arc::new(Store::new()),
app: Arc::new(Mutex::new(None)),
};
}
/// Exocore client.
pub struct Exocore {
pub store: Arc<Store>,
app: Arc<Mutex<Option<Box<dyn A... | true |
4ddb76af2fe73ec33918539a3ebf82b678a5880b | Rust | rgambee/advent-of-code | /2021/src/day25/solution25.rs | UTF-8 | 2,631 | 3.078125 | 3 | [] | no_license | use crate::util;
use std::fs;
use std::path;
fn move_cucumbers(grid: &mut [Vec<char>], facing: char, row_inc: usize, col_inc: usize) -> bool {
let mut moved = false;
let grid_len = grid.len();
let mut to_move: Vec<util::Point2D> = Vec::new();
for r in 0..grid_len {
let row_len = grid[r].len();
... | true |
e5f4f7609128cce9b3c8d7938041b105f59bccbd | Rust | rust-av/rust-av | /format/src/demuxer.rs | UTF-8 | 10,056 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::error::*;
use crate::buffer::Buffered;
use std::any::Any;
use std::io::SeekFrom;
use std::sync::Arc;
use crate::common::*;
use crate::data::packet::Packet;
use crate::stream::Stream;
/// Events processed by a demuxer analyzing a source.
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum Event {
/// A... | true |
91842bcf8d1ec19374d4749e256c985ddda31fe8 | Rust | jlingohr/ray_trace | /src/cube.rs | UTF-8 | 2,058 | 2.796875 | 3 | [] | no_license | use super::aabb::AABB;
use super::aarect::{AARectangle, Plane};
use super::hittable::{FlipFace, HitRecord, Hittable, HittableList};
use super::material::Material;
use super::point::Point;
use super::ray::Ray;
pub struct Cube {
box_min: Point,
box_max: Point,
sides: HittableList,
}
impl Cube {
pub fn n... | true |
66640d0c92c2d6278fa04cc3b7ad5deb6ca728aa | Rust | suzu-prg/Rust-parallel-experiment | /eratosthenes/examples/benchmark.rs | UTF-8 | 1,478 | 2.734375 | 3 | [] | no_license | // cargo run --release --example benchmark -- 8
use num_cpus;
use eratosthenes::seq_eratosthenes::eratosthenes as seq_eratosthenes;
use eratosthenes::par_eratosthenes::eratosthenes as par_eratosthenes;
use eratosthenes::par_eratosthenes2::eratosthenes as par_eratosthenes2;
use std::{env,f64};
use std::str::FromStr;
... | true |
e1c76b91a34d6d03fc3d2241d6fcb677ce1bd770 | Rust | tanaythan/avalon-tracker | /src/main.rs | UTF-8 | 1,386 | 2.640625 | 3 | [] | no_license | mod db;
pub mod types;
use std::env;
use std::path::PathBuf;
use db::{create_game, find_game, load_all_games};
use sqlx::sqlite::SqlitePool;
use structopt::StructOpt;
type AllResult<T> = Result<T, Box<dyn std::error::Error>>;
#[derive(Debug, StructOpt)]
#[structopt(
name = "avalon-tracker",
about = "Tracks ... | true |
de00ae7dca24d2a320aa8295a81ed17f96d6266d | Rust | vulpesgames/unibridge-rs | /hello-world/src/instance.rs | UTF-8 | 3,417 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use crate::glue::get_glue;
use std::convert::{TryFrom, TryInto};
#[repr(C)]
pub struct Instance(u64);
#[repr(C)]
#[derive(Clone, Copy)]
pub struct WeakInstance(u64);
#[repr(C)]
pub struct TypeCast<T>(pub(crate) bool, pub(crate) T);
impl Instance {
pub fn from_raw_unchecked(id: u64) -> Instance {
Instanc... | true |
5b16fdc3aa2f2384da169bfcab40611def0252f1 | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-52240.rs | UTF-8 | 365 | 3.03125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // issue-52240: Can turn immutable into mut with `ref mut`
enum Foo {
Bar(i32),
}
fn main() {
let arr = vec!(Foo::Bar(0));
if let (Some(Foo::Bar(ref mut val)), _) = (&arr.get(0), 0) {
//~^ ERROR cannot borrow data in a `&` reference as mutable
*val = 9001;
}
match arr[0] {
... | true |
fc81d54d44e270ee60b9d29b34ed9ebdb2783c2b | Rust | rasmusmerzin/crud-file-server | /src/serve.rs | UTF-8 | 2,101 | 2.6875 | 3 | [
"MIT"
] | permissive | use crate::{Config, State};
use async_std::fs::{remove_file, OpenOptions};
use async_std::io;
use async_std::sync::Arc;
use tide::{Body, Request, Response, StatusCode};
use uuid::Uuid;
async fn post(req: Request<Arc<State>>) -> tide::Result<String> {
let name = Uuid::new_v4().to_string();
let path = req.state(... | true |
a4d7c700a0b9d31171ba8fb0bd06e4b0f5442606 | Rust | mudit111/hawk-1 | /src/user_data.rs | UTF-8 | 1,970 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | use std::env;
use std::process::Command;
use kafka::consumer::{Consumer, FetchOffset, GroupOffsetStorage};
static CAMERA_SHUTTER_SPEED: &str = "1000";
static IMAGE_WIDTH: &str = "180";
static IMAGE_HEIGHT: &str = "200";
static INVALID_CLICKED_IMAGE: &str = "Unable to capture image";
static HOST: &str = "Host";
static... | true |
e3db2c43df6d47d46d61d914aff8c8cce7ea906c | Rust | JacksonGariety/earthmacs-rs | /src/editor.rs | UTF-8 | 4,773 | 2.734375 | 3 | [] | no_license | use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
use ncurses::*;
use std::path::PathBuf;
use syntect::parsing::SyntaxSet;
use syntect::highlighting::ThemeSet;
use std::path::Path;
use buffer::Buffer;
use window::Window;
use window_tree::WindowTree;
use cell::Cell;
use drawer::Drawer;
const NORTH: usiz... | true |
a4fe826488653ec8b0d3df4cc22db32f9f505422 | Rust | SimonWoodburyForget/rosetta | /parallel_brute_force/src/lib.rs | UTF-8 | 1,268 | 3.375 | 3 | [] | no_license | use rayon::prelude::*;
use sha2::{Digest, Sha256};
/// Recursive increament a buffer of lower case characters.
fn incr(mut buffer: &mut [u8], idx: usize) -> bool {
if buffer.len() <= idx {
false
} else if buffer[idx] >= b'z' {
incr(&mut buffer, idx + 1);
buffer[idx] = b'a';
true... | true |
b45d33e74f34a5c7da030899bb61bb69bb10ef4e | Rust | gnoliyil/fuchsia | /src/security/bin/cr50_agent/src/cr50/command/ccd.rs | UTF-8 | 7,545 | 2.53125 | 3 | [
"BSD-2-Clause"
] | permissive | // Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::{
cr50::command::{Deserializable, Header, Serializable, Subcommand, TpmRequest},
util::{DeserializeError, Deserializer, Serializer},
};
... | true |
6420cdc7c73df90178947fd71980d5a33b199348 | Rust | Pernosco/prettify-js | /tests/prettyprint_tests.rs | UTF-8 | 2,096 | 2.84375 | 3 | [
"BSD-2-Clause"
] | permissive | use prettify_js::*;
fn m(fl: u32, fc: u32, tl: u32, tc: u32) -> SourceMapping {
SourceMapping {
from: SourceCoord {
line: SourceMapLine(fl),
column: SourceMapColumn(fc),
},
to: SourceCoord {
line: SourceMapLine(tl),
column: SourceMapColumn(tc)... | true |
a608882bf0815a3a1676a084495c4ee6bb0c50d2 | Rust | TheEnbyperor/phetch | /src/main.rs | UTF-8 | 3,799 | 2.96875 | 3 | [
"MIT"
] | permissive | use phetch::{
args, gopher, menu,
ui::{Mode, UI},
};
use std::{env, process};
fn main() {
process::exit(run())
}
/// Start the app. Returns UNIX exit code.
fn run() -> i32 {
let str_args = env::args().skip(1).collect::<Vec<String>>();
let mut cfg = match args::parse(&str_args) {
Ok(c) => c... | true |
c343c1f609806279a9e6fb5404991300b5fb9729 | Rust | flauntingspade4/cakcukus | /tests/readme_test.rs | UTF-8 | 1,267 | 3.125 | 3 | [
"MIT"
] | permissive | #[cfg(feature = "built_in_types")]
use cakcukus::{
terms,
traits::{Differentiation, TermTrait},
Polynomial, Term,
};
#[cfg(feature = "built_in_types")]
#[test]
fn test_vec() {
// Build the initial equation, being 2x^2 - 3x + 5
let terms: Polynomial<f64> = Polynomial(vec![
Term::new(2., 2.),... | true |
7f9791d48d33b9cfdc9f11111c1ccad12a7e68aa | Rust | shocoman/YARSIE-Yet-Another-Space-Invaders-Emulator-On-Rust | /src/sdl_context.rs | UTF-8 | 1,496 | 2.59375 | 3 | [] | no_license | use sdl2::pixels::{Color, PixelFormatEnum};
use sdl2::render::Texture;
use std::time::Duration;
pub struct SdlContext {
pub sdl_context: sdl2::Sdl,
pub video_subsystem: sdl2::VideoSubsystem,
pub canvas: sdl2::render::WindowCanvas,
pub event_pump: sdl2::EventPump,
pub texture_creator: sdl2::render::... | true |
a8427e99bb0b70e293d0aeb6e7fc173623a2684d | Rust | AaronC81/tarn | /src/wasm/instruction.rs | UTF-8 | 4,990 | 2.75 | 3 | [] | no_license | use crate::wasm::core::{WasmCodeGen, ValueType, encode_i32, encode_u32};
#[derive(Debug, Clone)]
pub enum Instruction {
Unreachable,
Nop,
Block(BlockType, Vec<Instruction>), Loop(BlockType, Vec<Instruction>),
If(BlockType, Vec<Instruction>), IfElse(BlockType, Vec<Instruction>, Vec<Instruction>),
Br... | true |
68260945d1a46a2af18fadbd6c0858bfb70f1d6c | Rust | alexsult/bernard | /src/entities/recording.rs | UTF-8 | 987 | 2.796875 | 3 | [] | no_license | use entities::artist::ArtistCredit;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(default)]
pub struct Recording {
pub title: String,
pub video: bool,
pub length: Option<u32>,
pub disambiguation: Option<String>,
pub artist_credit: Option... | true |
efe3cd40c7524ef550d39a5064f762990533f47d | Rust | sks/rust_ground | /src/types.rs | UTF-8 | 437 | 2.84375 | 3 | [] | no_license | /*
Integers: u8, i8, ....
Floats: f32, f64
Boolean (bool)
Characters (char)
Tuples
Arrays
*/
pub fn run() {
// Default is i32
let x = -1;
// Default f64
let y = 2.5;
let z: i64 = 234567890;
let is_lessthan = 10 > 6;
let a1 = 'a';
let face = '\u{1F600}';
println!(
"{:?}"... | true |
05226ea739627737d0580033675d0b290903bc8c | Rust | vechema/AdventOfCode2017 | /01captcha/src/main.rs | UTF-8 | 1,116 | 3.609375 | 4 | [] | no_license | extern crate utilities;
fn main() {
let input = utilities::read_file("input.txt");
// Turn string into array of ints
let mut v = Vec::new();
for i in input.chars() {
v.push(i.to_digit(10).unwrap());
}
let ans = calc_captcha(&v, 1);
println!("{}", ans);
let v_len = v.len() / 2;
let ans2 = calc_captcha(&v,... | true |
74377984fd36c64f5319ce654fe26a7cb7035103 | Rust | Discreater/DAC_SDC2COCO | /src/xml_parser.rs | UTF-8 | 7,420 | 2.765625 | 3 | [] | no_license | use std::collections::BTreeMap;
use std::path::PathBuf;
use std::{fs, io};
use xml::reader::{Events, XmlEvent};
use xml::EventReader;
#[derive(Debug, Default)]
pub struct Annotataion {
filename: String,
size: Size,
object_name: String,
bndbox: Bndbox,
}
impl Annotataion {
/// one image one object... | true |
bc2d112776d72365fc1be4a5bf49f75228df3735 | Rust | markbenvenuto/kmip | /protocol/src/ser_xml.rs | UTF-8 | 13,360 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use serde::Serialize;
use strum::AsStaticRef;
use crate::{chrono::TimeZone, CryptographicUsageMask};
use crate::{
error::Result,
ser::{EncodedWriter, Serializer},
EnumResolver,
};
use std::{
rc::Rc,
str::{self, FromStr},
};
extern crate num;
//#[macro_use]
extern crate num_derive;
extern crate num... | true |
251c598fa2caae78028fbdf7f58d8bce2a7c903b | Rust | abbec/krang | /src/lib.rs | UTF-8 | 1,102 | 2.984375 | 3 | [
"MIT"
] | permissive | mod lexer;
use std::io::{stdin, stdout, BufRead, Write};
use tokio::runtime;
pub fn repl() -> Result<(), String> {
let lexer = lexer::Lexer::new();
#[cfg(target_os = "wasi")]
let runtime = runtime::Builder::new_current_thread().build().unwrap();
#[cfg(not(target_os = "wasi"))]
let runtime = runt... | true |
4b324223124c7c203007fc5fbe2dc9730c3f7f20 | Rust | mawis/my-exercism | /rust/armstrong-numbers/src/lib.rs | UTF-8 | 688 | 3.71875 | 4 | [] | no_license | pub fn is_armstrong_number(num: u32) -> bool {
let digit_count = Digits::of(num).count();
let sum = Digits::of(num).map(|n| n.pow(digit_count as u32))
.fold(0, |accu, n| accu + n);
num == sum
}
struct Digits {
remaining_digits: u32
}
impl Digits {
pub fn of(n: u32) -> Digits {
Digi... | true |
afc86345813416a5dce84dcddfaf6833a725d102 | Rust | mrnix/rust_d3_geo | /src/stream/triangle.rs | UTF-8 | 296 | 2.765625 | 3 | [] | no_license | use geo::CoordFloat;
use geo::Triangle;
use super::Stream;
use super::Streamable;
impl<T> Streamable for Triangle<T>
where
T: CoordFloat,
{
type T = T;
#[inline]
fn to_stream<SD: Stream<T = T>>(&self, _stream: &mut SD) {
todo!("Do I convert to polygon here?");
}
}
| true |
2173afbbdbeed90a6a0510bde67f5eeb9bfbd5fd | Rust | raathi/breadboard | /custom_types/src/main.rs | UTF-8 | 5,271 | 3.921875 | 4 | [] | no_license | #![allow(dead_code)]//annotating the entire file to allow dead code.
enum Status{
Rich,Poor,
}
fn main() {
//!Custom data types mainly using "struct" and "enum"
//! Constants using "const" and "static"
/*
STRUCTURES
3 types - tuple structs, C structs, Unit struts
*/
#[derive(Debug... | true |
9d58429cec53045471367d11558307078ad685c2 | Rust | jhjaggars/lsof-parser | /src/lib.rs | UTF-8 | 4,444 | 3.21875 | 3 | [] | no_license | #[derive(Clone)]
struct Offsets {
command: usize,
pid: usize,
user: usize,
fd: usize,
type_: usize,
device: usize,
size_off: usize,
node: usize,
name: usize,
}
#[derive(Debug)]
struct Row {
command: String,
pid: String,
user: String,
fd: String,
type_: String,
... | true |
eced7984e6de4b47754ec983313d0fd11ea12dc3 | Rust | nappa85/mysql-stream | /src/lib.rs | UTF-8 | 9,004 | 2.734375 | 3 | [] | no_license | #![deny(warnings)]
#![deny(missing_docs)]
//! # mysql-stream
//!
//! futures-core::Stream adapter for mysql_async
use std::{
marker::PhantomData,
pin::Pin,
task::{Context, Poll},
};
use futures_util::future::BoxFuture;
use mysql_async::{
from_row_opt,
prelude::{FromRow, Protocol},
FromRowErr... | true |
c188e7f5dcd63a5f32844bd1e685f7ca1720c95a | Rust | lewis-weinberger/crosscorr | /src/lib.rs | UTF-8 | 12,149 | 3.03125 | 3 | [
"MIT"
] | permissive | use byteorder::{NativeEndian, ReadBytesExt};
use fftw::array::AlignedVec;
use fftw::plan::*;
use fftw::types::*;
use num_complex::Complex;
use ron::de::from_reader;
use serde::Deserialize;
use std::f64::consts::PI;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
/// A struct containing the configur... | true |
d89f2a50c58c713f2d936938e2b4c018d686daf9 | Rust | sssooonnnggg/lua2js | /src/transpiler.rs | UTF-8 | 17,097 | 3.015625 | 3 | [] | no_license | use rslua::ast::*;
use rslua::ast_walker::*;
use rslua::lexer::Lexer;
use rslua::parser::Parser;
use rslua::types::*;
use std::mem;
use std::str;
pub struct Transpiler {
output: String,
indent: usize,
depth: usize,
}
#[allow(dead_code)]
impl Transpiler {
pub fn new() -> Self {
Transpiler {
... | true |
5f24d647fa868006fcfa54eb9ccda76e9462ee25 | Rust | tabac/countmin.rs | /evaluation/src/main.rs | UTF-8 | 9,470 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::cmp;
use std::collections::hash_map::RandomState;
use std::collections::HashMap;
use std::f64;
use std::fmt;
use std::fs::File;
use std::hash::Hash;
use std::io::{BufRead, BufReader, BufWriter, Write};
use std::path::Path;
use std::str;
use std::sync::{Arc, Mutex};
use std::thread;
use countminsketch::CountMi... | true |
33e8795d9799bc34f49deef67086ed99f3c1a357 | Rust | emrahtuncel/temperature-humidity-monitor | /dht_client/src/main.rs | UTF-8 | 1,371 | 2.65625 | 3 | [] | no_license | use dht_client::{Sensor, read_sensor_data, send_sensor_data, Config};
use std::{sync::mpsc, sync::Arc, thread};
use serde_yaml::Value;
pub fn main() {
let producer_config = Arc::new(parse_config());
let consumer_config = producer_config.clone();
let (tx, rx) = mpsc::channel();
let producer = thread:... | true |
5849cf545831784e389d7ceb5ecd6966364bb53c | Rust | ivfranco/notes | /OS/process/unix-shell/src/main.rs | UTF-8 | 3,412 | 2.90625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | use itertools::Itertools;
use nix::{
fcntl::{open, OFlag},
libc::{STDERR_FILENO, STDOUT_FILENO},
sys::stat::Mode,
sys::wait::wait,
unistd::{dup2, execvp, fork, ForkResult},
};
use std::{
ffi::CString,
io::{stdin, stdout, Write},
};
use unix_shell::Result;
const PROMPT: &str = "osc";
fn mai... | true |
719ed0e83469742e62a90f508d537a18adc26306 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/gpu-allocator-0.19.1/src/vulkan/mod.rs | UTF-8 | 26,129 | 2.8125 | 3 | [
"BSD-2-Clause",
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![deny(clippy::unimplemented, clippy::unwrap_used, clippy::ok_expect)]
#[cfg(feature = "visualizer")]
mod visualizer;
#[cfg(feature = "visualizer")]
pub use visualizer::AllocatorVisualizer;
use super::allocator;
use super::allocator::AllocationType;
use ash::vk;
use log::{debug, warn, Level};
use std::fmt;
use crat... | true |
47e0e993f59a4c59797657de178a9fff4f1e5b55 | Rust | meh/rust-picto | /src/buffer/buffer.rs | UTF-8 | 15,658 | 3.109375 | 3 | [
"WTFPL"
] | permissive | // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long... | true |
99356095713e670f4f1c8cdd3a4e74c064aeab63 | Rust | Britefury/lspace | /src/lib/lspace/input/pointer_click_interactor.rs | UTF-8 | 24,268 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::time::SystemTime;
use super::super::geom::affinexform2::AffineXform2;
use super::pointer::{PointerPosition, PointerState};
use super::pointer_event::{PointerEvent, PointerAction, TransformableAction};
use super::pointer_interactor::{PointerInteractor, EventResult};
use super::super::elements::element::{Elemen... | true |
bff16f49a8fb5b59f12663ff524fe4e7f6545205 | Rust | qtehfw/android_localization | /cli/tests/file_utilities/mod.rs | UTF-8 | 1,097 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | use test_utilities;
pub fn assert_eq_of_file_contents(actual_file_path: &str, expected_file_path: &str) {
let actual_file_lines = read_file_contents_as_lines(actual_file_path);
let expected_file_lines = read_file_contents_as_lines(expected_file_path);
assert_eq!(actual_file_lines, expected_file_lines)
}
p... | true |
cd468aca1602359b3e96402f52300b7627a44022 | Rust | TilBlechschmidt/thirtyfour | /src/common/capabilities/firefox.rs | UTF-8 | 6,874 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::path::Path;
use serde::Serialize;
use serde_json::{from_value, json, to_value, Value};
use crate::common::capabilities::desiredcapabilities::Capabilities;
use crate::error::WebDriverResult;
use crate::PageLoadStrategy;
#[derive(Debug, Clone, Serialize)]
#[serde(transparent)]
pub struct FirefoxCapabilities {... | true |
a310513e78de3bfd0def40686a83e9bf63f1edc3 | Rust | fyaniquez/erprus | /src/controllers/compra.rs | UTF-8 | 2,250 | 2.796875 | 3 | [] | no_license | /// controller compra
/// autor: fyaniquez
/// fecha: 2021-08-14 23:02:06.537215229 -04:00
///
use crate::handlers::compra::hndl_create;
use crate::models::compra::{Compra, CompraForm};
use crate::models::comprado::Comprado;
use crate::views::compra::*;
use crate::State;
use serde_qs::Config;
use sqlx::PgPool;
use tide... | true |
2db3530e5322b2d33c0b17a37a0fcb0c3102a731 | Rust | chatblanc-ciel/openrr | /openrr-gui/src/error.rs | UTF-8 | 607 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use thiserror::Error;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("iced: {:?}", .0)]
Iced(String),
#[error("urdf: {:?}", .0)]
Urdf(#[from] urdf_rs::UrdfError),
#[error("arci: {:?}", .0)]
Arci(#[from] arci::Error),
}
impl From<iced::Error> for Error {
fn from(e: iced:... | true |
60f9b8c2a350777fef816180a41f735fd65c4c43 | Rust | enso-org/enso | /app/gui/controller/double-representation/src/module.rs | UTF-8 | 25,373 | 2.609375 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! Code for module-level double representation processing.
use crate::prelude::*;
use enso_text::index::*;
use crate::alias_analysis;
use crate::definition;
use crate::definition::DefinitionProvider;
use crate::definition::EmptyDefinitionId;
use crate::identifier;
use crate::identifier::Identifier;
use crate::import... | true |
96b5e7d4e06792d1cf8f1509934478f0ebb9ed87 | Rust | florian-jackisch/pipelined-stream | /src/main.rs | UTF-8 | 1,647 | 3.09375 | 3 | [] | no_license | extern crate futures;
extern crate futures_cpupool;
extern crate rand;
use futures::{Future, Sink, Stream};
/// Sleep for a random time between 0 and 1 second.
fn sleep_random() {
let sleep_time_ms = rand::random::<u8>() as f64 / 255.0 * 1000.0;
std::thread::sleep(std::time::Duration::from_millis(sleep_time_m... | true |
286ed3f2755e9d9048c86c347990ec5e5f12ea80 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/parking_lot_core/src/thread_parker/generic.rs | UTF-8 | 1,431 | 2.609375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive |
use core::hint::spin_loop;
use core::sync::atomic::{AtomicBool, Ordering};
use std::thread;
use std::time::Instant;
pub struct ThreadParker {
parked: AtomicBool,
}
impl super::ThreadParkerT for ThreadParker {
type UnparkHandle = UnparkHandle;
const IS_CHEAP_TO_CONSTRUCT: bool = true;
#[in... | true |
2be2ea68a6505566da4b991c083c60c07ed15e3a | Rust | maxtnuk/create-rust-app | /template-plugin-auth/backend/mail/auth_register.rs | UTF-8 | 537 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::mail::Mailer;
pub fn send(mailer: &Mailer, to_email: &str, link: &str) {
let subject = "Registration Confirmation)";
let text = format!(
r#"
(This is an automated message.)
Hello,
Please follow the link below to complete your registration:
{link}
"#,
link = link
);
let html... | true |
a8339682b7e9c396ec0c26eb0f5e7eab76718146 | Rust | zpzgone/ev3dev-lang-rust | /src/driver.rs | UTF-8 | 4,510 | 3.3125 | 3 | [
"MIT"
] | permissive | //! Helper struct that manages attributes.
//! It creates an `Attribute` instance if it does not exists or uses a cached one.
use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt::{self, Debug};
use std::fs;
use std::string::String;
use crate::{utils::OrErr, Attribute, Ev3Error, Ev3Result, Port};
/// ... | true |
9fa2f87fffb8dfa672f778da2994ebf081f51983 | Rust | TAKEDA-Takashi/rust-project-euler | /project-euler/src/bin/problem-096.rs | UTF-8 | 897 | 2.8125 | 3 | [] | no_license | //! http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2096
//! Su Doku
use project_euler::problem_096::Sudoku;
use regex::Regex;
use std::fs;
fn main() {
let re = Regex::new(r"Grid \d\d\r\n").unwrap();
let content = fs::read_to_string("files/p096_sudoku.txt").unwrap();
let questions: Ve... | true |
4ef448e9865df0439308231b51eb9359a18075c8 | Rust | MMXVII/mmixal | /src/is.rs | UTF-8 | 1,754 | 3.28125 | 3 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq, Eq, Clone)]
pub enum Command {
Addu,
Addui,
Cmpu,
Cmpui,
Bz,
Bzb,
Bnz,
Bnzb,
Divu,
Trap,
Incl,
Setl,
Jmpb,
Get,
}
impl Command {
// TODO: replace this with implementation of FromStr interface
pub fn from_str(s: &str) -> Option<Self> {
... | true |
3babeb8b3096c4b23bdd2ce4a61f26e09a9cb045 | Rust | PlacidFireball/poker_proj | /src/card.rs | UTF-8 | 2,814 | 3.78125 | 4 | [] | no_license | /*
suit enum - used to keep track of the suit of a card
--Types--
Ace, Spade, Diamond, Heart, ERROR (for error handling)
--Traits--
PartialEq, Clone, Copy, Debug
--Methods--
as_str(&suit) - converts a (borrowed) suit to a string
str_to_suit(String) - converts a string to a suit
*/
#[allow(unused_imports)... | true |
3b23ccacb9a57e7e8194a550e7ab6d9da915789b | Rust | bradford-hamilton/the_rust_programming_langauge | /example_programs/employees_by_department.rs | UTF-8 | 1,565 | 4.28125 | 4 | [] | no_license | use std::collections::HashMap;
struct Company {
employees: HashMap<String, Vec<String>>,
}
impl Company {
fn employees_by_department(&self, department: String) -> Vec<String> {
let e = self.employees.get(&department);
match e {
Some(x) => x.to_vec(),
None => vec![],... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.