file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
stats.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | counts[bucket] += 1;
corpus_i += 1;
}
// Initialized to size bucket_number + 1 above; iterates up to bucket_number; subscript is in range; qed
bucket_bounds[bucket + 1] = bucket_end;
bucket_end = bucket_end + bucket_size;
}
Some(Histogram { bucket_bounds: bucket_bounds, counts: counts })
}
}
... | {
if corpus.len() < 1 { return None; }
let corpus_end = corpus.last().expect("there is at least 1 element; qed").clone();
let corpus_start = corpus.first().expect("there is at least 1 element; qed").clone();
trace!(target: "stats", "Computing histogram from {} to {} with {} buckets.", corpus_start, corpus_end, ... | identifier_body |
stats.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... |
let corpus_end = corpus.last().expect("there is at least 1 element; qed").clone();
let corpus_start = corpus.first().expect("there is at least 1 element; qed").clone();
trace!(target: "stats", "Computing histogram from {} to {} with {} buckets.", corpus_start, corpus_end, bucket_number);
// Bucket needs to be ... | { return None; } | conditional_block |
stats.rs | // Copyright 2015-2017 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any lat... | );
}
#[test]
fn data_range_is_not_multiple_of_bucket_range() {
assert_eq!(
Histogram::new(slice_into![1, 2, 5], 2),
Some(Histogram { bucket_bounds: vec_into![1, 4, 7], counts: vec![2, 1] })
);
}
#[test]
fn data_range_is_multiple_of_bucket_range() {
assert_eq!(
Histogram::new(slice_into![1, 2, 6... | fn smaller_data_range_than_bucket_range() {
assert_eq!(
Histogram::new(slice_into![1, 2, 2], 3),
Some(Histogram { bucket_bounds: vec_into![1, 2, 3, 4], counts: vec![1, 2, 0] }) | random_line_split |
glfw_windowing.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A windowing implementation using GLFW.
use windowing::{ApplicationMethods, WindowEvent, WindowMethods};
use w... | Loading => {
self.glfw_window.set_title("Loading β Servo")
}
PerformingLayout => {
self.glfw_window.set_title("Performing Layout β Servo")
}
FinishedLoading => {
match self.render_state {
Rend... | } | random_line_split |
glfw_windowing.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A windowing implementation using GLFW.
use windowing::{ApplicationMethods, WindowEvent, WindowMethods};
use w... |
self.last_title_set_time = now;
match self.ready_state {
Blank => {
self.glfw_window.set_title("blank β Servo")
}
Loading => {
self.glfw_window.set_title("Loading β Servo")
}
PerformingLayout => {
... | {
return
} | conditional_block |
glfw_windowing.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A windowing implementation using GLFW.
use windowing::{ApplicationMethods, WindowEvent, WindowMethods};
use w... | {
glfw_window: glfw::Window,
event_queue: @mut ~[WindowEvent],
drag_origin: Point2D<c_int>,
mouse_down_button: @mut Option<glfw::MouseButton>,
mouse_down_point: @mut Point2D<c_int>,
ready_state: ReadyState,
render_state: RenderState,
last_title_set_time: Timespec,
}
impl WindowMet... | Window | identifier_name |
glfw_windowing.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! A windowing implementation using GLFW.
use windowing::{ApplicationMethods, WindowEvent, WindowMethods};
use w... |
/// Sets the ready state.
fn set_ready_state(@mut self, ready_state: ReadyState) {
self.ready_state = ready_state;
self.update_window_title()
}
/// Sets the render state.
fn set_render_state(@mut self, render_state: RenderState) {
if self.ready_state == FinishedLoading &&
... | {
if !self.event_queue.is_empty() {
return self.event_queue.shift()
}
glfw::poll_events();
if self.glfw_window.should_close() {
QuitWindowEvent
} else if !self.event_queue.is_empty() {
self.event_queue.shift()
} else {
Idle... | identifier_body |
dto.rs | use game_status::PlayerName;
use card::Card;
use card::Suit;
use card::dto::CardDto;
use deal::Deal;
use deal::DealCard;
use error::Error;
use error::Result;
use std::convert::TryFrom;
use std::str::FromStr;
#[derive(Serialize, Deserialize, Debug)]
pub struct DealDto {
#[serde(rename = "DealNumber")]
deal_num... | impl TryFrom<DealCardDto> for DealCard {
type Error = Error;
fn try_from(dto: DealCardDto) -> Result<DealCard> {
Ok(DealCard {
player_name: dto.team_name.clone(),
card: Card::try_from(dto.card)?,
})
}
}
impl<'a> From<&'a DealCard> for DealCardDto {
fn from(deal_c... | card: CardDto,
}
| random_line_split |
dto.rs | use game_status::PlayerName;
use card::Card;
use card::Suit;
use card::dto::CardDto;
use deal::Deal;
use deal::DealCard;
use error::Error;
use error::Result;
use std::convert::TryFrom;
use std::str::FromStr;
#[derive(Serialize, Deserialize, Debug)]
pub struct DealDto {
#[serde(rename = "DealNumber")]
deal_num... | (dto: DealDto) -> Result<Deal> {
let deal_cards = dto.deal_cards
.into_iter()
.map(DealCard::try_from)
.collect::<Result<Vec<DealCard>>>()?;
let suit = Suit::from_str(&dto.suit_type)?;
Ok(Deal {
deal_number: dto.deal_number,
initiator: dto... | try_from | identifier_name |
dto.rs | use game_status::PlayerName;
use card::Card;
use card::Suit;
use card::dto::CardDto;
use deal::Deal;
use deal::DealCard;
use error::Error;
use error::Result;
use std::convert::TryFrom;
use std::str::FromStr;
#[derive(Serialize, Deserialize, Debug)]
pub struct DealDto {
#[serde(rename = "DealNumber")]
deal_num... |
}
#[derive(Serialize, Deserialize, Debug)]
pub struct DealCardDto {
#[serde(rename = "TeamName")]
team_name: PlayerName,
#[serde(rename = "Card")]
card: CardDto,
}
impl TryFrom<DealCardDto> for DealCard {
type Error = Error;
fn try_from(dto: DealCardDto) -> Result<DealCard> {
Ok(DealC... | {
DealDto {
deal_number: deal.deal_number,
initiator: deal.initiator.clone(),
suit_type: deal.suit.unwrap_or(Suit::Club).into(),
deal_cards: deal.deal_cards.iter().map(DealCardDto::from).collect(),
deal_winner: deal.deal_winner.clone(),
}
} | identifier_body |
dto.rs | use game_status::PlayerName;
use card::Card;
use card::Suit;
use card::dto::CardDto;
use deal::Deal;
use deal::DealCard;
use error::Error;
use error::Result;
use std::convert::TryFrom;
use std::str::FromStr;
#[derive(Serialize, Deserialize, Debug)]
pub struct DealDto {
#[serde(rename = "DealNumber")]
deal_num... | ,
deal_cards: deal_cards,
deal_winner: dto.deal_winner,
})
}
}
impl<'a> From<&'a Deal> for DealDto {
fn from(deal: &'a Deal) -> DealDto {
DealDto {
deal_number: deal.deal_number,
initiator: deal.initiator.clone(),
suit_type: deal.suit.... | {
Some(suit)
} | conditional_block |
mod.rs | /*
* Copyright 2015-2019 Ben Ashford
*
* 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 agree... | {
Auto,
LevenshteinDistance(i64),
Proportionate(f64),
}
from!(i64, Fuzziness, LevenshteinDistance);
from!(f64, Fuzziness, Proportionate);
impl Serialize for Fuzziness {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
use self::Fuzziness:... | Fuzziness | identifier_name |
mod.rs | /*
* Copyright 2015-2019 Ben Ashford
*
* 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 agree... | }
impl MatchAllQuery {
add_field!(with_boost, boost, f64);
build!(MatchAll);
}
#[cfg(test)]
mod tests {
extern crate serde_json;
use super::full_text::SimpleQueryStringFlags;
use super::functions::Function;
use super::term::TermsQueryLookup;
use super::{Flags, Query};
#[test]
fn... |
impl Query {
pub fn build_match_all() -> MatchAllQuery {
MatchAllQuery::default()
} | random_line_split |
lib.rs | //! A crate to custom derive `Position` and `Advance` for any type that has a field named `vector`
extern crate proc_macro;
use crate::proc_macro::TokenStream;
use quote::quote;
use syn;
#[proc_macro_derive(Advance)]
pub fn advance_derive(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::pars... |
let name = &ast.ident;
let gen = quote! {
impl Position for #name {
fn x(&self) -> f32 { self.vector.position.x }
fn y(&self) -> f32 { self.vector.position.y }
fn x_mut(&mut self) -> &mut f32 { &mut self.vector.position.x }
fn y_mut(&mut self) -> &mut f32... | random_line_split | |
lib.rs | //! A crate to custom derive `Position` and `Advance` for any type that has a field named `vector`
extern crate proc_macro;
use crate::proc_macro::TokenStream;
use quote::quote;
use syn;
#[proc_macro_derive(Advance)]
pub fn advance_derive(input: TokenStream) -> TokenStream |
#[proc_macro_derive(Position)]
pub fn position_derive(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(input).unwrap();
let name = &ast.ident;
let gen = quote! {
impl Position for #name {
fn x(&self) -> f32 { self.vector.position.x }
fn y(&self) ... | {
let ast: syn::DeriveInput = syn::parse(input).unwrap();
let name = &ast.ident;
let gen = quote! {
impl Advance for #name {
fn direction(&self) -> f32 {
self.vector.direction
}
fn direction_mut(&mut self) -> &mut f32 {
&mut self.... | identifier_body |
lib.rs | //! A crate to custom derive `Position` and `Advance` for any type that has a field named `vector`
extern crate proc_macro;
use crate::proc_macro::TokenStream;
use quote::quote;
use syn;
#[proc_macro_derive(Advance)]
pub fn advance_derive(input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::pars... | (input: TokenStream) -> TokenStream {
let ast: syn::DeriveInput = syn::parse(input).unwrap();
let name = &ast.ident;
let gen = quote! {
impl Position for #name {
fn x(&self) -> f32 { self.vector.position.x }
fn y(&self) -> f32 { self.vector.position.y }
fn x_mut(... | position_derive | identifier_name |
missing-doc.rs | #![warn(clippy::missing_docs_in_private_items)]
// When denying at the crate level, be sure to not get random warnings from the
// injected intrinsics by the compiler.
#![allow(dead_code)]
#![feature(global_asm)]
//! Some garbage docs for the crate here
#![doc = "More garbage"]
type Typedef = String;
pub type PubTyped... | enum Baz {
BazA { a: isize, b: isize },
BarB,
}
pub enum PubBaz {
PubBazA { a: isize },
}
/// dox
pub enum PubBaz2 {
/// dox
PubBaz2A {
/// dox
a: isize,
},
}
#[allow(clippy::missing_docs_in_private_items)]
pub enum PubBaz3 {
PubBaz3A { b: isize },
}
#[doc(hidden)]
pub fn... | }
}
| random_line_split |
missing-doc.rs | #![warn(clippy::missing_docs_in_private_items)]
// When denying at the crate level, be sure to not get random warnings from the
// injected intrinsics by the compiler.
#![allow(dead_code)]
#![feature(global_asm)]
//! Some garbage docs for the crate here
#![doc = "More garbage"]
type Typedef = String;
pub type PubTyped... | {
/// dox
PubBaz2A {
/// dox
a: isize,
},
}
#[allow(clippy::missing_docs_in_private_items)]
pub enum PubBaz3 {
PubBaz3A { b: isize },
}
#[doc(hidden)]
pub fn baz() {}
const FOO: u32 = 0;
/// dox
pub const FOO1: u32 = 0;
#[allow(clippy::missing_docs_in_private_items)]
pub const FOO2: ... | PubBaz2 | identifier_name |
capability_list.rs | // Copyright (c) 2017 David Renshaw and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify... | marker: PhantomData<T>,
reader: ListReader<'a>
}
impl <'a, T> Clone for Reader<'a, T> where T: FromClientHook {
fn clone(&self) -> Reader<'a, T> {
Reader { marker : self.marker, reader : self.reader }
}
}
impl <'a, T> Copy for Reader<'a, T> where T: FromClientHook {}
impl <'a, T> Reader<'a, T>... | type Builder = Builder<'a, T>;
}
pub struct Reader<'a, T> where T: FromClientHook { | random_line_split |
capability_list.rs | // Copyright (c) 2017 David Renshaw and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify... |
pub fn len(&self) -> u32 { self.reader.len() }
pub fn iter(self) -> ListIter<Reader<'a, T>, Result<T>> {
ListIter::new(self, self.len())
}
}
impl <'a, T> Reader<'a, T> where T: FromClientHook {
pub fn reborrow<'b>(&'b self) -> Reader<'b, T> {
Reader { reader: self.reader, marker: P... | {
Reader::<'b, T> { reader : reader, marker : PhantomData }
} | identifier_body |
capability_list.rs | // Copyright (c) 2017 David Renshaw and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify... | (builder : ListBuilder<'a>) -> Builder<'a, T> {
Builder { builder: builder, marker: PhantomData }
}
pub fn len(&self) -> u32 { self.builder.len() }
#[deprecated(since="0.9.2", note="use into_reader()")]
pub fn as_reader(self) -> Reader<'a, T> {
self.into_reader()
}
pub fn into... | new | identifier_name |
mod.rs | // SPDX-License-Identifier: Unlicense
mod device;
mod handler;
mod pager;
const UPPER_VA_BITS: usize = 39; // 512 GB, avoids 1 level
const LOWER_VA_BITS: usize = 48; // 256 TB
/// Live hardware abstraction layer for integration tests and releases.
#[cfg(not(test))]
mod hal;
/// Mock hardware abstraction layer for u... | pub use hal_test::core_id;
pub use pager::PageBlockDescriptor;
pub use pager::PageDirectory;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_use() {
assert_eq!(LOWER_VA_BITS, 48)
}
} | #[cfg(not(test))]
pub use hal::core_id;
#[cfg(test)] | random_line_split |
mod.rs | // SPDX-License-Identifier: Unlicense
mod device;
mod handler;
mod pager;
const UPPER_VA_BITS: usize = 39; // 512 GB, avoids 1 level
const LOWER_VA_BITS: usize = 48; // 256 TB
/// Live hardware abstraction layer for integration tests and releases.
#[cfg(not(test))]
mod hal;
/// Mock hardware abstraction layer for u... | () -> impl super::PageDirectory {
pager::new_page_directory()
}
#[cfg(not(test))]
pub use hal::core_id;
#[cfg(test)]
pub use hal_test::core_id;
pub use pager::PageBlockDescriptor;
pub use pager::PageDirectory;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_use() {
assert_eq!(LOWER_V... | new_page_directory | identifier_name |
type-params-in-different-spaces-2.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | std::io::println(A::test((&7306634593706211700, 8)));
} | fn main() { | random_line_split |
type-params-in-different-spaces-2.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | <U>(u: U) -> Self {
Tr::op(u) //~ ERROR expected Tr<U>, but found Tr<T>
}
}
impl<T> Tr<T> for T {
fn op(t: T) -> T { t }
}
impl<T> A for T {}
fn main() {
std::io::println(A::test((&7306634593706211700, 8)));
}
| test | identifier_name |
type-params-in-different-spaces-2.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
}
impl<T> A for T {}
fn main() {
std::io::println(A::test((&7306634593706211700, 8)));
}
| { t } | identifier_body |
config.rs | pub use crate::tracker::TrackerMode;
use serde::Deserialize;
use std::collections::HashMap;
#[derive(Deserialize)]
pub struct UDPConfig {
bind_address: String,
announce_interval: u32,
}
impl UDPConfig {
pub fn get_address(&self) -> &str {
self.bind_address.as_str()
}
pub fn get_announce_i... | (&self) -> &Option<String> {
&self.log_level
}
pub fn get_http_config(&self) -> Option<&HTTPConfig> {
self.http.as_ref()
}
pub fn get_db_path(&self) -> &Option<String> {
&self.db_path
}
pub fn get_cleanup_interval(&self) -> Option<u64> {
self.cleanup_interval
... | get_log_level | identifier_name |
config.rs | pub use crate::tracker::TrackerMode;
use serde::Deserialize;
use std::collections::HashMap;
#[derive(Deserialize)]
pub struct UDPConfig {
bind_address: String,
announce_interval: u32,
}
impl UDPConfig {
pub fn get_address(&self) -> &str {
self.bind_address.as_str()
}
pub fn get_announce_i... | }
#[derive(Deserialize)]
pub struct HTTPConfig {
bind_address: String,
access_tokens: HashMap<String, String>,
}
impl HTTPConfig {
pub fn get_address(&self) -> &str {
self.bind_address.as_str()
}
pub fn get_access_tokens(&self) -> &HashMap<String, String> {
&self.access_tokens
... | } | random_line_split |
execution_server.rs | use std::collections::VecDeque;
use std::fmt::Debug;
use std::iter::FromIterator;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use bazel_protos;
use grpcio;
use protobuf;
#[derive(Clone, Debug)]
pub struct MockExecution {
name: String,
execute_request: bazel_protos::remote_execution::ExecuteRequest,
operat... |
None => {
sink.fail(grpcio::RpcStatus::new(
grpcio::RpcStatusCode::InvalidArgument,
Some("Did not expect this request".to_string()),
));
}
}
}
}
impl bazel_protos::remote_execution_grpc::Execution for MockResponder {
fn execute(
&self,
_: grpcio::RpcCont... | {
sink.success(op.clone());
} | conditional_block |
execution_server.rs | use std::collections::VecDeque;
use std::fmt::Debug;
use std::iter::FromIterator;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
use bazel_protos;
use grpcio;
use protobuf;
#[derive(Clone, Debug)]
pub struct MockExecution {
name: String,
execute_request: bazel_protos::remote_execution::ExecuteRequest,
operat... | (mock_execution: MockExecution) -> TestServer {
let mock_responder = MockResponder::new(mock_execution);
let env = Arc::new(grpcio::Environment::new(1));
let mut server_transport = grpcio::ServerBuilder::new(env)
.register_service(bazel_protos::remote_execution_grpc::create_execution(
mock_res... | new | identifier_name |
execution_server.rs | use std::collections::VecDeque;
use std::fmt::Debug;
use std::iter::FromIterator;
use std::ops::Deref; |
#[derive(Clone, Debug)]
pub struct MockExecution {
name: String,
execute_request: bazel_protos::remote_execution::ExecuteRequest,
operation_responses: Arc<Mutex<VecDeque<bazel_protos::operations::Operation>>>,
}
impl MockExecution {
///
/// # Arguments:
/// * `name` - The name of the operation. It is ass... | use std::sync::{Arc, Mutex};
use bazel_protos;
use grpcio;
use protobuf; | random_line_split |
main.rs | // Copyright (C) 2015 - Will Glozer. All rights reserved.
#![feature(convert, core, plugin, collections, ip, ip_addr, libc, duration)]
#![plugin(docopt_macros, regex_macros)]
#![allow(dead_code)]
mod cms;
mod kqueue;
mod pf;
mod posix;
mod tail;
#[macro_use]
mod log;
#[macro_use]
extern crate bitflags;
#[macro_use]... |
fn is_global(addr: IpAddr) -> bool {
match addr {
IpAddr::V4(addr) => addr.is_global(),
IpAddr::V6(addr) => addr.is_global(),
}
}
#[cfg(test)] extern crate tempdir;
#[cfg(test)] mod tests;
| {
let tm = try!(time::strptime(&line[..15], "%b %e %T"));
let (year, month) = match tm.tm_mon as u32 + 1 {
month if month > now.month() => (now.year() - 1, month),
month => (now.year(), month),
};
let day = tm.tm_mday as u32;
let hour = tm.tm_hour as ... | identifier_body |
main.rs | // Copyright (C) 2015 - Will Glozer. All rights reserved.
#![feature(convert, core, plugin, collections, ip, ip_addr, libc, duration)]
#![plugin(docopt_macros, regex_macros)]
#![allow(dead_code)]
mod cms;
mod kqueue;
mod pf;
mod posix;
mod tail;
#[macro_use]
mod log;
#[macro_use]
extern crate bitflags;
#[macro_use]... | <Z: TimeZone>(line: &str, now: DateTime<Z>) -> Result<DateTime<Z>, time::ParseError> {
let tm = try!(time::strptime(&line[..15], "%b %e %T"));
let (year, month) = match tm.tm_mon as u32 + 1 {
month if month > now.month() => (now.year() - 1, month),
month => (now.year(), ... | timestamp | identifier_name |
main.rs | // Copyright (C) 2015 - Will Glozer. All rights reserved.
#![feature(convert, core, plugin, collections, ip, ip_addr, libc, duration)]
#![plugin(docopt_macros, regex_macros)]
#![allow(dead_code)]
mod cms;
mod kqueue;
mod pf;
mod posix;
mod tail;
#[macro_use]
mod log;
#[macro_use]
extern crate bitflags;
#[macro_use]... |
}
}
}
}
}
}
}
static PATTERNS: [Regex; 3] = [
regex!(r"sshd\[\d+\]: Invalid user (\w+) from (?P<addr>.+)"),
regex!(r"sshd\[\d+\]: Failed (.+) for( invalid user)? (\w+) from (?P<addr>.+) port"),
regex!(r"sshd\[\d+\]: Receiv... | {
syslog!("Address added to table '{}': {}", self.table, addr);
} | conditional_block |
main.rs | // Copyright (C) 2015 - Will Glozer. All rights reserved.
#![feature(convert, core, plugin, collections, ip, ip_addr, libc, duration)]
#![plugin(docopt_macros, regex_macros)]
#![allow(dead_code)]
mod cms;
mod kqueue;
mod pf;
mod posix;
mod tail;
#[macro_use]
mod log;
#[macro_use]
extern crate bitflags;
#[macro_use]... | limit: u64,
period: Duration,
table: &'a str,
}
impl<'a> IronGate<'a> {
fn monitor(&self, path: &Path) -> Result<(), tail::Error> {
let pf = try!(Pf::new());
let mut tailer = try!(Tailer::new(path.as_os_str()));
let resolution = |d: &Duration| { d.num_seconds() };
let ... |
struct IronGate<'a> { | random_line_split |
cryptography.rs | pub use rust_sodium::crypto::box_::curve25519xsalsa20poly1305 as crypto_box;
pub use rust_sodium::crypto::hash::sha256;
pub use rust_sodium::crypto::scalarmult::curve25519 as scalarmult;
pub use self::crypto_box::{PrecomputedKey, PublicKey, SecretKey};
use auth_failure::AuthFailure;
/// Number of bytes in a password... |
/// Randomly generates a secret key and a corresponding public key.
///
/// THREAD SAFETY: `gen_keypair()` is thread-safe provided that you
/// have called `fcp_cryptoauth::init()` (or `rust_sodium::init()`)
/// once before using any other function from `fcp_cryptoauth` or
/// `rust_sodium`.
pub fn gen_keypair() -> (... | {
if packet_end.len() < crypto_box::MACBYTES {
return Err(AuthFailure::PacketTooShort(format!(
"Packet end: {}",
packet_end.len()
)));
}
match crypto_box::open_precomputed(packet_end, nonce, &shared_secret) {
Err(_) => Err(AuthFailure::CorruptedPacket(
... | identifier_body |
cryptography.rs | pub use rust_sodium::crypto::box_::curve25519xsalsa20poly1305 as crypto_box;
pub use rust_sodium::crypto::hash::sha256;
pub use rust_sodium::crypto::scalarmult::curve25519 as scalarmult;
pub use self::crypto_box::{PrecomputedKey, PublicKey, SecretKey};
use auth_failure::AuthFailure;
/// Number of bytes in a password... |
match crypto_box::open_precomputed(packet_end, nonce, &shared_secret) {
Err(_) => Err(AuthFailure::CorruptedPacket(
"Could not decrypt handshake packet end.".to_owned(),
)),
Ok(buf) => {
let mut pk = [0u8; crypto_box::PUBLICKEYBYTES];
pk.copy_from_slice(&... | {
return Err(AuthFailure::PacketTooShort(format!(
"Packet end: {}",
packet_end.len()
)));
} | conditional_block |
cryptography.rs | pub use rust_sodium::crypto::box_::curve25519xsalsa20poly1305 as crypto_box;
pub use rust_sodium::crypto::hash::sha256;
pub use rust_sodium::crypto::scalarmult::curve25519 as scalarmult;
pub use self::crypto_box::{PrecomputedKey, PublicKey, SecretKey};
use auth_failure::AuthFailure;
/// Number of bytes in a password... | return Err(AuthFailure::PacketTooShort(format!(
"Packet end: {}",
packet_end.len()
)));
}
match crypto_box::open_precomputed(packet_end, nonce, &shared_secret) {
Err(_) => Err(AuthFailure::CorruptedPacket(
"Could not decrypt handshake packet end.".to_o... | shared_secret: &PrecomputedKey,
nonce: &crypto_box::Nonce,
) -> Result<(PublicKey, Vec<u8>), AuthFailure> {
if packet_end.len() < crypto_box::MACBYTES { | random_line_split |
cryptography.rs | pub use rust_sodium::crypto::box_::curve25519xsalsa20poly1305 as crypto_box;
pub use rust_sodium::crypto::hash::sha256;
pub use rust_sodium::crypto::scalarmult::curve25519 as scalarmult;
pub use self::crypto_box::{PrecomputedKey, PublicKey, SecretKey};
use auth_failure::AuthFailure;
/// Number of bytes in a password... | (my_sk: &SecretKey, their_pk: &PublicKey) -> PrecomputedKey {
crypto_box::precompute(their_pk, my_sk)
}
/// unseals the concatenation of fields msg_auth_code, sender_encrypted_temp_pk, and
/// encrypted_data of a packet.
/// If authentication was successful, returns the sender's temp_pk and the
/// data, unencrypt... | shared_secret_from_keys | identifier_name |
las.rs | //! Sink points into a las file.
use std::io::{Write, Seek};
use std::path::Path;
use las;
use Result;
use error::Error;
use point::{Point, ScanDirection};
use sink::{FileSink, Sink};
impl<W: Write + Seek> Sink for las::writer::OpenWriter<W> {
fn sink(&mut self, point: &Point) -> Result<()> {
try!(self.... |
}
/// Simple wrapper around x, y, and z scale factors.
#[derive(Clone, Copy, Debug, RustcDecodable)]
pub struct ScaleFactors {
x: f64,
y: f64,
z: f64,
}
/// Simple wrapper around version pair.
#[derive(Clone, Copy, Debug, RustcDecodable)]
pub struct Version {
major: u8,
minor: u8,
}
#[cfg(test)]... | {
LasConfig {
auto_offsets: Some(true),
point_format: Some(1),
version: Some(Version { major: 1, minor: 2}),
scale_factors: None,
}
} | identifier_body |
las.rs | //! Sink points into a las file.
use std::io::{Write, Seek};
use std::path::Path;
use las;
use Result;
use error::Error;
use point::{Point, ScanDirection};
use sink::{FileSink, Sink};
impl<W: Write + Seek> Sink for las::writer::OpenWriter<W> {
fn sink(&mut self, point: &Point) -> Result<()> {
try!(self.... | let mut writer = try!(las::Writer::from_path(path));
if let Some(s) = config.scale_factors {
writer = writer.scale_factors(s.x, s.y, s.z);
}
if let Some(a) = config.auto_offsets {
writer = writer.auto_offsets(a);
}
if let Some(p) = config.point_for... | random_line_split | |
las.rs | //! Sink points into a las file.
use std::io::{Write, Seek};
use std::path::Path;
use las;
use Result;
use error::Error;
use point::{Point, ScanDirection};
use sink::{FileSink, Sink};
impl<W: Write + Seek> Sink for las::writer::OpenWriter<W> {
fn | (&mut self, point: &Point) -> Result<()> {
try!(self.write_point(&try!(from_point(point))));
Ok(())
}
fn close_sink(self: Box<Self>) -> Result<()> {
self.close().map_err(|e| Error::from(e)).map(|_| ())
}
}
fn from_point(point: &Point) -> Result<las::Point> {
Ok(las::Point {
... | sink | identifier_name |
frequency.rs | //! System and Hardware Clocks
/// Internal Oscillator
pub const HSI: u32 = 8_000_000;
/// External clock
pub const HSE: u32 = 8_000_000;
use stm32f103xx::{Rcc, Flash, rcc};
/// Board clock speeds
pub struct | {
/// System Clock
pub sysclk: u32,
/// AHB peripheral clock
pub hclk: u32,
/// Low speed bus
pub apb1: u32,
/// high speed bus
pub apb2: u32,
}
impl ClockSpeeds {
/// Get clock speeds
pub fn get(rcc: &Rcc) -> ClockSpeeds {
let sysclk = match rcc.cfgr.read().sws(){
... | ClockSpeeds | identifier_name |
frequency.rs | //! System and Hardware Clocks
/// Internal Oscillator
pub const HSI: u32 = 8_000_000;
/// External clock
pub const HSE: u32 = 8_000_000;
use stm32f103xx::{Rcc, Flash, rcc};
/// Board clock speeds
pub struct ClockSpeeds{
/// System Clock
pub sysclk: u32,
/// AHB peripheral clock
pub hclk: u32,
//... | rcc::cfgr::Ppre1R::Div16 => hclk / 16,
_ => hclk,
};
let apb2 = match rcc.cfgr.read().ppre2() {
rcc::cfgr::Ppre2R::Div2 => hclk / 2,
rcc::cfgr::Ppre2R::Div4 => hclk / 4,
rcc::cfgr::Ppre2R::Div8 => hclk / 8,
rcc::cfgr::Ppre2R::Div16... | random_line_split | |
frequency.rs | //! System and Hardware Clocks
/// Internal Oscillator
pub const HSI: u32 = 8_000_000;
/// External clock
pub const HSE: u32 = 8_000_000;
use stm32f103xx::{Rcc, Flash, rcc};
/// Board clock speeds
pub struct ClockSpeeds{
/// System Clock
pub sysclk: u32,
/// AHB peripheral clock
pub hclk: u32,
//... | rcc::cfgr::Ppre1R::Div2 => hclk / 2,
rcc::cfgr::Ppre1R::Div4 => hclk / 4,
rcc::cfgr::Ppre1R::Div8 => hclk / 8,
rcc::cfgr::Ppre1R::Div16 => hclk / 16,
_ => hclk,
};
let apb2 = match rcc.cfgr.read().ppre2() {
rcc::cfgr::Ppre2R::Div2 ... | {
let sysclk = match rcc.cfgr.read().sws(){
rcc::cfgr::SwsR::Hse => HSE,
rcc::cfgr::SwsR::Pll => Self::get_pll_speed(rcc),
_ => HSI,
};
let hclk = match rcc.cfgr.read().hpre() {
rcc::cfgr::HpreR::Div2 => sysclk / 2,
rcc::cfgr::HpreR::D... | identifier_body |
mod.rs | /*
* niepce - fwk/base/mod.rs
*
* Copyright (C) 2017-2021 Hubert Figuière
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any lat... |
use std::collections::BTreeSet;
#[macro_use]
pub mod debug;
pub mod date;
pub mod fractions;
pub mod propertybag;
pub mod propertyvalue;
pub mod rgbcolour;
pub type PropertyIndex = u32;
pub type PropertySet<T> = BTreeSet<T>;
pub use self::propertyvalue::PropertyValue; | random_line_split | |
lib.rs | // =================================================================
//
// * WARNING *
//
// This file is generated!
//
// Changes made to this file will be overwritten. If changes are
// required to the generated code, the service_crategen project
// must be updated to g... | pub use generated::*; | pub use custom::*; | random_line_split |
decoder.rs | use std::io;
use std::io::Read;
use std::default::Default;
use byteorder::{ReadBytesExt, LittleEndian};
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: ... | (&mut self) -> ImageResult<usize> {
try!(self.read_metadata());
Ok(self.frame.width as usize)
}
fn read_scanline(&mut self, buf: &mut [u8]) -> ImageResult<u32> {
try!(self.read_metadata());
if self.decoded_rows > self.frame.height as u32 {
return Err(image::ImageEr... | row_len | identifier_name |
decoder.rs | use std::io;
use std::io::Read;
use std::default::Default;
use byteorder::{ReadBytesExt, LittleEndian};
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: ... | let mut webp = Vec::with_capacity(4);
try!(self.r.by_ref().take(4).read_to_end(&mut webp));
if &*riff!= b"RIFF" {
return Err(image::ImageError::FormatError("Invalid RIFF signature.".to_string()))
}
if &*webp!= b"WEBP" {
return Err(image::ImageError::Form... | let mut riff = Vec::with_capacity(4);
try!(self.r.by_ref().take(4).read_to_end(&mut riff));
let size = try!(self.r.read_u32::<LittleEndian>()); | random_line_split |
decoder.rs | use std::io;
use std::io::Read;
use std::default::Default;
use byteorder::{ReadBytesExt, LittleEndian};
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: ... |
fn colortype(&mut self) -> ImageResult<color::ColorType> {
Ok(color::ColorType::Gray(8))
}
fn row_len(&mut self) -> ImageResult<usize> {
try!(self.read_metadata());
Ok(self.frame.width as usize)
}
fn read_scanline(&mut self, buf: &mut [u8]) -> ImageResult<u32> {
... | {
try!(self.read_metadata());
Ok((self.frame.width as u32, self.frame.height as u32))
} | identifier_body |
decoder.rs | use std::io;
use std::io::Read;
use std::default::Default;
use byteorder::{ReadBytesExt, LittleEndian};
use image;
use image::ImageResult;
use image::ImageDecoder;
use color;
use super::vp8::Frame;
use super::vp8::VP8Decoder;
/// A Representation of a Webp Image format decoder.
pub struct WebpDecoder<R> {
r: ... |
Ok(())
}
}
impl<R: Read> ImageDecoder for WebpDecoder<R> {
fn dimensions(&mut self) -> ImageResult<(u32, u32)> {
try!(self.read_metadata());
Ok((self.frame.width as u32, self.frame.height as u32))
}
fn colortype(&mut self) -> ImageResult<color::ColorType> {
Ok(color:... | {
try!(self.read_riff_header());
try!(self.read_vp8_header());
try!(self.read_frame());
self.have_frame = true;
} | conditional_block |
origin.rs | // Copyright 2016 The rust-url developers.
//
// 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 ... | (&self) -> usize {
match *self {
Origin::Tuple(ref scheme, ref host, _) => {
scheme.heap_size_of_children() +
host.heap_size_of_children()
},
_ => 0,
}
}
}
impl Origin {
/// Creates a new opaque origin that is only equal to it... | heap_size_of_children | identifier_name |
origin.rs | // Copyright 2016 The rust-url developers.
//
// 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 ... |
/// https://html.spec.whatwg.org/multipage/#ascii-serialisation-of-an-origin
pub fn ascii_serialization(&self) -> String {
match *self {
Origin::Opaque(_) => "null".to_owned(),
Origin::Tuple(ref scheme, ref host, port) => {
if default_port(scheme) == Some(port) ... | {
matches!(*self, Origin::Tuple(..))
} | identifier_body |
origin.rs | // Copyright 2016 The rust-url developers.
//
// 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 ... | matches!(*self, Origin::Tuple(..))
}
/// https://html.spec.whatwg.org/multipage/#ascii-serialisation-of-an-origin
pub fn ascii_serialization(&self) -> String {
match *self {
Origin::Opaque(_) => "null".to_owned(),
Origin::Tuple(ref scheme, ref host, port) => {
... | }
/// Return whether this origin is a (scheme, host, port) tuple
/// (as opposed to an opaque origin).
pub fn is_tuple(&self) -> bool { | random_line_split |
niche-filling.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | <T> { None, Some(T) }
impl<T> Default for MyOption<T> {
fn default() -> Self { MyOption::None }
}
pub enum EmbeddedDiscr {
None,
Record { pre: u8, val: NonZeroU32, post: u16 },
}
impl Default for EmbeddedDiscr {
fn default() -> Self { EmbeddedDiscr::None }
}
#[derive(Default)]
pub struct IndirectNon... | MyOption | identifier_name |
niche-filling.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
}
#[derive(Default)]
pub struct IndirectNonZero {
pre: u8,
nested: NestedNonZero,
post: u16,
}
pub struct NestedNonZero {
pre: u8,
val: NonZeroU32,
post: u16,
}
impl Default for NestedNonZero {
fn default() -> Self {
NestedNonZero { pre: 0, val: NonZeroU32::new(1).unwrap(), post:... | { EmbeddedDiscr::None } | identifier_body |
niche-filling.rs | // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | }
}
pub enum Enum4<A, B, C, D> {
One(A),
Two(B),
Three(C),
Four(D)
}
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
let _x: MyOption<NonZeroU32> = Default::default();
let _y: EmbeddedDiscr = Default::default();
let _z: MyOption<IndirectNonZero> = Default::default();
le... | }
impl Default for NestedNonZero {
fn default() -> Self {
NestedNonZero { pre: 0, val: NonZeroU32::new(1).unwrap(), post: 0 } | random_line_split |
mod.rs | /* io::mod.rs */
use core::mem::volatile_store;
use kernel::sgash;
mod font;
/* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0225d/BBABEGGE.html */
pub static UART0: *mut u32 = 0x101f1000 as *mut u32;
pub static UART0_IMSC: *mut u32 = (0x101f1000 + 0x038) as *mut u32;
#[allow(dead_code)]
pub stati... |
while j < CURSOR_HEIGHT
{
while i < CURSOR_WIDTH
{
if ((map[CURSOR_HEIGHT - j] >> 4*(CURSOR_WIDTH - i)) & 1) == 1
{
*(addr as *mut u32) = FG_COLOR;
}
else
{
*(addr as *mut u32) = BG_COLOR;
}
addr -= 4;
i += 1;
}
addr += 4*(i+SCREEN_WIDTH);
i = 0;
j +=... |
let mut i = -1;
let mut j = 0;
let mut addr = START_ADDR + 4*(CURSOR_X + CURSOR_WIDTH + 1 + SCREEN_WIDTH*CURSOR_Y); | random_line_split |
mod.rs | /* io::mod.rs */
use core::mem::volatile_store;
use kernel::sgash;
mod font;
/* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0225d/BBABEGGE.html */
pub static UART0: *mut u32 = 0x101f1000 as *mut u32;
pub static UART0_IMSC: *mut u32 = (0x101f1000 + 0x038) as *mut u32;
#[allow(dead_code)]
pub stati... |
let font_offset = (c as u8) - 0x20;
let map = font::bitmaps[font_offset];
let mut i = -1;
let mut j = 0;
let mut addr = START_ADDR + 4*(CURSOR_X + CURSOR_WIDTH + 1 + SCREEN_WIDTH*CURSOR_Y);
while j < CURSOR_HEIGHT
{
while i < CURSOR_WIDTH
{
if ((map[CURSOR_HEIGHT - j] >> 4*(CURSOR_... | {
scrollup();
} | conditional_block |
mod.rs | /* io::mod.rs */
use core::mem::volatile_store;
use kernel::sgash;
mod font;
/* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0225d/BBABEGGE.html */
pub static UART0: *mut u32 = 0x101f1000 as *mut u32;
pub static UART0_IMSC: *mut u32 = (0x101f1000 + 0x038) as *mut u32;
#[allow(dead_code)]
pub stati... | ()
{
let mut i = CURSOR_HEIGHT*SCREEN_WIDTH;
while i < (SCREEN_WIDTH*SCREEN_HEIGHT)
{
*((START_ADDR + ((i-16*SCREEN_WIDTH)*4)) as *mut u32) = *((START_ADDR+(i*4)) as *u32);
i += 1;
}
i = 4*(SCREEN_WIDTH*SCREEN_HEIGHT - CURSOR_HEIGHT*SCREEN_WIDTH);
while i < 4*SCREEN_WIDTH*SCREEN_HEIGHT
{
... | scrollup | identifier_name |
mod.rs | /* io::mod.rs */
use core::mem::volatile_store;
use kernel::sgash;
mod font;
/* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0225d/BBABEGGE.html */
pub static UART0: *mut u32 = 0x101f1000 as *mut u32;
pub static UART0_IMSC: *mut u32 = (0x101f1000 + 0x038) as *mut u32;
#[allow(dead_code)]
pub stati... |
pub unsafe fn paint(color: u32)
{
let mut i = 0;
while i < SCREEN_WIDTH*SCREEN_HEIGHT
{
*((START_ADDR as u32 + i*4) as *mut u32) = color;
i+=1;
}
}
pub unsafe fn fill_bg()
{
paint(BG_COLOR);
}
#[allow(dead_code)]
pub unsafe fn read(addr: u32) -> u32
{
*(addr as *mut u32)
}
pub unsafe fn ... | {
let mut i = 0;
let mut j = 0;
while j < CURSOR_HEIGHT
{
while i < CURSOR_WIDTH
{
let addr = START_ADDR + 4*(CURSOR_X + i + SCREEN_WIDTH*(CURSOR_Y + j));
*(addr as *mut u32) = CURSOR_COLOR;
i += 1;
}
i = 0;
j += 1;
}
} | identifier_body |
error.rs | use ::{CATCH_STRUCT_PREFIX, CATCH_FN_PREFIX, CATCHER_ATTR};
use parser::ErrorParams;
use utils::*;
use syntax::codemap::{Span};
use syntax::ast::{MetaItem, Ident, TyKind};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax::tokenstream::TokenTree;
use syntax::parse::token;
const ERR_PARAM: &'static str = "__er... | let response = ::rocket::response::Responder::respond_to(user_response,
$req_ident)?;
let status = ::rocket::http::Status::raw($code);
::rocket::response::Response::build().status(status).merge(response).ok()
... | {
let mut output = Vec::new();
// Parse the parameters from the error annotation.
let error = ErrorParams::from(ecx, sp, meta_item, &annotated);
// Get all of the information we learned from the attribute + function.
let user_fn_name = error.annotated_fn.ident();
let catch_fn_name = user_fn_na... | identifier_body |
error.rs | use ::{CATCH_STRUCT_PREFIX, CATCH_FN_PREFIX, CATCHER_ATTR};
use parser::ErrorParams;
use utils::*;
use syntax::codemap::{Span};
use syntax::ast::{MetaItem, Ident, TyKind};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax::tokenstream::TokenTree;
use syntax::parse::token;
const ERR_PARAM: &'static str = "__er... | (ecx: &mut ExtCtxt,
sp: Span,
meta_item: &MetaItem,
annotated: Annotatable)
-> Vec<Annotatable>
{
let mut output = Vec::new();
// Parse the parameters from the error annotation.
let error = ErrorParams::from(ecx, sp, meta_item, &annot... | error_decorator | identifier_name |
error.rs | use ::{CATCH_STRUCT_PREFIX, CATCH_FN_PREFIX, CATCHER_ATTR};
use parser::ErrorParams;
use utils::*;
use syntax::codemap::{Span};
use syntax::ast::{MetaItem, Ident, TyKind};
use syntax::ext::base::{Annotatable, ExtCtxt};
use syntax::tokenstream::TokenTree;
use syntax::parse::token;
const ERR_PARAM: &'static str = "__er... |
// Push the static catch info. This is what the errors! macro refers to.
let struct_name = user_fn_name.prepend(CATCH_STRUCT_PREFIX);
emit_item(&mut output, quote_item!(ecx,
#[allow(non_upper_case_globals)]
pub static $struct_name: ::rocket::StaticCatchInfo =
::rocket::StaticCat... | random_line_split | |
flock.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() };
let ret = unsafe {
LockFileEx(handle, LOCKFILE_EXCLUSIVE_LOCK, 0, 100, 0,
&mut overlapped)
};
if ret == 0 {
unsafe { libc::CloseHandle(handle); }
... | {
fail!("create file error: {}", os::last_os_error());
} | conditional_block |
flock.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | (p: &Path) -> Lock {
let fd = p.with_c_str(|s| unsafe {
libc::open(s, libc::O_RDWR | libc::O_CREAT, libc::S_IRWXU)
});
assert!(fd > 0);
let flock = os::flock {
l_start: 0,
l_len: 0,
l_pid: 0,
... | new | identifier_name |
flock.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | }
}
#[cfg(windows)]
mod imp {
use libc;
use std::mem;
use std::os::win32::as_utf16_p;
use std::os;
use std::ptr;
static LOCKFILE_EXCLUSIVE_LOCK: libc::DWORD = 0x00000002;
#[allow(non_snake_case_functions)]
extern "system" {
fn LockFileEx(hFile: libc::HANDLE,
... | random_line_split | |
lib.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this | #![feature(ptr_as_ref)]
#![feature(custom_derive)]
#![feature(plugin)]
#![plugin(heapsize_plugin)]
#![plugin(plugins)]
extern crate app_units;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate cssparser;
extern crate euclid;
extern crate heapsize;
#[macro_use]
extern crate lazy_static;
extern crate libc;
... | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(as_unsafe_cell)]
#![feature(box_syntax)] | random_line_split |
cargo_alias_test.rs | use super::*;
use std::collections::HashMap;
#[test]
fn load_from_file_no_file() {
let tasks = load_from_file("./badfile.toml");
assert!(tasks.is_empty());
}
#[test]
fn load_from_file_parse_error() {
let tasks = load_from_file("./src/lib/test/cargo/invalid_config.toml");
assert!(tasks.is_empty());
}... | } | random_line_split | |
cargo_alias_test.rs | use super::*;
use std::collections::HashMap;
#[test]
fn load_from_file_no_file() {
let tasks = load_from_file("./badfile.toml");
assert!(tasks.is_empty());
}
#[test]
fn load_from_file_parse_error() {
let tasks = load_from_file("./src/lib/test/cargo/invalid_config.toml");
assert!(tasks.is_empty());
}... |
#[test]
fn load_from_file_aliases_found() {
let tasks = load_from_file("./src/lib/test/cargo/config.toml");
assert_eq!(tasks.len(), 4);
let mut map = HashMap::new();
for pair in &tasks {
map.insert(pair.0.clone(), pair.1.clone());
}
let mut task = map.get("b2").unwrap();
assert_... | {
let tasks = load_from_file("./Cargo.toml");
assert!(tasks.is_empty());
} | identifier_body |
cargo_alias_test.rs | use super::*;
use std::collections::HashMap;
#[test]
fn load_from_file_no_file() {
let tasks = load_from_file("./badfile.toml");
assert!(tasks.is_empty());
}
#[test]
fn | () {
let tasks = load_from_file("./src/lib/test/cargo/invalid_config.toml");
assert!(tasks.is_empty());
}
#[test]
fn load_from_file_no_alias_data() {
let tasks = load_from_file("./Cargo.toml");
assert!(tasks.is_empty());
}
#[test]
fn load_from_file_aliases_found() {
let tasks = load_from_file(".... | load_from_file_parse_error | identifier_name |
types.rs | // Copyright 2016-2021 Matthew D. Michelotti
//
// 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 ... |
macro_rules! const_fns {
($type:ty, $raw:ty) => {
impl $type {
/// A const constructor that does not check whether `value` is valid.
///
/// WARNING: This constructor does not panic even in debug mode.
/// As always, it is the user's responsibility to ensure... | {
R64::new(value)
} | identifier_body |
types.rs | // Copyright 2016-2021 Matthew D. Michelotti
//
// 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 ... | (value: f64) -> N64 {
N64::new(value)
}
/// Shorthand for `R32::new(value)`.
#[inline]
pub fn r32(value: f32) -> R32 {
R32::new(value)
}
/// Shorthand for `R64::new(value)`.
#[inline]
pub fn r64(value: f64) -> R64 {
R64::new(value)
}
macro_rules! const_fns {
($type:ty, $raw:ty) => {
impl $typ... | n64 | identifier_name |
types.rs | // Copyright 2016-2021 Matthew D. Michelotti
//
// 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 ... |
const_fns!(N32, f32);
const_fns!(N64, f64);
const_fns!(R32, f32);
const_fns!(R64, f64); | } | random_line_split |
batch.rs | //! Module providing write batches
use leveldb_sys::*;
use libc::{c_char, size_t, c_void};
use std::slice;
use options::{WriteOptions, c_writeoptions};
use super::error::Error;
use std::ptr;
use super::Database;
#[allow(missing_docs)]
struct RawWritebatch {
ptr: *mut leveldb_writebatch_t,
}
impl Drop for RawWrit... | else {
Err(Error::new_from_i8(error))
}
}
}
}
impl Writebatch {
/// Create a new writebatch
pub fn new() -> Writebatch {
let ptr = unsafe { leveldb_writebatch_create() };
let raw = RawWritebatch { ptr: ptr };
Writebatch { writebatch: raw }
}
... | {
Ok(())
} | conditional_block |
batch.rs | //! Module providing write batches
use leveldb_sys::*;
use libc::{c_char, size_t, c_void};
use std::slice;
use options::{WriteOptions, c_writeoptions};
use super::error::Error;
use std::ptr;
use super::Database;
#[allow(missing_docs)]
struct RawWritebatch {
ptr: *mut leveldb_writebatch_t,
}
impl Drop for RawWrit... | <T: WritebatchIterator>(&mut self, iterator: Box<T>) -> Box<T> {
use std::mem;
unsafe {
let mem = mem::transmute(iterator);
leveldb_writebatch_iterate(self.writebatch.ptr,
mem,
put_callback::<T>,
... | iterate | identifier_name |
batch.rs | //! Module providing write batches
use leveldb_sys::*;
use libc::{c_char, size_t, c_void};
use std::slice;
use options::{WriteOptions, c_writeoptions};
use super::error::Error;
use std::ptr;
use super::Database;
#[allow(missing_docs)]
struct RawWritebatch {
ptr: *mut leveldb_writebatch_t,
}
impl Drop for RawWrit... | }
extern "C" fn put_callback<T: WritebatchIterator>(state: *mut c_void,
key: *const i8,
keylen: size_t,
val: *const i8,
... | /// Callback for put items
fn put(&mut self, key: &[u8], value: &[u8]);
/// Callback for deleted items
fn deleted(&mut self, key: &[u8]); | random_line_split |
impl_numeric.rs | // Copyright 2014-2016 bluss and ndarray developers.
//
// 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
... | let rhs_broadcast = rhs.broadcast_unwrap(self.raw_dim());
self.iter().zip(rhs_broadcast.iter()).all(|(x, y)| (*x - *y).abs() <= tol)
}
} | identifier_body | |
impl_numeric.rs | // Copyright 2014-2016 bluss and ndarray developers.
//
// 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
... |
}
sum
}
/// Return sum along `axis`.
///
/// ```
/// use ndarray::{aview0, aview1, arr2, Axis};
///
/// let a = arr2(&[[1., 2.],
/// [3., 4.]]);
/// assert!(
/// a.sum(Axis(0)) == aview1(&[4., 6.]) &&
/// a.sum(Axis(1)) == aview1(&[3.,... | {
sum = sum + row.iter().fold(A::zero(), |acc, elt| acc + elt.clone());
} | conditional_block |
impl_numeric.rs | // Copyright 2014-2016 bluss and ndarray developers.
//
// 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
... | if let Some(slc) = row.as_slice() {
sum = sum + numeric_util::unrolled_sum(slc);
} else {
sum = sum + row.iter().fold(A::zero(), |acc, elt| acc + elt.clone());
}
}
sum
}
/// Return sum along `axis`.
///
/// ```
/// ... | let mut sum = A::zero();
for row in self.inner_iter() { | random_line_split |
impl_numeric.rs | // Copyright 2014-2016 bluss and ndarray developers.
//
// 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
... | (&self, axis: Axis) -> Array<A, <D as RemoveAxis>::Smaller>
where A: Clone + Zero + Add<Output=A>,
D: RemoveAxis,
{
let n = self.shape().axis(axis);
let mut res = self.subview(axis, 0).to_owned();
let stride = self.strides()[axis.index()];
if self.ndim() == 2 &&... | sum | identifier_name |
position.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for CSS handling of specified and computed values of
//! [`position`](https://drafts.csswg.org/c... |
}
| {
match self {
ZIndex::Integer(n) => n,
ZIndex::Auto => auto,
}
} | identifier_body |
position.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for CSS handling of specified and computed values of
//! [`position`](https://drafts.csswg.org/c... | <Integer> {
/// An integer value.
Integer(Integer),
/// The keyword `auto`.
Auto,
}
impl<Integer> ZIndex<Integer> {
/// Returns `auto`
#[inline]
pub fn auto() -> Self {
ZIndex::Auto
}
/// Returns whether `self` is `auto`.
#[inline]
pub fn is_auto(self) -> bool {
... | ZIndex | identifier_name |
position.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for CSS handling of specified and computed values of
//! [`position`](https://drafts.csswg.org/c... | /// The vertical component of position.
pub vertical: V,
}
impl<H, V> Position<H, V> {
/// Returns a new position.
pub fn new(horizontal: H, vertical: V) -> Self {
Self {
horizontal: horizontal,
vertical: vertical,
}
}
}
/// A generic value for the `z-index`... | random_line_split | |
client.rs | // Copyright (c) 2016, Mikkel Kroman <mk@uplink.io>
// All rights reserved.
//
// 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, mo... | /// Starts streaming the track provided in the tracks `stream_url` to the `writer` if the track
/// is streamable via the API.
pub fn stream<W: Write>(&self, track: &Track, mut writer: W) -> Result<usize> {
use hyper::header::Location;
if!track.streamable ||!track.stream_url.is_some() {
... | use hyper::header::Location;
if !track.downloadable || !track.download_url.is_some() {
return Err(Error::TrackNotDownloadable);
}
let url = self.parse_url(track.download_url.as_ref().unwrap());
let mut response = try!(self.http_client.get(url).send());
// F... | identifier_body |
client.rs | // Copyright (c) 2016, Mikkel Kroman <mk@uplink.io>
// All rights reserved.
//
// 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, mo... | lse {
Err(Error::ApiError("expected location header".to_owned()))
}
}
/// Returns a builder for a single track-by-id request.
///
/// # Examples
///
/// ```
/// use soundcloud::Client;
///
/// let client = Client::new(env!("SOUNDCLOUD_CLIENT_ID"));
/// let tr... | Ok(Url::parse(header).unwrap())
} e | conditional_block |
client.rs | // Copyright (c) 2016, Mikkel Kroman <mk@uplink.io>
// All rights reserved.
//
// 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, mo... | {
/// Integer ID.
pub id: usize,
/// API resource URL.
pub uri: String,
/// URL to the SoundCloud.com page
pub permalink_url: String,
/// URL to an external site.
pub external_url: String,
/// Username of the app creator.
pub creator: Option<String>,
}
/// User comment.
#[deriv... | App | identifier_name |
client.rs | // Copyright (c) 2016, Mikkel Kroman <mk@uplink.io>
// All rights reserved.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | use url::Url;
use hyper;
use std::result;
use std::borrow::Borrow;
use std::io::{self, Write};
use track::{Track, TrackRequestBuilder, SingleTrackRequestBuilder};
use error::{Error, Result};
pub type Params<'a, K, V> = &'a [(K, V)];
#[derive(Debug)]
pub struct Client {
client_id: String,
http_client: hyper:... | // 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.
| random_line_split |
issue-3556.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | // "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
let t = Text(box(GC) "foo".to_string());
let u = Section(box(GC) vec!("alpha".to_string()),
true,
box(GC) vec!(t),
box(GC) "foo".to_string(),
box(GC) "foo... | // assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())), | random_line_split |
issue-3556.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | {
// assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())),
// "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
let t = Text(box(GC) "foo".to_string());
let u = Section(box(GC) vec!("alpha".to_strin... | identifier_body | |
issue-3556.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... | (actual: &str, expected: &str) -> bool
{
if actual!= expected
{
println!("Found {}, but expected {}", actual, expected);
return false;
}
return true;
}
pub fn main()
{
// assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
// assert!(check_strs(fmt!("%?", ETag(... | check_strs | identifier_name |
issue-3556.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
return true;
}
pub fn main()
{
// assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())),
// "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
let t = Text(box(GC) "foo".to_string());
let u = Se... | {
println!("Found {}, but expected {}", actual, expected);
return false;
} | conditional_block |
hex.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
#[test]
pub fn test_from_hex_ignores_whitespace() {
assert_eq!("666f 6f6\r\n26172 ".from_hex().unwrap(),
b"foobar");
}
#[test]
pub fn test_to_hex_all_bytes() {
for i in 0..256 {
assert_eq!([i as u8].to_hex(), format!("{:02x}", i as usize));
}... | {
assert!("66y6".from_hex().is_err());
} | identifier_body |
hex.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {
assert_eq!("foobar".as_bytes().to_hex(), "666f6f626172");
}
#[test]
pub fn test_from_hex_okay() {
assert_eq!("666f6f626172".from_hex().unwrap(),
b"foobar");
assert_eq!("666F6F626172".from_hex().unwrap(),
b"foobar");
}
#[test]
p... | test_to_hex | identifier_name |
hex.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
//! Hex binary-to-text encoding
pub use self::FromHexError::*;
use std::fmt;
use std::error;
/// A trait for converting a value to hexadecimal encoding
pub trait ToHex {
/// Converts the value of `self` to a hex value, returning the owned
/// string.
fn to_hex(&self) -> String;
}
const CHARS: &'static ... | // except according to those terms. | random_line_split |
basic-types.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () {()}
| _zzz | identifier_name |
basic-types.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn _zzz() {()} | random_line_split | |
basic-types.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {()} | identifier_body | |
tweet.rs | #![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use color_eyre::{
eyre::{bail, eyre, Error, Result, WrapErr as _},
owo_colors::OwoColorize as _,
};
use oauth_client::Token;
use serde::{Deserialize, Serialize};
use std::pat... |
}
}
pub(super) fn save(path: impl AsRef<Path>, conf: &Config) -> Result<()> {
let path = path.as_ref();
let mut file = create(&path)?;
write(&path, &mut file, conf)?;
Ok(())
}
fn create(path: impl AsRef<Path>) -> Result<File> {
let path = path.as_ref()... | {
error!("Failed to read the existing config file");
eprintln!("Error detail: {:?}", err);
confirm_and_recreate(&path)
} | conditional_block |
tweet.rs | #![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use color_eyre::{
eyre::{bail, eyre, Error, Result, WrapErr as _},
owo_colors::OwoColorize as _,
};
use oauth_client::Token;
use serde::{Deserialize, Serialize};
use std::pat... |
fn write(&self, mut writer: impl Write) -> Result<()> {
serde_json::to_writer_pretty(&mut writer, self)?;
Ok(())
}
fn consumer_token(&self) -> Token {
Token::new(&self.consumer_key, &self.consumer_secret)
}
fn access_token(&self) -> Token {
Token::new(&self.access... | {
let conf = serde_json::from_reader(&mut reader)?;
Ok(conf)
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.