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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
4c55e410fd59b0428bb0879a55ae89d52b4261e3 | Rust | benj2468/holiday-coding-challenge | /src/day14/day14_2.rs | UTF-8 | 4,004 | 3.21875 | 3 | [] | no_license |
use std::fs::File;
use std::error::Error;
use std::io::{BufRead, BufReader, Lines};
use std::env;
use std::collections::HashMap;
struct Memory {
mask: HashMap<u32, usize>,
ram: HashMap<usize, usize>,
}
enum BinaryChange {
Add(u32),
Subtract(u32),
None,
}
fn check_k_bit(value: usize, k: u32) -> b... | true |
b3161c43b7895fffcc60ad554bf967a0f29b079b | Rust | loganintech/md5_phone_number_fun | /src/check.rs | UTF-8 | 955 | 2.890625 | 3 | [] | no_license | use std::fs::OpenOptions;
use std::io::{BufReader, BufRead, Read};
fn main() {
let file = OpenOptions::new()
.read(true)
.open("./collisions.txt")
.unwrap();
let file = BufReader::new(file);
let line_iter = file.lines().filter_map(Result::ok);
// let mut line_count = 0;
fo... | true |
de065cc893aad21309c3323f7bbc9dab4a70930f | Rust | veer66/bidix-tools | /src/reader.rs | UTF-8 | 3,233 | 2.921875 | 3 | [] | no_license | use data::{Entry, LexicalUnit};
use std::fs::File;
use std::io::BufReader;
use xml::reader::{EventReader, XmlEvent};
use xml::attribute::OwnedAttribute;
fn build_lexical_unit(parser: &mut EventReader<BufReader<File>>,
tag: &str) -> LexicalUnit {
let mut surfaces = vec![];
let mut symbols ... | true |
571bc41a2e43134dd821081ba5eee2dd0f3b8f20 | Rust | kildevaeld/tasks-rs | /tasks/src/filter_pipe.rs | UTF-8 | 3,405 | 2.625 | 3 | [] | no_license | use super::generic::Extract;
use super::{Rejection, Task};
use futures_core::{ready, TryFuture};
use pin_project::pin_project;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
#[derive(Clone, Copy)]
pub struct FilterPipe<T1, T2> {
t1: T1,
t2: T2,
}
impl<T1, T2> FilterPipe<T1, T2> {
... | true |
83c346655e1d875d56c18c4aa500930d7a9e3e12 | Rust | rust-osdev/uart_16550 | /src/lib.rs | UTF-8 | 2,931 | 3.140625 | 3 | [
"MIT"
] | permissive | //! Minimal support for
//! [serial communication](https://en.wikipedia.org/wiki/Asynchronous_serial_communication)
//! through [UART](https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter)
//! devices, which are compatible to the [16550 UART](https://en.wikipedia.org/wiki/16550_UART).
//!
//! This ... | true |
88b514e6c81e1c12e04626d0f3534829cfd090db | Rust | avp/gb-rust | /src/gpu.rs | UTF-8 | 13,373 | 2.84375 | 3 | [] | no_license | /// RGBA Color.
pub type RGBAColor = (u8, u8, u8, u8);
pub const HEIGHT: usize = 144;
pub const WIDTH: usize = 160;
const TILEMAP_HEIGHT: usize = 32;
const TILEMAP_WIDTH: usize = 32;
pub const VRAM_SIZE: usize = 0x2000;
pub const OAM_SIZE: usize = 0xa0;
const NUM_TILES: usize = 384;
const NUM_OBJECTS: usize = 40;
... | true |
9d0fb506988acd0b7280f86d5acb28ac2c1f3548 | Rust | dyg540/chromium | /build/rust/tests/test_mixed_source_set/src/lib.rs | UTF-8 | 882 | 2.734375 | 3 | [
"BSD-3-Clause"
] | permissive | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
extern "C" {
fn cpp_callback();
fn cpp_addition(a: u32, b: u32) -> u32;
}
#[no_mangle]
pub extern "C" fn rust_code() {
say_hello_from_a_cpp_c... | true |
432ec88eb292b06d14def5b45884f5098b29c7d7 | Rust | appetrosyan/p2pgossip-demo | /src/logging.rs | UTF-8 | 201 | 2.578125 | 3 | [] | no_license | pub trait LogExt {
fn log(self) -> Self;
}
impl<T, E> LogExt for Result<T, E>
where
E: std::fmt::Display,
{
fn log(self) -> Self {
if let Err(e) = &self {
log::error!("{}", e)
}
self
}
}
| true |
120e80ed9f06d16e3aafd28a5b047f5a7bf40bd2 | Rust | RSSchermer/ARWA | /arwa/src/cssom/transition/transition_event_target.rs | UTF-8 | 2,440 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::cssom::{
TransitionCancelEvent, TransitionEndEvent, TransitionRunEvent, TransitionStartEvent,
};
use crate::event::typed_event_iterator;
pub(crate) mod transition_event_target_seal {
pub trait Seal {
#[doc(hidden)]
fn as_web_sys_event_target(&self) -> &web_sys::EventTarget;
}
}
... | true |
75fd8439aa4674b83a25c3d9b11c40b841d8ac42 | Rust | IThawk/rust-project | /rust-master/src/test/ui/issues/issue-10200.rs | UTF-8 | 191 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | struct Foo(bool);
fn foo(_: usize) -> Foo { Foo(false) }
fn main() {
match Foo(true) {
foo(x) //~ ERROR expected tuple struct/variant, found function `foo`
=> ()
}
}
| true |
06dcc3dd3e709431f100daa19f891ac5ec02389e | Rust | tari-project/broadcast_channel | /src/async_channel.rs | UTF-8 | 7,831 | 2.546875 | 3 | [
"BSD-3-Clause"
] | permissive | use std::{pin::Pin, sync::Arc, task::Poll};
use crossbeam_channel as mpsc;
use futures::{
task::{self, AtomicWaker},
Sink,
Stream,
};
use log::*;
use crate::channel::{bounded as raw_bounded, Receiver, SendError, Sender, TryRecvError};
const LOG_TARGET: &str = "tari_broadcast_channel::async_channel";
cons... | true |
482c0f27f80a7ee21a0ec96d40f6a1ba1ce1ea00 | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/cargo_metadata/src/errors.rs | UTF-8 | 812 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use std::{io, str::Utf8Error, string::FromUtf8Error};
pub type Result<T> = ::std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("`cargo metadata` exited with an error: {stderr}")]
CargoMetadata {
stderr: String,
},
... | true |
ea34d39a14fba89e7aa5ccfa24d6e9a5b6294d8e | Rust | kvark/copyless | /src/boxed.rs | UTF-8 | 1,877 | 3.28125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use {
alloc::{
alloc::{alloc, dealloc, handle_alloc_error, Layout},
boxed::Box,
},
core::{
mem,
ptr::{self, NonNull},
},
};
/// A typesafe helper that stores the allocated pointer without the data initialized.
pub struct BoxAllocation<T>(
// ptr cannot be null since ... | true |
42c3caa9e45f0bd2c82138c671d2db338cc73ba0 | Rust | tempbottle/playform | /server/terrain/heightmap.rs | UTF-8 | 1,222 | 2.890625 | 3 | [
"MIT"
] | permissive | use noise::{Seed, Brownian2, Brownian3, perlin2, perlin3};
use field::Field;
pub struct HeightMap {
pub height: Brownian2<f64, fn (&Seed, &[f64; 2]) -> f64>,
pub features: Brownian3<f64, fn (&Seed, &[f64; 3]) -> f64>,
pub seed: Seed,
}
impl HeightMap {
pub fn new(seed: Seed) -> HeightMap {
let perlin2: f... | true |
89e119cba0a315ee9af359e97be797dcc47a8800 | Rust | suhassrivats/Data-Structures-And-Algorithms-Implementation | /Grokking-the-Coding-Interview-Patterns-for-Coding-Questions/11. Pattern Modified Binary Search/Minimum Difference Element (medium).py | UTF-8 | 2,278 | 3.90625 | 4 | [] | no_license | '''
Problem Statement
Given an array of numbers sorted in ascending order,
find the element in the array that has the minimum difference with the given ‘key’.
Example 1:
Input: [4, 6, 10], key = 7
Output: 6
Explanation: The difference between the key '7' and '6' is minimum than any other number in the array
Examp... | true |
f39fad7544338229fc0082694f3c443a56779848 | Rust | iotaledger/bee | /bee-runtime/src/event.rs | UTF-8 | 2,360 | 3 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020-2021 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
//! A module that provides a generic, type-safe event bus for arbitrary event types.
use std::any::{Any, TypeId};
use dashmap::DashMap;
type Listener<'a> = dyn Fn(&dyn Any) + Send + Sync + 'a;
/// An event bus for arbitrary event types.
pu... | true |
b9b548a0e5fe187732bd2739518d05bc362cfc96 | Rust | Devolutions/siquery-rs | /siquery/src/macos/uptime.rs | UTF-8 | 2,276 | 2.65625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::mem;
use std::ptr;
use crate::tables::Uptime;
use time::{Duration, OffsetDateTime};
impl Uptime {
pub fn get_specific() -> Vec<Uptime> {
let mut output : Vec<Uptime> = Vec::new();
let mut upt = Uptime {
days: 0,
hours: 0,
minutes: 0,
seconds... | true |
6e6b30263c06598f2f0cc933602e28aec665063d | Rust | Mark-Simulacrum/advent-of-code-2015 | /rust/day01/src/main.rs | UTF-8 | 783 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::io::prelude::*;
use std::fs::File;
fn main() {
let mut f = File::open("data").ok().unwrap();
let mut s = String::new();
f.read_to_string(&mut s).ok();
{
let mut floor = 0;
for c in s.chars() {
floor += match c {
'(' => 1,
')' => -1,... | true |
7ce355f1022815ac5dbd15d1ae100b9b60d7509e | Rust | matthieu-m/llmalloc | /llmalloc-core/src/internals/socket_local/test.rs | UTF-8 | 3,813 | 2.828125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Test helpers for socket_local.
use core::{
alloc::Layout,
cell::Cell,
mem,
ptr::NonNull,
};
use crate::{Configuration, Platform, PowerOf2};
use super::{HugeAllocator, HugePagesManager};
/// Test Huge Allocator
pub(crate) type TestHugeAllocator = HugeAllocator<TestConfiguration, TestPlatform>;
//... | true |
4930ea72e044e0adcb0a48bf9a23cda4b16e6574 | Rust | willy610/fsm2fsm-main | /tool/src/applic_folder/fsm_folder/dial_folder/fsmdial.rs | UTF-8 | 3,936 | 2.90625 | 3 | [] | no_license | use crate::applic_folder::fsm_folder::fsm::Fsm;
//use fsm::Fsm;
use crate::applic_folder::fsm_folder::fsm::OutEventAndNextStateAndUserCondValue;
use std::io;
impl Fsm {
pub fn get_cond_choice(
&self,
state_now: String,
in_event: String,
name: &str,
) -> &OutEventAndNextStateAndU... | true |
b6c763adfb9d42396bd50fc55278624ca9bb76a7 | Rust | Arcadie/md2src | /src/lib.rs | UTF-8 | 4,050 | 2.96875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright by Alexander Willner. See the LICENCE file for the license information.
//! Simple rust library and CLI to extract code blocks marked with triple backticks from markdown files into source files.
//!
//! [](https://gi... | true |
efa3ffbf5028e9cfbf53fade5b6e9dccb2e9876f | Rust | qiweiyu/project_euler | /bak/60/main.rs | UTF-8 | 4,174 | 2.953125 | 3 | [] | no_license | mod utils;
mod fraction;
mod primes;
mod fib;
mod queue;
mod poker;
use crate::primes::is_prime;
use crate::primes::generate_primes;
use crate::utils::select;
use std::collections::HashMap;
fn main() {
const LIMIT: usize = 10_000;
const LEN: usize = 5;
let p_list = generate_primes(LIMIT);
let mut pair... | true |
b4189c4ff0b91910b2c314ccdcff0244eab8fd97 | Rust | Leopard2A5/game-of-life-parsers | /src/parsers/life_1_06_parser.rs | UTF-8 | 3,652 | 3.0625 | 3 | [
"MIT"
] | permissive | use super::Parser;
use ::errors::{self, Error, ErrorKind};
use ::GameDescriptor;
use ::default_game_descriptor::DefaultGameDescriptor;
use std::io::{Read, BufRead, BufReader};
use regex::Regex;
/// Parser for files in the life 1.05 format.
pub struct Life106Parser {}
impl Life106Parser {
/// Construct a new instance... | true |
40bc7e52bfeae5dd70988472b4d7c9c1f02806ec | Rust | hacspec/hacspec | /lib/tests/test_arrays.rs | UTF-8 | 1,980 | 2.609375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use core::convert::TryInto;
use hacspec_lib::prelude::*;
mod test_util;
use test_util::*;
#[test]
#[allow(non_snake_case)]
fn test_array_U32() {
array!(TestSeq, 64, U32);
both_arrays!(PublicState, State, 73, U32, u32);
let x = PublicState::new();
let y: State = State::from_public(x);
let _z: Pub... | true |
53ea481e7250c8d4321edb7a609be27ef3205cdd | Rust | mendelt/snuif | /src/main.rs | UTF-8 | 2,756 | 3.03125 | 3 | [] | no_license | use std::{fmt::Display, ops::Deref};
use rawsock::open_best_library;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(name = "snuif")]
enum Cli {
/// Capture and display raw packets
Raw {
/// The number of packets to capture
count: u64,
},
/// List the available inter... | true |
1c5abcd6bec1ae5ac17015b14b24e61a30af29ff | Rust | AndyCoder/Advent2020 | /day-12-rain-risk/src/main.rs | UTF-8 | 3,539 | 3.671875 | 4 | [] | no_license | use std::fs;
fn main() {
let instructions: Vec<Instruction> = fs::read_to_string("input")
.expect("unable to read input file")
.split_whitespace()
.map(|s| str_to_inst(s))
.collect();
let result = part_1(&instructions);
println!("{}", result);
}
struct Instruction {
op:... | true |
8e9a6a5c3057eacd0cb1b8d0aec0547b8778f9cf | Rust | iwburns/roml | /src/matrix/mod.rs | UTF-8 | 1,576 | 3.453125 | 3 | [
"MIT"
] | permissive | // Self just needs to be a matrix. Size and shape of Self do not matter.
pub trait Matrix<T> {
type RowIndex;
type ColIndex;
type RowVector;
type ColVector;
fn add(&mut self, m: &Self) -> &mut Self;
fn add_into(&self, m: &Self, dest: &mut Self);
fn sub(&mut self, m: &Self) -> &mut Self;
... | true |
cc785141d9ff5b10f8042296d75220ebee32824d | Rust | derekjw/hearts | /src/hearts_client.rs | UTF-8 | 10,860 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use strategy::CardStrategy;
use game_status::{GameStatus, GameInstanceState, RoundState, HeartsGameInstanceState};
use game_status::dto::GameStatusDto;
use card::dto::CardDto;
use error::Error;
use error::Result;
use std::convert::TryFrom;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std:... | true |
282c9a5ccffaa7e2d838c194db0c608fba436e0f | Rust | Skgland/Learning-Rust | /chat_base/src/addons.rs | UTF-8 | 1,022 | 2.734375 | 3 | [] | no_license | use std::string::String;
use std::vec::Vec;
use std::option::Option;
pub mod alias;
///
/// A Trait for defining Chat Server/Client Commands
///
pub trait Command<AT> {
///
/// the primary name for this command
///
fn name(&self) -> &'static str;
///
/// a list of alternative names for thi... | true |
b6804ed38d6bf793e1bc47a00e12042ef5c7ab95 | Rust | utilForever/BOJ | /Rust/17418 - G++ Language.rs | UTF-8 | 5,759 | 3.171875 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{
io::{self, BufWriter, StdoutLock},
str,
};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
... | true |
1c3f9057404d564cea75f9bc1f8843331e5a786c | Rust | glyn/libcnab-rust | /src/tests.rs | UTF-8 | 12,676 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::cnab::*;
use semver::Version;
use serde_json::*;
use spectral::prelude::*;
#[test]
// Testing that we can build one with only the minimal fields.
fn test_bundle_simple() {
let bun: Bundle = r#"{
"name": "aristotle",
"invocationImages": [],
"schemaVersion": "1.0-WD",
"vers... | true |
e085ee668bee8d6784e1e538a04ebe47652657aa | Rust | celaus/matcha | /src/matching.rs | UTF-8 | 3,073 | 2.828125 | 3 | [] | no_license | use once_cell::sync::OnceCell;
use serde::{Deserialize, Serialize};
use xactor::message;
use crate::actors::Intent;
static ORDERIDGEN: OnceCell<u64> = OnceCell::new();
fn get_order_id() -> u64 {
let n = match ORDERIDGEN.get() {
Some(i) => *i,
None => 0,
};
ORDERIDGEN.set(n + 1);
n
}
... | true |
fa97f45e11449e78087f3211bd7bb8f41e923dec | Rust | anonymoustafa/fibonacci-series-with-rust | /src/main.rs | UTF-8 | 708 | 3.375 | 3 | [] | no_license | use std::io;
fn main() {
println!("Input the fibonacci index you want me to ask for calculation ");
let mut fibonacci_index = String::new();
io::stdin()
.read_line(&mut fibonacci_index)
.expect("Failed to read line");
let fibonacci_index: u32 = return match fibonacci_index.trim().parse(... | true |
9a3aafe74678ae45d6db38ae348afbb563e04f9a | Rust | INDAPlus20/rasan-chess | /chess/src/piece/position.rs | UTF-8 | 2,216 | 4 | 4 | [] | no_license | #[derive(Hash, Eq, PartialEq, Clone, Debug)]
pub struct Position {
pub row: i8,
pub column: i8 // Represented as a letter in String
}
impl Position {
pub fn new(_pos: String) -> Option<Self> {
// Checks if String is a valid character length
if _pos.chars().count() == 2 {
// C... | true |
a113be56054690a621f0fd91da389cbb5415018a | Rust | GoXLR-on-Linux/goxlr-utility | /daemon/src/cli.rs | UTF-8 | 2,090 | 2.625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | use clap::{Parser, ValueEnum};
use directories::ProjectDirs;
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(about, version, author)]
pub struct Cli {
/// Minimum log level to print out
#[arg(long, value_enum)]
pub log_level: Option<LevelFilter>,
/// Location of the daemon configuration fil... | true |
c9414bfd413a3be793bfdf97b64af601669788bc | Rust | smonv/exercism | /rust/bob/src/lib.rs | UTF-8 | 506 | 3.46875 | 3 | [] | no_license | pub fn reply(message: &str) -> &str {
let message = message.trim();
if message.is_empty() {
return "Fine. Be that way!";
}
let is_question = message.ends_with('?');
let is_yelling =
message.chars().any(|c| c.is_alphabetic()) && message == message.to_uppercase();
match (is_ques... | true |
c4f175f220dc9b7958c0cc54bf4ed4245ce6e71c | Rust | rrkjonnapalli/rust_intro | /src/two_cats_and_a_mouse.rs | UTF-8 | 432 | 2.703125 | 3 | [] | no_license | pub fn cats_and_mouse() {
let n:usize = read!();
for _i in 0..n {
let a:isize = read!();
let b:isize = read!();
let c:isize = read!();
let a_c:isize = a-c;
let b_c:isize = b-c;
if a_c.abs() < b_c.abs() {
println!("Cat A");
}else if a_c.abs()... | true |
f1590fea16dbc08c1fc423ee4c2030408684cf67 | Rust | nlhepler/rkm | /src/lib.rs | UTF-8 | 16,642 | 2.921875 | 3 | [
"MIT"
] | permissive | /*
This crate contains a simple implementation of the
[k-means clustering algorithm](http://en.wikipedia.org/wiki/K-means_clustering).
*/
extern crate num;
extern crate rand;
#[cfg(feature = "parallel")]
extern crate rayon;
#[macro_use(s)]
extern crate ndarray;
#[cfg(feature = "parallel")]
extern crate ndarray_parallel... | true |
fbd147988da5a21f33c665d422f4c2f4bd14b5de | Rust | liona24/rvh | /src/range_vector_hash_map.rs | UTF-8 | 8,244 | 3 | 3 | [
"MIT"
] | permissive | use std::collections::{BTreeSet, HashMap};
use crate::types::*;
fn get_masks<'a, I: Iterator<Item = &'a Range>>(ranges: I) -> Vec<Mask> {
ranges
.map(|r| {
let mut m = 0;
for _ in 0..r.0 {
m <<= 1;
m |= 1;
}
m
})
... | true |
491b40d38bc562111fd600eab72c216ef12a522e | Rust | Bestowinc/darkroom | /src/grpc.rs | UTF-8 | 4,515 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use crate::params::{iter_path_args, Params};
use anyhow::{anyhow, Context, Error};
use filmreel::{frame::Request, response::Response};
use lazy_static::lazy_static;
use serde::Deserialize;
use serde_json::json;
use std::{collections::HashMap, ffi::OsString, path::PathBuf, process::Command};
/// Checks to see if grpcur... | true |
2c3fd1d3b20f01fe08ae36fb7e719c8dcb0b9d4e | Rust | mksyposz/aoc2020 | /src/day20.rs | UTF-8 | 16,607 | 2.921875 | 3 | [] | no_license | use std::collections::HashMap;
const TILE_ID: i32 = 0;
const TILE: i32 = 1;
pub fn run<R>(input: R) -> (String, String)
where
R: std::io::BufRead,
{
let mut input_part = TILE_ID;
let mut tile: Vec<Vec<char>> = Vec::new();
let mut id = 0;
let mut images: HashMap<u64, Image> = HashMap::new();
for... | true |
72a313f55f74ec3aaabaf814413be8b9cd816e1d | Rust | vks/sample-sphere | /src/disk.rs | UTF-8 | 1,209 | 3.3125 | 3 | [] | no_license | //! Sample the unit disk.
use std::f64::consts::PI;
use rand::Rng;
use rand::distributions::{Distribution, Uniform};
/// Sample the unit disk in two Cartesian dimensions.
#[inline]
pub fn trigonometric<R: Rng>(rng: &mut R) -> [f64; 2] {
let uniform_r = Uniform::<f64>::new_inclusive(0., 1.);
let uniform_theta... | true |
acefbcd1a070533b9dabed133d72d78c0a35b98d | Rust | toku-sa-n/xhci | /src/registers/operational.rs | UTF-8 | 17,003 | 2.875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Host Controller Operational Registers
use super::capability::{Capability, CapabilityRegistersLength};
use accessor::array;
use accessor::single;
use accessor::Mapper;
use bit_field::BitField;
use core::convert::TryFrom;
use core::convert::TryInto;
use num_derive::FromPrimitive;
use num_traits::FromPrimitive;
/// ... | true |
c1800fe0d71ae3d159e8261245a0cb722bd60422 | Rust | jjhbw/background-modelling | /src/bg_model/mod.rs | UTF-8 | 5,250 | 2.6875 | 3 | [] | no_license | use bg_model::gmm::GaussianMixtureModel;
use bg_model::gmm::GaussianMixtureSettings;
use image::GrayImage;
use image::Luma;
use image::Rgb;
use image::RgbImage;
use nalgebra::Vector3;
use rayon::prelude::*;
use std::sync::mpsc::channel;
pub mod gmm;
// TODO: currently, conversion between Pixels and Vector3<f32> is do... | true |
124b30c17105e652b3af8ebc6696311e53142e31 | Rust | jonpalmisc/llml | /src/parser.rs | UTF-8 | 776 | 3.0625 | 3 | [
"BSD-3-Clause"
] | permissive | use pest::{iterators::Pair, Parser};
use regex::Regex;
/// Clean up input before parsing. Currently just removes indentation.
pub fn sanitize(content: &str) -> String {
let strip_indent = Regex::new(r#"\n\s+"#).unwrap();
strip_indent.replace_all(content, "\n").to_string()
}
#[derive(Parser)]
#[grammar = "gram... | true |
9691a1a7ba642155fc2b4849bd6dc9e8c69d1dc2 | Rust | realpacific/rustlings | /exercises/option/option2.rs | UTF-8 | 917 | 3.84375 | 4 | [
"MIT"
] | permissive | // option2.rs
// Make me compile! Execute `rustlings hint option2` for hints
fn main() {
let optional_value = Some(String::from("rustlings"));
/*
if optional_value.is_some() {
println!("the value of optional value is: {}", optional_value.unwrap());
} else {
println!("The... | true |
4b630a0457b27c00a5db9bacd188e07ffbcf8087 | Rust | Defi-Ninja/harmony_rust_sdk | /src/client/api/rest.rs | UTF-8 | 6,135 | 2.765625 | 3 | [
"MIT"
] | permissive | use super::*;
use crate::client::error::ClientError;
use prost::bytes::Bytes;
use reqwest::{multipart::*, Response};
use serde::Deserialize;
pub use crate::api::rest::*;
/// Uploads a file to the homeserver.
///
/// This endpoint requires authentication.
/// See [API documentation](https://github.com/harmony-develop... | true |
e523c07833d50c015cbaf84c243cdd90a1b0f79c | Rust | rpeden/rust-experiments | /procs/src/procs.rs | UTF-8 | 118 | 2.921875 | 3 | [] | no_license | fn main() {
let x = 5i;
let p = proc() { x * x };
println!("calling proc. value is: {}", p());
}
| true |
dc1549ab3d470b35bccde71d4a3f1b3ad515406e | Rust | expenses/fleet-project | /crates/background/src/lib.rs | UTF-8 | 4,344 | 2.703125 | 3 | [] | no_license | use components_and_resources::{gpu_structs::ColouredVertex, utils::uniform_sphere_distribution};
use rand::rngs::ThreadRng;
use rand::Rng;
use spade::delaunay::FloatDelaunayTriangulation;
use tint::Colour;
use ultraviolet::{Rotor3, Vec2, Vec3};
// https://www.redblobgames.com/x/1842-delaunay-voronoi-sphere/#delaunay
p... | true |
e60ef0469c42bbd0da0fc0283c3f482dc296f34e | Rust | kesslern/rust-todo | /src/components/count_square.rs | UTF-8 | 1,375 | 2.84375 | 3 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::io::stdout;
use crossterm::{
cursor::MoveTo,
event::Event,
execute,
Result,
style::Print,
};
use crossterm::event::MouseEventKind;
use crate::primitives::Square;
use crate::traits::{Draw, HandleEvent};
#[derive(Default)]
pub struct CountSquare {
pub square: Square,
pub count: u16... | true |
e1be3e46c7f76209aae9522aa9b25442ecf3b910 | Rust | move-z/adventofcode2018 | /src/bin/day07.rs | UTF-8 | 4,631 | 3.046875 | 3 | [] | no_license | use adventofcode2018::*;
use std::collections::{HashMap, HashSet};
use lazy_static::lazy_static;
use regex::Regex;
fn first(input: &[&str]) -> String {
let mut deps = parse(input);
travel(&mut deps)
}
fn second(input: &[&str]) -> usize {
do_second(input, 5, 60)
}
fn do_second(input: &[&str], worker_nu... | true |
81ba4c963670a0db78fa36ea9c99b9f0c0dea018 | Rust | vandercijr/algorithms_rust | /tests/statistics_test.rs | UTF-8 | 485 | 3.125 | 3 | [] | no_license | use algorithms_rust;
#[test]
fn it_variance() {
// let input: [f64; 4] = [5.0, 8.0, 10.0, 7.0];
let input = [5.0, 8.0, 10.0, 7.0];
assert_eq!(
3.25,
algorithms_rust::statistics::descriptive::variance(&input)
);
}
#[test]
fn it_std_dev() {
// let input: [f64; 4] = [5.0, 8.0, 10.0, ... | true |
06fbd8c10ec8ebb9de8afa1c98261463ba0edaf2 | Rust | wieslander/aoc-2019 | /src/bin/17-02.rs | UTF-8 | 2,293 | 3.28125 | 3 | [] | no_license | use std::collections::HashMap;
use aoc::get_input;
use aoc::intcode::Program;
enum Direction {
Left,
Right,
Up,
Down,
}
enum Tile {
Space,
Scaffold,
Droid(Direction),
}
#[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)]
struct Point {
x: i32,
y: i32,
}
impl Point {
pub fn ste... | true |
a0972bc5d19242bbc97ea049ad610d4975a0428f | Rust | schungx/rhai | /tests/if_block.rs | UTF-8 | 1,213 | 3.21875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use rhai::{Engine, INT};
#[test]
fn test_if() {
let engine = Engine::new();
assert_eq!(engine.eval::<INT>("if true { 55 }").unwrap(), 55);
assert_eq!(
engine.eval::<INT>("if false { 55 } else { 44 }").unwrap(),
44
);
assert_eq!(
engine.eval::<INT>("if true { 55 } else { 44 ... | true |
1ff3b71bbc89fdac0a6fa498acb282a105d2ccee | Rust | DaveDaCoda/citadel-tools | /citadel-install/src/util.rs | UTF-8 | 3,964 | 2.640625 | 3 | [] | no_license | use std::mem;
use std::ffi::CStr;
use std::str::from_utf8_unchecked;
use std::path::{Path,PathBuf};
use std::process::{Command,ExitStatus,Stdio};
use std::fs;
use libc::{self, c_char};
use failure::ResultExt;
use libcitadel::OsRelease;
use super::Result;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct UtsName(libc::uts... | true |
3994a7d53e4c105af949c5f50b5f6a348122cafe | Rust | dancojocaru2000/rust-c_wrapper | /src/c_error.rs | UTF-8 | 2,657 | 2.75 | 3 | [] | no_license | use std::ffi::CStr;
use serde::{Serialize, Deserialize};
macro_rules! generate_cerror {
($($rust_names:ident; to C $c_names:ident),+$(,)*) => {
#[derive(Deserialize, Serialize, Clone, Copy, Debug)]
pub enum CError {
$(
$rust_names,
)+
Unknown(libc... | true |
c3aa998a65e056f86b1e7ff2fdb496e62eab7f51 | Rust | ianbrault/palette | /src/pixel.rs | UTF-8 | 1,619 | 3.609375 | 4 | [] | no_license | /*
* src/pixel.rs
* pixel data structure
* author: Ian Brault <ian.brault@engineering.ucla.edu>
*/
#[derive(Clone, Debug, PartialEq)]
pub struct Pixel {
r: u8,
g: u8,
b: u8,
}
impl Pixel {
pub fn new(r: u8, g: u8, b: u8) -> Pixel {
Pixel { r, g, b }
}
pub fn as_hex(&self) -> Strin... | true |
52fca0f18241890504d71bc2989c0c1bfb898d8d | Rust | Swiftaff/rust_ray_tracer_challenge | /src/materials.rs | UTF-8 | 7,129 | 3.09375 | 3 | [] | no_license | use crate::patterns;
use crate::tuples;
pub const MATERIAL_DEFAULT: Material = Material {
pattern: None,
color: tuples::COLOR_WHITE,
ambient: 0.1,
diffuse: 0.9,
specular: 0.9,
shininess: 200.0,
reflective: 0.0,
transparency: 0.0,
refractive_index: REFRACTIVE_INDEX_VACUUM,
};
pub co... | true |
83d65cf5bf051b980e9aa9681971cb657fb9dcac | Rust | AudioSceneDescriptionFormat/asdfspline-rust | /src/monotonecubicspline.rs | UTF-8 | 8,256 | 3 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::borrow::Cow;
use superslice::Ext; // for slice::equal_range_by()
use crate::utilities::{bisect, check_grid, GridError};
use crate::PiecewiseCubicCurve;
use crate::Spline;
use crate::SplineWithVelocity;
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("values must not be decreasing")]
Decr... | true |
5db8cb99805e5333f4d2398233c03713d62aa491 | Rust | jjlorenzo/show-direnv-diff | /src/main.rs | UTF-8 | 2,190 | 2.84375 | 3 | [
"MIT"
] | permissive |
use base64;
use colored::*;
use flate2::read::ZlibDecoder;
use json;
use json::array;
use json::object;
use std::env;
use std::io::Read;
use std::panic;
use structopt::clap::arg_enum;
use structopt::StructOpt;
#[derive(Debug)]
#[derive(StructOpt)]
struct ArgumentParser {
#[structopt(
case_insensitive = true,
... | true |
1dc5ea6bba60eed33137a90497f373bab42948a8 | Rust | Matthias-Fauconneau/iced | /web/src/widget/scrollable.rs | UTF-8 | 4,702 | 3.046875 | 3 | [
"MIT"
] | permissive | //! Navigate an endless amount of content with a scrollbar.
use crate::{bumpalo, css, Align, Bus, Column, Css, Element, Length, Widget};
pub use iced_style::scrollable::{Scrollbar, Scroller, StyleSheet};
/// A widget that can vertically display an infinite amount of content with a
/// scrollbar.
#[allow(missing_debug... | true |
6ffc43e55e1df7ef1cad5738af0c874ca227a45c | Rust | dertin/sql-to-liquibase-xml-rs | /src/main.rs | UTF-8 | 9,203 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | extern crate chrono;
extern crate regex;
extern crate xml;
use chrono::offset::Utc;
use chrono::DateTime;
use regex::Regex;
use std::collections::HashMap;
use std::fs::File;
use std::time::SystemTime;
use std::{fs, io::Write};
fn main() {
let sql_raw = load_files_sql();
let str_find_insert: &str = "INSERT IN... | true |
cef19397b39e62ecbdb594f1458048f37c716c52 | Rust | PatrikValkovic/UDPtransfer | /src/packet/checksum.rs | UTF-8 | 2,675 | 3.4375 | 3 | [
"MIT"
] | permissive | use crate::packet::{ToBin, ParsingError};
pub struct Checksum {
size: usize,
checksum: Vec<u8>,
}
impl ToBin for Checksum {
fn bin_size(&self) -> usize {
self.size
}
fn to_bin_buff(&self, buff: &mut [u8]) -> usize {
buff.copy_from_slice(&self.checksum);
return self.bin_siz... | true |
c0139151f594cc2fe3eae5bd9fb919aec756e922 | Rust | pierreprinetti/rust-osauth | /src/stream.rs | UTF-8 | 2,737 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 Dmitry Tantsur <divius.inside@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... | true |
f364b6d5025b45169d83ccd805e3a4f95f5b1495 | Rust | robertdigital/fix-rust | /fixclient/src/connector/syncstate.rs | UTF-8 | 16,749 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | //! Manages fix party status and handles message synchronization
extern crate core;
use std::io;
// use std::rc::Rc;
use std::sync::Arc;
use std::sync::Mutex;
use std::fmt::{Display, Formatter, Error};
use super::MessageStore;
use fix::frame::FixFrame;
use fix::fixmessagegen::*;
/// Indicates the state of each par... | true |
c3e3f3c22f0d6f59ea354affc5182eb5f31713f3 | Rust | l0calh05t/poly-rs | /src/lib.rs | UTF-8 | 9,803 | 2.71875 | 3 | [
"MIT"
] | permissive | use core::convert::TryFrom;
use core::ops::{AddAssign, Div, Mul, MulAssign, SubAssign};
use num::traits::{MulAddAssign, Pow};
use num::Zero;
use smallvec::SmallVec;
mod add;
mod display;
mod mul;
mod sub;
pub use add::*;
pub use display::*;
pub use mul::*;
pub use sub::*;
#[cfg(debug_assertions)]
macr... | true |
e33dc404f2ea2eb66488c94e2df7ce5eaee080c5 | Rust | cassava/vicuno | /src/main.rs | UTF-8 | 3,484 | 2.984375 | 3 | [
"MIT"
] | permissive | use env_logger;
use log::{error, LevelFilter};
use std::io::Write;
use std::path::PathBuf;
use std::str::FromStr;
use structopt::StructOpt;
use thiserror::Error;
use vicuno::{Library, LibraryError};
#[derive(Debug, StructOpt)]
#[structopt(name = "vicuno", about = "Edit audio metadata with your editor.")]
struct Optio... | true |
af69139d1583e08e9c383f614ff0757a1ea50c8e | Rust | nikomatsakis/lark | /components/lark-build/src/codegen_rust.rs | UTF-8 | 10,151 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use lark_debug_with::DebugWith;
use lark_entity::{Entity, EntityData, ItemKind, LangItem};
use lark_error::{Diagnostic, WithError};
use lark_intern::{Intern, Untern};
use lark_mir::{
BasicBlock, FnBytecode, MirDatabase, Operand, OperandData, Place, PlaceData, Rvalue,
RvalueData, Statement, StatementKind,
};
use... | true |
82d5f342ab0d2bc25b2cc7fd555bd98531b60b6d | Rust | atheriel/trig-rs | /src/trig.rs | UTF-8 | 10,283 | 3.65625 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /*
This file is part of trig-rs, a library for doing typesafe trigonometry
with a variety of angle formats (radians, degrees, grad, turns, and so on).
*/
//! # `trig-rs`: Typesafe Trigonometric Primitives
//!
//! Leverage Rust's super-powered enums to create a typesafe system for
//! trigonometry in degrees, r... | true |
ec2a52d278a1dee6eaf6960bf8cc54351a7234e0 | Rust | panicbit/rustdoc_bug_33771 | /src/lib.rs | UTF-8 | 199 | 2.8125 | 3 | [] | no_license | /// Removing this very line makes it render correctly.
///
/// # I will not be rendered correctly
///
/// ```
///# fn foo() {} // A hidden line like this needs to exist
/// ```
pub fn some_item() {}
| true |
6323e047917aa4f395632d272262a0c1ba5f5fe3 | Rust | vain0x/languages | /picomet-lang/compiler/src/lsp/features/rename.rs | UTF-8 | 1,985 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::semantics::Sema;
use crate::syntax::DocId;
use lsp_types::*;
use std::cmp::min;
pub(crate) fn do_rename(
doc_id: DocId,
sema: &Sema,
position: Position,
) -> Option<Vec<crate::syntax::Range>> {
let line = position.line as usize;
let column = position.character as usize;
let (module_... | true |
3599b04aef7e9a2c8cfb518c411f3c896950aff4 | Rust | Takobyte/contagion | /src/core/vector.rs | UTF-8 | 2,644 | 3.421875 | 3 | [] | no_license | use std::ops::Add;
use std::ops::Sub;
use std::ops::Mul;
use std::ops::Div;
use std::ops::AddAssign;
use std::ops::SubAssign;
use std::ops::MulAssign;
use std::ops::DivAssign;
use std::marker::Sized;
use crate::core::scalar::Scalar;
pub trait Vector
: Clone
+ Copy
+ Sized
+ Add<Self, Output = Self>
... | true |
da50da11930ea63888312f16dbbbfc97e81f3e60 | Rust | connyay/heim-node-exporter | /src/metrics.rs | UTF-8 | 3,732 | 2.625 | 3 | [] | no_license | use std::io;
use std::ops;
use std::path;
use tokio::prelude::*;
use hyper::Chunk;
use bytes::{BytesMut, BufMut};
use crate::Tx;
#[derive(Debug, Default)]
pub struct Buffer(BytesMut);
impl Buffer {
fn into_inner(self) -> BytesMut {
self.0
}
}
// https://github.com/carllerche/bytes/issues/77
impl io... | true |
cbfce3adf9b893e0c19d5ce40041cfe267967d0f | Rust | icostin/halfbit | /src/io/stream/buffer.rs | UTF-8 | 13,769 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::io::IOResult;
use crate::io::IOError;
use crate::io::ErrorCode;
use crate::ExecutionContext;
use super::Read;
use super::Write;
use super::Seek;
use super::SeekFrom;
use super::Truncate;
use super::relative_position;
pub struct BufferAsOnePassROStream<'b> {
buffer: &'b [u8],
}
impl<'b> BufferAsOnePassR... | true |
076bbff74757a1f1a9e069659115b02e6883bd3a | Rust | SkyMomentum/tonegen-rs | /src/wavfile/formatchunk.rs | UTF-8 | 3,574 | 3.171875 | 3 | [] | no_license | use std::io::prelude::*;
use std::io::Result;
//#[macro_use]
use util::{zero_u8_array, append_bytes};
/// Struct for the format chunk of a .wav
///
/// Is not packed for same reason as WaveHeader.
#[derive(Debug)]
pub struct FormatChunk {
fmt_header: [u8; 4], // "fmt "
size_wave_chunk: u32, // 16 - number of... | true |
70550a09db508f995150c966b6e8bdb8a80e1c21 | Rust | notakay/ssirc | /src/server.rs | UTF-8 | 2,338 | 2.796875 | 3 | [] | no_license | use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::str::{from_utf8};
use std::sync::{Arc, Mutex, mpsc};
use std::{thread};
use bus::{Bus, BusReader};
use crate::threadpool::{ThreadPool};
pub struct Server {
bus_tx: Arc<Mutex<Bus<String>>>,
mpsc_tx: mpsc::Sender<String>,
mpsc_rx: mp... | true |
5b5a125cb3d46bceda10108aa9eed210b7405c6a | Rust | cmanallen/rdown | /src/main.rs | UTF-8 | 3,232 | 3.203125 | 3 | [] | no_license | use std::fs::File;
use std::io::Write;
use std::io::{BufRead, BufReader};
use std::path::Path;
fn parse_markdown_file(_filename: &str) {
print_short_banner();
println!("[ INFO ] Trying to parse {}...", _filename);
let input_filename = Path::new(_filename);
// Verbose
// let file = match File::ope... | true |
ea3b674134c77a279e9137293a0ad0b3e6f0f112 | Rust | blittable/rust-top-down | /demos/simple_thread/src/main.rs | UTF-8 | 1,007 | 3.515625 | 4 | [] | no_license | use std::thread;
use std::time::Duration;
fn main() {
println!("");
let split = |n| {
for _i in 1..n {
print!("*");
}
println!("");
};
split(45);
thread_lifetime();
}
//Note non-deterministic output
fn thread_lifetime() {
let x = 12;
let original_thread... | true |
d1de712b28dc1fedeeb422151057033c7ac4b3e6 | Rust | siimsoni/aoc2020 | /d02/src/lib.rs | UTF-8 | 3,382 | 3.375 | 3 | [] | no_license | extern crate btoi;
use btoi::btoi;
use std::io::BufRead;
fn p1_validate(line: &[u8]) -> bool {
let mut iter = &mut line.iter();
let mut buffer = [0; 32];
let mut buffer_len = 0;
for c in &mut iter {
if c == &b'-' {
break;
}
buffer[buffer_len] = *c;
buffer_... | true |
9bce2ab1d66c6756662dc729f266f7e978aa7d69 | Rust | chenjianxin/Peroxide | /src/util/useful.rs | UTF-8 | 2,606 | 3.578125 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! Useful missing tools
use std::convert;
use std::f64::MAX;
// =============================================================================
// Fundamental Utils
// =============================================================================
/// Near equal
///
/// # Examples
/// ```
/// extern crate peroxide;
///... | true |
3a794fba93c32187add1c382da4f779bb6d36f30 | Rust | tspooner/rstat | /src/univariate/cosine.rs | UTF-8 | 2,305 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::{
consts::{ONE_OVER_PI, ONE_THIRD, PI, PI2, PI4, TWO_OVER_PI2},
statistics::{Modes, Quantiles, UvMoments},
ContinuousDistribution,
Distribution,
Probability,
Univariate,
};
use rand::Rng;
use spaces::intervals::Closed;
use std::fmt;
locscale_params! {
#[derive(Copy)]
Params {... | true |
664e7fdff25d86ad02dbf060097810bc9b3c7041 | Rust | EmmaRamirez/rust | /linked_list/src/main.rs | UTF-8 | 1,415 | 4 | 4 | [] | no_license | use List::*;
enum List {
// Const: Tuple struct that wraps an element anda pointer to next
Const(u32, Box<List>),
//Note that signifies end
Nil,
}
impl List {
fn new() -> List {
// Nil has type List
Nil
}
fn prepend(self, elem: u32) -> List {
Cons(elem, Box::new(s... | true |
69962f0db611301b4f9ce6ded7f88ce6a72c701a | Rust | tyleo/libflo | /dep/libflo_action/src/error.rs | UTF-8 | 7,182 | 2.921875 | 3 | [
"MIT"
] | permissive | use libflo_std::{ error, event, libflo, module };
use number_or_string::NumberOrString;
use serde_json;
error_chain! {
types { }
links {
LibfloError(libflo::Error, libflo::ErrorKind);
LibfloErrorError(error::Error, error::ErrorKind);
LibfloEvent(event::Error, event::ErrorKind);
... | true |
0fd8148671f28fd57dad1527ebc5b7328fed1f3f | Rust | Bitspleaseee/controller | /src/db/threads.rs | UTF-8 | 10,841 | 2.890625 | 3 | [] | no_license | use diesel::prelude::*;
use failure::ResultExt;
use super::{DbConn, MAX_THREAD_LIMIT};
use crate::types::{InsertThread, Thread, UpdateThread};
use crate::{IntErrorKind, IntResult};
use datatypes::valid::ids::*;
/// Inserts a new thread into the thread table
pub fn insert_thread(con: &DbConn, thread: impl Into<Insert... | true |
a60d15c69e47b979edb32df730e8a21f6031b56e | Rust | molotfi/front-end-atp | /cop/src/szs.rs | UTF-8 | 760 | 2.90625 | 3 | [] | no_license | use core::fmt::{self, Debug, Display};
pub use NoSuccessKind::*;
pub use SuccessKind::*;
pub struct Status<K>(pub K);
impl<K: Debug> Display for Status<K> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "% SZS status {:?}", self.0)
}
}
pub struct Output<O>(pub O);
impl<O: Di... | true |
15d00d0e01d781b157c7e3a21781c1a1db0f97c8 | Rust | martinnabhan/chatwork_client | /src/lib.rs | UTF-8 | 2,978 | 3.71875 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! # chatwork_client (English)
//!
//! The `chatwork_client` crate is an API client for [Chatwork](https://www.chatwork.com).
//!
//! The client is currently synchronous, with plans for adding an asynchronous runtime later.
//!
//! ## Initialising the client
//!
//! The client requires a Chatwork API token which can b... | true |
041280797fdcb9cedd5db2239206e5ff18cfb79e | Rust | stivenson/Rust-Study | /implementables/src/main.rs | UTF-8 | 679 | 3.796875 | 4 | [] | no_license | use std::ops::{AddAssign, DivAssign};
#[derive(Debug)]
struct Count {
value: i32,
}
impl AddAssign for Count {
fn add_assign(&mut self, other: Count) {
self.value += other.value;
}
}
impl DivAssign for Count {
fn div_assign(&mut self, other: Count) {
if other.value == 0 {
... | true |
05530bb2cd179fe68db8a5fb11cefa22fb99bf3a | Rust | v3n/ProDBG | /src/prodbg/viewdock/src/serialize_helper.rs | UTF-8 | 1,609 | 2.59375 | 3 | [
"MIT"
] | permissive | /// Generates serialization code for tuple struct (currently used for DockHandler, SplitHandler)
macro_rules! gen_handle {
($name:expr, $type_name:ident, $visitor:ident) => {
impl serde::ser::Serialize for $type_name {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
... | true |
167811a17af91935290a9123ef2e0ca11ad70684 | Rust | scturtle/AdventOfCode2019 | /src/day25.rs | UTF-8 | 2,612 | 2.96875 | 3 | [] | no_license | use crate::intcode::Intcode;
pub fn run() {
let codes = crate::common::get_input(25)
.unwrap()
.trim_end()
.split(',')
.map(|i| i.parse::<i64>().unwrap())
.collect::<Vec<_>>();
// manual play
if false {
let mut intcode = Intcode::new(10000);
intcode.... | true |
784c8fdf6e2c2807d2f2b04e6ec83580cbbe0fdb | Rust | erikgrinaker/toydb | /src/storage/kv/test.rs | UTF-8 | 1,436 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use super::{Memory, Range, Scan, Store};
use crate::error::Result;
use std::fmt::Display;
use std::sync::{Arc, RwLock};
/// Key-value storage backend for testing. Protects an inner Memory backend using a mutex, so it can
/// be cloned and inspected.
#[derive(Clone)]
pub struct Test {
kv: Arc<RwLock<Memory>>,
}
i... | true |
116b62e38666373a3aaf4e19f6df2791b87ee04c | Rust | Sherlock-Holo/async_for | /tests/macro_test.rs | UTF-8 | 680 | 3 | 3 | [
"MIT"
] | permissive | use futures_util::{stream, StreamExt};
use async_for::async_for;
#[futures_test::test]
async fn test_normal() {
let st = stream::iter(vec![1, 2, 3]);
let mut result = vec![];
async_for! {
async for n in st {
result.push(n);
}
}
assert_eq!(result, vec![1, 2, 3]);
}
#... | true |
258a9f8c6b19cbe895714f3b2e9cf8045478e7ae | Rust | bbucko/rusty-pew-pew | /src/sdl/sdl_video.rs | UTF-8 | 5,810 | 2.546875 | 3 | [] | no_license | use game::Level;
use game::Position;
use game::Renderer;
use helpers::parsers;
use SCREEN_SIZE;
use sdl::sdl2::pixels::Color;
use sdl::sdl2::rect::Rect;
use sdl::sdl2::render::Canvas;
use sdl::sdl2::render::TextureCreator;
use sdl::sdl2::TimerSubsystem;
use sdl::sdl2::video::Window;
use sdl::sdl2::video::WindowContext;... | true |
666bfe5154a9fba1dcf3ff624c09a5e91f4e58fe | Rust | a759116/mos_rust | /src/virtual/virtual.rs | UTF-8 | 12,454 | 2.984375 | 3 | [] | no_license | use std::usize;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PTE {
pub is_valid: bool,
pub frame_number: i32,
pub arrival_timestamp: i32,
pub last_access_timestamp: i32,
pub reference_count: i32,
}
impl Default for PTE {
fn default() -> Self {
PTE {
is_valid: fal... | true |
eeaa352b9fa4e90621ccb4ff6ba78660928c15cb | Rust | catchthirtythree/bowling-rust | /src/frame.rs | UTF-8 | 1,363 | 3.21875 | 3 | [] | no_license | use crate::game::Game;
use rand::Rng;
#[derive(Clone, Debug)]
pub struct Frame {
pub number: usize,
pub rolls: Vec<u32>,
}
impl Frame {
pub fn new(number: usize, rolls: Vec<u32>) -> Frame {
Frame { number, rolls }
}
pub fn roll_frame(number: usize) -> Frame {
let mut rolls = vec![... | true |
13cdfc434a5531672dea9c2c265971d43566e3ed | Rust | hurryabit/rufus | /rufus-core/src/cek.rs | UTF-8 | 12,327 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::fmt;
use std::rc::Rc;
use crate::syntax::*;
#[derive(Debug)]
pub enum Value<'a> {
Num(i64),
Bool(bool),
PAP(PAP<'a>),
Record(HashMap<&'a Name, Rc<Value<'a>>>),
Fix(Rc<Value<'a>>),
}
#[derive(Clone, Debug)]
pub struct PAP<'a> {
prim: Prim<'a>,
arity:... | true |
58ecfef0b0634175336d32d69c74e2021f301fa1 | Rust | Mountlex/kserver | /kserver/src/algorithms.rs | UTF-8 | 9,878 | 2.8125 | 3 | [] | no_license | use serverlib::prelude::*;
macro_rules! min {
($x: expr) => ($x);
($x: expr, $($z: expr),+) => {{
let y = min!($($z),*);
if $x < y {
$x
} else {
y
}
}}
}
pub fn learning_augmented_alg<A: PredAlgorithm>(
alg: A,
instance: &Instance,
predic... | true |
8c53ac462f5ed4fa6f58894faeda9deb89ff1544 | Rust | cschlesselmann/AdventOfCode2017 | /Day 11/src/main.rs | UTF-8 | 1,455 | 3.609375 | 4 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
fn get_input() -> String {
let filename = "input.txt";
let mut file = File::open(filename).expect("file not found");
let mut contents = String::new();
file.read_to_string(&mut contents).expect("something went wrong reading the file");
contents
}
fn get... | true |
88afd53466031316604ea5defb2ec37e4d4bcd9a | Rust | robjtede/async-svc | /crates/svc/src/map.rs | UTF-8 | 1,708 | 2.9375 | 3 | [] | no_license | use core::{future::Future, marker::PhantomData, pin::Pin};
use pin_project_lite::pin_project;
use crate::Svc;
pin_project! {
pub struct MapSvc<'f, S, F, Req, Res> {
#[pin]
svc: S,
mapper: F,
_phantom: PhantomData<(&'f (), fn(Req) -> Res,)>,
}
}
impl<S, F, Req, Res> MapSvc<'_,... | true |
a83a3a13df6622ae2e8b16a209836465292ddfe1 | Rust | hdhoang/anne-key | /src/serial/mod.rs | UTF-8 | 3,376 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | pub mod bluetooth_usart;
pub mod led_usart;
use crate::protocol::MsgType;
use core::marker::Unsize;
pub struct Serial<USART, T: 'static>
where
USART: DmaUsart,
{
pub usart: USART,
send_buffer: &'static mut T,
pub send_buffer_pos: u16,
}
pub trait DmaUsart {
// TODO: naming of these isn't quite pe... | true |
d0acbbce8f151f842457380b1ebbab9e840d87b1 | Rust | ustulation/socket-collection | /src/crypto.rs | UTF-8 | 7,978 | 2.515625 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | // Copyright 2018 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or di... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.