我创建了一个名为Supervisor ElectionManager.Application和一名工人.
然后我查看了这些过程的信息:
iex(3)> proc = Process.whereis(ElectionManager.Application)
#PID<0.158.0>
iex(4)> Process.info proc
[registered_name: ElectionManager.Application,
current_function: {:gen_server, :loop, 7},
initial_call: {:proc_lib, :init_p, 5}, status: :waiting, message_queue_len: 0,
messages: [], links: [#PID<0.156.0>, #PID<0.159.0>],
dictionary: ["$initial_call": {:supervisor, Registry.Supervisor, 1},
"$ancestors": [#PID<0.156.0>]], trap_exit: true,
error_handler: :error_handler, priority: :normal, group_leader: #PID<0.155.0>,
total_heap_size: 986, heap_size: 610, stack_size: 10, reductions: 339,
garbage_collection: [max_heap_size: %{error_logger: true, kill: true, size: 0},
min_bin_vheap_size: 46422, min_heap_size: 233, fullsweep_after: 65535,
minor_gcs: 2], suspending: []]
iex(7)> {id, child, type, modules} = Supervisor.which_children(proc) |> …Run Code Online (Sandbox Code Playgroud) 我想让用户决定我的结构的格式,并将其传递给它下面的结构.
例如:
struct Coordinates {
x: i64,
y: i64,
}
impl fmt::Display for Coordinates {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Coordinates(x: {}, y: {})", self.x, self.y)
}
}
impl fmt::LowerHex for Coordinates {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Coordinates(x: {:x}, y: {:x})", self.x, self.y)
}
}
Run Code Online (Sandbox Code Playgroud)
我想要这样工作
let c = Coordinates { x: 10, y: 20 };
println!("{}", c);
// => Coordinates(x: 10, y: 20)
println!("{:010x}, c");
// => Coordinates(x: 000000000a, y: …Run Code Online (Sandbox Code Playgroud) 考虑这样的代码:
module Foo
# returns a copy of self
# @return [ ___ ]
def returns_new_self
self.class.new
end
end
class Bar
include Foo
end
class Zap
include Foo
end
Run Code Online (Sandbox Code Playgroud)
这样,Bar.new.returns_new_self将返回另一个Bar,同样的情况也是如此Zap.new.returns_new_self。
我想要用retuns_new_self返回类型记录 YARD。
如果我能做一些像Rust@return [Self]那样的事情那就太好了Self。
我可以做类似的事情吗?
编辑:(回复@spickermann)
实际的代码是这样的:
module MultipleItemBehaviour
# @return [Integer]
def count; not_implemented end
# @return [Enumerator]
def each_count
return enum_for(:each_count) unless block_given?
count.times do
yield single_item
end
end
# @return [ __SELF__ ]
def single_item; …Run Code Online (Sandbox Code Playgroud) OTP 主管重启策略名称对我来说似乎很奇怪,可能是因为我的母语不是英语。
one_for_one:当一个孩子死亡时,它会重新启动该孩子one_for_all:当一个孩子死亡时,它会杀死所有其他孩子并按顺序重新启动它们rest_for_one:当一个孩子死亡时,它会杀死在该死亡孩子之后启动的所有孩子,并按顺序重新启动它们我试图通过将它们读作句子来理解这些策略名称,例如“重新启动one孩子for one的死亡”。
那么要么one_for_allorrest_for_one对我来说似乎是一个颠倒的名字。( "restart one child for all children's death"??)
为什么这些策略如此命名?
cf erlang 文档one_for_all部分有一个数字说“全对一监督”。这只是一个错字吗?