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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
f99efe0522dd8b308ae8c91404b64d0380581dd7 | Rust | omnistreams/omnistreams-concurrent-rs | /src/main.rs | UTF-8 | 2,273 | 2.90625 | 3 | [] | no_license | mod omnistreams_concurrent;
use omnistreams_core::{Producer};
use serde_json;
use serde_json::Value;
use ws::{listen, Handler, Sender, Result, Message, CloseCode};
use std::thread;
use std::sync::mpsc::{Sender as ChannelSender, Receiver as ChannelReceiver};
use std::sync::mpsc;
struct Server {
out: Sender,
t... | true |
a2d3fc0127630ab57c727199db0be50fb73a2303 | Rust | barudisshu/dive-into-rust | /dive_into_rust/src/chap17/mod.rs | UTF-8 | 9,181 | 4.28125 | 4 | [] | no_license | //!
//!
//! “解引用”(Deref)是“取引用”(Ref)的反操作。取引用,我们有`&`、`&mut`等操作符,对应的,解引用,我们有`*`操作符
//!
//!
//!
///
///
///
///
#[test]
fn _17_01_01_deref() {
let v1 = 1;
let p = &v1; // 取引用
let v2 = *p; // 解引用
assert_eq!(v1, v2);
}
///
/// 自定义解引用
/// 解引用的操作可以被自定义。方法是,实现标准库中的`std::ops::Deref`或者`std::ops:... | true |
f488fe7b9e50c337928c3c1036ce4105e8d01ed8 | Rust | briancabbott/GitHub-Repository-Downloader | /TypeScript/resources/code/ts_lib/Apollo-Latest/apollographql/apollo-rs/crates/apollo-compiler/src/validation/scalar.rs | UTF-8 | 1,581 | 2.578125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::sync::Arc;
use crate::{
diagnostics::{ApolloDiagnostic, DiagnosticData, Label},
hir::{self, DirectiveLocation},
ValidationDatabase,
};
pub fn validate_scalar_definitions(db: &dyn ValidationDatabase) -> Vec<ApolloDiagnostic> {
let mut diagnostics = Vec::new();
let defs = &db.type_system_d... | true |
95717af1f90fe779b408baf0baf8b5559e55c3c0 | Rust | lengocgiang/fantoccini | /src/cookies.rs | UTF-8 | 4,136 | 3.28125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Cookie-related functionality for WebDriver.
use serde::{Deserialize, Serialize};
use time::OffsetDateTime;
use webdriver::command::WebDriverCommand;
use crate::client::Client;
use crate::error;
/// Type alias for a [cookie::Cookie]
pub type Cookie<'a> = cookie::Cookie<'a>;
/// Representation of a cookie as [defi... | true |
f669e3b4d13cc5fe2e432fd55a1a00329f056e9c | Rust | maximestevenot/aws-key-rotator | /src/aws/config.rs | UTF-8 | 3,000 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use dirs::home_dir;
use ini::Ini;
use rusoto_iam::AccessKey;
const AUTOMATION_SECTION: &str = "automation";
pub struct AwsConfigurationManager {
credentials_file: Ini,
pub aws_profile: String,
pub aws_username: String,
pub aws_mfa_arn: String,
}
impl AwsConfigurationManager {... | true |
a8f6af835f4d479d2aad0808dc1ce09f0b2c32f2 | Rust | Tamschi/raw-seeders | /src/lib.rs | UTF-8 | 27,245 | 2.890625 | 3 | [] | no_license | use arrayvec::{Array, ArrayVec};
use cast::{i32, u32, usize};
use encoding::{all::WINDOWS_1252, DecoderTrap, Encoding as _};
use log::{debug, trace};
use serde::{
de::{self, DeserializeSeed as _},
ser::{self, SerializeSeq as _, SerializeTuple as _},
};
use serde_seeded::{seed, seeded, DeSeeder, Seeded, SerSeeder};
us... | true |
f1fa799182af6cab48f2a2d2608525668138781b | Rust | RustCrypto/KDFs | /hkdf/tests/tests.rs | UTF-8 | 14,821 | 2.71875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use core::iter;
use hex_literal::hex;
use hkdf::{Hkdf, HkdfExtract, SimpleHkdf, SimpleHkdfExtract};
use sha1::Sha1;
use sha2::{Sha256, Sha384, Sha512};
struct Test<'a> {
ikm: &'a [u8],
salt: &'a [u8],
info: &'a [u8],
prk: &'a [u8],
okm: &'a [u8],
}
// Test Vectors from https://tools.ietf.org/html... | true |
d11c3272087dfc9c6ebe6dbb1f26c15c96d7f81d | Rust | yukihane/shadove | /src/repository.rs | UTF-8 | 2,255 | 3 | 3 | [] | no_license | use crate::card::Card;
use bytes::Bytes;
use serde_json::Value;
use std::fs;
use std::fs::File;
use std::io::{BufReader, BufWriter, Error, Write};
static SAVE_FILE: &str = "data.bin";
// raw: request-bodyそのままファイル保存するならtrue.
pub fn fetch_force(raw: bool) {
if raw {
let json = tokio::runtime::Runtime::new()... | true |
b3767135c3915d4d430342c569ad7b3de6b0dc9f | Rust | Nyrox/motokigo | /src/scanner.rs | UTF-8 | 5,945 | 3.296875 | 3 | [] | no_license | use crate::ast::{Position, Spanned};
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
Out,
In,
Let,
Mut,
If,
Else,
For,
To,
Uniform,
Struct,
Int,
Float,
LeftParen,
RightParen,
LeftBrace,
RightBrace,
Equals,
EqualsEquals,
Comma,
Colon,
Plus,
Minus,
Star,
Slash,
Less,
LessEq,
Greater,
... | true |
10c0a8ad55ff2e97c6d0777d7d404841b63208c3 | Rust | znewman01/bellman-bignat | /src/util/gadget.rs | UTF-8 | 6,027 | 2.734375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use sapling_crypto::bellman::pairing::ff::ScalarEngine;
use sapling_crypto::bellman::pairing::Engine;
use sapling_crypto::bellman::{ConstraintSystem, LinearCombination, SynthesisError};
use sapling_crypto::circuit::num::AllocatedNum;
use hash::circuit::CircuitHasher;
use super::bit::Bit;
use OptionExt;
pub trait Gad... | true |
2be1d75ef838a54a6e0511f172c640626dc36e07 | Rust | getappa/appa | /src/commands/task/functions.rs | UTF-8 | 1,382 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use super::super::super::ConfigurationFile;
use super::{Task, TaskUpdate};
pub fn new(file: &str, task: &Task) {
let mut config = ConfigurationFile::new(file);
config.tasks.push(task.to_hashmap());
config.save(&file);
}
pub fn update(file: &str, task: &TaskUpdate) {
let ... | true |
7b961757964b1d7c4b51419f272b87066711626a | Rust | isgasho/yubihsm-rs | /src/session/error.rs | UTF-8 | 1,926 | 2.9375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Session error types
use crate::{
connector::ConnectionError, device::DeviceErrorKind, error::Error,
serialization::SerializationError,
};
/// Session errors
pub type SessionError = Error<SessionErrorKind>;
/// Session error kinds
#[derive(Copy, Clone, Eq, PartialEq, Debug, Fail)]
pub enum SessionErrorKin... | true |
4c78416e1af0cc45872d27eab91ca4261999628e | Rust | gregokent/tms570 | /src/emac/rxmbpenable/mod.rs | UTF-8 | 55,349 | 2.6875 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::RXMBPENABLE {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &... | true |
48f80a3cf99853718324180b7932375515a3b95d | Rust | jpatel531/learning-rust | /syntax/phrases/src/japanese/mod.rs | UTF-8 | 484 | 2.71875 | 3 | [] | no_license |
pub use self::greetings::hello; // brings it to this modue's scope
pub use self::farewells::goodbye; // allows us to do japanese::goodbye()
// alternatively we could say pub use self::greetings to put everything
// in greetings into public scope
// self can be seen as '.' ; super can be seen as '..'
// outside of u... | true |
ec89f3fbb33d220b9274b6309f4ffbfa46de486b | Rust | MMaazQureshi/Rust-Code | /iot 2-2/closures/src/main.rs | UTF-8 | 87 | 2.875 | 3 | [] | no_license | fn main() {
let mut x=2;
let mut f=|| x=x+2;
f();
println!("{}",x);
}
| true |
b1624650e6adacbd5bd1301dc46a4da5000d9a46 | Rust | tlent/advent-of-code | /year_2022/day_20/src/lib.rs | UTF-8 | 1,648 | 3.390625 | 3 | [] | no_license | use std::ptr;
pub const INPUT: &str = include_str!("../input.txt");
pub fn parse_input(input: &str) -> Vec<i64> {
input.lines().map(|line| line.parse().unwrap()).collect()
}
pub fn part_one(numbers: &[i64]) -> i64 {
let mut references = numbers.iter().collect::<Vec<_>>();
mix(numbers, &mut references);
... | true |
d67814a23553b3ed9ff38a4f0dde67765c69f9a6 | Rust | B123BG/FinalProj_GuessGame | /src/guess.rs | UTF-8 | 1,806 | 3.421875 | 3 | [
"WTFPL"
] | permissive | extern crate rand;
extern crate colored;
use std::io::*;
use std::cmp::Ordering;
use rand::Rng;
use colored::*;
static GREETING: &str = "=> Guess the number!";
static FIRST_PROMPT: &str = "Please input your guess:";
static PROMPT: &str = "New guess?";
static TOO_LOW: &str = "Too small!";
static TOO_HIGH: &str = "Too ... | true |
0e6ea14eecc2e819ffc5f61131b2096993256913 | Rust | ogata-k/GUI_cmp | /example_conrod/src/main.rs | UTF-8 | 5,808 | 2.625 | 3 | [] | no_license | #[macro_use]
extern crate conrod;
extern crate find_folder;
use conrod::{widget, color, Colorable, Borderable, Sizeable, Positionable, Labelable, Widget};
use conrod::backend::glium::glium;
use conrod::backend::glium::glium::{DisplayBuild, Surface};
// 使用するid一覧
widget_ids!(
struct Ids {
canvas,
nu... | true |
74cb606bd3e3871a2692ee43693c11f7a71b0e8f | Rust | tomasz-rozanski/wasm-plasma-effect | /src/lib.rs | UTF-8 | 3,267 | 2.796875 | 3 | [] | no_license | // src/lib.rs
// #![no_std]
// #[panic_handler]
// fn handle_panic(_: &core::panic::PanicInfo) -> ! {
// loop {}
// }
use core::sync::atomic::{AtomicU32, Ordering};
use std::f32::consts::PI;
static FRAME: AtomicU32 = AtomicU32::new(0);
const WIDTH: usize = 400;
const HEIGHT: usize = 400;
#[no_mangle]
static m... | true |
37fa0275c88d3f351e2e156e851910efe2ca28bf | Rust | BlackCrawler/airmash-protocol-rs | /src/packets/server/player_type.rs | UTF-8 | 288 | 2.53125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use enums::PlaneType;
use types::Player;
/// A player has switched planes.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PlayerType {
pub id: Player,
#[cfg_attr(feature = "serde", serde(rename = "type"))]
pub ty: PlaneType,
}
| true |
2056c1af6ccd70a9bfeeef97c8ccaea478712309 | Rust | dinfuehr/dora | /dora-runtime/src/stack.rs | UTF-8 | 6,393 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::ptr;
use crate::handle::{create_handle, Handle};
use crate::object::{alloc, Array, Int32Array, Ref, Stacktrace, StacktraceElement, Str};
use crate::threads::current_thread;
use crate::vm::{display_fct, get_vm, CodeId, CodeKind, VM};
use dora_bytecode::Location;
pub struct NativeStacktrace {
elems: Vec<St... | true |
8ead11f7d9b70ecb86acbf6ededa167779f3720a | Rust | ZcashFoundation/zebra | /zebrad/src/components/sync/recent_sync_lengths.rs | UTF-8 | 3,461 | 3.125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! A channel which holds a list of recent syncer response lengths.
use tokio::sync::watch;
#[cfg(test)]
mod tests;
/// A helper type which holds a list of recent syncer response lengths.
/// These sync lengths can be used to work out if Zebra has reached the end of the chain.
///
/// New lengths are added to the fr... | true |
0a03ebe09dd098cc2f0fd56e114ba3fe03c172fd | Rust | mullvad/jnix | /src/from_java/implementations/std/net.rs | UTF-8 | 2,873 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{FromJava, JnixEnv};
use jni::{
objects::JObject,
signature::{JavaType, Primitive},
};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
fn read_inet_address_octets<'env, 'o>(env: &JnixEnv<'env>, source: JObject<'o>) -> JObject<'env>
where
'o: 'env,
{
let class = env.get_class("java/net/InetAddres... | true |
74fbb27bd0e8d3209fccd76960aa27c9e79d9064 | Rust | GlenDC/fluent-rs | /src/syntax/errors.rs | UTF-8 | 7,370 | 3.125 | 3 | [] | no_license | extern crate term;
use std::fmt;
macro_rules! error {
($kind:expr) => {{
Err(ParserError {
info: None,
kind: $kind
})
}};
}
#[derive(Debug, PartialEq)]
pub struct ErrorInfo {
pub slice: String,
pub line: usize,
pub pos: usize,
}
#[derive(Debug, PartialEq)]... | true |
79ddd035e042cfd544f467dbc0a229bf4d1d1711 | Rust | Yinet-project/asymmetric-crypto | /src/prelude.rs | UTF-8 | 1,198 | 2.578125 | 3 | [] | no_license | use crate::CryptoError;
use core::fmt::Debug;
use dislog_hal::{Bytes, Hasher};
use hex::{FromHex, ToHex};
use rand::RngCore;
use serde::{Deserialize, Serialize};
pub trait Splitable {
type Half: Debug + ToHex + FromHex + PartialEq;
fn split_finalize(self) -> (Self::Half, Self::Half);
}
pub trait Keypair: Def... | true |
10042ec91d13536254d5879c67ff4b77658d6edf | Rust | lengfangbing/rust | /rust_basic_grammar/src/structs/structs.rs | UTF-8 | 1,921 | 3.921875 | 4 | [] | no_license | struct User {
name: String,
email: String,
count: i64,
active: bool,
}
impl User {
fn email (&self) -> String {
String::from(self.email.to_owned() + "@bytedance.com")
}
}
pub fn get_comp_email () -> String{
let user = User {
name: "lengfangbing".to_owned(),
email: "l... | true |
51f322664a53ec488839fe19ce18d36ebed41f5f | Rust | cramertj/rust-jack | /src/test.rs | UTF-8 | 1,862 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::{thread, time};
use super::*;
fn info_handler(msg: &str) {
panic!("Info: {}", msg);
}
fn error_handler(msg: &str) {
panic!("Error Occurred!: {}", msg);
}
struct TestHandler {
pub callbacks_used: HashSet<&'static str>,
}
impl TestHandler {
pub fn new() -> Self ... | true |
2044d7adba99a4d891d2fa00d5d2e1ca712b225b | Rust | calvinfo/aoc-2020 | /day-09/src/main.rs | UTF-8 | 1,830 | 2.859375 | 3 | [] | no_license | use std::{fs::File, io::Read};
fn main() {
let test = load(String::from("./inp-test"));
let test_v = load_xmas(test);
let test_sol = part1(&test_v, 5);
println!("Part 1 test: {}", test_sol);
let test_sol2 = part2(&test_v, 127);
println!("Part 2 test: {}", test_sol2);
let inp = load(Strin... | true |
cb56d840035ca18fc5c5e86341397075829c4a9e | Rust | djedou/djed_maths | /src/linear_algebra/vector/vector2d.rs | UTF-8 | 518 | 3.5 | 4 | [] | no_license | use std::fmt::Debug;
use super::vector::Vector;
/// It has all functions and methods of Vector<T>
pub type Vector2D<T> = Vector<T>;
/*
impl<T: Debug + Clone + Default> Vector2D<T> {
/// new Vector2D
pub fn new_vec2d(value: &[T; 2]) -> Vector2D<T> {
Vector2D::new_from_vec(&value.to_vec())
}
}
#[... | true |
7ec9de92506121bf87c9cc3fec2a03fb8cbe53ea | Rust | jgjin/486-proj-data | /src/track.rs | UTF-8 | 3,313 | 2.546875 | 3 | [] | no_license | use std::{
sync::{
Arc,
RwLock,
},
};
use futures::{
Future,
};
use crate::{
client::{
ClientRing,
},
common_types::{
Paging,
},
track_types::{
AudioAnalysis,
AudioFeatures,
TrackFull,
},
utils::{
get_with_retry,
... | true |
b80f56aee153947e2b620d0df626eff7a3c3b51c | Rust | coadler/thingvellir | /src/error.rs | UTF-8 | 3,753 | 2.875 | 3 | [
"MIT"
] | permissive | use std::sync::{Arc, Mutex};
use thiserror::Error;
use tokio::sync::mpsc::error::SendError as MpscSendError;
use tokio::sync::oneshot::error::RecvError as OneShotRecvError;
#[derive(Debug, Clone, Error)]
pub enum ShardError {
#[error("shard is at capacity, and is unable to evict any records")]
ShardAtCapacity... | true |
fa445b08cff15c8cdd6363eb050987ec35e70b7d | Rust | MiSawa/dotter | /src/config.rs | UTF-8 | 17,667 | 2.609375 | 3 | [
"Unlicense"
] | permissive | use anyhow::{Context, Result};
use serde::{Deserialize, Deserializer, Serialize};
use crate::filesystem;
use std::collections::{BTreeMap, BTreeSet};
use std::fs;
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
#[serde(untagged)]
pub enum UnixUser {
... | true |
e3643420d9d6cbd2108e9bf956d882bdef221b20 | Rust | snsvrno/settingsfile-rs | /src/structs/settings.rs | UTF-8 | 29,361 | 3.765625 | 4 | [] | no_license |
use Format;
use Type;
use SupportedType;
use std::ops::{Add,AddAssign};
use std::io::prelude::*;
use std::collections::HashMap;
use std::fs::File;
use std::fs;
use failure::Error;
/// Basic one file settings
///
/// The main guts of `Settingsfile-rs`. The `Settings` struct
/// interacts with the file system to seria... | true |
18ecf9d36ae0a3bb365f355077a0348ae8f1d9b7 | Rust | mapx/leetcode-rust | /src/n0007_reverse_integer.rs | UTF-8 | 1,648 | 3.734375 | 4 | [
"MIT"
] | permissive | /**
* [7] Reverse Integer
*
* Given a 32-bit signed integer, reverse digits of an integer.
*
* Example 1:
*
*
* Input: 123
* Output: 321
*
*
* Example 2:
*
*
* Input: -123
* Output: -321
*
*
* Example 3:
*
*
* Input: 120
* Output: 21
*
*
* Note:
* Assume we are dealing with an environment whi... | true |
d826454fc912266af0226b9f15065ac00fecd02a | Rust | ViliamVadocz/Autoplay | /onitama/src/bot.rs | UTF-8 | 4,078 | 2.984375 | 3 | [] | no_license | use std::cmp::Ordering;
use bitwise::TestBit;
use crate::cards::{shift_bitmap, BitIter};
use crate::game::{Game, Move};
const PIECE_WEIGHT: i64 = 10;
const SQUARE_WEIGHT: i64 = 1;
const CHECK_WEIGHT: i64 = 10;
// positive is good for me, negative is good for other
pub fn game_eval(g: &Game) -> i64 {
let mut my_... | true |
5f81ec871c64177d106a72c85d21daa1dca424a2 | Rust | pendulum-project/ntpd-rs | /ntpd/src/ctl.rs | UTF-8 | 14,364 | 2.8125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{path::PathBuf, process::ExitCode};
use crate::daemon::{config::CliArg, tracing::LogLevel, Config, ObservableState};
use tracing_subscriber::util::SubscriberInitExt;
const USAGE_MSG: &str = "\
usage: ntp-ctl validate [-c PATH]
ntp-ctl status [-f FORMAT] [-c PATH] [-o PATH]
ntp-ctl -h | ntp-ctl ... | true |
b4f7cd79db9ab38bd6163cba2ac94a1d717afe8f | Rust | benjamingroeber/adventofcode18 | /day02/src/main.rs | UTF-8 | 2,249 | 3.421875 | 3 | [] | no_license | use std::collections::HashMap;
use std::error::Error;
use std::io;
use std::io::Read;
fn main() {
if let Err(e) = run() {
eprintln!("Error: {}", e)
}
}
fn run() -> Result<(), Box<Error>> {
let mut input = String::new();
io::stdin().read_to_string(&mut input)?;
let ids: Vec<_> = input.lines... | true |
4bb7cf3837e65b4a6e19f80fb14ac154343fc726 | Rust | mikedilger/mime-multipart | /src/lib.rs | UTF-8 | 22,623 | 2.703125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2016-2020 mime-multipart Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except ... | true |
d810b932e5f0a589ccd805618338000f81f850e3 | Rust | neoblackcap/starship | /src/modules/aws.rs | UTF-8 | 3,507 | 2.859375 | 3 | [
"ISC"
] | permissive | use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use std::str::FromStr;
use super::{Context, Module, RootModuleConfig};
use crate::configs::aws::AwsConfig;
use crate::formatter::StringFormatter;
type Profile = String;
type Region = String;
fn... | true |
1f9baac5fcf645646eea71f77ae041ebd87ec173 | Rust | kbukum/rust_skeleton | /src/bin/server.rs | UTF-8 | 1,123 | 3 | 3 | [
"MIT"
] | permissive | extern crate argparse;
extern crate rust_skeleton;
use rust_skeleton::Server;
use rust_skeleton::Props;
use argparse::{ArgumentParser, Store, Print};
fn main() {
let props = get_options();
println!("{:?}", props);
Server::serve(props);
}
fn get_options() -> Props {
let mut port: i32 = 8080;
let m... | true |
3d421a1a6f71d7253e59068cc1a7d6bd1fedb0b2 | Rust | coinmini/heim | /heim-process/src/os/linux/mod.rs | UTF-8 | 1,303 | 2.609375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Linux-specific extensions.
use heim_common::prelude::{BoxFuture, BoxStream};
use crate::ProcessResult;
mod io_counters;
mod memory;
pub use self::io_counters::IoCounters;
pub use self::memory::MemoryExt;
/// Linux-specific extension to [Process]
///
/// [Process]: ../../struct.Process.html
pub trait ProcessExt... | true |
7c62badfc1143846f1148b89882a6364f37a6890 | Rust | lauromoura/adventofcode | /advent2020/src/day_02.rs | UTF-8 | 1,657 | 3.265625 | 3 | [
"Unlicense"
] | permissive | use regex::Regex;
pub fn first() {
let filename = "day02-01.txt";
let lines = super::helpers::read_lines(filename);
println!(
"Day 2 - 1: {}",
lines
.filter(|i| check_password_mk1(i.as_ref().unwrap()))
.count()
);
}
fn parse_line(line: &str) -> regex::Captures {... | true |
50736ce1fdc4562b9f834932d498d92b4330f893 | Rust | mattsse/crossref-rs | /src/cn.rs | UTF-8 | 1,747 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize)]
#[allow(missing_docs)]
pub enum CnFormat {
RdfXml,
Turtle,
CiteProcJson,
CiteProcJsonIsh,
Text,
Ris,
BibTex,
CrossrefXml,
DataciteXml,
BibEntry,
CrossrefTdm,
}
impl CnFormat {
/// the mime identifie... | true |
53ba14ee5b7d776478dc0160a15aff7acecb4e07 | Rust | hoodie/bill-rs | /src/product.rs | UTF-8 | 1,871 | 3.3125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[cfg(feature = "serde")]
use serde::ser::{Serialize, SerializeStruct, Serializer};
use super::{Money, Tax};
/// Describes one particular product.
/// Amount is handled by `BillItem`
///
/// You can write your own product, just implement `BillProduct`
#[derive(Clone, Copy, Debug)]
pub struct Product<'a> {
pub nam... | true |
01d7d381e2e5465efc33420e7c5f3803c8e104d9 | Rust | reinaldogoes/snake_os_in_rs | /src/game2048/world.rs | UTF-8 | 7,143 | 2.9375 | 3 | [
"MIT"
] | permissive | use crate::display::{Color, Display};
use crate::game2048::board;
use crate::serial_println;
use crate::world::{CharsBuf, Direction, Game, GameState, ScreenPos};
use core::fmt::Write;
use pc_keyboard::{DecodedKey, KeyCode};
const BOARD_SIZE: usize = 4;
const MARGIN_PIXELS: usize = 4; // pixels
const BOARDER_PIXELS: us... | true |
674055ea0dc98e44449ca1212befde27f74d8071 | Rust | Spirou07/rsolve | /src/solving/heuristics/branching/random.rs | UTF-8 | 3,996 | 3.5625 | 4 | [
"MIT"
] | permissive | extern crate rand;
use solving::heuristics::BranchingHeuristic;
use core::*;
use self::rand::Rng;
// -----------------------------------------------------------------------------------------------
/// A Random heuristic for selecting decision variables.
// ------------------------------------------------------------... | true |
231babfde05cd4e66857725155a3aeeb285d5e49 | Rust | frececroka/paketbote | /src/db/account.rs | UTF-8 | 1,142 | 2.578125 | 3 | [] | no_license | use diesel::prelude::*;
use diesel::result::Error;
use fehler::throws;
use crate::db::models::{Account, NewAccount, Token};
use super::schema;
#[throws]
pub fn create_account(conn: &PgConnection, account: &NewAccount) -> Account {
use schema::account::dsl as a;
diesel::insert_into(a::account)
.values... | true |
f5af82be9bf1f7a7de5f4f3b4aca1a95fe62630a | Rust | m-kann0/atcoder-rust | /examples/abc024_c.rs | UTF-8 | 2,816 | 3.578125 | 4 | [] | no_license | use std::io::Read;
fn main() {
let mut buf = String::new();
std::io::stdin().read_to_string(&mut buf).unwrap();
let answer = solve(&buf);
println!("{}", answer);
}
fn solve(input: &str) -> String {
let mut iterator = input.split_whitespace();
let _n: usize = iterator.next().unwrap().parse()... | true |
fb82f81daa6d1980a05bd6810cd60c3acdaa348e | Rust | sebastianandreasson/2d-universe-sim | /src/simulator/src/physics.rs | UTF-8 | 1,946 | 3.078125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::Cell;
use crate::Element;
use crate::Particle;
use crate::Universe;
pub struct Physics<'a> {
pub x: i32,
pub y: i32,
pub universe: &'a mut Universe,
}
impl<'a> Physics<'a> {
pub fn get(&mut self, dx: i8, dy: i8) -> Cell {
let nx = self.x + dx as i32;
let ny = self.y + dy as i32;
if nx <... | true |
c7f13fc41e92afff003ef385f61a07680c927b60 | Rust | kerryeon/n3 | /n3-machine-ffi/src/smp.rs | UTF-8 | 2,817 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::env;
use std::marker::PhantomData;
use std::mem;
use raw_sync::locks::{LockImpl, LockInit, Mutex};
use shared_memory::{Shmem, ShmemConf, ShmemError};
use crate::error::{Result, SMPError};
pub struct SMPool<SM> {
name: String,
shmem: mem::ManuallyDrop<Shmem>,
mutex: mem::ManuallyDrop<Box<dyn Lock... | true |
719b328eef221a9ed8503cb4eb391b1872fa00f8 | Rust | jadestrong/rust-dip | /src/lib.rs | UTF-8 | 2,272 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
}
#[wasm_bindgen]
pub fn console_log_from_wasm(input_string: String) {
let result = format!("{}", input_string);
log(&result);
}
const KW: usize = 3;
const KH: usize = 3;
const KERNEL_... | true |
ab33d6506ee306a811720fc04dc36b25f357b651 | Rust | laanwj/k210-sdk-stuff | /util/esp8266at/src/traits.rs | UTF-8 | 729 | 3.078125 | 3 | [
"ISC"
] | permissive | use core::fmt;
#[cfg(feature = "std")]
use std::io;
/** The trait that's required of anything acting as serial port writer.
* It is much simpler than io::Write. The reason for implementing our own trait here
* is that this is compatible with no_std.
*/
pub trait Write {
type Error: fmt::Debug;
/** Write al... | true |
f019b1837cd6691a5c17fd2d849f72f89a539686 | Rust | gemarcano/libtock-rs | /examples-features/libtock_test.rs | UTF-8 | 6,693 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | // Libtock regression tests to be used with real hardware.
// Requires P0.03 and P0.04 to be connected (on a nRF52 DK) and
// P0.01 and P0.03 to be connected (on a nRF52840dk).
#![no_std]
extern crate alloc;
use alloc::string::String;
use core::fmt::Write;
use core::future::Future;
use core::mem;
use core::pin::Pin;
... | true |
c00c3c4ed9e735be3876c75895ba0169490933f7 | Rust | lukethacoder/rust-adventures | /audio-playground/src/watch_exec.rs | UTF-8 | 880 | 2.546875 | 3 | [] | no_license | use crate::fs_watcher::FsWatcher;
#[cfg(target_os = "linux")]
use crate::utils;
#[cfg(windows)]
use crate::utils::get_win32_ready_drives;
pub fn run() {
#[cfg(windows)]
win_run();
#[cfg(target_os = "linux")]
linux_run();
#[cfg(target_os = "macos")]
macos_run();
}
#[cfg(target_os = "macos")]
fn macos_ru... | true |
9d0997d19817491ef8d01cff5601e58a77cb7dd2 | Rust | sivizius/rla | /source/lib.rs | UTF-8 | 7,221 | 3.21875 | 3 | [] | no_license | //! RLA is a set of helper-functions for formal specification
//! to design, model, document, and verify programs,
//! especially concurrent systems and distributed systems.
#![warn(clippy::all)]
#![allow(clippy::suspicious_else_formatting)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![warn(miss... | true |
ed3cc099a2feb030a7ff859d0461aade1037b0e3 | Rust | GopherJ/rsmq-async-rs | /tests/test.rs | UTF-8 | 7,218 | 2.828125 | 3 | [
"MIT"
] | permissive | use rsmq_async_lite::{Rsmq, RsmqError, RsmqOptions};
use tokio::time::sleep;
use std::time::Duration;
#[tokio::test]
async fn send_receiving_deleting_message() {
let mut rsmq = Rsmq::<String>::new(RsmqOptions {
db: 0,
realtime: true,
..Default::default()
})
.await
.unwrap();
... | true |
d264a6303686b254d21b4f9a72b160041cb0444e | Rust | addam128/cextractor | /src/utils.rs | UTF-8 | 653 | 2.71875 | 3 | [
"MIT"
] | permissive |
#[derive(Debug)]
pub(crate) enum Error {
Io(std::io::Error),
Utf8Conversion(std::str::Utf8Error),
IsADirectory,
Regex(regex::Error),
FancyRegex(fancy_regex::Error),
BadRead,
UserChoice
}
impl From<std::io::Error> for Error {
fn from(err: std::io::Error) -> Self {Error::Io(err)}
}
im... | true |
1d9ba349b0e2ebfb668f18fdb09b37df04336fba | Rust | fu5ha/rayn2d | /src/material.rs | UTF-8 | 536 | 2.859375 | 3 | [] | no_license | use glam::{ Vec2, Vec3 };
pub trait Material {
fn evaluate_brdf(&self, ray_spectrum: Vec3, hit_pos: Vec2, incident: Vec2, normal: Vec2, out: Vec2) -> Vec3;
fn get_ior(&self) -> f32;
}
#[derive(Clone, Copy, Debug)]
pub struct Lambertian {
pub ior: f32,
pub color: Vec3,
}
impl Material for Lambertian {... | true |
1d2586172e44ba2a971715a0e9b734c86109a135 | Rust | xfoxfu/limeltl | /src/enforcers/ltl_afa.rs | UTF-8 | 2,914 | 3.078125 | 3 | [] | no_license | use super::Enforcer;
use crate::bool_logic::{PropExpr, Variable};
use crate::context::Context;
/// 保证 AFA 结构能够生成 LTL_f 公式,检查其存在符合要求的子树
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub struct LTLSubtreeEnforcer(Variable);
impl LTLSubtreeEnforcer {
/// 构造 LTL Enforcer
///
/// `ty` - 当前节点类型变量
///
///... | true |
60d536bd70e989752e5f9118e0dd55d3b81a8165 | Rust | peckpeck/rudder-language | /src/parser.rs | UTF-8 | 35,225 | 2.5625 | 3 | [] | no_license | mod error;
mod token;
use nom::branch::*;
use nom::bytes::complete::*;
use nom::character::complete::*;
use nom::combinator::*;
use nom::multi::*;
use nom::number::complete::*;
use nom::sequence::*;
use std::collections::HashMap;
use error::*;
use crate::error::*;
// reexport tokens
pub use token::Token;
#[allow(unu... | true |
1d46e4f5402a2192164a4e21f9f7a37695fb1dba | Rust | fengneu/cppbuild | /src/program.rs | UTF-8 | 8,916 | 3.015625 | 3 | [] | no_license | use crate::project::Project;
use std::cell::RefCell;
use std::io::Write;
use std::path::Path;
use std::process::Command;
use std::time::SystemTime;
use walkdir::WalkDir;
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub enum BuildMode {
Debug,
Release,
Normal,
Example,
Test,
}
impl BuildMode {
pu... | true |
fa1a88425378feaaec2c6078fd124eccf8b10931 | Rust | mhaig/adventofcode | /2022/day04/src/main.rs | UTF-8 | 1,272 | 3.015625 | 3 | [] | no_license | use std::io::{self, BufRead};
fn main() {
let lines = io::stdin().lock().lines();
let mut fully_contains: u32 = 0;
let mut overlaps: u32 = 0;
for line in lines {
let l = line.unwrap();
if !l.is_empty() {
let l_parts: Vec<&str> = l.split(',').collect();
let elf_... | true |
63abab05f4feb5468f3b8b90f62c9ba2c4e4211f | Rust | nix-rust/nix | /src/errno.rs | UTF-8 | 111,356 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::Result;
use cfg_if::cfg_if;
use libc::{c_int, c_void};
use std::convert::TryFrom;
use std::{error, fmt, io};
pub use self::consts::*;
cfg_if! {
if #[cfg(any(target_os = "freebsd",
target_os = "ios",
target_os = "macos"))] {
unsafe fn errno_location() -> *mut c_... | true |
5dd8bbd67fab59c7d9663a0c94fac790545db8c3 | Rust | noahwillcrow/alpha-noah | /src/turn_takers/weighted_random_selection_turn_taker.rs | UTF-8 | 2,943 | 3.078125 | 3 | [
"MIT"
] | permissive | use crate::enums::DecideNextStateError;
use crate::traits::{BasicGameState, GameRulesAuthority, GameStateWeightsCalculator, TurnTaker};
use rand::distributions::WeightedIndex;
use rand::prelude::*;
pub struct WeightedRandomSelectionTurnTaker<'a, GameState: BasicGameState> {
game_rules_authority: &'a dyn GameRulesA... | true |
9c37c84ab5814a4193a74d7e54862963d4869c95 | Rust | isgasho/capability-providers | /kvredis/tests/kv_test.rs | UTF-8 | 9,746 | 2.671875 | 3 | [] | no_license | use wasmbus_rpc::{provider::prelude::Context, RpcResult};
use wasmcloud_interface_keyvalue::*;
use wasmcloud_test_util::{
check, check_eq,
cli::print_test_results,
provider_test::{test_provider, Provider},
testing::{TestOptions, TestResult},
};
#[allow(unused_imports)]
use wasmcloud_test_util::{run_sele... | true |
c9289a19ad98d102bd2a973d39650f348f7dc2df | Rust | Byron/gitoxide | /gix-refspec/src/types.rs | UTF-8 | 918 | 3.125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::instruction;
/// The way to interpret a refspec.
#[derive(PartialOrd, Ord, PartialEq, Eq, Copy, Clone, Hash, Debug)]
pub(crate) enum Mode {
/// Apply standard rules for refspecs which are including refs with specific rules related to allowing fast forwards of destinations.
Normal,
/// Even thoug... | true |
8ead1047f639ea39bba42743f63b476b4ce8b6e3 | Rust | dwijnand/hubcaps | /src/releases/mod.rs | UTF-8 | 7,004 | 2.546875 | 3 | [
"MIT"
] | permissive | //! Releases interface
extern crate serde_json;
use futures::future;
use hyper::client::Connect;
use {Future, Github};
use users::User;
pub struct Assets<C>
where
C: Clone + Connect,
{
github: Github<C>,
owner: String,
repo: String,
releaseid: u64,
}
impl<C: Connect + Clone> Assets<C> {
#[do... | true |
3f1407075fb934e4481de6a052fad6272d8d280e | Rust | Drakulix/simplelog.rs | /examples/rgb_colors.rs | UTF-8 | 1,103 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[cfg(all(not(target_family = "windows"), feature = "termcolor"))]
use log::*;
#[cfg(all(not(target_family = "windows"), feature = "termcolor"))]
use simplelog::*;
#[cfg(all(not(target_family = "windows"), feature = "termcolor"))]
fn main() {
let config = ConfigBuilder::new()
.set_level_color(Level::Error,... | true |
d273135be67780f0b77be5e4fdfdd5ce2dd6dad1 | Rust | Spanfile/AoC-2018 | /src/puzzles/day5.rs | UTF-8 | 1,708 | 2.984375 | 3 | [] | no_license | use super::runner;
use crate::input::{self, Input};
use aoc_derive::aoc;
pub fn solve() {
runner::run_solutions(&do_solve_1, &do_solve_2);
}
fn react_polymer(polymer: String) -> i32 {
let mut chars = polymer.chars().collect::<Vec<char>>();
let mut new_chars = Vec::new();
let mut drop_next = false;
... | true |
244f9bfe2668f680decc5b408eaf258e5b2adf99 | Rust | the6p4c/catteprinter | /src/commands.rs | UTF-8 | 3,718 | 3.125 | 3 | [] | no_license | #![allow(clippy::new_ret_no_self)]
use crate::command::Command;
use itertools::Itertools;
pub struct FeedPaper;
impl FeedPaper {
const COMMAND: u8 = 0xa1;
pub fn new(steps: u16) -> Command {
Command::new(Self::COMMAND, &steps.to_le_bytes())
}
}
pub struct PrintLine;
impl PrintLine {
const C... | true |
6a6f10da4cb6c1c75ee1d9da8ffe335fbe57b606 | Rust | shelbyd/tassist | /src/options.rs | UTF-8 | 697 | 3.046875 | 3 | [] | no_license | #[derive(StructOpt, Debug)]
pub struct Options {
#[structopt(subcommand)]
pub command: Command,
}
#[derive(StructOpt, Debug)]
pub enum Command {
#[structopt(name = "play")]
Play(Play),
}
#[derive(StructOpt, Debug)]
pub struct Play {
/// Which .tas file to play
pub tas_file: String,
//... | true |
7fa7d3af27fac92616aa315e7e5ef9aed33d3b5e | Rust | niceucode/traffic-lights-rust | /src/lib/solutions/fair_share.rs | UTF-8 | 1,390 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::lib::input::{IntersectionID, Problem, Street};
use crate::lib::output::{IntersectionSchedule, StreetSchedule, Submission};
use crate::lib::solutions::Solution;
use std::collections::HashMap;
pub struct Solver {
pub problem: Problem,
}
struct Intersection {
in_streets: Vec<Street>,
}
impl Solution ... | true |
d08d93c88c74bfc35c94c33e9b132f158d3da6dc | Rust | andrewcharlton/advent-of-code | /2018/day01/src/main.rs | UTF-8 | 1,377 | 3.59375 | 4 | [
"MIT"
] | permissive | use std::collections::HashSet;
use std::fs;
fn main() {
let changes = fs::read_to_string("input").expect("Couldn't open file");
let changes = parse_file(changes);
println!("Part one: {}", file_sum(&changes));
println!("Part two: {}", repeat_sum(&changes));
}
fn parse_file(contents: String) -> Vec<i64... | true |
7e0c54ea741324972d9b8d2249e992595d06174c | Rust | MWatch/kernel | /kernel/src/system/mod.rs | UTF-8 | 1,832 | 2.5625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use time::{Date, Time};
use crate::application::{application_manager::ApplicationManager, FrameBuffer};
use heapless::String;
use self::{bms::BatteryManagement, notification::NotificationManager};
pub mod bms;
pub mod input;
pub mod notification;
pub mod syscall;
pub trait Clock {
fn get_time(&self) -> Time;
... | true |
028d003883acf2c52fe44d61b5ce1c4185b86c8b | Rust | enso-org/enso | /lib/rust/ensogl/core/src/display/shape/primitive/def/modifier.rs | UTF-8 | 5,176 | 3.0625 | 3 | [
"AGPL-3.0-only",
"Apache-2.0",
"AGPL-3.0-or-later"
] | permissive | //! This module contains definitions of all shape modifiers, such as transformations, boolean
//! operations, growing / shrinking shapes, etc.
// === Non-Standard Linter Configuration ===
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::data::color::*;
use crate::prelude::*;
use crate::display::s... | true |
798036f5b62b6c5bf8df985ce88450619a22f627 | Rust | rust-chainblock/blockchain7 | /fog/view/server/src/db_fetcher.rs | UTF-8 | 27,679 | 2.578125 | 3 | [] | no_license | // Copyright (c) 2018-2021 The MobileCoin Foundation
//! An object for managing background data fetches from the recovery database.
use crate::{block_tracker::BlockTracker, counters};
use mc_common::logger::{log, Logger};
use mc_crypto_keys::CompressedRistrettoPublic;
use mc_fog_recovery_db_iface::{IngressPublicKeyRe... | true |
68752c683776daab1cc878ae3c53a088752d927a | Rust | agorgl/bevy | /crates/bevy_ecs/src/schedule/parallel_executor.rs | UTF-8 | 38,223 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::Schedule;
use crate::{
resource::Resources,
system::{System, ThreadLocalExecution},
ArchetypesGeneration, TypeAccess, World,
};
use bevy_tasks::{ComputeTaskPool, CountdownEvent, TaskPool};
#[cfg(feature = "trace")]
use bevy_utils::tracing::info_span;
use bevy_utils::tracing::trace;
use fixedbitse... | true |
339d1a58572c3d144a4cc362c18a34f315d72e77 | Rust | abdullahwaqar/leetcode | /2114.Maximum_Number_of_Words_Found_in_Sentences/src/main.rs | UTF-8 | 479 | 3.25 | 3 | [] | no_license | struct Solution {}
impl Solution {
pub fn most_words_found(sentences: Vec<String>) -> i32 {
let mut sentence_len = -1;
sentences.iter().for_each(|sentence| {
let sentence_words = sentence.split_whitespace().collect::<Vec<_>>().len() as i32;
if sentence_len < sentence_words ... | true |
8182af207af1604d91ea766b4e3f63c3493079a4 | Rust | vshotarov/advent-of-code-2020 | /day12/src/main.rs | UTF-8 | 2,696 | 3.75 | 4 | [] | no_license | use std::io::{self, Read};
#[derive(Debug)]
struct Vec2 {
x: i32,
y: i32
}
impl Vec2 {
fn translate(&mut self, x: i32, y: i32) {
self.x += x;
self.y += y;
}
fn _rotate(&mut self, num_turns: i32, direction: i32) {
for _ in 0..num_turns {
let old_x = self.x;
... | true |
67333ab18986d7bbdefd5308884a9b1cddaeedb4 | Rust | tckastanek/kcat | /src/theme_helpers.rs | UTF-8 | 2,204 | 2.640625 | 3 | [
"MIT"
] | permissive | use errors::KcatError;
use std::path::Path;
use syntect::{
dumps::{dump_to_file, from_dump_file},
highlighting::{Theme, ThemeSet},
parsing::SyntaxSet,
};
pub fn get_theme_set(
list_file_types: bool,
list_embedded_themes: bool,
syntax_set: &SyntaxSet,
) -> ThemeSet {
let ts = ThemeSet::load_... | true |
1eb87f906c092443c314feb86b0d5cff71fa29ea | Rust | adamek727/learning-rust | /ex_8_strings/src/main.rs | UTF-8 | 782 | 3.25 | 3 | [] | no_license | fn main() {
let mut s= String::new();
let data = "some data string";
let string_from_data_1 = data.to_string();
let string_from_data_2 = String::from(data);
let mut short_str = "foo".to_string();
short_str.push_str(" bublebum");
let mut s1 = "foo".to_string();
let s2 = "bar";
s... | true |
686d0a2e02a77c8ba500b04522ad619a44d23b0e | Rust | solson/rig | /src/parser.rs | UTF-8 | 13,128 | 3.203125 | 3 | [
"ISC"
] | permissive | use ast;
use error;
use error::Level::*;
use intern::Symbol;
use std::ops::Range;
////////////////////////////////////////////////////////////////////////////////
// Lexer
////////////////////////////////////////////////////////////////////////////////
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Token {
pu... | true |
d90296c2d5784fac1c08a39f9091845496e8933e | Rust | isgasho/shine | /crates/shine-math/src/triangulation/graph/face.rs | UTF-8 | 1,903 | 3.21875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::triangulation::types::{rot3, FaceIndex, Rot3, VertexIndex};
use std::fmt;
/// Edge constraint
pub trait Constraint: Default + Clone + PartialEq + fmt::Debug {
fn is_constraint(&self) -> bool;
}
/// A face of the triangualtion
pub trait Face: Default {
type Constraint: Constraint;
fn vertex(&se... | true |
2bb763657a1eb19179f4d663a1e0752c0ccb478e | Rust | jqnatividad/qsv | /src/cmd/reverse.rs | UTF-8 | 2,136 | 3.125 | 3 | [
"MIT",
"Unlicense"
] | permissive | static USAGE: &str = r#"
Reverses rows of CSV data.
Useful for cases when there is no column that can be used for sorting in reverse order,
or when keys are not unique and order of rows with the same key needs to be preserved.
Note that this requires reading all of the CSV data into memory.
Usage:
qsv reverse [o... | true |
03784e2cbc9a7e186b6b007d58483865e402e31b | Rust | yuniruyuni/atcoder | /abc083-b/src/main.rs | UTF-8 | 433 | 3.015625 | 3 | [] | no_license | use proconio::input;
// use proconio::marker::Chars;
// use proconio::marker::Bytes;
fn calc(mut n: i32) -> i32 {
let mut d = 0;
while n != 0 {
d += n % 10;
n /= 10;
}
d
}
fn main() {
input! {
n: i32, a: i32, b: i32,
}
let mut ans = 0;
for i in 1..=n {
... | true |
0c9b17616b3d62c7e2814e44b3dc89037c5be4ae | Rust | blueluna/bt-mgmt | /examples/monitor.rs | UTF-8 | 6,951 | 2.546875 | 3 | [] | no_license | use std::fmt;
use std::os::unix::io::AsRawFd;
use mio::{unix::SourceFd, Events, Interest, Poll, Token};
use byteorder::{ByteOrder, LittleEndian};
use bt_mgmt::{
self,
eir::{self, EirEntry},
events::Event,
pack::UnpackFixed,
Error, Socket,
};
const MGMT_EVENTS: Token = Token(0);
fn main() -> Res... | true |
f39380ea45e7cb3c5b2a876744404e8b222fc553 | Rust | giraffate/ghrs | /examples/make_report.rs | UTF-8 | 3,626 | 2.609375 | 3 | [
"MIT"
] | permissive | use ghrs::{model::event::EventType, model::event::Payload, Client};
use chrono::NaiveDate;
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let args: Vec<String> = std::env::args().collect();
let user = args.get(1).unwrap();
let from = if args.get(2).is_some() {
let from = args.... | true |
6cea95b16ea5e3a7bb18d3228be3ca884d9645c9 | Rust | b-goodman/pukka | /src/password/mod.rs | UTF-8 | 1,718 | 3.328125 | 3 | [] | no_license | use rand::{thread_rng, Rng};
use std::collections::HashMap;
// Copied from https://passwordsgenerator.net/ - thanks!
// Include Symbols:( e.g. @#$% )
// Include Numbers:( e.g. 123456 )
// Include Lowercase Characters:( e.g. abcdefgh )
// Include Uppercase Characters:( e.g. ABCDEFGH )
// Exclude Similar Characters:( e.... | true |
820c562d3815ef1bbdc524ff9f583b7cd6ceac85 | Rust | yoshuawuyts/hot-ranking-algorithm-rs | /src/lib.rs | UTF-8 | 1,815 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate chrono;
pub use chrono::offset::Utc;
pub use chrono::DateTime;
use std::cmp;
const HALF_LIFE: i32 = 45_000;
/// Calculate the relevancy of an item based on upvotes, downvotes, a current
/// timestamp and the epoch at which the program is first run (e.g. no value can
/// be lower than that).
pub fn rank(... | true |
f2a017d1fde85916615fe72e903b2dd0117daaed | Rust | ovanwijk/aion | /aion/src/timewarping/signing.rs | UTF-8 | 5,802 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive |
use crate::iota_signing::*;
use crate::iota_conversion::{Trinary,long_value};
use crate::iota_constants;
use crate::iota_utils;
use crate::iota_crypto::{Kerl, Sponge};
use crate::iota_model::Bundle;
use iota_constants::HASH_TRINARY_SIZE;
//use std::cmp;
pub fn sign_tw_hash(private_key:&Vec<i8>, tw_hash:&str) -> Str... | true |
4b9a36ce44b729c92c5ebf068779e396a13bf52b | Rust | djtech-dev/volt | /src/compress/src/command.rs | UTF-8 | 1,958 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | /*
Copyright 2021 Volt Contributors
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 applicable law or agreed to in writing, software
... | true |
956827a7ec33a33ba1f45975579b2032db08fdeb | Rust | paperboycreates/bible-search-rust | /src/main.rs | UTF-8 | 5,519 | 3.34375 | 3 | [] | no_license | // Jacob Sheets
// L6
// Bible Search Project
// 11/21/2020
// Description: Bible search project that searches the bible till user stops with "q" and prints to file.
// Limitations: I could not get the abbreviations to work before the deadline, and was trying to fix before sending in late. Could not break through.
use... | true |
65aa91fd66f75204ca688d5c8f041b4d7d3e8d5a | Rust | Caruso33/rust | /zero_to_mastery/exercises/activities/src/bin/a42.rs | UTF-8 | 785 | 3.5625 | 4 | [] | no_license | // Topic: Implementing Iterator
//
// Summary:
// A game uses a scoring system that includes a score multiplier.
// The multiplier starts at 1 and increases by 1 each iteration.
// The amount the multiplier increases each iteration can be
// adjusted through in-game powerups.
//
// Example multiplier progression:
// 1,... | true |
29a7789e4243ee7519cbd136b500700b5f84300b | Rust | mdm/ronald | /ronald-cli/src/keyboard_configurator.rs | UTF-8 | 7,017 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::Write;
use ronald_core::constants;
use crate::keybindings;
const MODIFIERS: [&str; 6] = [
"ShiftLeft",
"ShiftRight",
"AltLeft",
"AltRight",
"ControlLeft",
"ControlRight",
];
pub struct KeyboardConfigurator {
print_key: bool,
... | true |
3bb37edb7b96c10526c240145d38876802edf1b3 | Rust | CryZe/AdventOfCode | /day-7/src/main.rs | UTF-8 | 8,110 | 3.5 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::ops::Not;
use std::str::FromStr;
use std::path::Path;
use std::fs::File;
use std::io::prelude::*;
use Expression::*;
struct CPU {
registers: HashMap<String, Expression>,
cache: HashMap<String, Option<u16>>,
}
#[derive(Debug, PartialEq, Clone)]
enum Expression {
Reg... | true |
c5ac273dfd6a7b85e4750de63e7c470b7a0b75ca | Rust | aLagoG/aoc2020 | /src/day4.rs | UTF-8 | 4,595 | 3.109375 | 3 | [] | no_license | use anyhow::{anyhow, Result};
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::{HashMap, HashSet};
const KEYS: [&'static str; 8] = [
"byr", // (Birth Year)
"iyr", // (Issue Year)
"eyr", // (Expiration Year)
"hgt", // (Height)
"hcl", // (Hair Color)
"ecl", // (Eye Color)
... | true |
e75a34ccc9f88f155755f529d18713431978115f | Rust | reujab/wallpaper.rs | /src/linux/lxde.rs | UTF-8 | 1,164 | 2.625 | 3 | [
"Unlicense"
] | permissive | use crate::{run, Error, Mode, Result};
use ini::Ini;
use std::env;
pub fn get() -> Result<String> {
// DESKTOP_SESSION in used on Raspbian
let session = env::var("DESKTOP_SESSION").unwrap_or_else(|_| "LXDE".into());
let path = dirs::config_dir()
.ok_or(Error::NoConfigDir)?
.join(format!("pc... | true |
299e2432ae03c13d67092d2605805137985c4970 | Rust | ajnewlands/rust_leet_code | /count_one_bits/src/lib.rs | UTF-8 | 708 | 3.546875 | 4 | [] | no_license | pub mod hamming_weight {
use std::mem::size_of;
pub struct Solution {}
impl Solution {
pub fn hamming_weight(n: i32) -> i32 {
let mut ones = 0;
for i in 0..size_of::<i32>()
{
if ( (n>>i) & 1) == 1
{
... | true |
ea5af1845dd8746e6ac84c7c9c11e2ebd47418cd | Rust | vanarchist/generic-game | /zomes/main/code/src/your_game/validation.rs | UTF-8 | 895 | 3.171875 | 3 | [] | no_license |
use crate::game::Game;
use crate::game_move::Move;
use super::{
GameState,
};
/**
*
* To implement your own custom rule validation all you need to do is re-implement the function `is_valid` on `Move`
*
* This function takes the current game and the game state (which includes all the existing moves)
* and... | true |
10e6e9607feef5ba613be9d9500b31e3fe086075 | Rust | dmolokanov/appinsights-rs | /appinsights/src/client/mod.rs | UTF-8 | 15,068 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use http::{Method, Uri};
use crate::{
channel::{InMemoryChannel, TelemetryChannel},
context::TelemetryContext,
contracts::Envelope,
telemetry::{
AvailabilityTelemetry, EventTelemetry, MetricTelemetry, RemoteDependencyTelemetry, RequestTelemetry,
SeverityLevel, ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.