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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
9c8261e223f61962812097dcf7ff6bdacf89cba5 | Rust | AzielioTor/dht-crawler | /src/proto/node_id.rs | UTF-8 | 2,319 | 3.078125 | 3 | [] | no_license | use rand;
use serde::de;
use serde::de::Visitor;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use serde::Serializer;
use std::fmt;
use hex;
/// A 20 byte value representing keys in the DHT.
#[derive(PartialEq, Eq, Copy, Clone)]
pub struct NodeID([u8; 20]);
impl NodeID {
pub fn random(... | true |
8ea9dcdbf71ea845ce6f2fbd386c85055de545d4 | Rust | MAURI-PROGRAM/rust_blockchain | /src/lib.rs | UTF-8 | 1,364 | 2.96875 | 3 | [] | no_license | extern crate time;
mod block;
pub use block::Block;
pub mod transaction;
pub use transaction::Transaction;
pub mod blockchain;
pub use blockchain::Blockchain;
pub fn now() -> i64 {
time::now().to_timespec().sec
}
/// Calculate crypto hash of block
/// # Example
///
/// ```
/// use rustblockchainlib::now;
/// us... | true |
7204eaf26037209daded087e52362e5716cc396a | Rust | ruma/ruma | /crates/ruma-federation-api/src/knock/send_knock.rs | UTF-8 | 2,058 | 2.71875 | 3 | [
"MIT"
] | permissive | //! `PUT /_matrix/federation/*/send_knock/{roomId}/{eventId}`
//!
//! Submits a signed knock event to the resident homeserver for it to accept into the room's graph.
pub mod v1 {
//! `/v1/` ([spec])
//!
//! [spec]: https://spec.matrix.org/latest/server-server-api/#put_matrixfederationv1send_knockroomideven... | true |
a8c73d70e30db2fd26d9812bdf2b38591c1a8773 | Rust | MutexUnlocked/lucid | /third_party/rust/ringbuf/src/lib.rs | UTF-8 | 24,011 | 3.703125 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | //! Lock-free single-producer single-consumer (SPSC) FIFO ring buffer with direct access to inner data.
//!
//! # Overview
//!
//! `RingBuffer` is the initial structure representing ring buffer itself.
//! Ring buffer can be splitted into pair of `Producer` and `Consumer`.
//!
//! `Producer` and `Consumer` are used to... | true |
5e6387a6a2de94e489e0714c14179d9499ada4c2 | Rust | ikornaselur/rusty-invaders | /src/cpu/instructions/call.rs | UTF-8 | 11,363 | 3.28125 | 3 | [] | no_license | use cpu::CPU;
fn process_call(cpu: &mut CPU, address: u16) -> () {
// A specific hack for full cpu test
if cpu.debug && address == 5 && cpu.c == 9 {
let offset = (u16::from(cpu.d) << 8) + u16::from(cpu.e);
if offset == 0x018B {
panic!("CPU HAS FAILED");
} else if offset == 0... | true |
4fe9e903133ec562a2b930881a171c3f8c5f8df4 | Rust | azazrehman/rust_programs | /ownership/src/main.rs | UTF-8 | 428 | 3.546875 | 4 | [] | no_license | fn main() {
//println!("Hello, world!");
let get = giveback();
println!("Hello, {}",get);
let batch3= String::from("IOT");
let assignment=receiver(batch3);
println!("Assignment {}",assignment);
println!("Batch 3 {}",batch3);
}
fn giveback()->String
{
let name= String::from("Azaz");
... | true |
3bbffd07377449dca3e867110867309fc39fad91 | Rust | ltriess/advent-of-code-2020 | /src/bin/12_rain-risk_part2.rs | UTF-8 | 2,790 | 3.3125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{self, BufRead, BufReader};
fn rotate_waypoint_right(rs: i32, cs: i32) -> (i32, i32) {
return if (rs < 0) & (cs < 0) {
// North-West.
(-cs.abs(), rs.abs())
} else if (rs < 0) & (cs >= 0) {
// North-East.
(cs.abs(), rs.abs())
} else if (rs >= 0... | true |
267c463d93295cc34ce91e4d905115009aee4624 | Rust | ebarnard/alac.rs | /src/bitcursor.rs | UTF-8 | 4,384 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::cmp;
const U32_BITS: usize = 32;
#[derive(Clone)]
pub struct BitCursor<'a> {
buf: &'a [u8],
current: u32,
current_len: u8,
current_pos: u8,
}
#[derive(Debug)]
pub struct NotEnoughData;
#[derive(Debug)]
pub struct BufferTooLong;
impl<'a> BitCursor<'a> {
pub fn new(buf: &'a [u8]) -> Resu... | true |
df03f4ac011e9c5e63e355becebaa31bdecdef48 | Rust | MauriceKayser/rs-winapi2 | /src/pe/base_relocation.rs | UTF-8 | 11,181 | 3.265625 | 3 | [
"MIT"
] | permissive | //! All types for parsing PE file base relocations.
/// An iterator over the base relocations.
pub struct Iterator<'a> {
buffer: &'a [u8]
}
impl<'a> Iterator<'a> {
/// Creates an iterator over the base relocations.
#[cfg_attr(not(debug_assertions), inline(always))]
pub fn new(pe: &mut super::PeFile<'a... | true |
dc31c6951b4ab346d31fb0e7e9b6a2af1e39384d | Rust | Pyrlang/Term | /src/reader.rs | UTF-8 | 3,904 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2022, Erlang Solutions Ltd, and S2HC Sweden AB
//
// 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 appli... | true |
de2cb9002d78bf07abaf69d2c025266b9efb6d79 | Rust | mayah/x86intrin | /examples/bit_operation.rs | UTF-8 | 1,045 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate x86intrin;
use x86intrin::*;
#[inline(never)]
fn xy_and(x: m128i, y: m128i) -> m128i {
mm_and_si128(x, y)
}
#[inline(never)]
fn xy_or(x: m128i, y: m128i) -> m128i {
mm_or_si128(x, y)
}
#[inline(never)]
fn xy_xor(x: m128i, y: m128i) -> m128i {
mm_xor_si128(x, y)
}
#[inline(never)]
fn xy_and... | true |
4344a426568d99af30fe542281e7bc0c874e2d8c | Rust | fujiapple852/tonic | /tests/integration_tests/tests/status.rs | UTF-8 | 3,210 | 2.515625 | 3 | [
"MIT"
] | permissive | use bytes::Bytes;
use futures_util::FutureExt;
use integration_tests::pb::{test_client, test_server, Input, Output};
use std::time::Duration;
use tokio::sync::oneshot;
use tonic::metadata::{MetadataMap, MetadataValue};
use tonic::{transport::Server, Code, Request, Response, Status};
#[tokio::test]
async fn status_with... | true |
eb8831740e2121533f75a82cd234c42c83befc5c | Rust | xujihui1985/learningrust | /ffi/example01/src/main.rs | UTF-8 | 352 | 2.90625 | 3 | [] | no_license | use libc::size_t;
use std::slice;
#[no_mangle]
pub extern "C" fn sum_of_even(n: *const u32, len: size_t) -> u32 {
let numbers = unsafe {
assert!(!n.is_null());
slice::from_raw_parts(n, len as usize)
};
numbers
.iter()
.filter(|&v| v % 2 == 0)
.sum()
}
fn main() {
... | true |
4c5b6527c37d46e912d73ce45dff28bbb8f44b83 | Rust | likr/atcoder | /abc064/src/bin/c.rs | UTF-8 | 827 | 2.71875 | 3 | [] | no_license | use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
fn... | true |
5acaa02930ef09a217a59898f8cbd0a149ceab04 | Rust | TedDriggs/darling | /tests/computed_bound.rs | UTF-8 | 845 | 3.0625 | 3 | [
"MIT"
] | permissive | use darling::{FromDeriveInput, FromMeta};
fn parse<T: FromDeriveInput>(src: &str) -> T {
let ast = syn::parse_str(src).unwrap();
FromDeriveInput::from_derive_input(&ast).unwrap()
}
#[derive(FromMeta, PartialEq, Eq, Debug)]
enum Volume {
Whisper,
Talk,
Shout,
}
#[derive(FromDeriveInput)]
#[darling... | true |
be8fe048f52f73823be6faef26aa9d4eaca7db80 | Rust | hetaoo/scf | /rust/tests/configuration_manager_test.rs | UTF-8 | 26,910 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive |
#[macro_use]
extern crate lang_extension;
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::atomic::*;
use lang_extension::convert::*;
use scf_core::source::*;
use scf_core::manager::*;
use scf_core::facade::*;
mod test_configuration_source;
use test_configuration_source::*;
mod test_dynamic_confi... | true |
9eac2057d45087d7a1f1d31af4fedb912eb6c790 | Rust | replit4/rfbproxy | /src/messages/server.rs | UTF-8 | 9,788 | 3.03125 | 3 | [
"MIT"
] | permissive | use super::io::*;
use super::Error;
use anyhow::{anyhow, Result};
/// Represents a message that is sent from the server to the client.
#[derive(Debug)]
pub enum Message {
FramebufferUpdate(Vec<u8>),
SetColorMapEntries(Vec<u8>),
Bell(Vec<u8>),
ServerCutText(Vec<u8>),
// Extensions
EndOfContinu... | true |
74a97e9d45ae16dbf8d7a061a4b7c5892cf987b0 | Rust | choubacha/grusp | /tests/integration.rs | UTF-8 | 4,069 | 2.59375 | 3 | [
"MIT"
] | permissive | extern crate assert_cli;
#[cfg(test)]
mod integration {
use assert_cli;
#[test]
fn it_can_find_fixture() {
assert_cli::Assert::main_binary()
.with_args(&["FIND THIS", "./tests/fixtures"])
.succeeds()
.stdout()
.contains("FIND THIS")
.unwr... | true |
a8297b674f936cc090c7a1b6e669d2ba215980be | Rust | woen4/learning-rust | /projects/exercises/fibonacci.rs | UTF-8 | 569 | 3.546875 | 4 | [] | no_license | fn main() {
const POSITION_WANTED: u8 = 50;
let result = fibonacci(POSITION_WANTED);
println!("Result: {}", result);
}
fn fibonacci(position: u8) -> u32 {
const INITAL_ARRAY_LENGTH: u8 = 2;
let mut sequence = vec![0, 1];
let number_target: u8 = position - INITAL_ARRAY_LENGTH;
for _i in 0..number_target ... | true |
c6871b7e8018af9814cb6318be8dc2b4e05ca259 | Rust | ZePedroResende/cuckoo_filter | /src/bucket.rs | UTF-8 | 1,231 | 3.53125 | 4 | [
"MIT"
] | permissive | type BucketVector = Vec<Option<u8>>;
#[derive(Debug, Clone)]
pub struct Bucket {
pub bucket: BucketVector,
}
impl Bucket {
pub fn new(capacity: usize) -> Bucket {
Bucket {
bucket: vec![None; capacity],
}
}
pub fn insert(&mut self, value: u8) -> bool {
match self.ge... | true |
91f04b9f4c629be130a956abeffc752bb639e9f3 | Rust | Nercury/twig-rs | /src/nodes/mod.rs | UTF-8 | 1,153 | 2.6875 | 3 | [
"BSD-3-Clause"
] | permissive | /*!
Produces an abstract syntax tree from a stream of tokens.
*/
mod parser;
mod node;
mod token_parser;
pub use self::node::body;
pub use self::node::expr;
pub use self::node::module::Module;
pub use self::token_parser::{ TokenParser };
pub use self::parser::{ Parser, Parse, ImportedFunction };
pub use self::parse... | true |
0397b93ac950d8403846dea28bb7f053ac3808f8 | Rust | Rust-Mikrocontroller-Praktikum-2017/raytracer | /lib/src/scenes/space.rs | UTF-8 | 3,722 | 2.546875 | 3 | [] | no_license | use scene::Scene;
use intersectables::sphere::Sphere;
use vector::{Vec3, VEC3_ZERO};
use reflectionmodel::ModifiedPhongModel;
use textures::color::NoTexture;
use textures::noise::EARTH_TEXTURE;
use texturemapping::sphere::MapXY;
use texture::MultTexture;
pub const SCENE_SPACE: Scene = Scene {
objects: &[
/... | true |
c74ebe4ab0d00ad60184dda905af687ae9fc74a5 | Rust | brson/rust-uuid | /uuid.rs | UTF-8 | 2,313 | 2.8125 | 3 | [
"MIT"
] | permissive | export uuid;
export uuid_random;
export uuid_time;
export to_str;
export from_str;
#[doc = "a uuid value"]
type uuid = {
a: u32,
b: u32,
c: u32,
d: u32,
};
#[cfg(target_os = "macos")]
#[nolink]
extern mod uuid {
fn uuid_generate(out: uuid);
fn uuid_generate_random(out: uuid);
fn uuid_gener... | true |
08ddb1d196302dcb2ef4b829f20266b1607c9dc9 | Rust | kontrio/rust-iouring-experiments | /uring-sys/src/submission_queue.rs | UTF-8 | 14,588 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{
ContiguousMem, EnterFlag, SetupFlag, SetupParameters, SubmissionQueueEntry,
SubmissionQueueFlag, SyscallLib,
};
use core::pin::Pin;
#[derive(Debug)]
pub enum SubmissionError {
QueueFull,
}
#[derive(Debug)]
pub struct SubmissionQueue<M: ContiguousMem, S: SyscallLib> {
k_head: *mut u32,
... | true |
ba6b7281c7150c0dffcc39b3b66508804768237b | Rust | ZacJoffe/znes | /src/cartridge/mapper3.rs | UTF-8 | 1,463 | 2.859375 | 3 | [
"MIT"
] | permissive | use crate::cartridge::Cartridge;
use crate::cartridge::Mapper;
use crate::cartridge::Mirror;
pub struct CNROM {
cart: Cartridge,
// https://wiki.nesdev.com/w/index.php/CNROM#Bank_select_.28.248000-.24FFFF.29
//
// "Select 8 KB CHR ROM bank for PPU $0000-$1FFF"
// only the lower 2 bits of the value ... | true |
b5103ec1845a3f326ef99876e640d133f7aa3e13 | Rust | JustinByrne/valheim-docker | /src/odin/server/process.rs | UTF-8 | 779 | 2.765625 | 3 | [
"BSD-3-Clause"
] | permissive | use sysinfo::{Process, System, SystemExt};
use crate::constants;
pub struct ServerProcess {
system: System,
}
impl ServerProcess {
pub fn new() -> ServerProcess {
ServerProcess {
system: System::new(),
}
}
pub fn get_valheim_processes(&mut self) -> Vec<&Process> {
self.system.refresh_proce... | true |
f71782fb6389a377bb586032f874a8651897a8e5 | Rust | Kayryu/TinyChain | /src/main.rs | UTF-8 | 1,424 | 2.8125 | 3 | [] | no_license | extern crate ctrlc;
mod block;
mod transaction;
use block::Block;
use transaction::Transaction;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
// A Minter that create a block
trait Minter {
fn mint(&self, trans: Vec<Transaction>) -> Self;
//fn proof(&self, hash: u64) -> u64;
}
// impleme... | true |
425c8cb68dc62fd8fa0659ddd69a66e3c6276f20 | Rust | Asi7ho/Exercism | /rust/matching-brackets/src/lib.rs | UTF-8 | 499 | 3.359375 | 3 | [] | no_license | pub fn brackets_are_balanced(string: &str) -> bool {
let mut bracket_stack = vec![];
for c in string.chars() {
match c {
'[' => bracket_stack.push(']'),
'(' => bracket_stack.push(')'),
'{' => bracket_stack.push('}'),
']' | ')' | '}' => {
... | true |
c8bfa960e62e6601205746eedf9fc4a06d9ddd27 | Rust | clemado1/rare | /warp-web/src/handlers/invite_handler.rs | UTF-8 | 1,400 | 2.515625 | 3 | [] | no_license | use warp;
use crate::{db::postgresql::POOL, models::invitation::Invitation};
pub async fn repeat(input: String) -> Result<impl warp::Reply, warp::Rejection> {
println!("{:#?}", &input);
Ok(warp::reply::html(input))
}
pub async fn invite(invitation: Invitation) -> Result<impl warp::Reply, warp::Rejection> {
... | true |
f632cd09f29c15e528d08f2d7c981c23f773d379 | Rust | eduardonunesp/river-jet-rs | /src/scenes/player.rs | UTF-8 | 1,968 | 2.765625 | 3 | [] | no_license | use cgmath::Vector2;
use ggez::graphics::Image;
use ggez::{event, event::KeyCode, input, Context};
use super::mechanics::drawable::load_image;
use super::mechanics::drawable::Drawable;
use super::mechanics::playable::Playable;
use super::mechanics::updatable::Updatable;
use super::mechanics::updatable::{self};
const ... | true |
e4dcac0e6b423ff5be25cc3fbb233589ccd5fef9 | Rust | iCodeIN/advent-of-code-3 | /crates/core/src/year2015/day12.rs | UTF-8 | 6,078 | 3.375 | 3 | [
"MIT"
] | permissive | use crate::Input;
use std::collections::HashMap;
#[derive(Eq, PartialEq, Debug)]
enum JsonValue<'a> {
String(&'a [u8]),
Number(i32),
Array(Vec<JsonValue<'a>>),
Object(HashMap<&'a [u8], JsonValue<'a>>),
Comma,
Colon,
EndOfArray,
EndOfObject,
EndOfInput,
}
fn parse<'a>(input: &'a [u8... | true |
01fee54d1e0139b2912392dadcd74e02d9e5d6d4 | Rust | vijfhoek/trillium | /native-tls/src/server.rs | UTF-8 | 1,658 | 2.546875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::Identity;
use async_native_tls::{Error, TlsAcceptor, TlsStream};
use trillium_tls_common::{async_trait, Acceptor, AsyncRead, AsyncWrite};
/**
trillium [`Acceptor`] for native-tls
*/
#[derive(Clone, Debug)]
pub struct NativeTlsAcceptor(TlsAcceptor);
impl NativeTlsAcceptor {
/**
constructs a NativeT... | true |
9fdc26565e0c14d630936e38a7dd6fd4529b4da9 | Rust | ferrite-rs/ferrite-tutorial | /src/bin/01_greet.rs | UTF-8 | 684 | 2.96875 | 3 | [] | no_license | use ferrite_session::prelude::*;
/**
# Excercise 1: Greet Provider
Implement a greeter provider that receives the name as a string value and then
print out the line "Hello, {name}!"
After completing your solution, you should get the following result
running the program:
```
$ cargo run --bin 01_greet
... | true |
25dffb53716e29b7716b2a5b7d8799ba9d2634b9 | Rust | olson-dan/rgc | /src/gemini.rs | UTF-8 | 4,042 | 2.90625 | 3 | [] | no_license | use async_native_tls::TlsConnector;
use async_std::net::TcpStream;
use async_std::prelude::*;
use url::Url;
#[derive(Debug)]
pub enum GeminiStatus<'a> {
Input(u32, &'a str),
Success(u32, &'a str),
Redirect(u32, &'a str),
TemporaryFailure(u32, &'a str),
PermanentFailure(u32, &'a str),
... | true |
9a52c031e51e97c33c2bd3b0fc3f444445adb658 | Rust | oxidecomputer/cio | /zoho-client/tests/create_lead.rs | UTF-8 | 3,812 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use serde_json::json;
use zoho_api::{
client,
client::{ModuleUpdateResponseEntry, ModuleUpdateResponseEntryError},
modules,
};
// This test requires manual intervention to run. Permanently deleting a lead from Zoho requires
// an admin to delete the lead from the Zoho Recycling Bin (via the web ui). Until ... | true |
8a85d882d995d205ead4ab29ff11eac6c55f292b | Rust | knutwalker/git-stats | /src/repo.rs | UTF-8 | 5,447 | 2.734375 | 3 | [] | no_license | use std::{borrow::Cow, collections::HashMap, path::PathBuf};
use color_eyre::Section;
use git2::{Commit, Repository};
use itertools::Itertools;
use once_cell::sync::Lazy;
use crate::{AuthorCounts, Result, StringCache};
pub const HAN_SOLO: &str = "Han Solo";
pub struct Repo {
repository: Repository,
replacem... | true |
fa5c89b3fa817188179d84dcb1ac8337bb3c69e9 | Rust | KJLankinen/mini_pascal | /compiler/src/logger.rs | UTF-8 | 8,874 | 3.34375 | 3 | [] | no_license | use super::data_types::ErrorType as ET;
use super::data_types::SymbolType as ST;
pub struct Logger<'a> {
errors: Vec<ET<'a>>,
lines: Vec<&'a str>,
pub file_name: &'a str,
}
impl<'a> Logger<'a> {
pub fn new(source_str: &'a str, file_name: &'a str) -> Self {
Logger {
errors: vec![],
... | true |
4ed926c63a53899d1ec5617923aea763194e2549 | Rust | gremenne/AdventOfCode2020 | /day6/src/main.rs | UTF-8 | 2,366 | 3.296875 | 3 | [] | no_license | use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
use std::collections::HashSet;
struct BLSeparatedData<'a, T>
where T: Iterator< Item=String > {
line_iter: &'a mut T,
}
impl<'a, T> Iterator for BLSeparatedData<'a, T>
where T: Iterator< Item=String > {
type Item = Vec<String>;
fn nex... | true |
5e51b40781ffc58080f7ad05a15921766925f5f5 | Rust | luciusmagn/permutation | /src/main.rs | UTF-8 | 2,031 | 3.3125 | 3 | [
"Fair"
] | permissive | use std::env::args;
use std::process::exit;
#[derive(Debug, Clone)]
struct Program {
name: char,
pos: usize,
}
fn main() {
let mut args = args().skip(1);
let mut programs: Vec<Program> = if let Some(prgs) = args.next() {
prgs
.chars()
.enumerate()
.map(|(pos, x)| Program { name: x, pos: pos })
.coll... | true |
0139c5df869aec53c9ea734c0d0a9df673eb382b | Rust | ChangeCaps/gui | /src/state/state.rs | UTF-8 | 771 | 2.828125 | 3 | [
"MIT"
] | permissive | use super::Transition;
use super::super::Frame;
use super::StateData;
pub trait State: Send + StateClone {
fn draw(&self, _frame: &mut Frame, _state_data: &StateData) {
}
fn shadow_draw(&self, _frame: &mut Frame, _state_data: &StateData) {
}
fn update(&mut self, _state_data:... | true |
4a37abcf7c9cdd86c5ce8f52cce5eb8175a70557 | Rust | PolySync/cargo-fel4 | /src/command_ext.rs | UTF-8 | 1,761 | 3.21875 | 3 | [
"MIT"
] | permissive | use super::Error;
use config::LoudnessOpts;
use std::ffi::OsStr;
use std::process::Command;
/// Extension methods for `Command` instances to supply common parameters or
/// metadata
pub trait CommandExt
where
Self: Into<Command>,
{
/// Add an argument if a predicate returns true, largely for easier chaining
... | true |
77d1623666ab8872d7182dcfac96bec8d753d279 | Rust | iCodeIN/lox | /src/io/stl/read.rs | UTF-8 | 23,907 | 3.09375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use std::{
collections::{HashMap, hash_map::Entry},
fmt,
fs::File,
hash::{Hash, Hasher},
marker::PhantomData,
io,
path::Path,
};
use byteorder::{ByteOrder, LittleEndian, ReadBytesExt};
use crate::{
prelude::*,
handle::hsize,
io::{
Error,
parse::{self, ParseBuf, ... | true |
e2faec6cda1ca52c58aef560696d6d0ad42730b2 | Rust | b2broker/findmarket | /src/collectors/binance/mod.rs | UTF-8 | 1,928 | 2.796875 | 3 | [] | no_license | use crate::collectors::*;
use serde::{Deserialize};
#[derive(Deserialize, Debug)]
#[allow(non_snake_case)]
struct Symbols {
symbol: String,
baseAsset: Option<String>,
quoteAsset: Option<String>,
}
#[derive(Deserialize)]
pub struct Base {
symbols: std::vec::Vec<Symbols>
}
pub struct BinanceUS;
impl B... | true |
44bb57299012da9f19171775bb15a5f317b8745f | Rust | tomhoule/prisma-engine | /libs/datamodel/core/src/dml/default_value.rs | UTF-8 | 4,566 | 3.15625 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
use crate::{ast, error::DatamodelError};
use chrono::Utc;
use std::{
convert::{TryFrom, TryInto},
fmt,
};
use uuid::Uuid;
#[derive(Clone, PartialEq)]
pub enum DefaultValue {
Single(ScalarValue),
Expression(ValueGenerator),
}
impl DefaultValue {
// Returns either a copy of the contain... | true |
26379da51c14ff7f9db9102c96f68573e108acb6 | Rust | Aterocana/basic_chat | /src/lib.rs | UTF-8 | 703 | 3.0625 | 3 | [] | no_license | use std::net::SocketAddr;
use std::sync::Arc;
#[derive(Debug)]
pub struct Message {
text: Arc<String>,
sender_addr: SocketAddr,
size: usize,
}
impl Message {
pub fn new(size: usize, text: Arc<String>, sender_addr: SocketAddr) -> Message {
Message {
size: size,
text: tex... | true |
619dbef1efe706d6ecd4b45f5141007058995e5c | Rust | oshinowo-stephen/knil | /src/env.rs | UTF-8 | 997 | 2.890625 | 3 | [] | no_license | use std::env;
use std::io;
#[cfg(not(feature = "loadenv"))]
pub fn read_env() -> io::Result<usize> {
let environment = env::var("RUST_ENV").unwrap_or_else(|_| "development".to_string());
parse_env(&environment)
}
#[cfg(feature = "loadenv")]
pub fn read_env(path: Option<&str>) -> io::Result<usize> {
if path.is_non... | true |
079444eb70d551fa69b8d937a33b331b0d43020d | Rust | mendelt/trem | /src/lib.rs | UTF-8 | 682 | 3.46875 | 3 | [] | no_license | use std::io::{Read, Write};
pub struct Trem<R, W> {
read: R,
write: W,
}
impl<R: Read, W: Write> Trem<R, W> {
pub fn new(read: R, write: W) -> Self {
Self {read, write}
}
/// Write a buffer to the output
pub fn write(&mut self, buf: &[u8]) {
self.write.write(buf).unwrap();
... | true |
113eb8d52a01fa72fcd4e67e5b463c39922bf906 | Rust | orglofch/pe-rust | /src/p052.rs | UTF-8 | 679 | 3.28125 | 3 | [] | no_license | // DONE: 142857
//
// Another opportunity to use our prime digit uniqueness trick.
const INDEX_PRIMES: [u32; 10] = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
fn prime_index(num: u32) -> u32 {
let mut index = 1;
let mut rem = num;
while rem > 0 {
index *= INDEX_PRIMES[(rem % 10) as usize];
rem ... | true |
e3362947892a1a7490dfd0a852efda081295b728 | Rust | kecors/AoC-2017 | /day-23/src/coprocessor.rs | UTF-8 | 5,277 | 3.3125 | 3 | [
"MIT"
] | permissive | use instruction::Instruction;
use std::collections::HashMap;
#[derive(Debug)]
pub struct Coprocessor {
code_segment: Vec<Instruction>,
instruction_pointer: i64,
registers: HashMap<char, i64>,
mul_count: u32,
}
impl Coprocessor {
pub fn new(instructions: Vec<Instruction>) -> Coprocessor {
... | true |
3f6ba825d99e3442f75a6b0162f246e59247df5a | Rust | mseqs/birlscript | /src/vm/parameter.rs | UTF-8 | 865 | 3.09375 | 3 | [
"MIT"
] | permissive |
use super::variable;
use nparser::function::ExpectedParameter;
#[derive(Debug, Clone)]
/// Representa um parametro que pode ser passado como argumento para uma seção
pub struct Parameter {
pub var: variable::Variable, // Contem o nome, valor e tipo
}
impl Parameter {
/// Se todos os parametros coincidem em t... | true |
980b0195d1309e0344e37894f0b929044467a839 | Rust | INDAPlus20/AssignmentsInstructions | /sorting-task-11/sorting-visualisation/src/main.rs | UTF-8 | 14,060 | 2.765625 | 3 | [] | no_license | /**
* Sorting visualisation example
* Author: Viola Söderlund <violaso@kth.se>
* Last updated: 2020-11-17
*/
use ggez::event;
use ggez::graphics::{self, Color};
use ggez::{Context, GameResult};
use std::path;
use rand::seq::SliceRandom;
use rand::thread_rng;
const ALG_SPAN: usize = 20;
const GRID_SIZE: (usize,... | true |
046217ea5556b547c04c836b5939b4ad6f898859 | Rust | intellij-rust/intellij-rust | /src/test/resources/org/rust/ide/formatter/fixtures/spacing.rs | UTF-8 | 10,131 | 2.546875 | 3 | [
"MIT"
] | permissive | extern crate std as ruststd ;
use core :: hash :: { self , Hash } ;
use core ::intrinsics:: {arith_offset ,assume} ;
use core::iter::FromIterator;
use core :: mem;
use core::ops::{ Index ,IndexMut };
const CAPACITY :usize = 2*B-1;
fn foo ( a ... | true |
e5528a4927a5b0f6e597aac826be429951ca6384 | Rust | ivoelbert/HECTOR | /src/tree/translate/callexp.rs | UTF-8 | 2,410 | 2.546875 | 3 | [] | no_license | use crate::ast::*;
use crate::tree::*;
fn generate_static_link(delta_depth: i32) -> Tree::Exp {
if delta_depth < 0 {
panic!("no se matematica")
}
if delta_depth == 0 {
MEM(Box::new(
plus!(
GLOBAL(named_global(FRAME_POINTER)),
CONST(STATIC_LINK_OFF... | true |
eb156e81c90385b8295e90005ad06009b583bdc8 | Rust | slowlove/fcp | /src/main.rs | UTF-8 | 491 | 2.671875 | 3 | [
"BSD-3-Clause"
] | permissive | use fcp::{fatal, fcp};
use std::env;
use std::process;
static HELP: &str = "\
fcp
USAGE:
fcp SOURCE DESTINATION_FILE
Copy SOURCE to DESTINATION_FILE, overwriting DESTINATION_FILE if it exists
fcp SOURCE ... DESTINATION_DIRECTORY
Copy each SOURCE into DESTINATION_DIRECTORY";
fn main() {
let args:... | true |
5845892ae897b841ea448c0e1b314a22a7de4fdb | Rust | theunkn0wn1/rustpad | /rustpad/examples/runtime_with_events.rs | UTF-8 | 1,873 | 2.671875 | 3 | [] | no_license | use gilrs::{Button, Event, EventType, Gilrs};
use rustpad::thrustmaster::{decode_warthog_throttle, WarthogThrottleEvent};
use std::collections::HashMap;
use toml;
fn gamepad_worker() {
let mut gilrs = Gilrs::new().unwrap();
let mut keymap: HashMap<String, gilrs::Gamepad> = HashMap::new();
// Iterate ov... | true |
57477b58d209e98095ecf334152b4e6cfa834235 | Rust | Alagris/GLEngineRust | /desktop/src/blocks/block.rs | UTF-8 | 1,305 | 2.78125 | 3 | [] | no_license | use std::fmt::{Display, Formatter};
use crate::blocks::block_properties::{BLOCKS, STONE};
use crate::render_gl::data::VertexAttribPointers;
use crate::blocks::face_orientation::FaceOrientation;
use crate::render_gl::data::VertexAttrib;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[repr(C, packed)]
#[derive(VertexAttr... | true |
825627549e015fa086e186c4452e45831450f58c | Rust | nfmelendez/rust-talk-examples | /rust-examples.rs | UTF-8 | 1,609 | 3.578125 | 4 | [] | no_license |
/*
//example O01
//OWNERSHIP TRANSFER.
fn take(v: Vec<i32>) {
println!("{}", v[0]);
// owner destroy here.
}
fn main() {
let v = vec![1,2,3];
take(v);
// println!("{}", v[0]); //fail because destroyed the owner. doesnt compile.
}
*/
/*
// example B01
//SHARED BORROWED: inmutable resource and many many borro... | true |
ef4890f5622d481f74207c2d90343990ea05981c | Rust | kp-forks/pixie-rust | /src/recommender/graph/mod.rs | UTF-8 | 8,765 | 3.8125 | 4 | [
"MIT"
] | permissive | //! # Graph
//!
//! The `graph` module is a collection of utilities to handle an
//! undirected graph structure.
//!
//! The end user of the library should not need to use this module
//! directly.
extern crate rand;
use rand::rngs::OsRng;
use rand::Rng;
use std::collections::HashMap;
use std::collections::HashSet;
u... | true |
a5a363d4273600cd9f82aadf4b2bba8e7b842974 | Rust | Skgland/Response-Time-Analysis-for-Fixed-Priority-Servers | /rta-for-fps-lib/tests/consolidated_tests/task_tests.rs | UTF-8 | 1,850 | 2.90625 | 3 | [] | no_license | use crate::rta_lib::curve::Curve;
use crate::rta_lib::iterators::curve::AggregationIterator;
use crate::rta_lib::iterators::CurveIterator;
use crate::rta_lib::task::curve_types::TaskDemand;
use crate::rta_lib::task::Task;
use crate::rta_lib::time::TimeUnit;
use crate::rta_lib::window::Window;
#[test]
fn demand_curve()... | true |
af336995c194208b8a09545c6912f229d9a9a13b | Rust | thatsokay/advent-of-code | /2022/07/solution.rs | UTF-8 | 1,751 | 3.0625 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs;
fn main() {
let input = parse_input();
println!("{}", part1(&input));
println!("{}", part2(&input));
}
fn parse_input() -> Vec<String> {
fs::read_to_string("input.txt")
.unwrap()
.lines()
.map(|line| line.to_string())
.collect... | true |
9105af01f33877f2a0265faac8f424c3c753eb83 | Rust | hmcol/xops | /xops_macros/src/lib.rs | UTF-8 | 5,639 | 3.265625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use darling::FromMeta;
use proc_macro::TokenStream;
use syn::{parse_macro_input, AttributeArgs};
use xops_core::*;
/// For deriving extra implementations of a binary operation.
///
/// The `binop` attribute can be applied to any binary operation trait implementation (see [`xops_core::BinOpImpl`].
///
/// It has thre... | true |
03ceed864d40f6d28bae1f9e458d7e72e15799a6 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/abc295/src/bin/a.rs | UTF-8 | 359 | 3.03125 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
w: [String; n],
};
let mut ok = false;
let words = vec!["and", "not", "that", "the", "you"];
for w_i in w {
if words.iter().any(|word| word == &w_i) {
ok = true;
}
}
let ans = ok;
println!("{... | true |
e73c1300068b8c51b69619f6ba8319402c2159e2 | Rust | grumbach/bls_dkg | /src/dev_utils/peer.rs | UTF-8 | 3,118 | 2.765625 | 3 | [
"MIT",
"BSD-3-Clause"
] | permissive | // Copyright 2020 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://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 d... | true |
427b65cfca502b59389250805ab2e25d705940cd | Rust | wusyong/tauri | /tauri-api/src/http.rs | UTF-8 | 5,136 | 3.046875 | 3 | [
"MIT",
"CC-BY-NC-ND-4.0",
"Apache-2.0"
] | permissive | use std::time::Duration;
use std::fs::File;
use std::collections::HashMap;
use attohttpc::{RequestBuilder, Method};
use http::header::HeaderName;
use serde_json::Value;
use serde::Deserialize;
use serde_repr::{Serialize_repr, Deserialize_repr};
#[derive(Serialize_repr, Deserialize_repr, Clone, Debug)]
#[repr(u16)]
///... | true |
4f4dd7f683c616f0af22d1e123f7900834db850f | Rust | chenyukang/tensorbase | /crates/datafusion/src/physical_plan/expressions/rank.rs | UTF-8 | 5,248 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-free-unknown",
"Apache-2.0"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
5c8398b59fb937200503f259d9d07850f75255b8 | Rust | sid-85/subkey | /src/types.rs | UTF-8 | 1,573 | 2.515625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct AddParams {
pub name: Option<String>,
pub password: Option<String>,
pub curve_type: Option<String>,
pub address_format: Option<String>,
}
#[derive(Serialize, Deserialize)]
pub struct ImportParams {
pub phrase: String... | true |
f4b1595645960429bcb7ea98dcceb27f467386e4 | Rust | amedviediev/data-generator | /src/cli.rs | UTF-8 | 1,510 | 3.078125 | 3 | [] | no_license | use clap::{Arg, App};
pub struct Params {
pub config: String,
pub number_of_records: u64,
pub output: String,
pub pretty: bool,
}
pub fn parse() -> Params {
let matches = App::new("Data generator")
.version("0.1.0")
.author("amedvedev <amedvyedyev@gmail.com>")
.about("Gener... | true |
93b4ad1ab279faf90a2dd032bca16d661c49ed34 | Rust | kevinastone/httpbox | /src/service/status_code.rs | UTF-8 | 867 | 2.796875 | 3 | [] | no_license | use crate::http::{bad_request, response, Request, Result, StatusCode};
pub async fn status_code(req: Request) -> Result {
let status = req.param::<StatusCode>("code").ok_or_else(bad_request)?;
response().status(status).into()
}
#[cfg(test)]
mod test {
use super::*;
use crate::test::*;
use hyper:... | true |
e056657581bd1cae5430a090730573edec20ceb1 | Rust | LaurentMazare/tch-rs | /src/tensor/ops.rs | UTF-8 | 6,660 | 3.046875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Implement various ops traits for tensors
use super::Tensor;
use crate::Scalar;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
fn id<T>(v: T) -> T {
v
}
fn neg(t: Tensor) -> Tensor {
t.neg()
}
fn inv(t: Tensor) -> Tensor {
t.pow_tensor_scalar(-1)
}
macro_rules! i... | true |
04bb67dc21390ed1b0e9d59b197b042dea4a70fe | Rust | Rustops/dwarf_seeks_fortune | /dsf_core/src/states/paused.rs | UTF-8 | 1,250 | 2.65625 | 3 | [
"BlueOak-1.0.0"
] | permissive | use amethyst::{
ecs::prelude::{Entity, WorldExt},
input::{is_key_down, VirtualKeyCode},
GameData, SimpleState, SimpleTrans, StateData, StateEvent, Trans,
};
use crate::resources::{UiHandles, UiType};
use crate::states::window_event_handler;
#[derive(Copy, Clone, Default, Debug)]
pub struct PausedState {
... | true |
9770635f74ecccba2df69bc9341663080ae70185 | Rust | mibac138/aliri | /aliri/src/jwa/usage.rs | UTF-8 | 341 | 2.6875 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
/// The intended use for a JWA
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum Usage {
/// The JWA is intended signing and verification
#[serde(rename = "sig")]
Signing,
/// The JWA is intended for encryption
#[serde(rename = "enc"... | true |
e7477ad8dbbc4f1ed714a11d90dacd81954bda0d | Rust | tarberd/dragon-book | /chapter-2/doodle/src/main.rs | UTF-8 | 331 | 3.4375 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
let input = "5 + 9";
let mut tokens = vec![];
for character in input.chars() {
if character.is_ascii_digit() {
tokens.push("digit");
}
if character == '+' {
tokens.push("+");
}
}
println!("{:?}", ... | true |
1d8045923417e96affea705100d1ce5ef09fe5d9 | Rust | Mythridor/yare-rust | /src/headless/yare_impl/spirit.rs | UTF-8 | 1,974 | 3.125 | 3 | [] | no_license | use super::{base::Base, shape::Shape, vec2::Vec2};
use crate::bindings::{
base::{CIRCLE_START_OFFSET, SQUARE_START_OFFSET, TRIANGLE_START_OFFSET},
spirit::ENERGIZE_RANGE,
};
#[derive(Clone, Debug)]
pub(crate) struct Spirit {
pub energy_cap: i32,
pub energy: i32,
pub hp: u32,
pub id: usize,
... | true |
4fe866dc503158a0d92ee0e97b1bb8cc6bd48d69 | Rust | anti-social/jsonpath-rs | /src/filter/mod.rs | UTF-8 | 1,758 | 2.703125 | 3 | [
"MIT"
] | permissive | use serde_json::Value;
use structs::{Criterion, StackItem, Step};
use iter::Iter;
mod comparison;
pub fn process_filter<'a>(stack: &mut StackItem, path: &[Criterion], root: &StackItem<'a>) -> bool {
match path[0] {
Criterion::Element => match path[1] {
Criterion::NamedChild(ref child_name) => ... | true |
716d27f4c0f0707c33a5309b4d84a035cbb1a887 | Rust | AdamWhitehurst/sim | /src/comp/collider.rs | UTF-8 | 370 | 2.515625 | 3 | [] | no_license | use amethyst::ecs::{Component, DenseVecStorage, Entity};
use std::default::Default;
use std::vec::Vec;
#[derive(Debug)]
struct Collider {
collisions: Vec<Entity>,
}
impl Default for Collider {
fn default() -> Self {
Self {
collisions: Vec::new(),
}
}
}
impl Component for Colli... | true |
f15b08d01daf31f58ace97a0712198330eb6b1be | Rust | kezenator/adventofcode | /2020/src/y2020/d03/mod.rs | UTF-8 | 1,467 | 2.984375 | 3 | [
"MIT"
] | permissive | use crate::support::*;
const EXAMPLE: &str = "..##.......\n#...#...#..\n.#....#..#.\n..#.#...#.#\n.#...##..#.\n..#.##.....\n.#.#.#....#\n.#........#\n#.##...#...\n#...##....#\n.#..#...#.#\n";
const INPUT: &str = include_str!("input.txt");
pub fn count_trees_down_slope(lines: &Vec<String>, right: usize, down: usize) -... | true |
c3c48a91e58e5224c3f8d4e2cde4c55234cac0f8 | Rust | FyroxEngine/Fyrox | /fyrox-ui/src/border.rs | UTF-8 | 8,193 | 3.109375 | 3 | [
"MIT"
] | permissive | #![warn(missing_docs)]
//! The Border widget provides a stylized, static border around its child widget. See [`Border`] docs for more info and
//! usage examples.
use crate::{
core::{algebra::Vector2, math::Rect, pool::Handle, scope_profile},
define_constructor,
draw::{CommandTexture, Draw, DrawingContext... | true |
db754936be6fbd91b30771a9ac1868a9f6f4884d | Rust | spacemaison/zellij-sticky-cwd | /src/main.rs | UTF-8 | 984 | 2.71875 | 3 | [] | no_license | use std::path::PathBuf;
use zellij_tile::prelude::*;
#[derive(Default)]
struct State {
cwd: Option<PathBuf>,
}
register_plugin!(State);
impl ZellijPlugin for State {
fn load(&mut self) {
subscribe(&[ EventType::Action, EventType::PaneUpdate ]);
}
fn update(&mut self, event: Event) {
... | true |
ca145bb99941a4eadb799e1978ceadc2b2974d60 | Rust | RSWilli/advent-of-code | /2022/rust/lib/src/spatial/parse.rs | UTF-8 | 2,657 | 3.0625 | 3 | [] | no_license | use std::{error::Error, str::FromStr};
use super::{dense::SpatialDense, point2d::Point2D};
impl FromStr for SpatialDense<Point2D, char> {
type Err = Box<dyn Error>;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let lines: Vec<_> = s.lines().collect();
let height = lines.len();
l... | true |
a79ed4dfc53dea8aaf0008d9636448dae0ec03c8 | Rust | EmbarkStudios/kajiya | /crates/bin/view/src/scene.rs | UTF-8 | 401 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[derive(serde::Deserialize)]
pub struct SceneDesc {
pub instances: Vec<SceneInstanceDesc>,
}
fn default_instance_scale() -> [f32; 3] {
[1.0, 1.0, 1.0]
}
#[derive(serde::Deserialize)]
pub struct SceneInstanceDesc {
pub position: [f32; 3],
#[serde(default = "default_instance_scale")]
pub scale: [f3... | true |
3d3cf60adafd339bbb26ab5522a2f727b1114eb7 | Rust | kliml/ray-tracer | /src/material.rs | UTF-8 | 3,363 | 2.828125 | 3 | [] | no_license | use crate::{hittable, ray, utility::*, vec};
use rand::prelude::*;
pub trait Material {
fn scatter(
&self,
ray: &mut ray::Ray,
record: &hittable::HitRecord,
attenuation: &mut vec::Color,
scattered: &mut ray::Ray,
rng: &mut ThreadRng,
) -> bool;
}
pub struct Lamb... | true |
1da9686a2f39627c29ffaa2beebb6071cb509af3 | Rust | t-fujiki/rur | /src/network.rs | UTF-8 | 1,038 | 3.03125 | 3 | [] | no_license | use std::net::TcpStream;
use std::io::prelude::*;
use std::io;
use std::io::{BufReader , BufWriter};
use std::net::{/* IpAddr, Ipv4Addr, SocketAddr, */ ToSocketAddrs};
pub fn read_line(reader: &mut BufReader<&TcpStream>) {
let mut msg = String::new();
reader.read_line(&mut msg).expect("RECEIVE FAILURE!!!");
... | true |
25c3b8e7aefdeb50794bdadeb76eeeea1d3a69c3 | Rust | VanillaBrooks/qbittorrent | /src/api.rs | UTF-8 | 7,440 | 2.59375 | 3 | [
"MIT"
] | permissive | use reqwest;
use serde_json;
use std::collections::BTreeMap;
// TODO: fix these to specifics
use super::data::*;
use super::error;
use super::queries::*;
#[derive(Debug)]
/// Main handle and access point to working with qbittorrent
///
/// Full documentation on provided methods is available here [here](https://github... | true |
25f78a39229ae840f4735c6a817ce112c607cf43 | Rust | gfreezy/APNS-in-Rust | /src/notification.rs | UTF-8 | 2,909 | 2.875 | 3 | [] | no_license | use std::io::Write;
use payload::Payload;
use rustc_serialize::{Encodable, json};
use rustc_serialize::hex::FromHex;
use byteorder::{BigEndian, WriteBytesExt};
const DEVICE_TOKEN_ITEM_ID: u8 = 1;
const PAYLOAD_ITEM_ID: u8 = 2;
const NOTIFICATION_IDENTIFIER_ITEM_ID:u8 = 3;
const EXPIRATION_DATE_ITEM_ID: u8 = 4;
const ... | true |
63e624b8768545095b9a63fdd6aec0f2589c88f2 | Rust | spliner/advent-of-code-2019 | /rust/day9/src/lib.rs | UTF-8 | 817 | 2.921875 | 3 | [] | no_license | use std::error::Error;
use std::fs;
use intcode::Intcode;
pub mod config;
pub mod intcode;
pub fn run(config: config::Config) -> Result<(), Box<dyn Error>> {
let program: Vec<i64> = fs::read_to_string(config.filename)?
.split(",")
.map(|s| s.trim().parse::<i64>().unwrap())
.collect();
... | true |
ea028dfc011d87cabc2a8049b04709d3b74accba | Rust | benbrunton/pusoy_dos_server | /project/src/data_access/game.rs | UTF-8 | 20,054 | 2.578125 | 3 | [] | no_license | use std::str;
use std::collections::HashMap;
use model::game::Game as GameModel;
use hyper::client::Client;
use hyper::{Method, Request};
use hyper::header::ContentType;
use tokio_core::reactor::Core;
use chrono::prelude::*;
use chrono::Utc;
use mysql;
use serde_json;
#[derive(Serialize, Deserialize)]
struct Player{
... | true |
0792463f72c4ff9741e654fe9ced0e1f11d9b32e | Rust | Devolutions/IronRDP | /crates/ironrdp-session/src/pointer.rs | UTF-8 | 639 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::collections::HashMap;
use std::rc::Rc;
use ironrdp_graphics::pointer::DecodedPointer;
#[derive(Debug, Clone, Default)]
pub struct PointerCache {
// TODO(@pacancoder) maybe use Vec<Optional<...>> instead?
cache: HashMap<usize, Rc<DecodedPointer>>,
}
impl PointerCache {
pub fn insert(&mut self, id... | true |
870cdc5a47f284239f179f2e2eaffb0fb50a2637 | Rust | OneSignal/L3-37 | /l337-redis/src/lib.rs | UTF-8 | 8,104 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Postgres adapater for l3-37 pool
// #![deny(missing_docs, missing_debug_implementations)]
use async_trait::async_trait;
use futures::{
channel::oneshot,
future::{self, BoxFuture},
};
use redis::aio::{ConnectionLike, MultiplexedConnection};
use redis::{Client, Cmd, IntoConnectionInfo, Pipeline, RedisError, ... | true |
2a50a28ee4c6c81f4c47b6fa8adabdc61230db48 | Rust | jrdzha/revaultd | /src/daemon/control.rs | UTF-8 | 20,153 | 2.65625 | 3 | [
"BSD-3-Clause"
] | permissive | //! By itself, the daemon is not doing much: it basically just keeps its database updated with the
//! chain events in the bitcoind thread.
//! Any process is at first initiated by a manual interaction. This interaction is possible using the
//! JSONRPC api, which events are handled in the RPC thread.
//!
//! The main ... | true |
5749029afd46042d28e0f7b796bb45c212af71cb | Rust | yingang/rust-training | /rust-lib/src/encoder.rs | UTF-8 | 1,029 | 3.515625 | 4 | [] | no_license | use anyhow::Result;
pub trait Encoder {
fn encode(&self) -> Result<Vec<u8>>;
}
pub struct Event<Id, Data> {
id: Id,
data: Data,
}
impl<Id: Encoder, Data: Encoder> Event<Id, Data> {
pub fn new(id: Id, data: Data) -> Self { Self { id, data } }
pub fn encode(&self) -> Result<Vec<u8>> {
let ... | true |
dd2d26f2c7452b81fee1db4c22aaf4c160d15ad2 | Rust | AlecFaye/Poker-Hand-Evaluator | /Rust/poker/src/Poker.rs | UTF-8 | 15,431 | 3.40625 | 3 | [] | no_license | // Tran Kelvin Lim (500769478)
// Section 01
//
// Section
struct Player {
hand: [u32; 7],
value: u32,
combo: [usize; 5],
}
fn buildPlayer(pHand: [u32; 7]) -> Player {
Player {
hand: pHand,
value: 0,
combo: [0, 0, 0, 0, 0],
}
}
fn sortHand(mut player: Player) -> Player ... | true |
27d6111a20fe7b47f35e6725e01de6625f6837b6 | Rust | faradayio/scrubcsv | /src/main.rs | UTF-8 | 12,865 | 2.796875 | 3 | [] | no_license | #![warn(clippy::all)]
#![forbid(unsafe_code)]
// Import from other crates.
use csv::ByteRecord;
use humansize::{file_size_opts, FileSize};
use lazy_static::lazy_static;
use log::debug;
use regex::bytes::Regex;
use std::{
borrow::Cow,
fs,
io::{self, prelude::*},
path::PathBuf,
process,
};
use struct... | true |
dcb89778720e3496f3ffc7766b5592871bfd0a0b | Rust | cloudhan/renderer | /src/material.rs | UTF-8 | 5,236 | 3.03125 | 3 | [] | no_license | use intersect::*;
use math::*;
use ray::*;
extern crate rand;
use self::rand::prelude::*;
fn random_in_unit_sphere(rng: &mut ThreadRng) -> Vec3 {
let mut p = Vec3::zeros();
loop {
p = 2.0 * Vec3::new(
rng.gen::<scalar>(),
rng.gen::<scalar>(),
rng.gen::<... | true |
55133e4d9850375cd163e1c123b81e2c03b8404e | Rust | lazear/spreadsheet | /tests/test.rs | UTF-8 | 1,782 | 3.0625 | 3 | [
"MIT"
] | permissive | use spreadsheet;
use spreadsheet::*;
#[test]
fn rowiter() {
let spread = Spreadsheet::read("test.csv", ',').unwrap();
let rows = spread
.iter_rows()
.map(Vec::from)
.collect::<Vec<Vec<Cell>>>();
assert_eq!(rows.len(), spread.rows);
assert_eq!(
rows[0],
vec![Cell:... | true |
0620aa8e6b1d6e63341d71f6dd49c4cceec531e4 | Rust | input-output-hk/chain-libs | /chain-vote/src/cryptography/zkps/correct_decryption/zkp.rs | UTF-8 | 3,897 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Non-interactive Zero Knowledge proof for correct ElGamal
//! decryption. We use the notation and scheme presented in
//! Figure 14 of the Treasury voting protocol spec.
//!
//! The proof is the following:
//!
//! `NIZK{(pk, C, M), (sk): M = Dec_sk(C) AND pk = g^sk}`
//!
//! This can be translated to the following p... | true |
d799d1f65d662db76915236306aa38874a054185 | Rust | domoritz/arrow2 | /src/buffer/bitmap.rs | UTF-8 | 18,866 | 3 | 3 | [
"Apache-2.0"
] | permissive | // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... | true |
9bd559d05fc66894b87b9d667c49333510d60850 | Rust | alexlai97/sorting_algorithm_demos | /src/bubblesort.rs | UTF-8 | 1,586 | 4.0625 | 4 | [] | no_license | /// Sort by repeatedly steps through the list, compares adjacent pairs and swaps them if they are
/// in the wrong order.
///
/// # Example
/// To-be-sorted array = ( 5, 1, 4, 2, 8 )
///
/// ## First Pass
/// ( **5 1** 4 2 8 ) → ( **1 5** 4 2 8 )
/// ( 1 **5 4** 2 8 ) → ( 1 **4 5** 2 8 ) * Swap since 5 > 4
/// ( 1... | true |
d8f712d118e35261ad9d057498cb994c1a75d8fa | Rust | sec-bit/zkp-toolkit | /scheme/src/r1cs/impl_lc.rs | UTF-8 | 12,365 | 2.765625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // The following code is from (scipr-lab's zexe)[https://github.com/scipr-lab/zexe] and thanks for their work
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub};
use math::Field;
use smallvec::smallvec;
use super::{LinearCombination, SmallVec, Variable};
impl<F: Field> AsRef<[(Variable, F)]> for LinearCombina... | true |
2341605e662ff236393230515724cf0f28bbc064 | Rust | inre/mioqu | /src/fragments.rs | UTF-8 | 2,336 | 3.8125 | 4 | [
"MIT"
] | permissive | pub trait Index {
fn from_usize(i: usize) -> Self;
fn as_usize(&self) -> usize;
}
#[derive(Debug)]
pub struct Fragments<E, I: Index> {
list: Vec<Option<E>>,
free: Vec<I>,
}
impl<E, I> Fragments<E, I> where I: Index {
pub fn new() -> Self {
Fragments {
list: Vec::new(),
... | true |
a2f87901d9c7d10d3b95411617c456809b5e9037 | Rust | nlanson/rail-network | /src/draw/lines.rs | UTF-8 | 2,447 | 3.328125 | 3 | [] | no_license | #![allow(non_snake_case, dead_code, unused_variables)]
/*
Line module that houses functions that
draw straight linesm two point turn lines
and one point turn ones.
*/
//Dependencies
use crate::{
Point2,
App,
Frame,
math
};
use super::{
util
};
/*
Takes in a start point, end point... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.