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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8797eddcf8e39c73847e56efc548f3cbff4e4aa0 | Rust | cst781/audio-filters | /src/filter_band_wide.rs | UTF-8 | 9,166 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
filter_band::{FilterBandCoefficients, ProcessType},
first_order_iir_wide::{WideIIR1, WideIIR1Coefficients},
second_order_iir_wide::{WideIIR2, WideIIR2Coefficients},
units::FP,
wide_units::WIDE,
MAX_CASCADE_COUNT,
};
#[derive(Copy, Clone, Debug)]
pub struct WideFilterBandCoefficient... | true |
e5303b55264772fa7dbb70c1d46fc8645810aaff | Rust | juchiast/gameoflife | /rle/src/lib.rs | UTF-8 | 2,955 | 3.265625 | 3 | [
"MIT"
] | permissive | use lazy_static::lazy_static;
// Parse errors
#[derive(Debug)]
pub enum Error {
IO(std::io::Error),
Invalid(String),
IntParse(std::num::ParseIntError),
NoHeader,
}
// Read file's header, return dimensions of the pattern
fn parse_header<'a, I>(lines: &mut I) -> Result<(i32, i32), Error>
where
I: It... | true |
8b2041dd8a85c097c47ac8afc85bdd5ca882d5d6 | Rust | 38/grass-demo | /grass/src/algorithm/components.rs | UTF-8 | 5,731 | 2.78125 | 3 | [] | no_license | use std::fmt::{Debug, Formatter, Result};
use std::iter::Enumerate;
use std::{
cmp::{Ordering, Reverse},
marker::PhantomData,
};
use std::{
collections::{BinaryHeap, HashMap},
hash::Hash,
};
use crate::{
properties::{WithRegion, WithRegionCore},
ChromName,
};
pub struct Point<C: ChromName, T: ... | true |
fc0d58230eb14847930df0abca74fc305d43a6cf | Rust | radioreptile/szyszka | /src/class_dialog_rule_size_letters.rs | UTF-8 | 1,385 | 2.546875 | 3 | [
"MIT"
] | permissive | use gtk::prelude::*;
#[derive(Clone)]
pub struct GuiSizeLetters {
pub radio_button_letters_type_uppercase: gtk::RadioButton,
pub radio_button_letters_type_lowercase: gtk::RadioButton,
pub radio_button_letters_usage_name: gtk::RadioButton,
pub radio_button_letters_usage_extension: gtk::RadioButton,
... | true |
40fbb4165057b9c0a86b02c0e0bf512c7b21a2dc | Rust | Liby99/mpm-rs | /core/src/resources/consts.rs | UTF-8 | 218 | 2.59375 | 3 | [] | no_license | use crate::utils::*;
pub struct Gravity(Vector3f);
impl Default for Gravity {
fn default() -> Self {
Self(Vector3f::new(0.0, -9.8, 0.0))
}
}
impl Gravity {
pub fn get(&self) -> Vector3f {
self.0
}
}
| true |
d85ba61a9e0be6c20d39e1ac792f3930cc6362d7 | Rust | ry/tokio | /tokio-async-await/examples/src/echo_client.rs | UTF-8 | 1,193 | 2.828125 | 3 | [
"MIT"
] | permissive | #![feature(await_macro, async_await, futures_api)]
#[macro_use]
extern crate tokio;
use tokio::net::TcpStream;
use tokio::prelude::*;
use std::io;
use std::net::SocketAddr;
const MESSAGES: &[&str] = &[
"hello",
"world",
"one two three",
];
async fn run_client(addr: &SocketAddr) -> io::Result<()> {
... | true |
c01d701318146e52892fb5dda086d6b74bccf57e | Rust | msmousehome/expectrl | /tests/session.rs | UTF-8 | 5,029 | 3.09375 | 3 | [
"MIT"
] | permissive | use expectrl::spawn;
use std::{thread, time::Duration};
#[cfg(feature = "async")]
use futures_lite::io::{AsyncReadExt, AsyncWriteExt};
#[cfg(not(feature = "async"))]
use std::io::{Read, Write};
#[cfg(windows)]
use std::io::BufRead;
#[cfg(unix)]
#[cfg(not(feature = "async"))]
#[test]
fn send() {
let mut session =... | true |
2008ab31bfccabb2182fbb92635febe5f21e3bfd | Rust | baitcenter/maskerad_stack_allocator | /src/stacks/stack_allocator.rs | UTF-8 | 48,513 | 3.28125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | // Copyright 2017-2018 Maskerad 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 accord... | true |
ac272735791c49298eee7eebb06b5ecb035a0380 | Rust | rpeden/rust-experiments | /cargo/src/main.rs | UTF-8 | 72 | 2.546875 | 3 | [] | no_license |
fn main() {
println!("Yay, I'm finally writing something in Rust!");
} | true |
fab876c0666716517b730c1feb6dc2fe66449f89 | Rust | emartisoft/fltk-rs | /fltk/src/utils.rs | UTF-8 | 1,048 | 3.515625 | 4 | [
"MIT"
] | permissive | use std::ffi::CString;
pub(crate) trait FlString {
fn safe_new(s: &str) -> CString;
}
impl FlString for CString {
fn safe_new(s: &str) -> CString {
match CString::new(s) {
Ok(v) => v,
Err(r) => {
let i = r.nul_position();
CString::new(&r.into_vec... | true |
4f53ab3d1fd5e379811a222357b6416e09e17b80 | Rust | code-relay-io/viuer | /src/printer/iterm.rs | UTF-8 | 2,379 | 2.8125 | 3 | [] | no_license | use crate::error::ViuResult;
use crate::printer::{adjust_offset, find_best_fit, Printer};
use crate::Config;
use image::{DynamicImage, GenericImageView};
use lazy_static::lazy_static;
use std::io::{BufReader, Read, Write};
#[allow(non_camel_case_types)]
pub struct iTermPrinter {}
lazy_static! {
static ref ITERM_S... | true |
efeb88e613faa2f0c70a4ef6aaf0a61d2300d9ba | Rust | jbradaric/advent-of-code-2019 | /day_06/src/main.rs | UTF-8 | 3,955 | 3.03125 | 3 | [] | no_license | use std::cell::RefCell;
use std::collections::{HashMap, VecDeque};
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::rc::Rc;
use std::str::FromStr;
#[derive(Debug)]
enum Error {
InvalidOrbit(String),
}
struct Orbit {
pub center: String,
pub object: String,
}
impl FromStr for Or... | true |
551b58f41733aab45ac0769c888866afc4e19809 | Rust | yagui-rs/yagui | /yagui/src/config.rs | UTF-8 | 2,519 | 3.40625 | 3 | [
"MIT"
] | permissive | use yaml_rust::{Yaml, YamlLoader};
use crate::error::{ensure, Result, YaguiError};
pub struct Config {
yaml: Yaml,
}
impl Config {
pub fn new(yaml: &Yaml) -> Self {
Config { yaml: yaml.clone() }
}
pub fn from_yaml(yaml: &str) -> Result<Self> {
let mut docs = YamlLoader::load_from_str... | true |
97b227ad7a42a5f5c9ba6791132d71c16497df5b | Rust | mesalock-linux/crates-sgx | /vendor/jpeg-decoder/src/worker/threaded.rs | UTF-8 | 1,828 | 3 | 3 | [
"Apache-2.0"
] | permissive | use error::Result;
use std::sync::mpsc::{self, Sender};
use std::thread;
use super::{RowData, Worker};
use super::immediate::ImmediateWorker;
enum WorkerMsg {
Start(RowData),
AppendRow((usize, Vec<i16>)),
GetResult((usize, Sender<Vec<u8>>)),
}
pub struct ThreadedWorker {
sender: Sender<WorkerMsg>,
}
... | true |
0be62345f0d6676c9a14b63e0dbdc02419a3949d | Rust | peemai27th/wrangler | /src/settings/target/site.rs | UTF-8 | 1,160 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::path::PathBuf;
use serde::{Deserialize, Serialize};
const SITE_ENTRY_POINT: &str = "workers-site";
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Site {
pub bucket: String,
#[serde(rename = "entry-point")]
pub entry_point: Option<String>,
pub include: Option<Vec<String>>,
pub... | true |
b65333edb04fab7ebd78697d6305fc6e62886da4 | Rust | michael-gutman/tinyrustcaster | /src/main.rs | UTF-8 | 3,132 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::prelude::*;
// converts 8 bit rgba vals into a 4 byte int for storage as an img/pixel array
fn pack_colour(r: u32, g: u32, b: u32, a: u32) -> u32 {
(a << 24) + (b << 16) + (g << 8) + r
}
// takes a 4 byte int colour and returns the 8 bit rgba values for easy use
fn unpack_colour(co... | true |
acd716d302514a74c8369d33eb97f9ad1415338c | Rust | ZulfikarAkbar/ferris_wheel | /compile-pass/io-read-write.rs | UTF-8 | 319 | 2.640625 | 3 | [] | no_license | // FIXME: Make me compile! Diff budget: 2 lines.
use std::io;
use std::io::prelude::*;
use std::fs::File;
struct ReadWrapper<T: io::Read> {
inner: T
}
impl <T: io::Read>io::Read for ReadWrapper<T> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.read(buf)
}
}
fn main() { }
| true |
1a190b7843bc388aa4087a6a50df7400d5376fb6 | Rust | yemily17/Telescope | /src/api/rcos/users/navbar_auth.rs | UTF-8 | 1,755 | 2.75 | 3 | [
"MIT"
] | permissive | //! GraphQL query to get navbar authentication info on a user.
use crate::api::rcos::prelude::*;
use crate::api::rcos::send_query;
use crate::api::rcos::users::UserRole;
use crate::error::TelescopeError;
use chrono::Utc;
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "graphql/rcos/schema.json",
query_path =... | true |
e892b1e40cdbfd058f51296e2f94b1b5432ca856 | Rust | swgillespie/rust-os-class | /ps1/average.rs | UTF-8 | 544 | 3.09375 | 3 | [] | no_license | use std::os;
fn main() {
let mut args: ~[~str] = os::args();
if args.len() == 1 {
fail!("Usage: average [values]");
}
let mut aggregator = 0f64;
let mut total = 0f64;
args.remove(0);
for argument in args.iter() {
match from_str::<f64>(*argument) {
Some(number) =>... | true |
02b8321411b2ec07894ed4a984ee8c0ac0a24cfe | Rust | hgentry/euler | /src/problems/p42.rs | UTF-8 | 427 | 2.9375 | 3 | [] | no_license | use crate::utils::math;
use crate::utils::strings;
pub fn solve() -> i64 {
let s: String = strings::read_file_to_string("input/p042_words.txt");
let list: Vec<String> = strings::process_list(s);
let mut count = 0;
for l in list {
let t = strings::wordscore(&l);
if math::is_triangle(t) {
count += 1;
}
}
c... | true |
d187b8135a9181337ba76ce52594f81731be8fec | Rust | soorajkarthik/elevate-backend | /src/views/location.rs | UTF-8 | 3,432 | 2.90625 | 3 | [] | no_license | use crate::models::auth::{BearerToken, TokenType};
use crate::models::database::PGConnection;
use crate::models::location::Location;
use crate::models::user::User;
use crate::services::mapquest::{get_address, MapquestResult};
use crate::views::request::StandardResponse;
use crate::{fetch_user, transaction};
use rocket:... | true |
0d5d7498f70b4d9113ce295d47679f0ea2a88055 | Rust | thmyrk/rust-exercises | /custom-trait/src/main.rs | UTF-8 | 895 | 3.671875 | 4 | [] | no_license | fn main() {
let mark = 5;
let student = Student::new(mark, 53, "Janusz".to_string());
println!("{:#?}", student);
let teacher = Teacher::new("Maths".to_string(), 14, "Boghdan".to_string());
println!("{:#?}", teacher);
}
#[derive(Debug)]
struct Student {
personal_data: PersonalData,
mark:... | true |
91d77b5c8c4d677063ec1fb4d0e8946551ea7966 | Rust | pnlybubbles/yew-befunge | /src/main.rs | UTF-8 | 10,278 | 2.6875 | 3 | [] | no_license | #![recursion_limit="128"]
#[macro_use]
extern crate yew;
use std::time::Duration;
use std::char;
use yew::html::*;
use yew::services::timeout::TimeoutService;
fn main() {
let model = init_model();
program(model, update, view);
}
struct Model {
input: String,
interval: String,
time: u64,
befunge: Befunge,... | true |
4bcd8a9386bb5863eba5dba4e2ed9fa2db44a6fa | Rust | EFanZh/LeetCode | /src/problem_0392_is_subsequence/mod.rs | UTF-8 | 408 | 3.046875 | 3 | [] | no_license | pub mod greedy;
pub trait Solution {
fn is_subsequence(s: String, t: String) -> bool;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [(("abc", "ahbgdc"), true), (("axc", "ahbgdc"), false)];
for ((s, t), expected) in test_cases {
a... | true |
36379cfe6b9a00c338ef458e92175bd9d4c77460 | Rust | MohamedHajr/Problem-Solving | /leetCode/622.design-circular-queue.rs | UTF-8 | 4,539 | 3.609375 | 4 | [] | no_license | /*
* @lc app=leetcode id=622 lang=rust
*
* [622] Design Circular Queue
*
* https://leetcode.com/problems/design-circular-queue/description/
*
* algorithms
* Medium (38.18%)
* Total Accepted: 20.1K
* Total Submissions: 52.3K
* Testcase Example: '["MyCircularQueue","enQueue","enQueue","enQueue","enQueue","... | true |
4559a2b03d2b2170b6b85d3493b8bf5938d38869 | Rust | rust-embedded/embedonomicon | /ci/dma/src/lib.rs | UTF-8 | 2,015 | 3.390625 | 3 | [
"CC-BY-SA-4.0",
"MIT",
"CC-BY-SA-3.0",
"Apache-2.0"
] | permissive | #![allow(unused_variables)]
pub const USART1_TX: usize = 0x4000_0000;
pub const USART1_RX: usize = 0x4000_0004;
/// A singleton that represents a single DMA channel (channel 1 in this case)
///
/// This singleton has exclusive access to the registers of the DMA channel 1
pub struct Dma1Channel1 {
// ..
}
impl Dm... | true |
3458425a8223011e774e4019ed37599b80b0b4a1 | Rust | peckpeck/my-pi | /clock/src/keys.rs | UTF-8 | 5,921 | 3.09375 | 3 | [] | no_license | use rppal::gpio::*;
use std::time::*;
use std::thread::sleep;
use std::sync::Arc;
/* Keys are all connected to the same pin and just have a different resistance value
*
*
*
* __o__ -------- 220nF
* V+ ------* *--|x ohms|---T---||-----\
* -------- | |
* ... | true |
1910a7d5f6d5b03c6af00c04361b9f4fd8b307a3 | Rust | Jaic1/xv6-riscv-rust | /src/fs/file/mod.rs | UTF-8 | 6,970 | 2.78125 | 3 | [
"MIT"
] | permissive | use alloc::sync::Arc;
use core::cell::UnsafeCell;
use core::cmp::min;
use core::convert::TryInto;
use crate::consts::driver::NDEV;
use crate::consts::fs::{MAXOPBLOCKS, BSIZE};
use crate::consts::fs::{O_RDONLY, O_WRONLY, O_RDWR, O_CREATE, O_TRUNC};
use crate::driver::DEVICES;
use crate::mm::Address;
use super::{ICACHE... | true |
298933545b037877c26fae4fb3dd5e3146c44bbb | Rust | piceaTech/MMM-rusty-things | /src/types/task.rs | UTF-8 | 8,413 | 2.71875 | 3 | [] | no_license | use serde_json::Value;
use std::convert::From;
use super::deserialize_some;
use serde::{Deserialize, Serialize};
impl From<Value> for Task {
fn from(value: Value) -> Self {
serde_json::from_value(value).unwrap()
}
}
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
pub struct Task {
#[serd... | true |
c0da0948f48dcb867b03c738f338a6fa6a6733eb | Rust | ssyuan/stargate | /sgnetwork/src/message.rs | UTF-8 | 1,917 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::helper::get_unix_ts;
use libra_crypto::{
hash::{CryptoHash, CryptoHasher, TestOnlyHasher},
HashValue,
};
use libra_types::account_address::AccountAddress;
use parity_codec::{Decode, Encode};
#[derive(Clone, Debug)... | true |
c6df354069d31c509180b87923ab42feeb294f36 | Rust | yangxuan-321/hello-rust | /src/main.rs | UTF-8 | 544 | 3.421875 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
// 测试打印
// {} 作为占位符
println!("hello world! - {}", "first");
// {:o} 打印8进制
println!("打印16进制 - 小写 - {:o}", 16);
// {:x} 打印16进制 - 小写
println!("hello world! - {:x}", 255);
// {:X} 打印16进制 - 大写
println!("打印16进制 - 大写 - {:X}", 255);
let str1 = "... | true |
8d1020bf1101de1074fec87fa58f07e29b598fc9 | Rust | Gitter499/firstNonRepeatingCharacter | /algo/src/main.rs | UTF-8 | 504 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
fn main() {
solve(String::from("jjjaalllkxxxklll"));
}
fn solve(s: String) {
let mut chars: HashMap<char, i32> = HashMap::new();
for elem in s.chars() {
if chars.contains_key(&elem) {
*chars.get_mut(&elem).unwrap() += 1;
} else {
char... | true |
31c217cabbb8f3b1bae2c4264d7d51cea998bfc8 | Rust | endoli/ui.rs | /src/color/hsva.rs | UTF-8 | 1,579 | 3.140625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.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 according to those terms.
//! HSVA Colors
#[... | true |
6e84a8f0f1a6f14c590e4b25d15ae32ce6fa8242 | Rust | lenzomj/rubigino | /src/lib.rs | UTF-8 | 3,172 | 2.765625 | 3 | [
"MIT"
] | permissive | pub mod gpio;
pub mod spi;
pub mod display {
pub mod font;
#[cfg(feature = "rpi")]
pub mod matrix;
}
pub mod util {
use std::convert::TryFrom;
pub trait Bits {
fn to_bits(&self) -> [u8; 8];
fn from_bits(bits: &[u8; 8]) -> u8;
}
impl Bits for u8 {
fn to_bits(&self... | true |
25bfd4e89af28ffa85fbcefabbcb3b9569754a60 | Rust | kannapoix/nakamoto | /client/src/handle.rs | UTF-8 | 3,318 | 2.671875 | 3 | [
"MIT"
] | permissive | //! Node handles are created from nodes by users of the library, to communicate with the underlying
//! protocol instance.
use std::net;
use std::ops::Range;
use crossbeam_channel as chan;
use thiserror::Error;
use nakamoto_common::block::filter::BlockFilter;
use nakamoto_common::block::tree::ImportResult;
use nakamo... | true |
a200f96fd62d0ef2d14d259e93ff485064ce78ab | Rust | jhunt/vault-of-cardboard | /src/bin/query.rs | UTF-8 | 7,013 | 2.84375 | 3 | [] | permissive | use std::fmt::Display;
use vault_of_cardboard::prelude::*;
use vault_of_cardboard::scryfall;
fn or<T: Display>(pri: &Option<T>, sec: &str) -> String {
match pri {
Some(pri) => format!("{}", pri),
None => sec.to_string(),
}
}
fn yn(maybe: &Option<bool>) -> String {
match maybe {
Som... | true |
f696365cbd3e7d425db23c249c4eb692a334ea53 | Rust | CJHJ/rust-tutorial | /ownership/src/dangling_ref.rs | UTF-8 | 250 | 3.375 | 3 | [] | no_license | fn main() {
let reference_to_nothing = dangle();
println!("{}", reference_to_nothing);
}
fn dangle() -> String {
let s = String::from("hello");
// &s // Will result in a dangling reference because 's' goes out of scope
s // OK
} | true |
3a12aa180a579a971585717b8bca122b5ae8f67b | Rust | caiges/pwong | /src/entities/theme.rs | UTF-8 | 677 | 2.71875 | 3 | [] | no_license | extern crate sdl2;
use self::sdl2::pixels::Color;
use self::sdl2::rwops::RWops;
use self::sdl2::ttf::Font;
use self::sdl2::ttf::Sdl2TtfContext;
pub struct Theme<'ttf, 'a> {
pub color: Color,
pub font: Font<'ttf, 'a>,
pub font_size: u16,
}
impl<'ttf, 'a> Theme<'ttf, 'a> {
pub fn new(color: Color, fon... | true |
c6912ecc5e5ae96f39ba98f54ed2124fbc5d146e | Rust | sorz/moproxy | /src/policy/capabilities.rs | UTF-8 | 2,550 | 3.375 | 3 | [
"MIT"
] | permissive | use std::{fmt::Display, mem};
use flexstr::SharedStr;
use serde::Serialize;
#[derive(Debug, Clone, Eq, PartialEq, Hash, Default, Serialize)]
pub struct CapSet(Box<[SharedStr]>);
impl CapSet {
pub fn new<I>(caps: I) -> Self
where
I: Iterator,
I::Item: Into<SharedStr>,
{
let mut cap... | true |
a1f03562e56a195d355dbfd6ae24e5c5387c3a2c | Rust | booyaa/scratchpad | /rust/strings/src/main.rs | UTF-8 | 2,800 | 3.546875 | 4 | [
"Artistic-2.0"
] | permissive | // further reading
// http://hermanradtke.com/2015/05/03/string-vs-str-in-rust-functions.html
// http://stackoverflow.com/a/29998582/105282
// https://github.com/hoodie/concatenation_benchmarks-rs
// use std::iter::FromIterator;
// http://stackoverflow.com/questions/31799482/efficiently-extract-prefix-substrings
// h... | true |
9b19ef2872a9aa9dbaa08c4224d00f804adf52e1 | Rust | crides/moss | /src/modules/sf.rs | UTF-8 | 19,834 | 2.828125 | 3 | [
"CC0-1.0"
] | permissive | #![allow(clippy::many_single_char_names)]
#![allow(non_snake_case)]
// Special mathematical functions
// == Literature ==
// [1] Richard P. Brent: "Fast Algorithms for High-Precision
// Computation of Elementary Functions", 2006
// [2] Semjon Adlaj: "An eloquent formula for the perimeter
// of an ellipse", Notices of ... | true |
51ed918f2d83e4d147211fe047fb7f5997bb97aa | Rust | elonmuskceo/tokenizers | /bindings/python/src/models.rs | UTF-8 | 4,744 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | extern crate tokenizers as tk;
use super::error::ToPyResult;
use super::utils::Container;
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::types::*;
use std::path::Path;
/// A Model represents some tokenization algorithm like BPE or Word
/// This class cannot be constructed directly. Please use one of the concre... | true |
785becbb140c77b8b6620a41af44eb536eb2c105 | Rust | simonasstipinas/framework | /helper_functions/helper_functions_2/src/crypto.rs | UTF-8 | 8,853 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use bls::{
AggregatePublicKey, AggregateSignature, PublicKey, PublicKeyBytes, Signature, SignatureBytes,
};
use ring::digest::{digest, SHA256};
use ssz::DecodeError;
use std::convert::TryInto;
use tree_hash::{SignedRoot, TreeHash};
use types::primitives::H256;
pub fn hash(input: &[u8]) -> Vec<u8> {
digest(&SH... | true |
0db5bdf9f2453107a176fc490f5bad0e6f127b0c | Rust | clucompany/cluLamansh | /src/lib.rs | UTF-8 | 15,037 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | #![feature(try_from)]
#![feature(exact_chunks)]
#![feature(test)]
/*!
A binary record of the values stored in the array using the Lamansh protocol.
# Protocol Lamansh
```rust
extern crate cluLamansh;
use cluLamansh::lamansh::sized::U8;
use cluLamansh::lamansh::sized::U64;
use cluLamansh::new_custom_lamansh;
let lam... | true |
1ddf9704a750b6ca5ede4044ef5283fe5e4b0a8c | Rust | tomhoule/prisma-engine | /libs/datamodel/core/src/common/functions/builtin.rs | UTF-8 | 1,860 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use super::Functional;
use crate::ast;
use crate::common::{
value::{MaybeExpression, ValueValidator},
ScalarType, ScalarValue,
};
use crate::error::DatamodelError;
/// Environment variable interpolating function (`env(...)`).
pub struct EnvFunctional {}
impl Functional for EnvFunctional {
fn name(&self) -... | true |
17a915ffd54d8a307bf611d971821d193f0ecff2 | Rust | chokomancarr/effective-rust | /src/embed.rs | UTF-8 | 994 | 2.515625 | 3 | [] | no_license | use super::{coproduct::Embed, Context, Effectful, Poll};
use std::marker::PhantomData;
use std::pin::Pin;
/// An effectful computation created by `embed()` combinator
///
/// `EmbedEffect` is used to "widen" the effect that the task will perform
pub struct EmbedEffect<C, Target, Indices>(C, PhantomData<(Target, Indic... | true |
94172415711a62ea945f2f5fda2a2b1ad576c2a9 | Rust | mhk032/sequencer_lighting_linux | /src/animation/ripple.rs | UTF-8 | 1,933 | 3.09375 | 3 | [] | no_license | use crate::{
animation::animation_custom_colors::AnimationCustomColors,
animation::animation_speeds::AnimationSpeed, animation::animation_themes::AnimationThemes,
animation::Animation,
};
#[derive(Debug)]
pub struct Ripple {
pub direction: Option<RippleSize>,
pub speed: Option<AnimationSpeed>,
... | true |
7778b78d635e6dce9ae239a7be06a3e357aebe92 | Rust | sjep/array | /src/zeroable.rs | UTF-8 | 535 | 2.796875 | 3 | [
"MIT"
] | permissive | /// Marker trait to determine if a type is auto-zeroable. This allows the initialization to simply
/// zero out the buffer on initialization.
pub trait Zeroable {}
impl Zeroable for u8 {}
impl Zeroable for i8 {}
impl Zeroable for u16 {}
impl Zeroable for i16 {}
impl Zeroable for u32 {}
impl Zeroable for i32 {}
impl Ze... | true |
0d24ceca44cad36d790fbc1551f1039fbc216675 | Rust | TheNumerus/enigmap | /enigmap-renderer/src/renderers/ogl.rs | UTF-8 | 6,926 | 2.75 | 3 | [
"MIT"
] | permissive | use glium::*;
use glium::glutin::event_loop::EventLoop;
use rand::prelude::*;
use enigmap::{HexMap, Hex, HexType, RATIO};
use crate::renderers::{Image, Renderer, get_hex_vertex, ColorMode};
use crate::renderers::colors::ColorMap;
/// Basic hardware renderer
///
/// Supports multisampling
pub struct OGL {
/// Si... | true |
23f5697a30c8abb98065f82ec79ac4445d97c7c1 | Rust | danieleades/chesterfield | /src/database.rs | UTF-8 | 8,404 | 3.328125 | 3 | [
"Apache-2.0"
] | permissive | mod delete;
mod get;
mod insert;
mod update;
//mod replication;
pub use self::{
delete::DeleteRequest, get::GetRequest, insert::InsertRequest, update::UpdateRequest,
};
use crate::{client::Client, Error};
use futures::compat::Future01CompatExt;
use serde::Serialize;
/// Interface for interacting with a specific C... | true |
aa36298d03dc79a58742e1be120acc300d5742cf | Rust | Farooq-azam-khan/rust-practice | /slice.rs | UTF-8 | 247 | 3.28125 | 3 | [] | no_license | fn main() {
let nums = [1,2,3,4, 5, 6, 7];
let subset = get_slice(&nums, 1, 5);
for n in subset.iter() {
print!("{} ", n);
}
println!();
}
fn get_slice(a: &[i32], s: usize, e: usize) -> &[i32] {
&a[s..e]
}
| true |
1e44709a9277b60c0e8e3fa25ff992a3419d6527 | Rust | Latias94/rust-practice | /leetcode/src/s1480_running_sum_of_1d_array.rs | UTF-8 | 897 | 3.296875 | 3 | [
"MIT"
] | permissive | struct Solution;
//leetcode submit region begin(Prohibit modification and deletion)
impl Solution {
pub fn running_sum(nums: Vec<i32>) -> Vec<i32> {
let n = nums.len();
let mut result = vec![0; n];
result[0] = nums[0];
for i in 1..n {
result[i] = result[i - 1] + nums[i];... | true |
e16fcf074d71116a9d63d7a3633ed15e8ed18dd0 | Rust | TuckerBMorgan/GoBoom | /examples/client.rs | UTF-8 | 978 | 2.515625 | 3 | [] | no_license | mod client_lib;
//use GoBooM;
use storm::*;
use std::net::TcpStream;
use GoBooM::*;
use client_lib::*;
fn main() {
Engine::start(
WindowSettings {
title: String::from("Storm: GoBoom"),
display_mode: DisplayMode::Windowed {
width: 1280,
height: 1024,... | true |
21a98951b65b339b39979b585380f8f0a8153f92 | Rust | drwilco/aoc | /2020/day1/src/bin/second_faster.rs | UTF-8 | 623 | 2.875 | 3 | [] | no_license | use std::{fs, io};
fn main() -> io::Result<()> {
let input = fs::read_to_string("input.txt")?
.trim()
.split('\n')
.map(|x| x.parse().expect("not a number"))
.collect::<Vec<u64>>();
for a in &input {
if *a < 2020 {
for b in &input {
if a + b ... | true |
47cfcc1a2953176857548c4193b3ca9dd73bfc52 | Rust | leeopop/rust-bitmap | /src/lib.rs | UTF-8 | 10,513 | 3.859375 | 4 | [
"MIT"
] | permissive | //! See the `Bitmap` type.
/// A dense bitmap, intended to store small bitslices (<= width of usize).
pub struct Bitmap {
entries: usize,
width: usize,
// Avoid a vector here because we have our own bounds checking, and
// don't want to duplicate the length, or panic.
data: *mut u8,
}
#[inline(alw... | true |
90b1e5c2c8cdd72a994801f10d9ebf618744499b | Rust | rwarnking/pir-task-fbecker-rwarnking | /sheet6/task1/src/lib.rs | UTF-8 | 776 | 3.75 | 4 | [] | no_license | extern crate num_traits;
use num_traits::Num;
/// Clamps a numerical value between two other values
pub fn clamp<T>(value: T, min: T, max: T) -> T
where T: PartialOrd + Copy
{
if value < min {
min
} else if value > max {
max
} else {
value
}
}
/// Returns a tuple containin... | true |
bf5a1f1ea66cd1cd80faa04feaf50a60511f631b | Rust | TGElder/rust | /frontier/src/artists/vegetation_artist.rs | UTF-8 | 4,123 | 3.015625 | 3 | [
"CC-BY-4.0"
] | permissive | use crate::world::*;
use commons::barycentric::triangle_interpolate_any;
use commons::grid::Grid;
use commons::rectangle::Rectangle;
use commons::*;
use isometric::cell_traits::*;
use isometric::coords::*;
use isometric::drawing::*;
use isometric::Command;
use std::collections::HashMap;
use std::fmt::Debug;
#[derive(C... | true |
b8e6b1b8c62feeab35ca381e3da3668b0cae047c | Rust | olsonjeffery/rust-encoding | /src/whatwg.rs | UTF-8 | 19,083 | 2.875 | 3 | [
"MIT"
] | permissive | // This is a part of rust-encoding.
// Copyright (c) 2013, Kang Seonghoon.
// See README.md and LICENSE.txt for details.
/*!
* An alternative API compatible to WHATWG Encoding standard.
*
* WHATWG Encoding standard, compared to the native interface provided by rust-encoding, requires
* both intentionally different... | true |
c5ec3eeb15fc00957fa3008017563fc824485634 | Rust | molvin/RustSmallGame | /src/game.rs | UTF-8 | 11,548 | 2.796875 | 3 | [] | no_license | use ggez::{Context, GameResult, timer};
use ggez::graphics::{self, DrawMode, Color };
use ggez::event::{EventHandler, KeyCode};
use rand::thread_rng;
use rand::seq::SliceRandom;
use tetromino::Tetromino;
use renderer::Renderer;
use input::Input;
use crate::utility::Point;
pub mod tetromino;
pub mod renderer;
pub mod i... | true |
b9d968f95cf9c2e1fc38aaf928bfe5e1781e7d6c | Rust | hyrsky/tiled-json | /src/utils.rs | UTF-8 | 4,888 | 2.953125 | 3 | [
"MIT",
"CC-BY-4.0"
] | permissive | use std::io::Read;
use std::str::FromStr;
use serde::{de, Deserialize, Deserializer};
use serde_json::{Number, Value};
use crate::error::TiledError;
/// Algoritm used to compress the tile layer data.
#[derive(Debug, PartialEq, Clone, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Compression {
Zlib,
... | true |
a0d6aa28b7afc9eefec73d43a4d8a7c8d2b63ac7 | Rust | Kineolyan/project-tz-io | /rs-parser/parser/src/instruction/mov.rs | UTF-8 | 4,287 | 2.734375 | 3 | [
"MIT"
] | permissive | use nom::branch;
use nom::bytes::complete::tag;
use nom::character::complete::{space0, space1};
use nom::IResult;
use crate::instruction::base as ptr;
use language::instruction::Operation;
fn consume_mov(input: &[u8]) -> IResult<&[u8], ()> {
let (rest, _) = nom::sequence::tuple((tag("MOV"), space1))(input)?;
... | true |
793b7cb65ddbbb24af3783a5a16391d8cfc91cfe | Rust | Al-Kindi-0/tfhe | /tests/bootstrapping_tests.rs | UTF-8 | 4,903 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | use tfhe::encryption::{
decrypt, encrypt, generate_keys, generate_parameters, Parameters, SecurityLevel,
};
use tfhe::{
gates::{
and as boots_and, andny as boots_andny, andyn as boots_andyn, constant as boots_constant,
nand as boots_nand, nor as boots_nor, not as boots_not, or as boots_or, orny as boots_orn... | true |
3e013ce6854827e101c4f4f920043e699a05c567 | Rust | ROki1988/pna | /project-01/src/server.rs | UTF-8 | 4,158 | 2.953125 | 3 | [] | no_license | use crate::command::{Request, Response};
use crate::engine::KvsEngine;
use crate::error::KvsErrorKind;
use crate::thread_pool::ThreadPool;
use crate::Result;
use slog::*;
use std::io::{BufRead, BufReader, Write};
use std::net::{TcpListener, TcpStream, ToSocketAddrs};
use std::str::FromStr;
use std::sync::atomic::{Atomi... | true |
d84787133fcd64f91ea0210fe11f15115bee982a | Rust | xarvic/rust_gui_test | /src/state/key.rs | UTF-8 | 1,679 | 3.484375 | 3 | [] | no_license | use std::ops::Deref;
use crate::state::lens::Lens;
/// Key allows to change a value and informs the owner about it
/// The current Implementation isn't the final form but it is designed in a way, that the Interface
/// dont have to change much in the Future
pub struct Key<'a, T: Clone> {
pub(crate) value: &'a mut ... | true |
947df140893b7caa2c7454c8fd175292d6a7eded | Rust | IThawk/rust-project | /rust-master/src/test/ui/error-codes/E0297.rs | UTF-8 | 114 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | fn main() {
let xs : Vec<Option<i32>> = vec![Some(1), None];
for Some(x) in xs {}
//~^ ERROR E0005
}
| true |
c49d46a0c7ddca3283663d13dc6c5c1d3b875c62 | Rust | matttgregg/advent2020 | /src/day25.rs | UTF-8 | 1,507 | 3.171875 | 3 | [] | no_license | use std::time::SystemTime;
use advent2020::{fmt_bright, print_day, print_duration};
fn data() -> (u64, u64) {
(8_252_394, 6_269_621)
}
pub fn run() {
print_day(25);
let start = SystemTime::now();
// Let's do this...
let key = crack(data().0, data().1);
println!("The door/card encryption key... | true |
d66c2421defe2118f69a7121dcc8c4d624f47e58 | Rust | bokuweb/wasm-bindgen | /examples/comments/src/lib.rs | UTF-8 | 1,190 | 3.203125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![feature(use_extern_macros)]
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
/// A user defined comment
pub struct Comment {
name: String,
comment: String,
/// The position this comment
/// should exist at
pub count: u32,
color: Color,
}
#[wasm_bindgen]
impl Commen... | true |
9382fcd57a36086eecdb0a619ba62a38887fe040 | Rust | citahub/rust-web3 | /src/types/log.rs | UTF-8 | 2,400 | 3.203125 | 3 | [] | no_license | use types::{BlockNumber, Bytes, H160, H256, U256};
/// A log produced by a transaction.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Log {
/// H160
pub address: H160,
/// Topics
pub topics: Vec<H256>,
/// Data
pub data: Bytes,
/// Block Hash
#[serde(rename = "bl... | true |
af976f9dc30b98fbc018b42c19a113a2afa541ef | Rust | vjancik/rust_socket_benchmark | /src/macros.rs | UTF-8 | 1,691 | 3.296875 | 3 | [] | no_license | // use crate::prelude::*;
#[allow(unused_macros)]
macro_rules! anon {
( $( $field_name:ident : $value:expr ),+ ) => {
{
// Abusing field_name by using it also as type's name.
// #[derive(Debug, Clone, Eq, PartialEq, PartialOrd)]
#[allow(non_camel_case_types)]
... | true |
97e989f76ab0ccc7a2369120e53297fd06fd164b | Rust | technomunk/gnet | /tests/single_client_test.rs | UTF-8 | 2,710 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use gnet::byte::ByteSerialize;
use gnet::connection::context::Context;
use gnet::connection::packet;
use std::net::{SocketAddr, UdpSocket};
#[derive(Debug, PartialEq, Clone)]
enum TestParcel {
String(String),
Index(u64),
}
impl ByteSerialize for TestParcel {
fn byte_count(&self) -> usize {
match self {
Self::... | true |
373c5126362d86fca96233d5d2599df220b955ac | Rust | bekh6ex/wikidata-realtime-dumps | /continuous_download/src/lib.rs | UTF-8 | 4,411 | 2.859375 | 3 | [] | no_license | use core::task::{Context, Poll};
use std::pin::Pin;
use std::time::Duration;
use futures::future::{ready, Ready};
use futures::stream::{once, Chain, FilterMap, Flatten, Map, Once};
use futures::*;
use futures_timer::Delay;
use log::*;
use pin_utils::{unsafe_pinned, unsafe_unpinned};
use std::fmt::Debug;
type Sleep<X... | true |
f9c9db38d1f9aa6c66b1221cba9bb5aaa344ced1 | Rust | Valink16/raymarch_2d | /raymarch/src/ray.rs | UTF-8 | 3,268 | 3 | 3 | [] | no_license | use crate::geom;
use crate::Marchable;
use crate::vec_math::VectorMath;
use crate::geom::{Drawable, Distance};
use sfml::system::{Vector2f};
use sfml::graphics::{RenderWindow, CircleShape, Color, Shape, Transformable, RenderTarget};
use sfml::graphics::{VertexArray, Vertex, PrimitiveType};
pub struct Ray {
pub ori... | true |
6a35b657c6adc9b15efdf1f894451f61353ee7b6 | Rust | uu4k/rust_book_sample_code | /sample_code/src/main.rs | UTF-8 | 6,972 | 3.578125 | 4 | [] | no_license | fn main() {
// tuple
let tup: (i32, f64, u8) = (500, 6.4, 1);
// println!("tup: {}", tup);
let (x, y, z) = tup;
println!("x y z: {} {} {}", x, y, z);
println!("tup.0 tup.1 tup.2: {} {} {}", tup.0, tup.1, tup.2);
let arr = [1, 2, 3, 4, 5];
let first = arr[0];
let second = arr[1];
... | true |
12340d530aa66f28cf402bea19159106e7bf5638 | Rust | antoyo/relm | /relm-examples/examples/7gui/6_circle_drawer/src/model/circle_group.rs | UTF-8 | 1,986 | 3.75 | 4 | [
"MIT"
] | permissive | use crate::model::Circle;
/// A group of circles.
/// Only one circle can be selected at any time.
#[derive(Clone)]
pub struct CircleGroup {
circles: Vec<Circle>,
}
impl CircleGroup {
/// Create a new, empty circle group.
pub fn new() -> Self {
Self { circles: vec![] }
}
/// Add a circle ... | true |
96a37f424f331332fc70b1e6163a8d42d01f6715 | Rust | jockbert/jockbert_ants_bot | /src/strategy/multisearch/mod.rs | UTF-8 | 4,332 | 3.3125 | 3 | [] | no_license | use crate::strategy::search::SearchResult;
use crate::strategy::*;
use std::collections::BinaryHeap;
use std::collections::HashSet;
/// Search from multiple origins to multiple target.
pub trait MultiSearch {
/// Search nearest orders from 'from' to 'to'. The search can
/// be limited/scoped by number of sough... | true |
4347b9ae1a66076acdc79e900b7e00d30c2d2ba5 | Rust | veltzer/demos-rust | /src/performance/timeit.rs | UTF-8 | 930 | 3.75 | 4 | [
"Apache-2.0"
] | permissive | // This is an example of how to time code using the
// std::time::Instant standard API.
//
// References:
// - https://doc.rust-lang.org/std/time/struct.Instant.html
use std::time::Instant;
fn time_it(func: fn()) {
let now = Instant::now();
// Code block to measure.
func();
let elapsed = now.elapse... | true |
d8e5d652151f266cde7ae56cd014ad7b43028305 | Rust | remique/ocl-blur | /src/main.rs | UTF-8 | 5,752 | 2.671875 | 3 | [] | no_license | #![allow(deprecated)]
extern crate image;
extern crate ocl;
use ocl::enums::{ImageChannelDataType, ImageChannelOrder, MemObjectType};
use ocl::{builders::DeviceSpecifier, Buffer, Image, ProQue};
use std::fs;
use std::path::Path;
use std::time::Instant;
fn create_matrix(radius: i32) -> Vec<f32> {
let width = ((rad... | true |
a640d2b1f59ba1b3e3ca623887835539762443a2 | Rust | appleboyyb/rl-diablo-2-hack | /rlinjector/src/main.rs | UTF-8 | 2,595 | 2.890625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod injector;
mod options;
use options::{Command, Options};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let opt = Options::default();
injector::enable_debug_privilege()?;
match opt.command {
Command::Inject { dll_path, process_name } => inject(dll_path, process_name)?,
//Comman... | true |
b97d8a8e54ce08521b4cb75ff68471bbbdfdc645 | Rust | marti1125/rust-ejemplos | /tipos_primitivos/src/main.rs | UTF-8 | 1,444 | 4.15625 | 4 | [
"MIT"
] | permissive | fn main(){
// Char
let caballo = '♞';
println!("Caballo {:?}", caballo);
// Booleanos
let t = true;
println!("boolean {:?}", t);
let f :bool = false;
println!("boolean f:bool {:?}", f);
// Tipos Numericos
let n1 = 42; // de tipo i32
let float = 1.5; // de tipo f64
le... | true |
8004e8af20ba0bb07a96841a7a317b1df62a833b | Rust | juntyr/necsim-rust | /necsim/core/src/reporter/used.rs | UTF-8 | 937 | 2.828125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::marker::PhantomData;
use crate::reporter::boolean::{Boolean, False, True};
#[allow(clippy::module_name_repetitions)]
#[repr(transparent)]
pub struct MaybeUsed<T, B: Boolean> {
inner: T,
_used: PhantomData<B>,
}
pub type Used<T> = MaybeUsed<T, True>;
pub type Ignored<T> = MaybeUsed<T, False>;
impl<... | true |
ebb71b5c74ffaa4320474ef1088774437f213a16 | Rust | motoras/rust-algos | /timus/1098/src/main.rs | UTF-8 | 1,098 | 3.046875 | 3 | [
"MIT"
] | permissive | /**
* Again brute force will fail. Use the recursive soluton for Josephus problem. In order to find it
* look to cases at least from 1 to 10.
*/
use std::io::{ Read, Write};
use std::io::stdin;
use std::io::stdout;
const NO_COMMENTS: &str = "No comments";
const YES: &str = "Yes";
const NO: &str = "No";
fn answe... | true |
85bdad332f6ed7c1981d2a52e442c66474c0b79e | Rust | chrisvittal/aoc-2017 | /src/bin/day25.rs | UTF-8 | 3,077 | 3.375 | 3 | [
"MIT"
] | permissive |
use std::collections::VecDeque;
#[derive(Clone,Copy)]
enum State {
A,
B,
C,
D,
E,
F
}
struct Machine {
tape: VecDeque<bool>,
pos: usize,
state: State,
}
impl Machine {
fn new() -> Self {
const LEN: usize = 10001;
Machine {
tape: vec![false; LEN].in... | true |
a9bc89a9f2f215a477fcc599c847e977a4181516 | Rust | mistodon/config_struct | /src/enums.rs | UTF-8 | 5,137 | 3.453125 | 3 | [] | no_license | use std::path::Path;
use crate::{
error::{Error, GenerationError},
files,
format::Format,
generation,
options::{EnumOptions},
validation,
};
/// Generate Rust source code defining an enum based on a map-like config file.
///
/// The enum variants are based on the keys of the map. The format of... | true |
bdc99f7941e3704a8dcb9605e61851ae59eb08c4 | Rust | sogapalag/contest | /codeforces/edu66/f.rs | UTF-8 | 3,574 | 2.6875 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
($($r:tt)*) => {
let stdin = std::io::stdin();
let mut bytes = std::io::Read::bytes(std::io::BufRea... | true |
967e7a06df1eeced651fd47d6d996a6f73a7af12 | Rust | pola-rs/polars | /crates/polars-pipe/src/executors/sources/reproject.rs | UTF-8 | 1,147 | 2.546875 | 3 | [
"MIT"
] | permissive | use polars_core::prelude::SchemaRef;
use crate::executors::operators::reproject_chunk;
use crate::operators::{PExecutionContext, PolarsResult, Source, SourceResult};
/// A source that will ensure we keep the schema order
pub(crate) struct ReProjectSource {
schema: SchemaRef,
source: Box<dyn Source>,
posit... | true |
8ceac8f0e3957e615b1508a5412fe4bb359be525 | Rust | nikclayton/gflags-derive | /tests/derive_with_default.rs | UTF-8 | 1,238 | 2.703125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate gflags_derive;
use gflags;
use gflags_derive::GFlags;
mod common;
use common::*;
use std::path::PathBuf;
#[test]
fn derive_with_default() {
#[derive(GFlags)]
#[allow(dead_code)]
struct Config {
/// True if log messages should also be sent to STDERR
#[gflags(default = true)]
... | true |
fb49dc513ff2822ddf1f3ce535d9d56a21866dc9 | Rust | mjm/advent-of-code-2020 | /src/bin/day21/main.rs | UTF-8 | 1,138 | 2.890625 | 3 | [] | no_license | mod food;
use advent_of_code_2020::read_input;
use crate::food::IngredientList;
use nom::lib::std::collections::HashMap;
use std::collections::HashSet;
use itertools::Itertools;
fn main() {
let contents = read_input();
let lists = IngredientList::from_lines(&contents).unwrap();
let allergens = IngredientL... | true |
a27aa285ad0cca7047351dc484c77bc0f658a9db | Rust | LaikaStudios/shotgrid-rs | /src/filters.rs | UTF-8 | 46,892 | 3.9375 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A *somewhat type-safe* filtering API.
//!
//! Filters come in two flavors: [`basic()`] and [`complex()`].
//! Each of these functions will ultimately produce a [`FinalizedFilters`], which
//! can be then handed off to a query method.
//!
//! Filters play a role in a number of places in the ShotGrid API including:
/... | true |
f74344237d9aa376b46cf7b4dd842f32270aff45 | Rust | utilForever/BOJ | /Rust/6171 - Ddangddaemokgi.rs | UTF-8 | 2,603 | 3.140625 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{io, str};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
reader,
buf_str: vec![],
buf_iter: ""... | true |
79cf042c086c4c25513cca34ace471b66ee99b24 | Rust | up1/rust-hello-world-with-test | /src/hello.rs | UTF-8 | 269 | 3.046875 | 3 | [] | no_license | pub fn say_hi(_name: String) -> String {
let first = "Hello ".to_string();
return first + &_name;
}
#[cfg(test)]
mod test {
#[test]
fn hello_world_with_rust() {
assert_eq!("Hello somkiat", crate::hello::say_hi("somkiat".to_string()));
}
} | true |
3c92e38eabff52c542e5e362416105582113325b | Rust | filmor/rusty_erlang | /src/term/detail.rs | UTF-8 | 1,237 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::hash::Hash;
use std::hash::sip::SipState;
use types::Pid;
use term::Eterm;
// TODO: Redo following Eterm* types with byte-precision on the heap
#[deriving(Eq)]
pub struct EtermList {
value: Box<Eterm>,
tail: Box<Eterm>,
}
impl PartialEq for EtermList {
fn eq(&self, other: &EtermList) -> bool {
sel... | true |
0c4df9e636ab2cdb1fa5f054d480f21587f53684 | Rust | t-bast/blue-avocado | /src/cipher/block/mars.rs | UTF-8 | 16,527 | 3.234375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | //! # Mars
//!
//! `mars` implements the mars block cipher.
//! Mars was one of the AES finalists.
/// A Mars block cipher.
pub struct Mars {
key: [u32; 40],
}
// Public methods.
impl Mars {
/// new creates a mars cipher with the given key.
/// The key needs to contain between 4 and 14 words.
pub fn n... | true |
3aa2c41a2e33475bae65c9278e4f8eb29a904480 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/tokio/src/signal/mod.rs | UTF-8 | 2,604 | 2.78125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | /
/
!
Asynchronous
signal
handling
for
Tokio
.
/
/
!
/
/
!
Note
that
signal
handling
is
in
general
a
very
tricky
topic
and
should
be
/
/
!
used
with
great
care
.
This
crate
attempts
to
implement
'
best
practice
'
for
/
/
!
signal
handling
but
it
should
be
evaluated
for
your
own
applications
'
needs
/
/
!
to
see
if
it
'... | true |
99191f5ba32cecc61e12bbc9e45143f23b9e5a48 | Rust | ZoranPandovski/al-go-rithms | /sort/bubble_sort/Rust/bubble_sort.rs | UTF-8 | 437 | 3.21875 | 3 | [
"CC0-1.0"
] | permissive | fn bubble_sort(mut arr :Vec<i32>) -> Vec<i32> {
for _ in 0..arr.len() {
let mut flag = false;
for j in 0..arr.len() - 1 {
if arr[j] > arr[j + 1] {
arr.swap(j, j+1);
flag = true
}
}
if !flag {
break;
}
}
... | true |
002584c804991be310ac1428ad1f62df6765b747 | Rust | tomcur/advent-of-code-2018 | /src/december10.rs | UTF-8 | 4,089 | 2.78125 | 3 | [] | no_license | #![feature(test)]
extern crate test;
extern crate regex;
extern crate euclid;
use euclid::{Rect, Point2D, Vector2D};
mod utils;
type Result<T> = std::result::Result<T, Box<std::error::Error>>;
type Sky = Vec<(Point2D<i64>, Vector2D<i64>)>;
fn parse(lines: &[String]) -> Result<Sky> {
let re = regex::Regex::new(r"^... | true |
c771f14197e24cf8dfac9845bd1c5530133b43ee | Rust | mm304321141/rush | /src/example/test/32_1.rs | UTF-8 | 910 | 2.78125 | 3 | [
"MIT"
] | permissive |
void main()
{
test('1')
test('2')
test('3')
}
void test(rstr s)
{
if s=='1':
printl 'pass 1'
elif s=='2':
printl 'pass 2'
else:
printl 'other'
if(s=='1')
{
printl 'pass 1'
}
else
{
printl 'other'
}
switch s
case '1'
printl 'pass 1'
case '2'
printl 'pas... | true |
f16dac1529ac327d485ec800ff8f65a8aea68c71 | Rust | fdoyon/pyo3_numpy.rs | /src/lib.rs | UTF-8 | 5,464 | 2.71875 | 3 | [] | no_license | pub extern crate pyo3;
use std::mem::size_of;
use std::slice::from_raw_parts_mut;
use pyo3::prelude::*;
// A link between a rust object and a numpy dtype
pub trait NumpyDtype {
// The dtype name, like "float32"
const DTYPE: &'static str;
}
// Numpy don't have u8 or i8 🙁
impl NumpyDtype for u16 {
const... | true |
cd32dcf33d3678045c7e2f4842fc90c0d348cc96 | Rust | museun/twitchchat | /src/messages/user_state.rs | UTF-8 | 2,788 | 2.875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | use crate::twitch::{parse_badges, parse_emotes, Badge, BadgeInfo, Color, Emotes};
use crate::{irc::*, MaybeOwned, MaybeOwnedIndex, Validator};
/// Identifies a user's chat settings or properties (e.g., chat color)..
#[derive(Clone, PartialEq)]
pub struct UserState<'a> {
raw: MaybeOwned<'a>,
tags: TagIndices,
... | true |
48073d0d4096aa3901d924a09cb14ea96edd0061 | Rust | kompendium-llc/fct-vanitygen | /src/files.rs | UTF-8 | 1,211 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | use std::path::Path;
use std::io::prelude::*;
use std::io::{self, BufRead};
use std::fs::{File, OpenOptions};
use super::valid_base58;
pub fn read_file(filepath: &str) -> Vec<String> {
let mut prefixes = Vec::new();
let path = Path::new(filepath);
let lines = parse_lines(path).expect("Unable to open prefix... | true |
dcd70fec317546b50275304ac96675b3cba83d34 | Rust | 1ucian0/qiskit-terra | /crates/accelerate/src/error_map.rs | UTF-8 | 4,200 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | // This code is part of Qiskit.
//
// (C) Copyright IBM 2022
//
// This code is licensed under the Apache License, Version 2.0. You may
// obtain a copy of this license in the LICENSE.txt file in the root directory
// of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
//
// Any modifications or deriv... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.